Hi,

On 05/11/2016 09:22 AM, Richard Hainsworth wrote:
I had

grammar RatingGrammar {

     rule TOP        { ^ <statement>+ $ };

     rule statement  { <id> '=' <endvalue>
                      | {
                             if ($/.CURSOR.pos < $/.orig.chars) {

                                 self.panic($/, "Declaration syntax
incorrect.")
                             }
                         }
                     };


This generates an error for a correct input because it fails <statement>
at the end of input.

I think the problem is that you use | which instructs the compiler to try both paths "at the same time" (no extra threading involved, just notionally). You really want to use || instead, which is "first try the first path, and if it doesn't work, try the second path".

Cheers,
Moritz

Reply via email to