Notation
Grammar
The syntax is specified using a variant of Extended Backus-Naur Form (EBNF):
Production = production_name '=' [ Expression ] '.' .
Expression = Term { '|' Term } .
Term = Factor { Factor } .
Factor = production_name | token | Group | Option | Repetition .
Group = '(' Expression ')' .
Option = '[' Expression ']' .
Repetition = '{' Expression '}' .
Productions are expressions constructed from terms and the following operators, in increasing precedence:
| alternation
() grouping
[] option (0 or 1 times)
{} repetition (0 to n times)
Lowercase production names identify lexical tokens (terminals, defined in
Lexical elements).
Capitalized names identify non-terminals (syntactic productions).
Lexical tokens are enclosed in double quotes "".
The form a … b represents an arbitrary character or token from a
through b as alternatives.
Reading examples
Script source is presented in fenced code blocks:
def greet { <c> do "say hello [name $c]" }
Most examples in this document are fragments meant to illustrate one
construct, not complete scripts. A complete script is a sequence of
top-level forms (Declarations and
scope). When a fragment contains a
bare statement (let foo …, do …, [recall $self …]), read it as
if it appeared inside an enclosing block body, since the top level
admits only def, const, and event handlers.
Examples are drawn from or modelled on real scripts in the world data.
Terminology
- Owner: Every script is attached to a game entity — a mobile, an object, or a room — called its owner. Handlers fire in response to events on the owner.
- Builtin: A primitive operation provided by the language and invoked as an ordinary command call (see Built-in functions).
- Block: A first-class callable code value with optional access to enclosing bindings (Types, Blocks).
- Function: A block bound to a name — by
def, or as a builtin (Declarations and scope, Built-in functions). - Handler: A block registered against a
(phase, event)pair on the owner (Program initialization and execution).