in reply to Re: Parse::RecDescent and Dynamically Matched Subrule Repetition
in thread Parse::RecDescent and Dynamically Matched Subrule Repetition
And I also changed /\S+/ to /\S+(?!\S)/ to make sure each elem was a maximum-length word.
Useless. P::RD will not backtrack through /.../. They always match as much as possible.
For example,
use Data::Dumper qw( Dumper ); use Parse::RecDescent (); my $p = Parse::RecDescent->new(<<'__END_OF_GRAMMAR__'); parse : /a*/ /a/ /\Z/ { [ $item[1], $item[2] ] } __END_OF_GRAMMAR__ print(Dumper($p->parse('aaaaa')));
outputs
$VAR1 = undef;
I almost said "The \b in /\d+\b/ is also useless.", but it turns "2foo bar" into an error.
|
---|
In Section
Seekers of Perl Wisdom