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

craig at palantir.co.za craig at palantir.co.za
Wed Nov 11 21:00:20 PST 2009


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.

given:

xpath : d+=declaration* p+=path
        -> sql(declarations={$d}, paths={$p})
;

... many productions later ...

comp : ^('comparison' (op='=' | op='<' | op='>' | op='like') lv=relativePath
rv=relativePath)
       -> {IsIndexed($rangeExpr::path)}? sqlWhere(path={$rangeExpr::path},
lv={$lv.st}, rv={$rv.st}, op={$op})
       -> xmlWhere(path={$rangeExpr::path}, lv={$lv.st}, rv={$rv.st}, op={$op})
;

I now need to reference those declarations in xpath above in the xmlWhere and
sqlWhere templates below. There are many productions in between so it's going
to be hard to carry them all the way though.

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

Thanks
Regards
Craig.



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




More information about the antlr-interest mailing list