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

Francis ANDRE francis.andre.kampbell at orange.fr
Mon Aug 13 22:33:29 PDT 2012


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
>



More information about the antlr-interest mailing list