groovy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jochen Theodorou <>
Subject Re: So I want to be able to pretty-print ASTNode and children...
Date Thu, 16 Mar 2017 21:39:50 GMT
On 16.03.2017 17:46, Andrew Bayer wrote:
> I don't think there's anything out there that does this currently, so
> I'm gonna write up a PR to add this. Now I need to figure out what the
> right implementation would be. Do I go with adding useful .toString()
> methods to the various ASTNode children that don't already have them
> (i.e., most of the *Node classes, some Expressions, some Statements) or
> do I instead write a helper class that has all the to-string logic for
> all the ASTNode children in it? Thoughts?

I would not depend on toString here. You want a pretty-print, that will 
require some kind of formatting information across the AST nodes, even 
if it is only indentation. toString will not give you that. I would make 
an visitor instead, that goes through the AST and produces the pretty-print.

bye Jochen

View raw message