[stringtemplate-interest] padding and such for pretty printing

Terence Parr parrt at cs.usfca.edu
Sun Jul 6 13:58:24 PDT 2008


Interesting. my basic design is to build a parse tree, not an AST, and  
then look up a template for each rule. I.e., for rule expression, emit  
it with a template called expression.  Now, within the expression, we  
need to be able to say what can be broken up and what needs to be  
wrapped and so on.  Jurgen Vinju gave me a nice demonstration of what  
he is working on... I think this paper might summarize:

http://ftp.cwi.nl/CWIreports/SEN/SEN-R0601.pdf

Right. you'll note that in his table 2, view showing boxes with stuff  
inside. Then he can say whether they should be laid out horizontally  
(H) or vertically (V).  Verryyyy  interesting.

Ter

On Jul 5, 2008, at 8:01 PM, Zenaan Harkness wrote:

>> <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
>
> I've only done mine at the model layer, so it is somewhat specific  
> to my
> model.
>
> I'm introducing new model types, so it is getting more generic.
>
> I have formatting of the following genres:
> -  truncation (to show short version of longer strings)
> -  the obvious toUpper/Lower
> -  padding formatting, which is high-performance if a standard
>   pad character is used (which I think is all I support for now).
>
> I don't have a "requirements spec", and I wrote the code earlier this
> year now, but happy to pass on the code to anyone interested.
>
> Also, I wrote a clean STGTraverser, for Iterating, and Iterable-ing,
> StringTemplateGroup parents. Again, just email if you want it.
>
> zen
>
> -- 
> Homepage: www.SoulSound.net -- Free Australia: www.UPMART.org
> Please respect the confidentiality of this email as sensibly  
> warranted.
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org:8080/mailman/listinfo/stringtemplate-interest



More information about the stringtemplate-interest mailing list