Syntax summary
This is the language at a glance. Each form links to the page that explains it.
A script
Section titled “A script”script := [ parent ] { field | enum | function }parent := "super" stringAnatomy of a script · Inheritance
Declarations
Section titled “Declarations”field := "let" [ "mut" [ "controlled" ] ] name [ ":" type ] "=" exprenum := "enum" name "{" { option [ "=" int ] } "}"function := { "event" | "export" | "const" | "virtual" | "override" } "fn" name "(" [ param { "," param } ] ")" [ "->" type ] blockparam := name [ ":" type ] [ "=" expr ]type := "int" | "float" | "bool" | "string" | "vec2" | "vec3" | "vec4" | "list" | "var" | "Entity" | "Component" | "User" | "Reference"Fields · Enums · Functions · Types
Statements
Section titled “Statements”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.
Expressions
Section titled “Expressions”expr := expr binary-op expr | ( "!" | "-" ) expr | postfixpostfix := 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 onlyliteral := int | float | string | "true" | "false" | "null" | "[" [ expr { "," expr } ] "]" | "vec2(" n "," n ")" | "vec3(" … ")" | "vec4(" … ")"Binary operators, loosest first: || · && · == != < <= > >= · + - · * / %.
Expressions and operators · Calling natives
Keywords
Section titled “Keywords”fn let mut if else while for switch break continue return enum event virtual override export const controlled super as in true false null
List methods
Section titled “List methods”| 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 |