Documentation Index
Fetch the complete documentation index at: https://mintlify.com/boblio-max/origin/llms.txt
Use this file to discover all available pages before exploring further.
Every syntactic construct in the Origin language is represented as a Python object that inherits from ASTNode. These objects are produced by parser.Parser and consumed by interpreter.Interpreter. The node classes themselves are intentionally thin — they carry only the data fields the interpreter needs, with no evaluation logic of their own. All node classes are defined in classes.py and re-exported via from classes import * in both the parser and interpreter.
Every node class inherits from ASTNode and therefore carries a line attribute. The parser sets this attribute to the 1-based source line number of the first token that triggered the node. The interpreter uses it to inject globals()['_origin_runtime_line'] = N markers into the emitted Python source, enabling accurate runtime error reporting.
Base Class
class ASTNode:
def __init__(self, line=None):
self.line = line # int | None — set by Parser._set_line()
All other node classes call super().__init__() without arguments, leaving line as None until the parser assigns it.
Program and Block Nodes
These two nodes form the structural skeleton of every parsed Origin program.
ProgramNode(statements)
The root of every AST. Returned by Parser.program().
| Field | Type | Description |
|---|
statements | list[ASTNode] | Top-level statements in document order |
BlockNode(statements)
A { … } block body. Returned by Parser.block() and stored in the body fields of control-flow and definition nodes.
| Field | Type | Description |
|---|
statements | list[ASTNode] | Statements inside the braces |
Literal Nodes
NumberNode(value, type)
An integer or float literal.
| Field | Type | Values |
|---|
value | int | float | The parsed numeric value |
type | str | "int" or "float" |
StringNode(value, type)
A string literal with its quotes stripped.
| Field | Type | Values |
|---|
value | str | Content without surrounding quotes |
type | str | Always "str" |
BoolNode(value)
A boolean literal (true or false in Origin source).
| Field | Type | Values |
|---|
value | bool | True or False |
type | str | Always "bool" (set in __init__) |
NoneNode()
The none literal. Carries type = "none" and no other fields.
PassNode()
The pass statement. No fields; generates "pass" in Python.
Variable and Assignment Nodes
VarNode(name, type=None)
A reference to a named variable.
| Field | Type | Description |
|---|
name | str | Variable identifier |
type | str | None | Statically known type, if any |
AssignNode(name, value, type=None)
A let declaration or a bare name = value assignment.
| Field | Type | Description |
|---|
name | str | Target variable name |
value | ASTNode | Right-hand side expression |
type | str | None | Declared type annotation (e.g. "int") |
ConstAssignNode(name, value)
A const declaration. The interpreter records the name in CONST_VARS and rejects any later AssignNode targeting the same name.
| Field | Type | Description |
|---|
name | str | Constant name |
value | ASTNode | Initializer expression |
CompoundAssignNode(name, op, value)
A compound assignment (+=, -=, *=, /=, %=, **=, //=, &=, |=).
| Field | Type | Description |
|---|
name | str | Target variable name |
op | str | The compound operator string, e.g. "+=" |
value | ASTNode | Right-hand side expression |
Expression Nodes
BinOpNode(left, op, right)
A binary operation. The + operator receives special treatment in the interpreter (smart string concatenation).
| Field | Type | Description |
|---|
left | ASTNode | Left operand |
op | str | Operator: +, -, *, /, //, %, **, ==, !=, <, >, <=, >=, … |
right | ASTNode | Right operand |
UnaryOpNode(op, node)
A unary operation.
| Field | Type | Description |
|---|
op | str | Operator: -, not, !, ++, -- |
node | ASTNode | The operand |
LogicOpNode(left, op, right)
A logical operation. The interpreter maps && → and and || → or.
| Field | Type | Description |
|---|
left | ASTNode | Left operand |
op | str | "and", "or", "&&", "||" |
right | ASTNode | Right operand |
SpecialOpNode(left, op, right)
A special-operator expression (??, ->, =>, <=>, ::).
| Field | Type | Description |
|---|
left | ASTNode | Left operand |
op | str | The special operator string |
right | ASTNode | Right operand |
Control Flow Nodes
IfNode(condition, then_body, elif_nodes, else_body)
An if / elif / else construct.
| Field | Type | Description |
|---|
condition | ASTNode | Boolean-valued expression |
then_body | BlockNode | The if branch body |
elif_nodes | list[ElifNode] | Zero or more elif branches |
else_body | BlockNode | None | The else branch body, or None |
ElifNode(condition, then_body)
A single elif branch, stored inside IfNode.elif_nodes.
| Field | Type | Description |
|---|
condition | ASTNode | Boolean-valued expression |
then_body | BlockNode | The elif branch body |
WhileNode(condition, body)
A while loop.
| Field | Type | Description |
|---|
condition | ASTNode | Loop continuation condition |
body | BlockNode | Loop body |
ForNode(var_name, iterable, body)
A for var in iterable { } loop.
| Field | Type | Description |
|---|
var_name | str | Loop variable name |
iterable | ASTNode | The sequence to iterate |
body | BlockNode | Loop body |
TryNode(try_body, except_body, else_body)
A try / except / else construct. Each except block is parsed into its own BlockNode and appended to except_body; the interpreter emits a bare except Exception: for each one.
| Field | Type | Description |
|---|
try_body | BlockNode | The guarded block |
except_body | list[BlockNode] | One entry per except clause |
else_body | BlockNode | None | The else clause, or None |
Function and Class Nodes
FuncNode(name, params, body)
A def function definition.
| Field | Type | Description |
|---|
name | str | Function name |
params | list[str] | Parameter names in declaration order |
body | BlockNode | Function body |
ClassNode(name, fields, body)
A class definition. Fields become __init__ parameters (all defaulting to None).
| Field | Type | Description |
|---|
name | str | Class name |
fields | list[str] | Instance field names |
body | BlockNode | Additional methods and statements |
CallNode(callee, args)
A function or method call.
| Field | Type | Description |
|---|
callee | ASTNode | The callable (VarNode, AttributeNode, etc.) |
args | list[ASTNode] | Positional arguments |
ReturnNode(value)
A return statement.
| Field | Type | Description |
|---|
value | ASTNode | The returned expression |
YieldNode(value)
A yield expression (generator support).
| Field | Type | Description |
|---|
value | ASTNode | The yielded expression |
BreakNode
A bare break statement. No fields.
ContinueNode
A bare continue statement. No fields.
Data Structure Nodes
ListNode(elements)
A list literal [e1, e2, ...].
| Field | Type | Description |
|---|
elements | list[ASTNode] | Element expressions |
TupleNode(elements)
A tuple literal (e1, e2, ...). Produced by a parenthesized comma-separated list.
| Field | Type | Description |
|---|
elements | list[ASTNode] | Element expressions |
DictNode(elements)
A dictionary literal {k1: v1, k2: v2, ...}.
| Field | Type | Description |
|---|
elements | dict[ASTNode, ASTNode] | Key-value pairs (both sides are AST nodes) |
IndexNode(collection, index)
A subscript read collection[index].
| Field | Type | Description |
|---|
collection | ASTNode | The subscriptable object |
index | ASTNode | The subscript expression |
IndexAssignNode(collection, index, value)
A subscript write collection[index] = value.
| Field | Type | Description |
|---|
collection | ASTNode | The subscriptable object |
index | ASTNode | The subscript expression |
value | ASTNode | The value to store |
ListCallNode(list_node, pos)
A call[list, pos] expression — syntactic sugar for list element access.
| Field | Type | Description |
|---|
list_node | ASTNode | The list expression |
pos | ASTNode | The position expression |
Object Access Nodes
AttributeNode(obj, attr)
An attribute read obj.attr.
| Field | Type | Description |
|---|
obj | ASTNode | The object expression |
attr | str | Attribute name |
AttributeAssignNode(obj, attr, value)
An attribute write obj.attr = value.
| Field | Type | Description |
|---|
obj | ASTNode | The object expression |
attr | str | Attribute name |
value | ASTNode | The value to assign |
I/O Nodes
PrintNode(expr)
A print statement.
| Field | Type | Description |
|---|
expr | ASTNode | The expression to print |
A user input call.
| Field | Type | Description |
|---|
prompt | StringNode | None | Optional prompt string |
OpenNode(name, path, type)
A file-open operation.
| Field | Type | Description |
|---|
name | str | Variable name to bind the file handle |
path | ASTNode | Path expression |
type | str | Open mode (e.g. "r", "w") |
Math Built-In Nodes
SqrtNode(value)
sqrt(value) — maps to math.sqrt(...).
| Field | Type | Description |
|---|
value | ASTNode | The radicand |
RandNumNode(start, end)
rand_num(start, end) — maps to random.randint(start, end).
| Field | Type | Description |
|---|
start | ASTNode | Lower bound (inclusive) |
end | ASTNode | Upper bound (inclusive) |
LenNode(value)
len(value) — maps to Python’s built-in len.
| Field | Type | Description |
|---|
value | ASTNode | The collection |
RangeNode(start, end)
range(start, end) — maps to Python’s built-in range.
| Field | Type | Description |
|---|
start | ASTNode | Start of the range (inclusive) |
end | ASTNode | End of the range (exclusive) |
CastNode(cast_type, value)
An explicit type cast — int(v), str(v), float(v), bool(v).
| Field | Type | Description |
|---|
cast_type | str | Target type name: "int", "str", "float", "bool" |
value | ASTNode | The expression to cast |
type | str | Same as cast_type (for get_type inference) |
Hardware Nodes
SetNode(name, num, type_, params)
A hardware state assignment (set pin, set servo).
| Field | Type | Description |
|---|
name | str | Device type: "pin", "servo", etc. |
num | ASTNode | Channel or pin number expression |
type_ | str | None | Sub-type, e.g. "angle" for a servo |
params | ASTNode | Value to set |
HardwarePrimitiveNode(namespace, method, args)
A protocol primitive call: i2c.read(...), spi.write(...), uart.send(...).
| Field | Type | Description |
|---|
namespace | str | Protocol name: "i2c", "spi", or "uart" |
method | str | Method name, e.g. "read" or "write" |
args | list[ASTNode] | Call arguments |
The interpreter emits _execute_{namespace}_{method}(args), which the runtime resolves to one of the hardware helper functions injected into runtime_globals.
Module Nodes
ImportNode(name)
An import name statement.
| Field | Type | Description |
|---|
name | str | Module name |
If name is in Interpreter.original_imports (currently {"calc": "/lib/calc.or"}), the .or library is inlined at codegen time rather than emitting a Python import.
ImportFromNode(name, library)
A from library import name statement.
| Field | Type | Description |
|---|
name | str | The symbol to import |
lib | str | The source library |
ImportAsNode(name, alias)
An import name as alias statement.
| Field | Type | Description |
|---|
name | str | Module name |
alias | str | Local alias |
Execution Nodes
PyNode(code)
A py { ... } raw Python block. The code field holds the verbatim Python source text extracted from between the braces. The interpreter emits it without any transformation.
| Field | Type | Description |
|---|
code | str | Raw Python source |
ExecNode(code)
An exec "string" statement. At codegen time the interpreter writes the string to a temporary file and runs it via runner.py in a subprocess.
| Field | Type | Description |
|---|
code | str | Origin source code to execute |
ParallelNode(body, threads)
A parallel { ... } or parallel(N) { ... } block.
| Field | Type | Description |
|---|
body | BlockNode | The statements to parallelize |
threads | int | Fixed thread count (0 = one thread per statement) |
Experimental Bytecode Path
The bComp.py module contains a Compiler class and an OpCode enum that target a custom stack-based virtual machine (VM). The Compiler.compile(node) method accepts the same AST node classes described above and emits integer opcodes into self.bytecode, with literal values stored in self.constants. This path supports most of the same node types as the interpreter, including FuncNode (with jump patching), ForNode (with GET_ITER / FOR_ITER), WhileNode, BreakNode, and ContinueNode.
The bytecode compiler and VM are experimental and are not invoked by the default runner.py. They exist as a foundation for a future native execution mode and are not feature-complete relative to the interpreter backend.