[antlr-interest] Re: equals and issameas (was: if-then-else)

Mark Lentczner markl at glyphic.com
Fri Apr 23 07:47:56 PDT 2004


> exp1 : exp2 (EQUALS^|SAMEAS^|EQUAL_SIGN^) exp2;

Try this

exp1 : exp2 equals^ exp2 ;
equals : ( "equals" | "issameas" | EQUAL_SIGN ) { 
#equals->setType(EQUAL_SIGN); } ;

This way you can have your literals as literals (rather than lexer 
tokens) and the generated AST will use only one token type as the tree 
root.

I do this sort of thing all the time, as I like my AST trees to be very 
simple and regular.

	- Mark

Mark Lentczner
markl at wheatfarm.org
http://www.wheatfarm.org/



 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
     http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
     antlr-interest-unsubscribe at yahoogroups.com

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



More information about the antlr-interest mailing list