[stringtemplate-interest] indented IFs in STv4
Nicola Musatti
Nicola.Musatti at objectway.it
Tue Nov 10 01:00:07 PST 2009
In my opinion if either an <if(x)>, and <else> or an <endif> are
followed by whitespace until the following newline both the whitespace
and the newline should be ignored; any newline following the if or the
else body should be preserved. Thus:
[
<if()>
foo
<endif>
]
should print either
[
foo
]
or
[
]
while
[
<if()>
foo
<else>
bar
<endif>
]
should print either
[
foo
]
or
[
bar
]
On the other hand
[
<if(x)>foo<endif>
]
should print either
[
foo]
or
[
]
This approach is more natural than the current one when you need to
insert alternate blocks of line and may also be used for inline
conditionals.
Cheers,
Nicola Musatti
Terence Parr wrote:
> Ooops. correct that it should not indent twice...but it shouldn't
> indent even once:
>
> [
> foo
> ]
>
> The IF indent indicates you want that as just a "readability" indent
> and not a true one. We have to subtract that from indent of foo or bar.
>
> An IF on line by itself is a true indent:
>
> <if(x)>foo<endif>
>
> Ter
> On Nov 6, 2009, at 2:47 PM, Terence Parr wrote:
>
>> Hi,
>>
>> Some of you have asked for (and I've wanted) to indent IFs w/o
>> screwing up the indentation. For example,
>>
>> [
>> <if(x)>
>> foo
>> <else>
>> bar
>> <endif>
>> ]
>>
>> should not indent foo or bar twice, which it did in STv3. result is
>>
>> [
>> foo
>> ]
>>
>> or
>>
>> [
>> bar
>> ]
>>
>> took me a bit to make this happen but worth it.
>>
>> Ter
>>
>> _______________________________________________
>> stringtemplate-interest mailing list
>> stringtemplate-interest at antlr.org
>> http://www.antlr.org/mailman/listinfo/stringtemplate-interest
>
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org/mailman/listinfo/stringtemplate-interest
>
--
La presente comunicazione potrebbe contenere informazioni riservate e/o protette
da segreto professionale ed e' indirizzata esclusivamente ai destinatari della
medesima qui indicati. Se avete ricevuto per errore la presente comunicazione,
siete invitati a segnalarcelo, rispondendo a questo stesso indirizzo di e-mail,
e a cancellare il presente messaggio dal Vostro sistema. E' strettamente proibito
e potrebbe essere fonte di violazione di legge qualsiasi uso, comunicazione, copia
o diffusione dei contenuti di questa comunicazione da parte di chi la abbia
ricevuta per errore o in violazione degli scopi della presente.
Il messaggio e' stato analizzato alla ricerca di virus o contenuti pericolosi
ed e' risultato NON infetto.
More information about the stringtemplate-interest
mailing list