Skip to the content.

Script semantics (what actually runs)

This is the interpreter you are targeting, not an abstract language spec. Match examples to this behavior.

Tokenization

  1. Skip spaces/tabs (and newlines unless indentation is marked significant).
  2. Skip line comments (markers) and block comments (pairs).
  3. Longest match among operators, terminators, (), [], block delimiters, argument/member separators, decorator prefixes.
  4. Numbers: optional -, digits, optional fractional part if floats enabled.
  5. Strings: each literals.string.forms delimiter, default ". Escapes: n t r 0 and “unknown escape is the next char.”
  6. Words: [A-Za-z_][A-Za-z0-9_]*. If the word is in any keyword list (including custom kinds and true/false/null), it is a keyword token.

Unicode identifiers are not fully implemented even if the JSON says they are.

Statements

Processed in order. Decorators may precede a statement.

Blocks: { ... } using configured delimiters, or a single statement if { is missing.

Statement terminators (often ;) are optional between many statements but recommended in generated examples.

Expressions (Pratt parser)

Prefix: unary -, !, not; parenthesized expr; [a, b] arrays; numbers; strings; true/false/null words; identifiers.

Infix / postfix:

&& / and and || / or short-circuit.

+ concatenates if either side is a string (to_string on the other).

Division by zero throws RuntimeError.

Assignment target must be an identifier (x = 1, not a[0] = 1 yet).

Scope

Functions

Arity must match. Extra/missing args throw. Recursion is allowed. Nested fn is parsed if it appears as a statement inside a block; the inner function is still registered on globals by name (last one wins).

Load vs run vs unload

Action Functions Top-level let / exprs / types / classes / imports
load Registered (free functions on entry scripts). Imported script files are parsed as isolated modules Not executed
run Re-registered; class methods bound on the instance Executed; class instances created; imports bind host packages or script exports
unload Names removed Names removed

eval does all three.

Truthiness

Used by if / while: null, false, 0, "", empty array → false. Everything else → true.