[stringtemplate-interest] Indirect attribute lookup
Terence Parr
parrt at cs.usfca.edu
Sat Sep 6 14:45:47 PDT 2008
Hi Roman, i don't think there's a way to ask for the internal hashmap
containing the args...we need a this.(foo) I think.
Ter
On Sep 6, 2008, at 2:14 AM, Roman Odaisky wrote:
> Greetings,
>
> I’ve discovered this code in language/ASTExpr.py:
>
> # Special case: if it's a template, pull property from
> # it's attribute table.
> # TODO: TJP just asked himself why we can't do inherited attr
> here?
> elif isinstance(o, stringtemplate3.StringTemplate):
> attributes = o.attributes
> if attributes:
> if attributes.has_key(propertyName): # prevent
> KeyError...
> value = attributes[propertyName]
> else:
> value = None
>
> However, I was unsuccessful in trying to refer to the template from
> within
> itself, neither did outer ::= inner(...) and $outer.(expr)$ help.
>
> How can I refer to a template argument indirectly by having an
> expression
> which evaluates to its name?
>
> P. S. The Python code above is identical to:
>
> elif ...:
> value = o.attributes and o.attributes.get(propertyName)
>
> --
> TIA
> Roman.
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org:8080/mailman/listinfo/stringtemplate-interest
More information about the stringtemplate-interest
mailing list