[stringtemplate-interest] summarizing white space and indentation

Sam Harwell sharwell at pixelminegames.com
Mon Nov 9 21:40:06 PST 2009


#3 is a "simple" rule that actually solves a complicated problem. For
example:

foo() ::= <<
    <bar()>
>>

bar() ::= <<

something
>>

With just rules 1 and 2, the output is "    \n    something"

I believe that the intent in bar() is a blank line, not a line with the
indent only. With rule 3 in place, the output is "\n    something". A
complicated rule regarding indentation and blank lines could be formed,
but the easiest is just trimming trailing whitespace from the final
output.


-----Original Message-----
From: Jonathan Buhacoff [mailto:jonathan at buhacoff.net] 
Sent: Monday, November 09, 2009 10:35 PM
To: Sam Harwell
Cc: Terence Parr; StringTemplate Mailing List
Subject: Re: [stringtemplate-interest] summarizing white space and
indentation

> 3. By default, trim trailing whitespace from the end of each line of  
> the
> final output, but allow this to be overridden in code.
>

I don't really understand the need for #3, or maybe I prefer the  
default to be the other way - I prefer to leave the inside template  
alone unless the programmer says otherwise.



More information about the stringtemplate-interest mailing list