[antlr-interest] Previous rule element reference in a scope

Graham Mer gd.antlr at gmail.com
Wed Apr 13 17:36:59 PDT 2011


> 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!


More information about the antlr-interest mailing list