トークンの正規表現にはパラメータも可
#!/usr/bin/env perl use strict; use Parse::RecDescent; use Data::Dumper; my $grammar = q{ inputs : /[a-z]/i { print Data::Dumper::Dumper($item[1]); } }; my $parse = new Parse::RecDescent ($grammar); while (<>) { defined $parse->inputs($_) or print "Bad text!\n"; }
で、
a $VAR1 = 'a'; A $VAR1 = 'A';