[antlr-interest] (no subject)

Jim Idle jimi at temporal-wave.com
Tue Oct 7 07:24:22 PDT 2008


On Tue, 2008-10-07 at 14:53 +0200, Florian Friedemann wrote:

> Hi,
> I'm currently working on a parser generating an AST.
> Into that AST I want to put information that hasn't been parsed but generated during the process of parsing
> (one example would be the Integer-typed index of a parsed variable within a scope).
> So I wrote a function creating a CommonTree.



> If it is flawed, is there any other way I can add information that was generated during parsing to the AST?


Make a subclass of CommonTree that contains the information fields you
need.
Change the option ASTLabelType=MyCommonTreeSubClass.
Element references are now to objects of your new type and you can add
the information you need.

But, you might really be wanting Heterogeneous tree nodes? See wiki
articles on this.

Jim


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20081007/fb0856da/attachment.html 


More information about the antlr-interest mailing list