Skip to content

Syntax summary

This is the language at a glance. Each form links to the page that explains it.

script := [ parent ] { field | enum | function }
parent := "super" string

Anatomy of a script · Inheritance

field := "let" [ "mut" [ "controlled" ] ] name [ ":" type ] "=" expr
enum := "enum" name "{" { option [ "=" int ] } "}"
function := { "event" | "export" | "const" | "virtual" | "override" } "fn" name
"(" [ param { "," param } ] ")" [ "->" type ] block
param := name [ ":" type ] [ "=" expr ]
type := "int" | "float" | "bool" | "string" | "vec2" | "vec3" | "vec4"
| "list" | "var" | "Entity" | "Component" | "User" | "Reference"

Fields · Enums · Functions · Types

block := "{" { statement } "}"
statement := "let" [ "mut" ] name [ ":" type ] "=" expr
| target "=" expr
| expr
| "if" expr block [ "else" ( if-statement | block ) ]
| "while" expr block
| "for" name "in" expr ( ".." | "..=" ) expr [ "step" int ] block
| "switch" expr "{" { ( expr | "_" ) "=>" block } "}"
| "return" [ expr ] | "break" | "continue"

A line break ends a statement unless the statement plainly continues; see Lexical structure.

Locals · Control flow

expr := expr binary-op expr | ( "!" | "-" ) expr | postfix
postfix := primary { "." name [ "(" args ")" ] | "as" type }
primary := literal | name | "(" expr ")"
| name "(" args ")" own function
| "super" "::" name "(" args ")" parent's function
| "$" namespace "." name "(" args ")" native
| Enum "::" Option
| "if" expr "{" expr "}" "else" "{" expr "}"
args := [ arg { "," arg } ]
arg := [ name ":" ] expr names: own functions only
literal := int | float | string | "true" | "false" | "null"
| "[" [ expr { "," expr } ] "]"
| "vec2(" n "," n ")" | "vec3(" … ")" | "vec4(" … ")"

Binary operators, loosest first: || · && · == != < <= > >= · + - · * / %.

Expressions and operators · Calling natives

fn let mut if else while for switch break continue return enum event virtual override export const controlled super as in true false null
Method Does
l.len() Number of values
l.get(i) Value at position i
l.set(i, v) Replace the value at i
l.push(v) Add to the end
l.destroy() Free the list