ternlang_compat/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-compat — Compatibility bridges for the ternary computing ecosystem
7//!
8//! This crate is the convergence point for existing ternary computing projects,
9//! making ternlang the common runtime they all target.
10//!
11//! ## Bridges implemented
12//!
13//! - **`tasm`** — 9-trit RISC assembly → BET bytecode assembler
14//! Translates the Brandon Smith / ternary-computing.com `.tasm` assembly
15//! dialect (9-trit words, RISC-like mnemonics) into BET VM bytecode.
16//!
17//! - **`owlet`** — S-expression ternary front-end
18//! Parses Owlet-style S-expressions into ternlang AST nodes for evaluation
19//! on the BET VM.
20//!
21//! ## 9-trit word model
22//!
23//! The `.tasm` ecosystem uses 9-trit words (range −9841 to +9841 = 3⁹).
24//! Each trit is one of {−1, 0, +1}. Literals use 'T' for −1 (e.g. `10T` = 8).
25//!
26//! BET mapping:
27//! - Registers r0–r8 → BET registers 0–8
28//! - LOAD/STORE → TLOAD (0x07) / TSTORE (0x08)
29//! - ADD → TADD (0x02)
30//! - NEG → TNEG (0x04)
31//! - MUL → TMUL (0x03)
32//! - JMP → TJMP (0x0b)
33//! - BEQ (branch if zero) → TJMP_ZERO (0x06)
34//! - BLT (branch if neg) → TJMP_NEG (0x07)
35//! - HALT → THALT (0x00)
36//! - NOP → no-op (emit nothing)
37
38pub mod tasm;
39pub mod owlet;
40
41pub use tasm::{TasmAssembler, TasmError};
42pub use owlet::OwletParser;