[antlr-interest] [v3.1b1:] Is unparsing to textual representation of rewritten AST possible?

Andy Tripp antlr at jazillian.com
Tue Mar 4 08:39:10 PST 2008


Ralf,
Sounds like you're just looking for a "prettyprinter" which prints the 
AST out, looking roughly
like the original input. Yes, you can use an ANTLR treewalker and ST to 
do that.
Or you can do it "by hand". See 
http://www.antlr2.org/article/1170602723163/treewalkers.html
for a comparison of the two approaches.

Andy

Ralf Cremerius wrote:
> Hello,
>
> I'd like to ask, if it is possible to generate an AST, to modify that AST and to automatically unparse that modified AST to it's textual representation afterwards? I thought of something like this:
>
> ( textual input ) -> ANTLR lexer+parser grammar constructing AST -> ( AST ) -> ANTLR tree grammar rewriting AST (using v3.1b1 ...) -> ANTLR tree grammar with options output=template and rewrite=true -> (modifiet textual input [according to operations on the AST])
>
> My question is only about the last step, if unparsing from an AST to modified input is possible. Or do I have to define a StringTemplate-template to get the modifications from the rewritten AST into textual output again?
>
> Thanks in advance,
>   Ralf
> _____________________________________________________________________
> Unbegrenzter Speicherplatz für Ihr E-Mail Postfach? Jetzt aktivieren!
> http://freemail.web.de/club/landingpage.htm/?mc=025555
>
>
>   



More information about the antlr-interest mailing list