[antlr-interest] Building trees with the correct associativity

Paul J. Lucas pauljlucas at mac.com
Wed Dec 1 18:06:46 PST 2004


	I'm surprised it took me this long to notice I had a problem
	with this, but...

	If I have:

		addExpr
		    : e1:mulExpr
		      (ao:addOp! e2:mulExpr!
		      	{
			    ## = #([ADD_EXPR,"ADD_EXPR"], ao, e1, e2);
			}
		      )*
		    ;

	then my trees get built the wrong way, e.g.:

		5 - 2 + 3

	is as if it were:

		5 - (2 + 3)

	which is wrong.  Maybe I'm being a but slow, but it's not
	immediately clear how to build the tree the other way, i.e.:

		(5 - 2) + 3

	Help.

	- Paul



 
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