|
|
Re: terminals gets my knickers in a twist every time... [message #632446 is a reply to message #632429] |
Wed, 13 October 2010 00:35 |
Henrik Lindberg Messages: 2509 Registered: July 2009 |
Senior Member |
|
|
WOOT !
(Hint «{=expr}» is an "echo", while «{expr}» just has side effects, but
can include printing of templates inline).
--- testingIfSebastianGetsABeer.b3
« This is a documentation clause with trimmed whitespace and
processing of \t as in Java String. It should have different
appearance in the editor than a Template.
Testing { }«} «
»
function testIfSebastianGetsBeer :
testIfConstructorGetsBeer("Sebastian", 2).print() ;
function testIfSomeoneGetsBeer(String someone, Integer pints) {
if pints < 0 then throw "no beer return" endif;
«The constructor of my terminal rules' logic, «{=someone}», is
hereby granted «{=
switch pints
case 0 : "no"
default : pints
endswitch
}» «{=
switch pints
case 0 : "beer"
case 1 : "pint"
default : "pints"
endswitch
}» since this template with stuff like { }«} parses ok «{="\u263A"}»!
Look out for the lo«{(0..pints).do(x|«o«{=x}»o».print()) }»op»;
}
function testing () {
var a = 1;
« content «{ a }» content «{ a }» content »;
««{ /* */ a }»«{ /* */ a }»»;
« content «{ a }» content /* */ »;
« «{ a }» »;
// ««{}»»; // uncomment for correct parse error (no expression)
// ««{=}»»; // uncomment for correct parse error (no expression)
« a »;
« } } } { { { « arbitrary content »;
« } »;
// « » »; // uncomment for correct parse error (end end)
« « »;
«»;
}
Now I should do "9 green bottles hanging on a wall" HTML template as an
exercise...
See you @ ESE ;-)
Regards,
Sebastian
On 10/12/10 10:41 PM, Sebastian Zarnekow wrote:
> Hi Henrik,
>
> StringLiteral:
> values+=TEXT
> | values+=TEXTSTART values+=ID (values+=TEXTMID values+=ID)*
> values+=TEXTEND
> ;
>
> terminal TEXT : '[' ( (("%" !'>')|("<" !'%'))|!('%'|"<"|"]"))* ']';
> terminal TEXTSTART : '[' ( (("%" !'>')|("<" !'%'))|!('%'|"<"|"]"))* '<'
> '%';
> terminal TEXTEND : '%' '>' ( (("%" !'>')|("<" !'%'))|!('%'|"<"|"]"))* ']';
> terminal TEXTMID : '%' '>' ( (("%" !'>')|("<" !'%'))|!('%'|"<"|"]"))*
> '<' '%';
>
> parses:
>
> [ content <% ID %> content <% ID %> content ];
>
> [<% /* */ ID %><% /* */ ID %>];
>
> [ content <% ID %> content /* */ ];
>
> [ <% ID %> ];
>
> [ ID ];
>
> [ % % % > < arbitrary content ];
>
> [ % ];
>
> [ > ];
>
> [ < ];
>
> [];
>
> See you @ ESE ;-)
>
> Regards,
> Sebastian
|
|
|
Powered by
FUDForum. Page generated in 0.04790 seconds