[stringtemplate-interest] Indirect attribute lookup

Roman Odaisky roma at qwertty.com
Sat Sep 6 02:14:33 PDT 2008


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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2286 bytes
Desc: not available
Url : http://www.antlr.org:8080/pipermail/stringtemplate-interest/attachments/20080906/8698f6ca/attachment.bin 


More information about the stringtemplate-interest mailing list