------ Original Message (Monday, August 02, 2010 11:28:13 AM) From: Bob ------ Subject: [antlr-interest] Can I drive "CMinusWalker.g" from an external AST? > Regarding "Building a tree grammar for the C-Language" chapter: > > My AST for "C-" is already built by non-Antlr means, however, it does match > the "CMinus" grammar of chapter 8.2. To repeat, the AST image in 8.3, p200 > exists and was constructed outside of Antlr. > > I'd like to drive "CMinusWalker.g" by an in-order traversal of my AST (to > serialize). > > Q: Can I do this, and what is this interface going to look like? > Assume my AST nodes have token id values from "CMinus.tokens". Only if your AST is indistinguishable from an Antlr generated AST. Regardless of the picture, real Antlr ASTs have embedded DOWN and UP tokens delimiting subtrees. Also, your individual tree node fields and methods would have to match up with Antlr CommonTree nodes - you will have to cast to CommonTree. If you have this in place, then sure. > That is, how would this setup change? Just substitute in your generated AST for the Antlr generated AST.
Unless there is some essential reason to use an Antlr walker, may be better to continue on with a non-Antlr solution. 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.
