[antlr-interest] Understanding priorities in lexing (newbie) [Suggestion]

Susan Jolly easjolly at ix.netcom.com
Fri Jul 13 10:18:22 PDT 2007


I really appreciate people who take the time to write the simplest possible
grammar that illustrates the problem they are having rather than embedding
huge grammars in their posts.  

I've run into the described lexer problem several times; I'd say it is
pretty common to want to do something along these lines.

Here is one way to get v3 to generate the code so the lexer looks ahead for
the original example.  Is there any reason not to do this?

fragment KEYWORD : 'a' 'b' 'c' ;
fragment OTHER : 'a' | 'b' | 'c';
DUMMY : (  (KEYWORD) => KEYWORD {$type = KEYWORD;} 
        |  OTHER  {$type = OTHER;}
        );

-S




More information about the antlr-interest mailing list