Skip Menu |

This queue is for tickets about the Regexp-Grammars CPAN distribution.

Report information
The Basics
Id: 129318
Status: resolved
Priority: 0/
Queue: Regexp-Grammars

Owner: Nobody in particular
Requestors: LSTROUS [...]

Bug Information
Severity: (no value)
Broken in: 1.049
Fixed in: (no value)

Subject: Parse fails except when using debugger
Download (untitled) / with headers
text/plain 430b
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.
text/x-perl 1009b
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
Download perl-V.log
application/octet-stream 2.8k

Message body not shown because it is not plain text.

Added files with the output when not debugging, and the output when debugging.
Subject: output-with-debugging.txt

Message body is not shown because it is too large.

Subject: output-without-debugging.txt
No match: Trailing text index 9: ',' Expected statement, but found 'N : count,' instead
Subject: Re: [ #129318] Parse fails except when using debugger
Date: Fri, 26 Apr 2019 22:46:51 +0000
To: bug-Regexp-Grammars [...]
From: Damian Conway <damian [...]>
Download (untitled) / with headers
text/plain 971b
Thanks for the report, Louis. That was definitely a nasty Heisenbug, and was an interesting challenge to track down and fix. I've just uploaded a new version of Regexp::Grammars to CPAN (version 1.050), which fixes the problem. It should propagate within the next 30 minutes or so. BTW, to save you some time debugging the actual problem with your grammar, the issue is that you're not allowing for the possibility of trailing whitespace (e.g. comments) after the last <statement> in your input. To fix it, you need either to change <rule: statements>: <rule: statements> <[statement]>+ % [,] <ws> # Allow for trailing whitespace after last statement or you need to change the top-level match: \A <statements> (?: <ws> \Z # Allow for trailing whitespace after last statement | <error: (?{ "Trailing text index $INDEX: '$CONTEXT'" })> ) Thanks again for helping improve the module with this important bug report. Damian

This service is sponsored and maintained by Best Practical Solutions and runs on infrastructure.

Please report any issues with to