[antlr-interest] accessing parent attributes

Terence Parr parrt at cs.usfca.edu
Fri Mar 28 13:42:47 PDT 2008


Hi. You can't access the attr from surrounding template because you've  
hidden it with redef of parameter. Just use fname and mname or  
something.

Ter
On Mar 28, 2008, at 8:52 AM, Vincent Dupuis wrote:

> Hello,
>
> I don't know if this is the right post for these kind (level) of  
> question. (If not, tell me where to do it)
>
> I'm a new user of antlr 3 and StringTemplate.
>
> Question:
> Is it possible, in a template, to obtain the "parent" values.
>
> Example:
>
> file(name, methods) ::= <<
> /*
>  * Generated <name>
>  */
>
> <methods; separator="\n\n">
> >>
>
> method(retType, name, params) ::= <<
> <retType> <file.name>::<name>(<params>)
> {
> }
> >>
>
> Of course the <file.name> doesn't work but it's what I want.
> Do I need to pass the file.name for every method as a parameter?
>
> Thanks,
>
> Vincent
>
>
>
> Envoie un sourire, fair rire, amuse-toi! Employez-le maintenant!

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080328/7ac8c64d/attachment.html 


More information about the antlr-interest mailing list