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

craig at palantir.co.za craig at palantir.co.za
Wed Nov 18 00:42:53 PST 2009


Hi Kaleb,

Sorry for the late response, I have been away.

My question then is how do I put a 'tempate' into a scope so that I can use it
again.

If I have:
xpath: d+=declaration p+=path
       ->template(d=d, p=p) .. do stuff.

... (Lots of productions)

comp: ^('comparison' (op= ... // etc
       ->xmlWhere(declarations=d)

I need the 'd' template from the top production in xmlWhere which is a template
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 know
how to keep a template in the scope and use it again.
how do I reference the 'd' from 'd+=declaration' in the child production.

Thanks
Regards
Craig.


On Wed, Nov 11, 2009 at 9:00 PM,  <craig at palantir.co.za> wrote:
> Hi,
>
> I have a grammar that I am using to generate sql. My question is: Is
> there any easy way to refer to a 'parent' template in a child production.

[...snip..]

> I need xmlWhere(declarations={$d}...) but it's not available.

I was going to say that you need to use scopes to make that available later in
your code, but it looks like you're already using scopes.
Can you elaborate a bit on what I may have missed that makes scopes insufficient
for your needs?

Thanks.

--
Kaleb Pederson

Blog - http://kalebpederson.com
Twitter - http://twitter.com/kalebpederson




----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.




More information about the antlr-interest mailing list