Subject: | Parse fails except when using debugger |
The attached perl script defines a Regexp::Grammars grammar and checks some text against it. As is, with debugging off, it reports that there is no match. But when I turn debugging on (by uncommenting the "<debug:run>" statement), it reports that there is a match. I expected that with debugging turned on I'd be able to tell why no match was found with debugging turned off.
I also attach the "perl -V" output, in perl-V.log.
Subject: | parser-bug.pl |
use Modern::Perl;
use Regexp::Grammars;
use YAML::Any qw(Dump);
my $grammar =
qr{
#<debug:run>
<nocontext:>
\A <statements>
(?: \Z
| <error: (?{ "Trailing text index $INDEX: '$CONTEXT'" })>
)
<token: ws>
(?: \s+ | \#[^\n]* )*+
<rule: statements>
<[statement]>+ % [,]
<rule: statement>
<spec> : <fieldname>
| \[ <count> \] \{ <statements> \}
| <error:>
<rule: count>
<pptemplate>
| \* <fieldname>
| <funcname> \( <count> \)
<rule: spec>
<pptemplate>
| <funcname> \( <spec> \)
<token: fieldname>
\w++
<token: funcname>
\w++
<token: pptemplate>
\w++
}s;
my $input = <<EOD;
N : count,
[a(b(*count))] { square(N) : foo, # yes, foo!
C3 : bar } # and bar, too
EOD
if ($input =~ $grammar) {
print "Match:\n", Dump(\%/);
} else {
print "No match:\n ", join("\n ", @!);
}
Subject: | perl-V.log |
Message body not shown because it is not plain text.