ternlang-core
The compiler and virtual machine for Ternlang — a balanced ternary language for AI and ML systems.
Every value is a trit: reject (−1), tend (0), or affirm (+1). The tend state is a first-class computational directive — not null, not false, but "hold until evidence crosses threshold."
What's in this crate
| Component | Description |
|---|---|
| Lexer + Parser | Tokenises and parses .tern source into an AST |
| Semantic analyser | Type-checks, validates exhaustive 3-arm match |
| Bytecode emitter | Compiles AST → BET (Balanced Ternary Execution) bytecode |
| BET VM | Stack-based VM — 51 opcodes, 27 registers, tensor heap, agent runtime |
@sparseskip |
Codegen directive: emits TSPARSE_MATMUL to skip zero-state weights |
| StdlibLoader | Resolves use std::trit etc. at compile time with zero runtime I/O |
Quick start
Or use the API directly:
use ;
let mut parser = new;
let mut emitter = new;
while let Ok = parser.parse_stmt
let mut vm = new;
vm.run.unwrap;
Language snapshot
fn triage(conscious: trit, vitals: trit) -> trit {
match conscious {
reject => { return reject; } // hard gate — skip all further checks
tend => { return tend; } // wait for more data
affirm => { return consensus(conscious, vitals); }
}
}
License
LGPL-3.0 — open core. See LICENSE-LGPL.