[antlr-interest] multiple tree walkers

Andreas Meyer Andreas.Meyer at smartshift.de
Mon Feb 9 09:37:35 PST 2009


Hi!

What I did: have a "base" tree grammar with only the rules, but no actions.
Then, have a "do something" tree grammar that imports the base grammar, and
only overrides the interesting rules. However, it seems that ANTLR 3.1
currently has a bug when using it like this (see previous mails), so you
need to uncomment some lines within the ANTLR sources.

Cheers,
Andreas Meyer

-----Ursprüngliche Nachricht-----
Von: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] Im Auftrag von Oliver Zeigermann
Gesendet: Montag, 9. Februar 2009 09:51
An: Michael Bedward
Cc: antlr-interest at antlr.org
Betreff: Re: [antlr-interest] multiple tree walkers

Hi Michael!

I do the same thing and have the same concerns. I have no better
solution now, but ANTLR 3.2 will feature pattern based tree rewriting
which might solve this:

http://www.antlr.org/wiki/display/~admin/2008/11/30/Example+tree+rewriting+w
ith+patterns

I set up a page where I share my experience with multiple tree
transformer stages:

http://www.antlr.org/wiki/display/ANTLR3/Complex+tree+transformations+using+
cascading+tree+rewriters

Maybe you would like to add yours?

-Oliver

2009/2/9 Michael Bedward <michael.bedward at gmail.com>:
> Hi folks,
>
> I'm working on a little DSL, called jiffle, to create raster images
> from maths expressions.  I build an initial AST from the input jiffle
> script, and next use a couple of tree walkers to (1) check for
> undefined vars and (2) categorize vars on whether thay depend on pixel
> position or not.
>
> The grammar for each of these tree-walkers is essentially the same as
> that for the token parser, except that only a very small number of
> rules / sub-rules have actions.  Everything is working swimmingly at
> the moment - but I'm concerned that this approach of cloning a grammar
> might be prone to error as the language evolves since it depends on
> keeping all of clones in sync.
>
> Are there other approaches / best-practices for writing multiple tree
walkers ?
>
> cheers
> Michael
 

__________ Hinweis von ESET Smart Security, Signaturdatenbank-Version 3839
(20090209) __________

E-Mail wurde geprüft mit ESET Smart Security.

http://www.eset.com
 



More information about the antlr-interest mailing list