[antlr-interest] Again simple nondeterminism problems

John B. Brodie jbb at acm.org
Tue Aug 23 09:45:35 PDT 2005

...regarding how to handle Keywords That Look Like Identifiers...

>Yes I've read them here:
>But does not work for me. Any suggestions please?

something like (haven't actually run it through the tool):

class ErsinErLexer extends Lexer;

options { testLiterals=false; }

tokens { ID_AND="and"; ID_OR="or"; }

OID options{ testLiterals=true; } : NUMERICOID | DESCR;
protected DESCR: ALPHA ( ALPHA | DIGIT | '-' )*;
protected ALPHA: 'A'..'Z' | 'a'..'z';

NUMERICOID : ...whatever...

...other lexer rules, but *not* ID_AND | ID_OR...

More information about the antlr-interest mailing list