Skip to main content

ternlang_core/
lib.rs

1// SPDX-License-Identifier: LGPL-3.0-or-later
2// Ternlang — RFI-IRFOS Ternary Intelligence Stack
3// Copyright (C) 2026 RFI-IRFOS
4// Open-core compiler. See LICENSE-LGPL in the repository root.
5
6//! # ternlang-core
7//!
8//! Compiler and VM for Ternlang — balanced ternary language with
9//! affirm/tend/reject trit semantics, `@sparseskip` codegen, and BET
10//! (Balanced Encoded Ternary) bytecode execution.
11//!
12//! ## Quick start
13//!
14//! ```no_run
15//! use ternlang_core::{Trit, pack_trits, unpack_trits};
16//!
17//! let trits = vec![Trit::Affirm, Trit::Tend, Trit::Reject];
18//! let packed = pack_trits(&trits);
19//! let round_tripped = unpack_trits(&packed, trits.len()).unwrap();
20//! assert_eq!(trits, round_tripped);
21//! ```
22
23pub mod trit;
24pub mod types;
25pub mod vm;
26pub mod lexer;
27pub mod ast;
28pub mod parser;
29pub mod semantic;
30pub mod codegen;
31pub mod stdlib;
32pub mod wasm_simd;
33
34// ─── Consolidated re-exports ───────────────────────────────────────
35// Trit, TritBlock5, and packed arithmetic helpers all come from the
36// types module so downstream crates (ternlang-ml, ternlang-mcp, etc.)
37// can simply do `use ternlang_core::{Trit, TritBlock5, packed_add}`.
38pub use types::trit::{Trit, TritBlock5, pack_5_trits, unpack_5_trits};
39pub use trit::Trit as LegacyTrit; // deprecated alias — do not use in new code
40pub use vm::bet::{pack_trits, unpack_trits, BetFault};
41pub use vm::{BetVm, Value as VmValue};
42pub use lexer::Token;
43pub use ast::*;
44pub use parser::Parser;
45pub use semantic::SemanticAnalyzer;
46pub use codegen::betbc::BytecodeEmitter;
47pub use stdlib::{StdlibLoader, ModuleResolver};