[antlr-interest] How to write this lexer rule?

Gavin Lambert antlr at mirality.co.nz
Wed Jan 14 11:18:26 PST 2009


At 07:29 15/01/2009, Jim Idle wrote:
>This tends to suggest that the rest of your lexer is where the 
>problems lie and it is taking considerable effort on behalf of 
>the lexer/analysis to work out your rules. However, without 
>seeing the rest of your lexer, I would suggest that this is 
>better, as it avoids any predicates.
>
>IDENT
>   : ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'_'|'0'..'9')*
>     {
>        if ($text.equals("FUNCTION") { $type = FUNCTION_DECL; }
>     }
>   ;

That won't work because of what FUNCTION_DECL needs to do (see 
earlier in the thread).



More information about the antlr-interest mailing list