[antlr-interest] StringTemplate: help on global dynamically scoped attribute/value/parameter

Terence Parr parrt at cs.usfca.edu
Tue Aug 14 10:57:18 PDT 2012


It could be that those actions are evaluated to strings before they are injected into the output template. I try to avoid that, but there could have been some implementation convenience I needed to do that for.

Ter
On Aug 13, 2012, at 10:33 PM, Francis ANDRE wrote:

> Hi Terr
> 
> By looking at the Java.stg of the org.antlr.tool, this is what I deduced about 
> the dynamic scope of attribute. For example, the LEXER attribute specified in 
> the outputFile template as parameter is used all along the various templates.
> 
> But what puzzles me is that <LEXER> is not recognized when it is used in the 
> evalSynPredicate template.
> 
> WIth:
> evalSynPredicate(pred,description) ::= "<pred>() /*<LEXER>*/"
> 
> I got this error
> context [/evalSynPredicate] 1:52 attribute LEXER isn't defined
> 
> So, what's wrong with the reference of <LEXER> in evalSynPredicate??
> 
> FA
> 
> 
> Le 13/08/2012 21:40, Terence Parr a écrit :
>> Hi, to make a "global" just create an attribute in the outermost template. That, through dynamic scoping, any template that is embedded within that template will see that outermost attribute. For example, when I am generating a file I usually have a fileName attribute at the outermost level in file() template. then, and I stick inside like method() can access that fileName attribute with <fileName>.
>> T
>> On Aug 13, 2012, at 5:52 AM, Francis ANDRE wrote:
>> 
>>> Hi
>>> 
>>> I am concerned about defining/using global dynamic scope attributes in ST.
>>> Beside reading the documentation, I did not found anything that is closed to
>>> this concept.
>>> 
>>> Can someone confirm that there is no global attribute statically or dynamically
>>> scoped?
>>> 
>>> TIA
>>> 
>>> FA
>>> 
>>> List: http://www.antlr.org/mailman/listinfo/antlr-interest
>>> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>> 
> 
> 
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address



More information about the antlr-interest mailing list