Bill, As you are using action code anyway, then you can just use the standard Java methods for tree building in your code. However, it is good practice to move such code into external methods of some helper class so that your grammar is not cluttered with unreadable inline code.
You can look at the generated code to see how to do that via the tree adaptor. Jim > -----Original Message----- > From: [email protected] [mailto:antlr-interest- > [email protected]] On Behalf Of Bill Andersen > Sent: Wednesday, August 11, 2010 12:17 PM > To: antlr-interest > Subject: [antlr-interest] AST construction - adding extra children via semantic > action > > Hi Folks > > Here's the relevant fraction of a tree grammar I'm working on... > > spec > : ^(SPEC rule+) > ; > > rule > : ^(RULE_DECL ID alts) > ; > > It's a grammar that recognizes a language, the output of which is another > ANTLR grammar. > > I want the first rule to look like this: > > spec > : ^(SPEC rule+) > { < some action here > } > -> ^(SPEC < augmented list of rules >) > ; > > In other words, I want to add some extra RULE_DECL trees on to the end of > whatever rule+ accumulates, based on semantic information gathered during > the tree parse. > > Is there a straightforward way to do this? > > Thanks > > .bill > > 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.
