perlquestion
citromatik
<p>Hi all</p>
<p>I am trying to write a simple grammar just to learn how to use [cpan://Parse::RecDescent]. Why this doesn't work "as expected"?:</p>
<c>
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 \%item;}
));
$p2->Format('a-');
$p2->Format('-a');
</c>
<p>I would expect both strings matching and printing "-a" or "a-", but I get:
</p>
<c>
$VAR1 = {
'Post' => '-',
'__RULE__' => 'Entry'
};
</c>
<p>i.e. Both are valid patterns, but only the first one triggers the action</p>
<p>I would expect getting this:</p>
<c>
$VAR1 = {
'Post' => 'a-',
'__RULE__' => 'Entry'
};
$VAR1 = {
'Post' => '-a',
'__RULE__' => 'Entry'
};
</c>
<p>I am not getting something obvious here... Any help would be appreciated</p>
<!-- Node text goes above. Div tags should contain sig only -->
<div class="pmsig"><div class="pmsig-615480">
<p><i>citromatik</i></p>
</div></div>