[antlr-interest] Change operator precedence in a AST

Bryan Ewbank ewbank at synopsys.com
Sun Sep 26 13:38:02 PDT 2004


Joan Jesús said:
> How can I change the precedence of operator of my AST
> to reflect the operator precedence in  Java.
> Someone has some example?

I'm puzzled.  In an AST there isn't really precedence - you just evaluate
bottom-up.  Are you looking for guidance in rewriting/rotate the trees to
reflect a change in precedence?  E.g, something like this?

Given:
	(+ A (* C D))
Produce:
	(* (+ A C) D)

Or are you looking for a stack implementation that will ignore the shape of
the AST and evaluate an expression based on a different set of rules?

- Bryan Ewbank



 
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