Skip to main content

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.

Origin provides a rich set of operators drawn from both Python semantics and English-like readability conventions. All operators are recognized by the lexer as distinct token types — ARITH, COMP, LOGIC, SPECIAL, UNARY, and ASSIGN_OP — so there is no ambiguity between them. This page serves as a complete reference, covering every operator category, smart string concatenation, built-in functions that behave like operators, hexadecimal literals, and the full operator precedence table.

Arithmetic Operators

These operators work on int and float values. When one operand is a float, the result is promoted to float:
OperatorOperationExampleResult
+Addition3 + 47
-Subtraction10 - 37
*Multiplication6 * 742
/Division10 / 42.5
//Floor division10 // 42
%Modulo (remainder)10 % 31
**Exponentiation2 ** 8256

Smart String Concatenation

The + operator has special behavior when either operand is a str. Instead of raising a TypeError, Origin automatically converts both sides to strings and concatenates them:
let label: str = "Sensor reading: " + 42
print label    # → Sensor reading: 42
This is implemented directly in the interpreter’s BinOpNode handler. The generated Python is:
(str(left) + str(right)) if isinstance(left, str) or isinstance(right, str) else (left + right)
This applies at runtime any time + is used and either operand is a string.

Comparison Operators

OperatorMeaning
==Loose equality
!=Loose inequality
===Strict equality (type + value)
!==Strict inequality
<Less than
>Greater than
<=Less than or equal to
>=Greater than or equal to
<>Alias for !=
let a: int = 5
let b: int = 10

print a == 5      # → True
print a === 5     # → True  (strict)
print a <> b      # → True  (same as !=)
print a >= b      # → False

Logical Operators

Origin accepts both English keywords and C-style symbols — they compile to identical Python bytecode:
KeywordSymbolMeaningExample
and&&Logical ANDx > 0 and x < 100
or||Logical ORx < 0 || x > 100
not!Logical NOTnot flag / !flag
let x: int  = 42
let ok: bool = x > 0 && x < 100
print ok      # → True

print not ok  # → False
print !ok     # → False

Bitwise Operators

Bitwise operators work on integer values at the binary level:
OperatorOperationExample
&Bitwise AND0xFF & 0x0F
|Bitwise OR0x01 | 0x10
^Bitwise XOR0b1010 ^ 0b1100
<<Left shift1 << 4
>>Right shift256 >> 3
let mask: int = 0xFF
let val:  int = 0x3A
print val & mask    # → 58
print 1 << 4        # → 16

Compound Assignment Operators

Compound operators combine an arithmetic or bitwise operation with assignment, mutating the variable in place:
OperatorEquivalent To
+=x = x + value
-=x = x - value
*=x = x * value
/=x = x / value
%=x = x % value
**=x = x ** value
//=x = x // value
&=x = x & value
|=x = x | value
let n: int = 100
n -= 25     # n = 75
n *= 2      # n = 150
n //= 7     # n = 21

Unary Operators

OperatorMeaningExample
++Increment (prefix)++i
--Decrement (prefix)--i
-Arithmetic negation-x
not/!Logical negationnot flag
let i: int = 10
++i    # 11
--i    # 10

Special Operators

The following tokens are recognized by the lexer as the SPECIAL token type and are valid in expressions syntactically, but they are not yet implemented in the interpreter. Using them will raise a RuntimeError: Unknown node type at runtime.
??, ->, =>, <=>, and :: are reserved for future use. They are fully tokenized and parsed into SpecialOpNode AST nodes, but no code-generation handler exists in the interpreter yet. Do not rely on them in production scripts.
OperatorNamePlanned Purpose
??Null coalesceReturn right operand when left is none
->ArrowPipe / callback syntax
=>Fat arrowLambda / case arm syntax
<=>SpaceshipThree-way comparison ordering
::ScopeScope / namespace resolution

Built-in Functions That Act Like Operators

These are recognized as keywords by the lexer and compile to built-in function calls, but behave like unary or binary operators in expressions:
ExpressionDescription
len(x)Returns the length of a list, string, or dict
sqrt(x)Returns the square root of a number
rand_num(a, b)Returns a random integer between a and b
range(a, b)Generates a sequence from a to b (exclusive)
input("prompt")Reads a line of user input, returns a string
let items: list  = ["a", "b", "c"]
let count: int   = len(items)        # → 3
let root:  float = sqrt(144)         # → 12.0
let roll:  int   = rand_num(1, 6)    # → 1..6
let name:  str   = input("Name: ")   # reads stdin

Hexadecimal Literals

Integer literals can be written in hexadecimal using the 0x prefix. The lexer matches them with the HEX token type and converts them to int at parse time:
let addr: int = 0x40     # → 64
let mask: int = 0xFF     # → 255
let flag: int = 0x1F     # → 31

Operator Precedence

Operators are evaluated from highest to lowest precedence. Within the same level, evaluation is left-to-right:
LevelCategoryOperators
1Unary (highest)++, --, - (negation), not, !
2Multiplicative*, /, //, %, **
3Additive+, -
4Comparison==, !=, ===, !==, <, >, <=, >=, <>
5Logicaland / &&, or / ||
6Special (lowest)??, ->, =>, <=>, ::
Use parentheses to override the default precedence at any point in an expression:
let result: int = (2 + 3) * 4     # → 20, not 14

Build docs developers (and LLMs) love