[antlr-interest] Look-ahead problem parsing phrase?

Gavin Lambert antlr at mirality.co.nz
Sun Jun 28 14:05:24 PDT 2009


At 05:54 29/06/2009, Sean O'Dell wrote:
>     WS : (' '|'\t')+;
>     DIGIT : ('0'..'9');
>     LETTER : ('a'..'z'|'A'..'Z');
>     NEWLINE : '\r'? '\n';
>
>     WORD : (LETTER|DIGIT)+;
>
>     EOL : WS? NEWLINE?;
>
>     PHRASE : WORD (WS WORD)*;
>
>     line : WS? PHRASE EOL?;

Turn DIGIT and LETTER into fragment rules.
Turn EOL and PHRASE into parser rules.

(In general, a lexer rule should not refer to any other lexer 
rule, unless that rule is a fragment.)



More information about the antlr-interest mailing list