You don't need to do that. There is a user field in the COMMON_TREE node that you can use to store a pointer to your own data - this is much simpler. If you use a custom node, it must really embed COMMON_TREE, which embeds BASE_TREE. Each of these has super pointers to the larger structure but passes around BASE_TREE (though the pointers are void * in the grammar).
-----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Heiko Folkerts Sent: Thursday, October 01, 2009 6:21 AM To: [email protected] Subject: [antlr-interest] Modifying and printing AST under C target 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:[email protected] WWW: http://www.david-bs.de Eintragung: Amtsgericht Braunschweig, HRB 3167 Geschäftsführer: Frank Ptok ______________________________________________ List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en -~----------~----~----~----~------~----~------~--~---
