[antlr-interest] Able to emulate java.text.ChoiceFormat ?
Christopher Brown
chris77550 at gmail.com
Mon Nov 26 01:35:23 PST 2007
Hi,
Is it possible to create templates that have the capabilities of
ChoiceFormat with StringTemplate (I'm using ST#3)?
http://java.sun.com/javase/6/docs/api/java/text/ChoiceFormat.html
For example, the following template doesn't work:
fileInfo(fileName,fileSize) ::= <<
File $fileName$, $fileSize$ $if(fileSize>1)$bytes$else$byte$endif$.
>>
(I'm using a group template file with the default lexer, not the angle
bracket one, as my target is HTML...).
There only seems to be support for conditions based on string equality
or just non-nullity, not numeric comparisons. I'm not wanting to add
computation into the view, but it's important in many (human)
languages to be able to vary the text along with a quantity, and I
don't want to hard-code parts of the template into the code that calls
it.
Thanks,
Christopher
More information about the antlr-interest
mailing list