[antlr-interest] tree parser example PDF docs and ANTLR Patte rns (was Re: the tree parser exampl)

mzukowski at yci.com mzukowski at yci.com
Tue May 7 14:50:51 PDT 2002


> This is on applying rewrite rules for grammar transformation.  There 
> has been quite a bit of research on rewriting, and it would be 
> interesting to interface the BURG (bottom up rewrite 
> generator)algorithm with ANTLR to do the "match pattern and rewrite" 
> approach to rule and tree transformation (as opposed to ANTLR's match 
> rule and rewrite according to user annotations).

Antlr also does have some tree matching routines built in.  See the
implementations of the methods below in antlr.BaseAST
    public boolean equals(AST t);
    public boolean equalsList(AST t);
    public boolean equalsListPartial(AST t);
    public boolean equalsTree(AST t);
    public boolean equalsTreePartial(AST t);
    public ASTEnumeration findAll(AST tree);
    public ASTEnumeration findAllPartial(AST subtree);

I've not needed these for my projects but would be interested in hearing how
people use them.  

> BTW, I just received a letter that okays release of my rewriting 
> support and tree grammar generation extensions under 
> copyright.  Now I 
> have to find out what else I need to do to actually release it, but I 
> can hope for an early June release.  This is probably a good starting 
> point for incorporating meta-level rewrite rules--the extensions 
> generate a syntax tree for the output grammar from an input grammar.

That's great news!

> > * Compilers
> 
> This is a matter of interfacing to a backend.  An interesting 
> start in 
> this direction would be for someone to generate RTL from a 
> transformed 
> ANTLR syntax tree.  Monty's GNU C grammar is much cleaner 
> than the GNU 
> C flex/bison (at least the gcc front end used to be a case of 
> "abandon 
> hope all ye who enter here"--I haven't looked at the source since a 
> 1.xx release) and an ANTLR C++ front end would be a major improvement.

It was pretty ugly.  I'm no YACC expert, so I gave up trying to deduce the
actual grammar from the flex/bison code.  I understand that David Wigg and
his group are porting it from Java to C++.  The Aspect C tool is being
written with it.  It's a source to source tool but should have some
interesting analysis and transformations going on in it.

 
> > * Interpreters
> 
> I don't know of an interpreter written in ANTLR, although Ter has 
> provided a few hooks for the purpose.  It would be 
> interesting to hear 
> of any experiences with ANTLR in this area.

Sinan has written a BASIC interpreter.  It's the tinybasic example in the
antlr distribution.

Monty
www.codetransform.com

 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list