You need to combine a tree walker with StringTemplate for output.  The tree 
walker can reflect high-level semantic concepts in its productions 
(declarations, method/function calls, etc.) that the depth first visitor 
cannot.  StringTemplate helps in rearranging tokens, adding syntactic sugar, 
etc. and your templates can be organized to suit the productions of the tree 
walker.

--Loring




>
>From: sgoto <[email protected]>
>To: [email protected]
>Sent: Friday, July 24, 2009 12:17:43 PM
>Subject: [antlr-interest] source code formatter
>
>Hi,
>
>
>   I am having a hard time using tree grammars for source code 
> formatting/beautifier for language X. Are tree grammars actually meant to 
> help me with source code formatting or am I better off with depth first 
> visitors ?
>
>
>   By reading Terrence's post about how translators should use tree grammars 
> makes me want to use it, it seems to be addressing the issues I have with 
> visitors for translators, but I am not sure if it will help me much with 
> formatters.
>
>
>   ideas ?
>
>-- 
>f u cn rd ths u cn b a gd prgmr !
>


      
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

Reply via email to