[antlr-interest] Modifying and printing AST under C target

Heiko Folkerts Heiko.Folkerts at david-bs.de
Thu Oct 1 06:20:46 PDT 2009


Hello,
I have a parser that creates an AST. Now I want to annotate the AST with own data. It would be enough to change the payload coresponding to each node. Afterwards I want to print out the AST so I can write unit tests to check everything works as expected.

When I use the ASTLabelType pANTLR3_BASE_TREE and set the $type attribute within a rule I can run the parser, but the function toStringTree only prints out the tokentext. But I'd like to get also the type of the token in the output to check whether the assignment to the $type-Attribute was correct.

I tried using pANTLR3_COMMON_TREE but when running the function tostring (tostringTree is only in pANTLR3_BASE_TREE) my program crashes. 

So: 1. Do I have to use the base tree or the common tree?
2. If I need the common tree what do I have to do to use it correctly?

Thx
Heiko


Mit freundlichem Gruß
Heiko Folkerts
Systementwicklung und -design
--
______________________________________________
DAVID GmbH · Wendenring 1 · 38114 Braunschweig
Tel.: +49 531 24379-14
Fax.: +49 531 24379-79
E-Mail: mailto:Heiko.Folkerts at david-bs.de
WWW:   http://www.david-bs.de 
Eintragung: Amtsgericht Braunschweig, HRB 3167
Geschäftsführer: Frank Ptok
______________________________________________

 


More information about the antlr-interest mailing list