jnthn/grammar-debugger

Does not report FAIL on whole match expression

drforr opened this issue · 0 comments

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

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

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

}
}

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 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.