Antlr v3 & Trees (was: [antlr-interest] if-then-else - Grammar generates faulty parser code)

John D. Mitchell johnm-antlr at non.net
Thu Apr 22 13:23:55 PDT 2004


>>>>> "Monty" == Monty Zukowski <monty at codetransform.com> writes:
[...]

> Jeff, You have a unique situation in that your tree parser actions are
> your runtime and you call them to "execute" the script you have parsed.
> Actually that's pretty clever -- (NOTE TO TERENCE) we (ahem, as I recall)
> haven't given much thought to how to create interpreters with ANTLR
> beyond "do it in the actions."  This merits attention at the next ANTLR
> Cabal to refine ANTLR 3 designs.

I guess I'm a bit confused by what you're saying here.  Creating a tree
walker which executes as its actions is basically logically the same as
doing the execution in parser actions (but you get all of the benefits of
having a clean IR, etc. including the ability to jam in earlier tree
walkers which hack on the tree).

This approach blends nicely into the realm of optimizing interpreters, JIT
compilers, and dynamic compilers.


> Loring and I have been trying to distill comprehensive guidelines to tree
> building.

Cool.  Feel free to drag me in.

> We've been examining the "EMPTY_BLOCK" placeholder node trick.  The
> tradeoff is computation v. space but also introducing a placeholder node
> may be required to eliminate ambiguity to support something like the C
> "for" -- for: #(FOR e1:expr e2:expr e3:expr)--if you made the expr's
> optional then you would need some other sentinel such as leaving in the
> semicolon so you knew which place the expr was in to accommodate for
> empty exprs.

> 	But without an ambiguity it really becomes space v. code size.
> Ideally we(I)'ll come up with a number of distinct scenarios and work
> them in different styles to really nail down the tradeoffs.

I'm perplexed.  Do you have some example where the addition of an imaginary
node is some kind of problem?  The only examples that I can think of would
all be issues of a very poorly designed tree to begin with.

Thanks,
	John


 
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