[stringtemplate-interest] Force single-valued template

Terence Parr parrt at cs.usfca.edu
Sun Nov 20 08:43:05 PST 2005


On Nov 19, 2005, at 11:19 PM, Sohail Somani wrote:

> Is there a way to force a single valued template?
>
> For example:
>
> foo(bar)::=<<
> <bar>
>>>
>
> I want foo to die if there is more than one bar. Is there another  
> way to
> approach this?

Hi.  Do you mean throw an exception when you try to set bar?  Or, do  
you mean just not print anything?

My first design for arguments of templates included cardinality like:

foo(a,b?,c*,d+) ::= "..."

where plain 'a' meant exactly one.  Unfortunately there was so much  
stuff written with just plain arguments listed that I didn't feel  
like it was possible to change.  Further, it complicated the  
evaluation of predicates (slowed it down a bit) and I wasn't sure how  
many people would use it.  I believe I have the infrastructure in  
there still; just not hooked up.

Can you explain the primary motivation?

Ter


More information about the stringtemplate-interest mailing list