In the WITH node, when you walk the tree, you can have a scope and set the node of the WITH subject in to the scope, then you refer to it in the scope when you walk the tree and find a . node that has no LHS.
Don't try to rewrite it as that isn't the way to do it. Jim > -----Original Message----- > From: [email protected] [mailto:antlr-interest- > [email protected]] On Behalf Of Graham Mer > Sent: Wednesday, April 13, 2011 5:37 PM > To: [email protected] > Subject: Re: [antlr-interest] Previous rule element reference in a > scope > > > It's not clear from your question if only method calls are legal > > within a "with" statement, in which case the suggestions made should > > work, or if (as I suspect) any statement is legal within a "with", > like in javascript. > > Thanks for the replies, everyone. > > You're correct, Peter, it is not limited to only method calls. I don't > think parameter passing will work, since the enclosed statement block > is not part of the withStatement rule. I (over-?) simplified my example > grammar fragment as an illustration; withStatement and the stuff inside > the With block are all "statements" in higher rules, so I'd need to > pass parameters among large numbers of rules, which is doesn't seem > very maintainable. Isn't this exactly what a scope was intended for? > > Assuming this is an appropriate place to use a scope, how do I get that > withStatement ID value into a scope instead of into a parameter? > > Thanks again! > > 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.
