|
|
出来るデキスクリップトFrom $1目次
Deki Wiki includes an expression notation for creating dynamic content and invoking functions. Table of Contents
SyntaxThis section describes the syntax and the semantics of DekiScript, including which tokens are valid, how they can be combined, and what their combinations mean.
The language is explained using the extended BNF notation,
in which
( x )* means 0 or more x's, and ( x )? means an optional x.
Non-terminals are shown like non-terminal, terminals are shown like Lexical ConventionsNames in DekiScript can be any string of letters, digits, and underscores, not beginning with a digit. Note that any character considered alphabetic by the current locale can be used in an identifier. Identifiers are used to refer to variables and table fields.
The following SyntaxA DekiScript block allows for a single expression with the following syntax:
Nil (1.8.1)The empty value is represented by _, nil, and null. All tokens are synonymous and their variations are provided for convenience. Bool (1.8.1)Logical values are represented by true and false. Number (1.8.1)Numbers must have a decimal part
and may have an optional decimal exponent. DekiScript also accepts hexadecimal constants,
by prefixing them with Examples of valid numbers are:
String (1.8.1)Strings
can be delimited by matching single or double quotes
and can contain these escape sequences:
' Examples of valid strings are:
Map (1.8.1)A map is an associative array that assigns a key to an expression. The key can either be a name or a string. The evaluation order of expressions inside a map is non-deterministic. map ::= { ( field ( , field )* )? } Examples of valid maps are:
Note: Because DekiScript blocks can be enclosed inside double curly braces (i.e. {{ }}
)
, care must be applied when nesting tables, as two consecutive }} will be interpreted as the end of the DekiScript block. The values of a map are accessed by providing the key either as a name preceded by a dot (.) or as an expression surrounded by brackets ([]). Valid examples of accessing a map are:
If the key is not found in the map, the expression evaluates to nil. List (1.8.1)A list is an indexed array of expressions. The evaluation order of expressions inside a list is non-deterministic.
Examples of valid lists are:
The values of a list are accessed by using a numeric expression surrounded by brackets ([]). The first value in a list has index 0. Valid examples accessing a list are:
If the index is not within range, the expression evaluates to nil. Function Call (1.8.1)In a function call, the prefix is evaluated first. If the value of the prefix has type uri, the arguments are evaluated in a non-deterministic order. Otherwise, an exception is thrown. Arguments can be specified with two different notations, either as a list or as a map. Valid examples of calling a function with an argument list are:
Valid examples of calling a function with an argument map are:
Using an argument map enables the caller to pass in arguments by name. Unspecified arguments have value nil, while specified arguments that don't correspond to the parameter name will be ignored (but they are evaluated). Operator .. (1.8.2)The .. operator is used to concatenate two strings. If the values being concatenated are not strings, they are converted to strings first. Valid examples of the .. operator are:
Operator ?? (1.8.2)The ?? operator is used to test for nil. First, the expression to the left of the ?? operator is evaluated. If the resulting value is nil, the expression to the right is evaluated and returned instead. Valid examples of the ?? operator are:
Magic Identifier (1.8.2)A magic identifier is an automatically generated string that is guaranteed to be unique across scopes. The scope of a magic identifier is a single page or template instance. For example, if a page or template is loaded multiple times via inclusion, each page will have unique values for its magic identifiers. Magic identifiers are commonly used to create channels for PubSub communication. By using magic identifiers, the channels are guaranteed to be unique and not interfere with similarly named channels on other included pages. Valid examples of the magic identifiers are:
Built-in Functions & VariablesThe following functions and variables are part the Deki Wiki runtime environment and are always available. Wiki Functions
Date Functions & Variables
Site Variables
Page Variables
User Variables
Site, Page, and User Variables Examples
タグ:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||