ekiru (>):
> [1:38pm] tylercurtis: rakudo: grammar Foo { token TOP { 'b' } }; say
> Foo.parse('abc').Bool; # this is right
> [1:38pm] p6eval: rakudo 19931f: OUTPUT«0␤»
> [1:38pm] tylercurtis: rakudo: grammar Foo { token TOP { 'b' } }; say
> Foo.parse('bc').Bool; # I don't think this is.
> [1:38pm] p6eval: rakudo 19931f: OUTPUT«1␤»
> [1:38pm] tylercurtis: rakudo: grammar Foo { token TOP { 'b' } }; say
> Foo.parse('ab').Bool; # Also right.
> [1:38pm] p6eval: rakudo 19931f: OUTPUT«0␤»
> [1:39pm] tylercurtis: Grammar.parse seems to anchor to the beginning
> of the string but not to the end.
> 
> If I correctly understand the behavior of Grammar.parse and regex
> methods, only "b" should match the Foo grammar above because regex
> methods are automatically anchored to the beginning and end of the
> string when called directly as Grammar.parse should do with Foo.TOP.

I went looking for support of this view in S05. Didn't find any.

The reason the 'b' is only matched at the beginning of the string in the 
examples above has 
nothing to do with the grammar anchoring to the beginning of the string, but is 
a consequence 
of the 'token' keyword turning backtracking off, and starting the match at a 
new position counts 
as a form of backtracking.

Rejecting the ticket.

Reply via email to