mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-09-04 17:15:23 -06:00
Skylark: docs
git-svn-id: svn://ultimatepp.org/upp/trunk@5241 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
08bbbcbf1f
commit
ca1d24b00a
7 changed files with 338 additions and 155 deletions
|
|
@ -226,7 +226,7 @@ Value Compiler::ExeOrl::Eval(ExeContext& x) const
|
|||
|
||||
Value Compiler::ExeCond::Eval(ExeContext& x) const
|
||||
{
|
||||
if(cond->Eval(x))
|
||||
if(IsTrue(cond->Eval(x)))
|
||||
return ontrue->Eval(x);
|
||||
else
|
||||
if(onfalse)
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ topic "Witz template language";
|
|||
[b50;2 $$21,21#03324558446220344731010354752573:Par]
|
||||
[{_}%EN-US
|
||||
[s2; Witz&]
|
||||
[s3; 1. Preprocessing&]
|
||||
[s3; Preprocessing&]
|
||||
[s0; &]
|
||||
[s0; First phase in compilation of witz templates is preprocessing.
|
||||
Preprocessing itself can be broken to include phase, when other
|
||||
|
|
@ -71,10 +71,191 @@ If there are more definition for single id, the last one is used.&]
|
|||
[s7; #define BODY&]
|
||||
[s7; <b><i>Hello world!</i></b>&]
|
||||
[s0; &]
|
||||
[s3; 2. Witz code&]
|
||||
[s3; Witz code&]
|
||||
[s0; &]
|
||||
[s0; Witz code is marked by `'`$`' character (the end of code within
|
||||
template is determined by syntax rules, in rare situations you
|
||||
might have to enclose expressions in parenthesis).&]
|
||||
[s0; &]
|
||||
[s0; Values&]
|
||||
[s0; &]
|
||||
[s0; The type of values processed by Witz is basically equal to U`+`+
|
||||
Value. Skylark understands some of Value types and perform operations
|
||||
on them (like arithmetics for numbers, concatenating Strings),
|
||||
but generally any Value can be yielded by expression evaluation
|
||||
(either come from handler variables, or be created by function).
|
||||
Skylark always uses .ToString method of Value to convert final
|
||||
expression value before inserting it to the document.&]
|
||||
[s0; &]
|
||||
[s0; Witz primary values come from shared variable space of Skylark
|
||||
handler; the only other way to define a new variable is by using
|
||||
[/ for] statements. Variable names follow C/C`+`+ rules, `'.`'
|
||||
before variable designates session variable, `'`@`' designates
|
||||
cookie.&]
|
||||
[s0; &]
|
||||
[s0; There are also value literals:&]
|
||||
[s0; &]
|
||||
[s0; numbers: [@5 1], [@5 `-100], [@5 1.23]&]
|
||||
[s0; strings: [@5 `"string`"]&]
|
||||
[s0; array: [@5 `[1, `"hello`", 123`]]&]
|
||||
[s0; map: [@5 `{ `"key1`":`"value1`", `"key2`":123 `}]&]
|
||||
[s0; &]
|
||||
[s3;H0; [+150 Expressions]&]
|
||||
[s0; &]
|
||||
[s0; When expressions are used as logical values, then:&]
|
||||
[s0; &]
|
||||
[s0;i150;O0; if expression yields a number (int, int64, double, bool),
|
||||
it is false if it is Null or zero, true otherwise&]
|
||||
[s0;i150;O0; if expression yields a ValueArray, it is false if ValueArray
|
||||
is empty, true otherwise&]
|
||||
[s0;i150;O0; in other cases, it is false if expression is Null, true
|
||||
otherwise (note that this means that empty String is false, non`-empty
|
||||
true).&]
|
||||
[s0; &]
|
||||
[s0; In following table, thick lines divide operators with the same
|
||||
priority, with topmost items having the highest priority:&]
|
||||
[s0; &]
|
||||
[ {{4468:5532h1;@(216) [s0; Operator]
|
||||
:: [s0; Comments]
|
||||
::^@2 [s0; [/C map][*C `[][/C key][*C `]]]
|
||||
:: [s0; Map value at [/ key]. If there is no such ]
|
||||
:: [s0; [/C map][*C .][/C field]]
|
||||
:: [s0; Same as [/ map]`[`"[/ field]`"`].]
|
||||
:: [s0; [/C array][*C `[][/C index][*C `]]]
|
||||
:: [s0; Array element at position [/ index].]
|
||||
:: [s0; [/C function(value1, value2, ...)]]
|
||||
:: [s0; Call to function (functions are defined in C`+`+).]
|
||||
:: [s0; [/C handler(value1, value2, ...)]]
|
||||
:: [s0; If the id before `'(`' represents Skylark handler, then what
|
||||
looks like function call gets actually translated to into the
|
||||
URL link to Skylark handler function, replacing [/ value] parameters
|
||||
at their corresponding positions in the URL, so they act as handler
|
||||
parameters.]
|
||||
::t33/15 [s0; [*C `-][/C number]]
|
||||
:: [s0; Unary minus.]
|
||||
::t0/15 [s0; [*C `~][/C number]]
|
||||
:: [s0; Bit`-wise complement.]
|
||||
:: [s0; [*C !][/C value]]
|
||||
:: [s0; Logical not. 1 when value represents false, 0 otherwise.]
|
||||
::t33/15 [s0; [/C number][*C `* ][/C number]]
|
||||
:: [s0; Multiplication.]
|
||||
::t0/15 [s0; [/C number][*C / ][/C number]]
|
||||
:: [s0; Division.]
|
||||
:: [s0; [/C number][*C % ][/C number]]
|
||||
:: [s0; Modulo.]
|
||||
::t33/15 [s0; [/C String][*C `+ ][/C String]]
|
||||
:: [s0; Concatenates [/ Strings].]
|
||||
::t0/15 [s0; [/C number][*C `+ ][/C number]]
|
||||
:: [s0; Addition.]
|
||||
:: [s0; [/C number][*C `- ][/C number]]
|
||||
:: [s0; Subtraction.]
|
||||
::t33/15 [s0; [/C number][*C << ][/C number]]
|
||||
:: [s0; Shift left.]
|
||||
::t0/15 [s0; [/C number][*C >> ][/C number]]
|
||||
:: [s0; Shift right.]
|
||||
::t33/15 [s0; [/C number][*C < ][/C number]&]
|
||||
[s0; [/C number][*C > ][/C number]&]
|
||||
[s0; [/C number][*C <`= ][/C number]&]
|
||||
[s0; [/C number][*C >`= ][/C number]]
|
||||
:: [s0; Comparison of [/ number]s.]
|
||||
::t0/15 [s0; [/C String][*C < ][/C String]&]
|
||||
[s0; [/C String ][*C > ][/C String]&]
|
||||
[s0; [/C String][*C <`= ][/C String]&]
|
||||
[s0; [/C String][*C >`= ][/C String]]
|
||||
:: [s0; Comparison of [/ Strings].]
|
||||
::t33/15 [s0; [/C value][*C `=`= ][/C value]]
|
||||
:: [s0; Equality.]
|
||||
::t0/15 [s0; [/C value][*C !`= ][/C value]]
|
||||
:: [s0; Inequality.]
|
||||
::t33/15 [s0; [/C number][*C `& ][/C number]]
|
||||
:: [s0; Binary and.]
|
||||
:: [s0; [/C number][*C `^ ][/C number]]
|
||||
:: [s0; Binary xor.]
|
||||
:: [s0; [/C number][*C `| ][/C number]]
|
||||
:: [s0; Binary or.]
|
||||
:: [s0; [/C value][*C `&`& ][/C value]]
|
||||
:: [s0; Logical and. If first value is false, second value is not evaluated,
|
||||
just skipped.]
|
||||
:: [s0; [/C value][*C `|`| ][/C value]]
|
||||
:: [s0; Logical or. If first value is true, second value is not evaluated,
|
||||
just skipped.]
|
||||
:: [s0; [/C value ][*C ?][/C value ][*C :][/C value]]
|
||||
:: [s0; Conditional expression. Only necessary expressions are evaluated.]}}&]
|
||||
[s0; &]
|
||||
[s0; &]
|
||||
[s3; Statements&]
|
||||
[s0; &]
|
||||
[s0; Note that for structured statements, `'`$/`' is an alternative
|
||||
to `'`$endfor`' and `'`$endif`'.&]
|
||||
[s0; &]
|
||||
[ {{4508:5492h1;@(216) [s0; Statement]
|
||||
:: [s0; Comments]
|
||||
::^@2 [s0; [/C `$expression]]
|
||||
:: [s0; Expression. It gets evaluated and the result is put into the
|
||||
document.]
|
||||
:: [s0; [*C `$if(][/C condition][*C )]&]
|
||||
[s0; [*C ...]&]
|
||||
[s0; [*C `$endif ][/C or][*C `$/]]
|
||||
:: [s0; Conditional statement.]
|
||||
:: [s0; [*C `$if(][/C condition][*C )]&]
|
||||
[s0; [*C ...]&]
|
||||
[s0; [*C `$else ]&]
|
||||
[s0; [*C ...]&]
|
||||
[s0; [*C `$endif ][/C or][*C `$/]]
|
||||
:: [s0; Conditional statement with else clause.]
|
||||
:: [s0; [*C `$for(][/C variable][*C in ][/C array`_or`_map][*C )]&]
|
||||
[s0; [*C ...]&]
|
||||
[s0; [*C `$endfor ][/C or][*C `$/]&]
|
||||
[s0;*C &]
|
||||
[s0;*C ]
|
||||
:: [s0;/C &]
|
||||
[s0; ]
|
||||
:: [s0; [*C `$for(][/C variable][*C in ][/C array`_or`_map][*C )]&]
|
||||
[s0; [*C ...]&]
|
||||
[s0; [*C `$else]&]
|
||||
[s0; [*C ...]&]
|
||||
[s0; [*C `$endfor ][/C or][*C `$/]&]
|
||||
[s0;*C ]
|
||||
:: [s0; The optional else clause is invoked if no iteration is performed
|
||||
(map or array is empty).]}}&]
|
||||
[s0; &]
|
||||
[s3; [3 Standard library]&]
|
||||
[s0;3 &]
|
||||
[ {{2479:7521h1;@(216) [s0; Function]
|
||||
:: [s0; Comments]
|
||||
::^@2 [s0;*C ]
|
||||
:: [s0; ]
|
||||
:: [s0;*C ]
|
||||
:: [s0; ]
|
||||
:: [s0;*C ]
|
||||
:: [s0; ]
|
||||
:: [s0;*C ]
|
||||
:: [s0; ]
|
||||
:: [s0;*C ]
|
||||
:: [s0; ]
|
||||
:: [s0;*C ]
|
||||
:: [s0; ]
|
||||
:: [s0;*C ]
|
||||
:: [s0; ]
|
||||
:: [s0;*C ]
|
||||
:: [s0; ]
|
||||
:: [s0;*C ]
|
||||
:: [s0; ]
|
||||
:: [s0;*C ]
|
||||
:: [s0; ]
|
||||
:: [s0;*C ]
|
||||
:: [s0; ]
|
||||
:: [s0;*C ]
|
||||
:: [s0; ]
|
||||
:: [s0;*C ]
|
||||
:: [s0; ]
|
||||
:: [s0;*C ]
|
||||
:: [s0; ]
|
||||
:: [s0;*C ]
|
||||
:: [s0; ]
|
||||
:: [s0;*C ]
|
||||
:: [s0; ]
|
||||
:: [s0;*C ]
|
||||
:: [s0; ]}}&]
|
||||
[s0; &]
|
||||
[s0; ]]
|
||||
Loading…
Add table
Add a link
Reference in a new issue