mismatchedtoken with antlr syntactic predicates

Posted by varzan on Stack Overflow See other posts from Stack Overflow or by varzan
Published on 2010-05-03T13:31:17Z Indexed on 2010/05/03 17:28 UTC
Read the original article Hit count: 212

Filed under:

I have the following lexer rules in my grammar file:

   LINE    :    'F' | 'G';
RULE    :    (('->' ('F' | 'G')) => 'F' | 'G' )
                | LINE LINE + | LINE * (ROTATE + LINE+)+ ;
fragment ROTATE    :    ('/' | '\\');

I'm basically trying to match productions that look like F -> F/F\F\F/F. It successfully matches stuff like the above, but I'm guessing there's a problem with my syntactic predicate, since G -> G produces a MismatchedTokenException. The predicate serves to disambiguate between single letters on the lhs of '->', which I want to be recognized as the LINE token, and those on the rhs, which should be RULEs.

Any idea what I'm doing wrong?

© Stack Overflow or respective owner

Related posts about antlr