LATERALUS
A programming language that spirals outward — from simple ideas to profound compositions.
What Is Lateralus?
Lateralus is a proprietary programming language (v2.4.0) created by bad-antics. It combines pipeline-driven data flow, algebraic data types, Hindley-Milner type inference, and built-in scientific/crypto engines into a language built for scientists, security researchers, and software engineers.
It ships two tightly-coupled languages and a full compiler / VM stack:
| Extension | Language | Purpose |
|---|---|---|
.ltl | Lateralus Script | High-level: pipelines, ADTs, pattern matching, async/await, generics |
.ltasm | Lateralus Assembly | Low-level register+stack assembly targeting the LTasm VM |
Repository Layout
| Directory | What Lives Here |
|---|---|
lateralus_lang/ | Core Python implementation — compiler, lexer, parser, IR, type system, VM, codegen, engines, tooling |
lateralus_lang/codegen/ | 7 backends: Python, C99, JavaScript, WASM, bytecode, IR, binary |
lateralus_lang/vm/ | Stack-based VM, assembler, disassembler, 102 opcodes |
lateralus_lang/errors/ | Error types, DNA fingerprinting, error bridge |
lateralus_lang/markup/ | LTLML markup parser + HTML/ANSI renderers |
stdlib/ | 59 standard library modules written in .ltl |
examples/ | 38 example programs (.ltl + .ltasm) |
tests/ | 43 test files, 1,976 tests (pytest) |
docs/ | Language spec, tutorial, cookbook, papers, blog — all in .ltlml |
bootstrap/ | Self-hosting compiler sources (Lateralus-in-Lateralus, toward v2.0) |
vscode-lateralus/ | VS Code / VSCodium extension (syntax, LSP, snippets, icons) |
lateralus-os/ | LateralusOS — bare-metal x86_64 OS with GUI desktop |
scripts/ | Build / test / health-check utilities |
Compiler Pipeline
Source (.ltl)
│
▼ Lexer (lexer.py) → Token stream
│
▼ Parser (parser.py) → AST (ast_nodes.py — 106 node types)
│
▼ SemanticAnalyzer (ir.py) → IRModule (three-address code) + errors
│
├──▶ BytecodeGenerator → .ltbc bytecode → VM execution
├──▶ PythonTranspiler → .py (Python 3.10+)
├──▶ CTranspiler → .c (hosted or freestanding C99)
├──▶ JSTranspiler → .js (ES2022+)
└──▶ WASMTranspiler → .wat (WebAssembly Text)
Source (.ltasm)
│
▼ Assembler (two-pass) → .ltbc bytecode → VM execution
The Compiler class in compiler.py orchestrates everything.
The Target enum selects: BYTECODE, PYTHON,
C, ASM, or CHECK (type-check only).
Key Modules
Lexer — lateralus_lang/lexer.py
Tokenizes .ltl and .ltasm source into a stream of Token objects.
559 lines; token kinds defined in the TK enum.
- Keywords, operators (
|>,=>,::,?) - String interpolation, hex/binary literals
- Single-line (
//,#) and multi-line (/* … */) comments - Every token carries a
Spanfor error reporting
Parser — lateralus_lang/parser.py
Recursive-descent parser, 1,756 lines. Produces a Program AST node containing imports + body statements.
Expression precedence chain:
pipeline → logical → comparison → bitwise → shift → additive
→ multiplicative → power → unary → postfix → primary
v1.5 additions: _parse_pattern(), _parse_type_match_expr() for match-as-expression.
AST — lateralus_lang/ast_nodes.py
949 lines, 106 node types organized as Stmt and Expr subtrees. Every node carries a Span.
Node (base)
├── Program
├── Module
├── Stmt
│ ├── FnDecl / AsyncFnDecl
│ ├── LetDecl
│ ├── ReturnStmt
│ ├── IfStmt / MatchStmt
│ ├── WhileStmt / ForStmt / LoopStmt
│ ├── TryStmt (try / recover / ensure)
│ ├── ImportStmt
│ ├── ExprStmt
│ └── BlockStmt
└── Expr
├── Literal (int, float, str, bool, nil)
├── Ident, BinOp, UnaryOp
├── CallExpr, IndexExpr, FieldExpr
├── LambdaExpr, ListExpr, MapExpr
├── AwaitExpr, CastExpr
├── TypeMatchExpr (v1.5)
├── ResultExpr (v1.5)
└── OptionExpr (v1.5)
v1.5 pattern nodes: WildcardPattern, LiteralPattern, BindingPattern,
TypePattern, EnumVariantPattern, TuplePattern, ListPattern, OrPattern.
Type System — lateralus_lang/type_system.py
871 lines. Hindley-Milner inference with Robinson unification.
| Component | Description |
|---|---|
TypeKind enum | INT, FLOAT, STR, BOOL, NIL, LIST, MAP, TUPLE, FUNCTION, STRUCT, ENUM, GENERIC, ANY |
occurs_check() | Prevents infinite recursive types |
unify() | Robinson unification with 10 cases |
substitute() | Recursive substitution application |
solve() | Drains constraint queue, returns error list |
infer_pattern() | Infers bindings for all 8 pattern kinds |
IR — lateralus_lang/ir.py
Three-address intermediate representation. SemanticAnalyzer walks the AST and emits
IRInstr objects into an IRModule. Feeds bytecode generation and powers
type/error checking.
Codegen Backends — lateralus_lang/codegen/
| Backend | File | Lines | Notes |
|---|---|---|---|
| Bytecode | bytecode.py | 316 | IR → LTasm; two-pass with back-patching |
| Python | python.py | 1,457 | AST → Python 3.10+; reference transpiler |
| C99 | c.py | 1,030 | Hosted (libc) or freestanding (bare-metal); powers LateralusOS |
| JavaScript | javascript.py | 484 | AST → ES2022+ |
| WASM | wasm.py | 485 | IR → WAT format |
Virtual Machine — lateralus_lang/vm/
| File | Description |
|---|---|
opcodes.py | 102 opcode enum; registers r0–r15, sp, pc, flags (Z/C/N/O) |
assembler.py | Two-pass .ltasm → bytecode; sections, directives, labels |
vm.py | Stack-based executor; call frames, error stack, coroutine support |
disassembler.py | Bytecode → readable assembly; round-trip verified |
Built-in Engines
🔬 Science Engine
CODATA constants, RK4 ODE solvers, FFT, statistics, linear systems
⚙️ Math Engine
Arbitrary-precision, complex numbers, polynomials, integration, number theory
🔒 Crypto Engine
SHA-256/512, BLAKE2b, AES-256-GCM, HMAC, PBKDF2, Fernet
🔎 Pattern Engine
Pattern matching engine for expression evaluation
📊 Query Engine
Data query engine for structured data processing
📡 Reactive Engine
Reactive streams and event-driven programming
CLI Commands
All commands are available as lateralus <cmd>, ltlc <cmd>, or python -m lateralus_lang <cmd>.
| Command | Description |
|---|---|
run <file.ltl> | Execute a program |
py <file> -o out.py | Transpile → Python |
c <file> -o out.c | Transpile → C99 (add --freestanding for bare-metal) |
js <file> -o out.js | Transpile → JavaScript (ES2020) |
wasm <file> -o out.wat | Compile → WebAssembly text format |
check <file> | Type-check only |
repl | Interactive REPL (--enhanced for :save/:doc/:profile) |
asm <file.ltasm> | Assemble → bytecode |
disasm <file.ltlc> | Disassemble bytecode binary |
ast <file> | Dump AST (--json for JSON output) |
ir <file> | Dump three-address IR |
test <file> | Run @test functions |
bench <file> | Benchmark compilation pipeline |
profile <file> | Profile execution with timing |
doc <file.ltlml> | Render markup (--html for HTML) |
fmt <file> | Format code |
lint <file> | Lint code (21+ rules) |
clean | Remove build artifacts |
info | Toolchain info |
Language Features by Version
int, float, str, bool, nil),
control flow, functions, closures, lambdas, pipelines (|>, |?),
try/recover/ensure<T>, decorators, yield/generators,
spawn/concurrency, self, pubforeign blocks for Python/JS/R interop, VS Code extension, REPL,
.ltasm assemblerthrow, emit/event system, probe/introspection,
measure/timing, TryExpr, error DNA fingerprinting|>=, ? propagation, math/crypto/science engines,
LTLML markup, binary .ltlc format, 28 stdlib modulesResult::Ok/Result::Err,
Option::Some/Option::None, match-as-expression (8 pattern types + guards),
:: scope operator, HM type inference, C99 backend,
LateralusOS, 1,158 testsStandard Library — 59 Modules
Located in stdlib/, written entirely in .ltl:
algorithms.ltl
Sorting, searching, graph algorithms
async.ltl
Async/await utilities
collections.ltl
24 collection utilities
core.ltl
Core builtins and helpers
crypto.ltl
Hashing, HMAC, encoding
data.ltl
Data structures
datetime.ltl
Date/time types, formatting, durations
functional.ltl
compose, pipe, curry, memoize
graph.ltl
Graph data structures
http.ltl
HTTP client, Request/Response types
io.ltl
File I/O, paths, prompts
iter.ltl
Lazy iterators, map/filter/zip/chain
json.ltl
JSON parse / stringify
linalg.ltl
Linear algebra
math.ltl
Math functions and constants
matrix.ltl
Matrix operations
network.ltl
Networking utilities
numerics.ltl
Numerical methods, ODE solvers
optimize.ltl
Optimization algorithms
os.ltl
Process, environment, filesystem ops
random.ltl
Random number generation
regex.ltl
Regular expressions, Pattern type
result.ltl
Result/Option monadic operations
science.ltl
Scientific computing
signals.ltl
Signal processing
stats.ltl
Statistics and regression
strings.ltl
19 string functions
testing.ltl
Test framework utilities
time.ltl
Timestamps and durations
fmt.ltl
String formatting
csv.ltl
CSV parse / generate
uuid.ltl
UUID generation
hash.ltl
Hashing utilities
base64.ltl
Base64 encode / decode
sort.ltl
Sorting algorithms
set.ltl
Set data structure
event.ltl
Event system
heap.ltl
Heap / priority queue
deque.ltl
Double-ended queue
trie.ltl
Trie data structure
ini.ltl
INI file parser
lru.ltl
LRU cache
+ 15 more
arena, pool, color, logger, enum_utils, etc.
Testing
43 test files with 1,976 tests, all managed via pytest.
# Full suite
pytest tests/ -v --tb=short
# Specific areas
pytest tests/test_parser.py -v
pytest tests/test_type_system.py -v
pytest tests/test_v15_features.py -v
pytest tests/test_c_backend.py -v
# Health check
python scripts/health_check.py
# Master runner
python scripts/run_all_tests.py --suite all_new
Test File Coverage
Core Pipeline
test_lexer, test_parser, test_compiler, test_full_pipeline
Type System
test_type_system, test_v15_features
Backends
test_c_backend, test_javascript_transpiler
VM & Bytecode
test_vm, test_bytecode_format
Engines
test_math_engine, test_crypto_engine, test_science, test_engines, test_pattern_engine, test_query_engine
Tooling
test_formatter_linter, test_lsp_server, test_debugger, test_profiler, test_cli_extensions
Runtime
test_async_runtime, test_reactive, test_error_engine
Other
test_optimizer, test_source_map, test_notebook, test_markup, test_package_manager, test_v12_features
LateralusOS
A bare-metal operating system written in Lateralus (transpiled to freestanding C99) + x86_64 assembly.
Located in lateralus-os/.
User Applications → GUI Desktop → System Services → Shell
→ Kernel (scheduler, IPC, VFS, network) → Memory Manager
→ HAL (interrupts, timers, I/O) → Bootstrap (C + ASM) → Bare Metal
| Layer | Contents |
|---|---|
boot/ | Multiboot2 x86_64 long-mode bootstrap (NASM + C stubs) |
kernel/ | Scheduler, IPC, VFS, cooperative task scheduler, memory manager (kmalloc bump allocator) |
hal/ | PIC, PIT, interrupts, I/O ports |
drivers/ | VGA text (80×25), PS/2 keyboard + mouse, serial port, PC speaker (PIT Ch2, melody queue) |
fs/ | RAM filesystem (64 inodes, pre-populated /home, /etc, /tmp) |
shell/ | ltlsh — 15+ commands (help, uname, uptime, free, cpuid, ls, cat, touch, mkdir, gui…) |
gui/ | Double-buffered 1024×768 framebuffer, window manager, functional terminal (17 commands), animated wallpaper (Fibonacci spirals, stars), Alt+Tab switcher, window open/close/minimize animations, start menu, context menu, desktop icons, system monitor, Catppuccin Mocha theme |
services/ | Mesh agent, crypto, system monitor |
cd lateralus-os && bash build_and_boot.sh --testKernel size: ~375 KB | ISO: ~13 MB | Build: 11-step pipeline, 11 .o files
Phase 3: Functional terminal (17 commands), RAM VFS, PC speaker audio, cooperative task scheduler, animated wallpaper (Fibonacci spirals, twinkling stars), window animations, Alt+Tab window switcher
Requires:
nasm, gcc, ld, grub-mkrescue, qemu-system-x86_64
VS Code Extension
Located in vscode-lateralus/. Supports VS Code and VSCodium.
| Feature | Details |
|---|---|
| Syntax highlighting | .ltl, .ltasm, .ltlml, .ltlcfg, .ltlnb |
| LSP client | Spawns lateralus_lang.lsp_server — diagnostics, completions, hover |
| Snippets | 17 snippets for v1.5 constructs (Result, Option, match, pipelines) |
| Icons | 6 custom SVG file icons for all Lateralus file types |
# Install
make vscode-install
# Or use the workspace task:
# "Install Lateralus VS Code Extension"
Development Setup
# Requirements: Python 3.10+
python3 -m venv .venv
source .venv/bin/activate
pip install -e .
# Verify installation
lateralus --version # → LATERALUS 2.4.0
lateralus info # Toolchain details
# Run all tests
pytest tests/ -v --tb=short
# Run a program
lateralus run examples/hello.ltl
# Interactive REPL
lateralus repl
# LateralusOS (additional requirements)
# nasm, gcc, ld, grub-mkrescue, xorriso, qemu-system-x86_64
Make Targets
| Target | What It Does |
|---|---|
make install | pip install -e . |
make test | Full pytest suite |
make test-c-backend | C backend tests only |
make lint | Lint stdlib with Lateralus linter |
make format | Format stdlib with Lateralus formatter |
make check | Type-check all examples |
make docs | Build .ltlml → HTML |
make vscode-install | Install VS Code extension |
make repl | Launch interactive REPL |
make bench | Run benchmarks |
make health | Run health check script |
make clean | Remove __pycache__, .pyc, build artifacts |
Public API
from lateralus_lang import (
# Compiler pipeline
Compiler, CompileResult, Target,
compile_file, compile_source,
run_file, run_source,
# Lexer / Parser
lex, Token, TK, LexError,
parse, ParseError,
# Intermediate Representation
analyze, IRModule,
# Virtual Machine
VM, Bytecode, assemble,
# Code generation
generate_bytecode, transpile_to_python,
# REPL
start_repl, REPL,
# Error handling
LTLError, ErrorContext, ErrorReporter, Severity,
get_bridge, ErrorBridge,
)
Roadmap
| Version | Theme | Status |
|---|---|---|
| v1.0 – v1.5 | Genesis → ADT Edition | ✅ Complete |
| v2.0 – v2.3 | C Backend, JS/WASM, IRC, Jupyter, OS | ✅ Complete |
| v2.4 | VM Disassembler, Enhanced REPL, Optimizer | 🟢 Current |
| v2.5 | Self-Hosting Bootstrap | ◯ Planned |
Rules of Engagement
- No version ships with failing tests. Ever.
- Every feature gets at least 3 tests before merge.
- Backward compatibility is sacred — old
.ltlfiles must always work. - The Python transpiler is the reference implementation until v2.0.
- Versions follow semver within the 1.x series.