citromatik has asked for the wisdom of the Perl Monks concerning the following question:
Hi all
I am trying to write a simple grammar just to learn how to use Parse::RecDescent. Why this doesn't work "as expected"?:
my $p2 = Parse::RecDescent->new(q( hyphen : "-" option : "a" | "b" | "c" Format : Entry(s) Pre : hyphen option Post : option hyphen Entry : Pre | Post { use Data::Dumper; print Dumper \%ite +m;} )); $p2->Format('a-'); $p2->Format('-a');
I would expect both strings matching and printing "-a" or "a-", but I get:
$VAR1 = { 'Post' => '-', '__RULE__' => 'Entry' };
i.e. Both are valid patterns, but only the first one triggers the action
I would expect getting this:
$VAR1 = { 'Post' => 'a-', '__RULE__' => 'Entry' }; $VAR1 = { 'Post' => '-a', '__RULE__' => 'Entry' };
I am not getting something obvious here... Any help would be appreciated
citromatik
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Parse::RecDescent grammar definition
by jethro (Monsignor) on Mar 21, 2011 at 12:09 UTC | |
by citromatik (Curate) on Mar 21, 2011 at 17:15 UTC | |
by jethro (Monsignor) on Mar 21, 2011 at 17:22 UTC | |
Re: Parse::RecDescent grammar definition
by lancer (Scribe) on Mar 21, 2011 at 12:10 UTC | |
by citromatik (Curate) on Mar 21, 2011 at 12:56 UTC | |
Re: Parse::RecDescent grammar definition
by Anonymous Monk on Mar 21, 2011 at 14:39 UTC |
Back to
Seekers of Perl Wisdom