grammar-debugger icon indicating copy to clipboard operation
grammar-debugger copied to clipboard

Does not report FAIL on whole match expression

Open drforr opened this issue 9 years ago • 0 comments

The test below fails (correctly) when attempting to match an expression with a trailing semicolon, and the tracer correctly reports MATCH on <ECHO> and <DIGITS> terms. Yet it doesn't report FAIL on the overall <TOP> rule.

--cut here-- use v6; use Test; use Grammar::Tracer;

grammar Trivially::Broken { token ECHO { 'echo' } token DIGITS { \d+ } rule TOP { <ECHO> <DIGITS> } }

my $g = Trivially::Broken.new; ok $g.parse('echo 32;'); # Notice the final semicolon, which breaks the overall match. --cut here--

Output here: --cut here-- perl6 -Ilib t/02-corpus.t TOP | ECHO | * MATCH "echo" | DIGITS | * MATCH "32"

  • MATCH "echo 32" not ok 1 - --cut here--

Rule <TOP> did match correctly, so in one sense the grammar "did its job". But it didn't match the whole expression, and the overall parse fails. I suspect that requires overriding or monkeypatching the parse() method which is outside of the scope of the debugger, and that's fine by me, but it's an inconsistency I thought worth pointing out.

drforr avatar Jan 09 '16 06:01 drforr