whitespace rules for st4?

26 views
Skip to first unread message

Colin Fraizer

unread,
Jul 21, 2015, 9:36:26 AM7/21/15
to stringtempla...@googlegroups.com
Is there a place in the documentation where all the whitespace rules are explained? (I use '$' for both delimiters throughout.)

It seems like the expansion of
```
foo() ::= <<
A
>>
```

and

```
foo() ::= <<
A>>
```

are equivalent to

```
foo()::= <<A>>
```

So, it appears the rule is:
newlines are ignored immediately after '<<' and immediately before '>>' and immediately after $endif$ (or <endif> or whatever. YDMV.)

Are those the only places where newlines are treated specially (besides the obvious <% %>)?

```
foo() ::= <<
$if (true)$A
$else$B
$endif$C
>>

bar() ::= <<
$if (true)$A
$else$B
$endif$
>>

baz() ::= <<
$if (true)$A
$else$B
$endif$
C
>>

quux() ::= <<
$if (true)$A
$else$B
$endif$C>>

quuux() ::= <<$if (true)$A
$else$B
$endif$C
>>

quuuux() ::= <<
$if (true)$$\\$
A
$else$$\\$
B
$endif$C
>>

quuuuux() ::= <<
$if (true)$$\\$
A$\\$
$else$$\\$
B$\\$
$endif$C
>>

quuuuuux() ::= <<
$if (true)$$\\$
A$\\$
$else$$\\$
B$\\$
$endif$
C
>>

my_test() ::= <<
<!-- Test foo -->$foo()$<!-- EndTest -->
<!-- Test bar -->$bar()$<!-- EndTest -->
<!-- Test baz -->$baz()$<!-- EndTest -->
<!-- Test quux -->$quux()$<!-- EndTest -->
<!-- Test quuux -->$quuux()$<!-- EndTest -->
<!-- Test quuuux -->$quuuux()$<!-- EndTest -->
<!-- Test quuuuux -->$quuuuux()$<!-- EndTest -->
<!-- Test quuuuuux -->$quuuuux()$<!-- EndTest -->
>>
```

my_test expands to

```
        <!-- Test foo -->A
        C<!-- EndTest -->
        <!-- Test bar -->A
        <!-- EndTest -->
        <!-- Test baz -->A
        C<!-- EndTest -->
        <!-- Test quux -->A
        C<!-- EndTest -->
        <!-- Test quuux -->A
        C<!-- EndTest -->
        <!-- Test quuuux -->A
        C<!-- EndTest -->
        <!-- Test quuuuux -->AC<!-- EndTest -->
        <!-- Test quuuuuux -->AC<!-- EndTest -->
```

Terence Parr

unread,
Jul 21, 2015, 5:05:50 PM7/21/15
to stringtempla...@googlegroups.com
Hi. Yeah,  There is no obvious place in the documentation that explains all the rules for white space. Sorry. <<...>> does strip 1 \n before and after. We tried to make everything work fairly naturally. some of it is trial and error
Ter

--
You received this message because you are subscribed to the Google Groups "stringtemplate-discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to stringtemplate-dis...@googlegroups.com.
To post to this group, send email to stringtempla...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/stringtemplate-discussion/CAGo9M35V1E%3DGcWMPt_0n81g%3DmAhR3fDnf8JCToP2v-Pmj%2BuWNA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.



--
Dictation in use. Please excuse homophones, malapropisms, and nonsense. 
Reply all
Reply to author
Forward
0 new messages