O Language

Tokens and operators

Reference the literal tokens, operators, delimiters and keywords recognized by the current O Language parser.

O Language pagesTokens and operators
On this page

This page follows the lexer and parser in runtime revision eb2301c. A token name being defined in the source does not guarantee that the parser or every execution path implements it.

Literals and delimiters

The common literal forms are integer, string, boolean, array, hash, function and float. The current float syntax uses the float keyword:

def count = 42
def ratio = float 3.14
def name = "OnixOS"
def enabled = true
def profiles = ["Core", "KDE"]
def base = {"name": "OnixOS"}

Parentheses group expressions and function arguments. Braces delimit code blocks and hashes. Square brackets delimit arrays and index lookups. Commas separate items, colons separate hash keys and values, and semicolons can separate statements.

Operators

Operator Current use
+, -, *, / Arithmetic; + also joins strings.
==, != Equality comparisons.
<, >, <=, >= Numeric comparisons.
!, unary - Boolean negation and numeric negation.
-> Scope member access in parsed scope forms.
name[index] Array indexing or hash lookup.

The parser does not register &&, ||, modulo, compound assignment or dot-property access as normal expressions. Do not use them as if this were a conventional C-like grammar.

Comments

The lexer maps # to end-of-input. It therefore stops reading the rest of the program at the first #; it is not a usable line or inline comment marker in this runtime revision. Avoid adding comments to executable source until the lexer behavior changes.

Keywords and forms

The common language forms are def, fn, return, true, false, if, else, for, in, while, loop and load.

The parser also recognizes system-oriented forms such as proc, env, sock, scope, route, signal, eval, begin, except, recover, final, async and wait. Their behavior is not equally complete across the interpreter and compiler paths. See system APIs and the execution model before relying on them.

For the supported beginner grammar, see Language basics. For runtime object names, see Types.