[stringtemplate-interest] whitespace in IF
Terence Parr
parrt at cs.usfca.edu
Sun Nov 8 10:47:23 PST 2009
On Nov 7, 2009, at 9:46 PM, Zenaan Harkness wrote:
> What about just a blank line? That evaluates to a blank line right?
yep.
> And if there is whitespace before the expression?
> Of course - this is kind of what we are discussing here.
Yep and " \n" evaluates to just \n. Indents are special.
> Here's an example from my st usage, just pretend it does _not_ have
> the leading spaces on each line:
>
> get(att) ::= <<
> <if(att.hasBody)>
> <callGet(att)>
> <else><if(att.final)>
> <varGet(att)>
> <else><if(model.final)>
> <varGet(att)>
> <else>
> <callGet(att)>
> <endif><endif><endif>
>>>
>
So you want no lines in output? Can u use <\\>?
> I have a few thousand lines of ST templates across about 30 ST group
> files, and without a backwards compatibility option I would be
> required to carefully run through each file, test cases etc, to debug
> all required changes. On the other hand I'm personally happy doing
> that if it means consistency.
Yeah, it's a tough call. I'm mostly redoing to remove ANTLR 2.7.7
dependency but I might as well clean up. No real new functionality so
can stick with 3.2.1 ST unless you can use 2.7.7 for license reasons.
>> With {x | foo} subtemplates, I'm ignoring whitespace after the pipe
>> so
>> you can format like:
>>
>> {x |
>> foo
>> }
>
> Again, breaking consistency.
actually it's consistent. one WS char in front of any multi-line
template.
> What about whitespace prefix operators :
see prev email.
> It's intuitive, deterministic, with a low cognitive overhead, and
> accords with principle of least surprise. I have spent many
> frustrating hours in total, fiddling with end-of-line rubbish,
me too
> in ST, when it should be simple and deterministic. I'd say this is
> my greatest frustration with ST to date (non deterministic, at least
> apparently so, whitespace behaviour in templates). This essentially
it's deterministic just weird.;)
> Any deviation (from simplest obviously correct mode of operation)
> should be something that is overrided with explicit syntax.
>
> Would "<>" (without the quotes) mean "absolutely nothing", or "empty
> template" etc, and provide for desires to layout a little nicer, eg:
>
> mytemplate(args) ::= <<<
>> even if in a file<
>>>>
>
> or
We have <\\> nowadays which can work.
> On the other hand, when I think back to my 3000+ lines of ST group
> file code, I have dozens of templates defined which take advantage of
> the current "ignore leading and trailing whitespace" behaviour.
later we could make a mode to do that.
> ST4 is a break-backwards compatibility release though... so clean up
> is first priority.
Agreed.
Thanks...
T
More information about the stringtemplate-interest
mailing list