[antlr-interest] Re: Help me please to improve lexer

Andrew Voelker avoelker at yahoo.com
Thu Dec 5 17:22:59 PST 2002


Try the following:

START options { ignore WS; } :
("aaa" "bbb" "ccc" | "ddd" "eee" | "fff" XXX | YYY) { do(); };

XXX options { ignore WS; } :
("iii" "jjj" | "kkk"} { do(); };

YYY options { ignore WS; } :
("lll" "mmmm" | "nnnn") { do(); };

-avoelker

> -----Original Message-----
> From: alekseyandreev [mailto:andreev at q...]
> Sent: Thursday, December 05, 2002 1:30 AM
> To: antlr-interest at y...
> Subject: [antlr-interest] Help me please to improve lexer
> 
> 
> My lexer grammar looks like this:
> 
> START options { ignore WS; } 
>    : "aaa"{do();} "bbb"{do();} "ccc"{do();}
>    | "ddd"{do();} "eee"{do();}
>    | "fff"{do();}  XXX {do();}
>    |  YYY {do();}
>    ;
> XXX options { ignore WS; } 
>    : "iii"{do();} "jjj"{do();}
>    | "kkk"{do();}
>    ;
> YYY options { ignore WS; } 
>    : "lll"{do();} "mmm"{do();}
>    | "nnn"{do();}
>    ;
> 
> Is there any opportunity to remove actions {do();}
> after every element and have analogue behavior?
> 
> Aleksey
> 
> 
>  
> 
> Your use of Yahoo! Groups is subject to 
http://docs.yahoo.com/info/terms/


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list