[antlr-interest] Transforming input
Terence Parr
parrt at cs.usfca.edu
Sun May 6 12:31:30 PDT 2007
On May 5, 2007, at 4:41 PM, Miguel Ping wrote:
> Hi all,
>
> It seems that I can parse a reasonable subset of sql selects now,
> and my problem now is finding a nice way of generating output. I
> thought of string template, but I think it would be a bit overkill
> since the difference between the input and output is small, and I
> do not want to target multiple languages, which I believe one of ST
> strong point. Because I need to retain original formatting
> including whitespaces, what is the best way of storing and
> outputing the result?
option rewrite=true and optionally output=ST
> I tried setting the token text within a visitor class, and after
> that using a custom token stream to output token texts +
> whitespaces. It didn't work, I guess antlr internally copies/clones
> the tokens when creating the the AST tree. Can anyone give me a
> good hint on this?
>
It only keeps a poitner to it. You need to use rewrite mode...nice
description in book about doing these kind of translations ;)
Ter
More information about the antlr-interest
mailing list