[stringtemplate-interest] padding and such for pretty printing

Terence Parr parrt at cs.usfca.edu
Sat Jul 5 13:54:57 PDT 2008


hi! Heh, I need to start thinking about building a pretty printer and  
have a basic architecture in mind. The problem is that I need away in  
ST to pad things out or anchor things more easily. Moreover, I might  
need to say things in the template like "if the help look for this  
element exceeds 20 characters, start it on a new line".Technically, we  
can do any expression we want as long as it is on the shape or the  
presence or absence of an attribute. We just can't test its value  
(booleans being the only special case). In other words there is  
nothing against model-view separation doing this:

<if(width(anotherTemplate()) > 20)>...<else>...<endif>

This means we have to add expressions within IF tags and I would need  
to do some type checking to make sure that you only did  computations  
on things like width() function results.

Has anybody built a pretty printer and know what the requirements  
are?  Jurgen Vinju at CWI in Amsterdam has a really nice tool in  
MetaEnv where you can group chunks into effectively large characters  
like latex... it then knows how to move them to a new line or whatever.

Ter


More information about the stringtemplate-interest mailing list