[antlr-interest] Referencing Template(s) in a grammar.

Craig Main craig at palantir.co.za
Tue Nov 24 06:49:14 PST 2009

How do I put a 'tempate' into a scope so that I can expand it again.

If I have:

xpath: decl+=declaration p+=path
       ->template(decl=decl, p=p) .. do stuff.

... (Lots of productions)

comp: ^('comparison' (op= ... // etc

I need the 'decl' template from the top production in xmlWhere which is a
in a much lower production, how do I add the template to a scope in xpath so
that the same template is available as a parameter in xmlWhere.

I am sure that a scope will work. I have used the scopes before, but don't
how to keep a template in the scope and use it again.
how do I reference the 'decl' from 'decl+=declaration' in the child

Is it even possible to reference upwards?


More information about the antlr-interest mailing list