[stringtemplate-interest] Different formats for data

FranklinChen at cmu.edu FranklinChen at cmu.edu
Tue Feb 12 13:32:54 PST 2008


I have an application using ANTLR3 and StringTemplate that basically
parses data and then outputs it in two very different formats.  For
example, dates need to be output as both 12-FEB-2008 and 2008-02-12.
I would like advice on how to do this, using a single tree grammar and
two ST group files.  E.g., if the tree grammar has

birthdate
    :
        DATE
        ->
        birthdate(date={$DATE.text})
    ;

then there is a problem, because of the strict separation that
apparently prevents me from having birthdate() in A.stg and B.stg do
"computations" to reformat the date.  E.g., suppose DATE came from the
lexer as 12-FEB-2008.  Then A.stg's birthdate() is trivial, but
B.stg's birthdate() can't be done.  What is the solution?

-- 
Franklin


More information about the stringtemplate-interest mailing list