On Sun, 02 Apr 2017 19:19:11 -0700, lloyd.fo...@gmail.com wrote: > use Grammar::Tracer; > grammar G { > token TOP { <first-fail> || <second-succeed> } > token first-fail { <thing> '?' } > token second-succeed { <thing> '!' } > token thing { "foo" } > } > note G.parse("foo!") > > #grammar tracer output: > > TOP > | first-fail > | | thing > | | * MATCH "foo" > | * FAIL > | second-succeed > | | thing > | | * MATCH "" # it actually matches it but it's an empty string... > | * FAIL > * FAIL > Nil > > If you just create an identical second token and use that instead it works: > > grammar G { > token TOP { <first-fail> || <second-succeed> } > token first-fail { <thing> '?' } > token second-succeed { <thing2> '!' } > token thing { "foo" } > token thing2 { "foo" } > } > > note G.parse("foo!") > > 「foo!」 > second-succeed => 「foo!」 > thing2 => 「foo」
Moved to Grammar::Debugger's ticket queue[^1], since it matches just fine when the module isn't used. It has a related ticket about `.parse`ing twice. https://github.com/jnthn/grammar-debugger/issues/33