At 05:43 2/12/2008, Terence Parr wrote: >'.' is great to avoid a subtree or any random operand node >you don't care about. As a root, it can only be a node so >it's pretty easy to give the set of valid roots if necessary.
"Easy" is a relative term, depending on how many of them there are :) >Remember that AST construction is all about identifying the >ops and pseudo-ops in your program, then making them roots. >Why would you ever want to ingore what operation your looking at? That's not the only use for them. They can be used to indicate types or categories as well -- and in some contexts you care, while in others you might not. This is especially true when you have multiple tree parsers reading a single AST input, since different walkers might care about different things. >Oh, I just found one. You want to find all ID refs...well, >actually that is just: > >id : ID ; > >If you don't care about the root, just don't give it, right? > >x : ^(. ID) ; > >is identical to ID except it won't match ID as a root but >plain ID would. If ID on its own can match a tree of ^(FOO ID), then that's a bug. >If you don't care about structure, one could argue why you're using >a grammar to do that ;) You might not care *sometimes*, in *some contexts*. But you care a lot about other contexts. List: http://www.antlr.org:8080/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org:8080/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 -~----------~----~----~----~------~----~------~--~---
