[antlr-interest] Re: Building trees with the correct associativity
lgcraymer
lgc at mail1.jpl.nasa.gov
Wed Dec 1 18:53:26 PST 2004
Sorry--
I miswrote the second case which should have been
addExpr
:
mulExpr (addOp addExpr)?
;
and you can do the rewrite within the ()?.
Out of curiosity, why are you avoiding the more compact
addExpr
:
mulExpr (addOp^ mulExpr)*
;
The binary trees avoid inserting the extra node.
--Loring
--- In antlr-interest at yahoogroups.com, "Paul J. Lucas"
<pauljlucas at m...> wrote:
> On Thu, 2 Dec 2004, lgcraymer wrote:
>
> > addExpr:
> > :
> > mulExpr (addOp mulExpr)*
> > ;
>
> This elides the tree-building code, a la:
>
> ## = #([ADD_EXPR,"ADD_EXPR", ao, e1 e2);
>
> If I add that in inside the ()*, the ## gets its value
> overwritten (as Terence noted and I subsequently corrected).
>
> > addExpr
> > :
> > mulExpr (addOp addExpr)*
> > ;
>
> This is what I actually have now (as I corrected myself in a
> previous e-mail). This doesn't work.
>
> I want an ADD_EXPR to be present in the tree only if an
> expression actually contains an addOp thus prodicing "compact"
> trees without lots of useless intervening nodes.
>
> - 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