Language Reference
For a complete list of reserved words, see the Keyword Reference.
Data types
| Type | Example | Notes |
|---|---|---|
number | 42, 3.14 | Numeric values |
text | "hello" | String values |
boolean | true, false | Condition values |
list | [1, 2, 3] | Ordered values with zero-based indexing |
XE uses an inferred type system with a Typed IR. The compiler maps variables to native Rust types for performance, falling back to a dynamic XeValue only when types are mixed or unknown.
Invalid operations now fail with explicit runtime errors instead of silently producing fallback values.
Operators
Arithmetic
+-*/%
Comparison
==!=<><=>=
Logic
andornot
Built-in functions
| Function | Purpose | Example |
|---|---|---|
print(...) | Print one or more values | print("hi") |
input(prompt) | Read text from the user | name = input("Name? ") |
length(value) | Return length of text or list | length([1, 2, 3]) |
type(value) | Return the XE type name as text | type(42) |
convert(value, target) | Convert between supported types | convert("42", "number") |
Valid convert targets:
"number""text""boolean"
Control flow
ifelifelserepeat N timeswhilefor name in iterablebreakcontinue
for loops currently iterate over:
- lists
- text values, one character at a time
Function syntax
xe
fun name(arg1, arg2):
return arg1 + arg2Functions can access:
- parameters
- variables created inside the function
- built-in functions
- other user-defined functions
- imported user-defined functions
- global module-level variables
They do not yet support nested closures (capturing local variables from an outer function).
Modules and imports
XE modules are other .xe files.
xe
from math_utils import double
print(double(21))Available forms:
import helpersfrom helpers import square, cube
Current rules:
- imports resolve relative to the importing file
import module_namebrings that module's top-level functions into scopefrom module_name import nameimports selected top-level functions- only top-level functions are importable today
- imports must appear before executable top-level statements
- imported module top-level code runs once before the entry module's top-level code
Example project shape:
main.xehelpers.xe
Notes on formatting
- XE uses indentation-based blocks
- spaces are the expected style for indentation
- there are no braces for
if,elif,else,repeat,while,for, orfunblocks
Assignment semantics
name = valuecreates a variable if that name does not exist in any enclosing scope- otherwise, it reassigns the nearest existing variable instead of creating a shadow copy
- names first created inside a block stay local to that block
Error behavior
- compiler errors include line/column information, the source line, and a caret marker
- invalid runtime operations stop the program with a
Runtime error: ...message
