Damian Conway wrote: > rule expr1 { > <term> { m:cont/@operators/ or fail } <term> > } > > Backtracking would just step back over the rule as if it were atomic > (or followed by a colon).
Ok, thanks. (The "followed by a colon" is just to explain the behavior, right? It's illegal to follow a code block with a colon, isn't it?) After talking to Aaron yesterday, I was wondering if sub-rules are meant to backtrack at all. Does the following example backtrack into <foo>? rule foo { b+ } rule bar { a <foo> b } If it doesn't, I think we're restricted to pure LL(1) grammars. That would suck. Apoc 5 is so close to ANTLR or precc that it would be a shame not to be LL(k). I've been playing around with converting regex operators into Perl 6 attribute grammars and they look good. If backtracking into rules doesn't work though, these conversions don't work. a ? rule x { a | <null> } a * rule x { a <x> | <null> } a + rule x($i=0) { a <x($i+1)> | <($i>0)> <null> } a {n,m} rule x($i=0) { <($i<$m)> a <x($i+1)> | <($i>=$n)> <null> } The non-greedy versions just reverse the productions, so for example a *? rule x { <null> | a <x> } - Ken