[antlr-interest] The right way to invoke templates with nullarguments?
Terence Parr
parrt at cs.usfca.edu
Fri Jun 22 00:10:24 PDT 2007
On Jun 22, 2007, at 11:02 AM, Diehl, Matthew J wrote:
>> (have to have a cumbersome conditional in there).
>
> I've decided (I'm new though) that the best way to setup your
> 'cumbersome conditional' is whenever there's a conditional part,
> set it
> equal to something (s2 like you did below), and then in the
> StringTemplate section, define it as:
>
> stat2={s2!=null?$s2.st:false}
Correct.
> Instead of false, you can also probably try null.
correct.
> This allows you so
> that when you write the group file, <if(stat1)>other
> stuff<stat1><endif>
> can be used as well. When I was setting it as:
> stat2={s2!=null?$s2.st:""} it would always return true for
> <if(stat1)><endif> since it was not null or false,
correct "" is a present attribute so IF evals to true on that.
Set it to null :)
Ter
More information about the antlr-interest
mailing list