[antlr-interest] Parse simle list

Bryan Ewbank ewbank at gmail.com
Sat Jan 22 06:20:15 PST 2005

On Sat, 22 Jan 2005 12:57:09 +0100, Tomasz Bluszcz <moviem at web.de> wrote:
> Here is the very simple parser grammar:
> parse           :       (KW_ELEMENT LEGALNAME attribs)* ;
> attribs :       '{'! (CCBOOL LEGALNAME)* '}'!;
> Can anybody point my an example or give my some hints?
> What modification i have to do to get the tree structure described above?

I think what you want is to change "parse" to be:
   parse : (KW_ELEMENT^ LEGALNAME attribs) *;
I did not test this

> Exist a c++ class to view the ast like the java class ASTviewer?

There is an example C++ tree printer in the antlr manual.  It displays
a textual representation of the tree.  You can all used toStringList()
to emit the tree in a parenthesized form.

Hope this helps,
- Bryan

More information about the antlr-interest mailing list