[antlr-interest] StringTemplate naming question

Terence Parr parrt at cs.usfca.edu
Wed Jul 14 10:19:06 PDT 2004


On Jul 13, 2004, at 3:08 PM, matthew ford wrote:

> Yes that reservered name has always worried me.
>
> In WebStringTempatesV2 I have introduced the concept of root and 
> current
> contexts
> The root context is referred to by .  (dot)
> the current context is referred to by ..  (doubledot)
> Although I handle lists without embedded or sub-templates the concept 
> can
> still
> be applied to StringTemplates
>
> In WebStringTemplatesV2 instead of
>> $names:{<b>$attr$</b>}$
> where names is a list, you would say
> $[list names]  <!-- this sets each item in the names list as the 
> current
> context one at a time-->
> <b>$[..]</b>
> $[endlist]
>
> where the $[..] returns the current context. I.e the
> current item of the name list being processed.

$...$ is not bad.  I'm leaning towards $obj$ now.

> Applying this to StringTemplates
>> $names:{<b>$attr$</b>}$
> would become
>> $names:{<b>$..$</b>}$
>
> If names had the structure
> firstname, surname
> That is names is a list of maps or beans that contain entries for 
> firstname
> and surname
> then
>> $names:{<b>$attr.firstname$ $attr.surname$</b>}$
> would become (under this proposal)
>> $names:{<b>$firstname$ $surname$</b>}$
> because by default attributes are always looked upwithin the current 
> context
> $firstname$ is the same as $..firstname$

I have a super.template() now, which is a one level "up" operator. :)

Thanks,
Ter
--
CS Professor & Grad Director, University of San Francisco
Creator, ANTLR Parser Generator, http://www.antlr.org
Cofounder, http://www.jguru.com
Cofounder, http://www.knowspam.net enjoy email again!
Cofounder, http://www.peerscope.com pure link sharing





 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
    antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



More information about the antlr-interest mailing list