Skip to main content

frazaro_core/
lib.rs

1//! frazaro-core: the host-free home of the Frazaro language's bridges.
2//!
3//! The contract (docs/HORIZON.md, section 12): bytes in, bytes out, nothing
4//! else. No clock, no randomness, no threads, no file system, no socket. On
5//! the wasm32 target the built module's import section is empty, and
6//! tools/check_core_imports.ps1 pins that count at zero.
7//!
8//! Since PORT.12 (2026-10-08) the language itself is a crate of its own,
9//! `vla-lang`, this crate's one dependency: the reader, the forms and their
10//! printing, macro expansion, the head table, the intrinsics, the message
11//! catalogue's mechanism with the language's own refusals, the version
12//! predicates, the grid, the references read out of a formula's text, the
13//! relation rows and the view record. Those modules are re-exported here
14//! whole, below, so every path a door used before the cut resolves as it
15//! did. What this crate holds is the bridges: the English engine
16//! (`english`), the VBA and formula emitters (`emit`), the workbook writer
17//! (`build` over `sheet`'s formats) and the readers (`reflect`), the formula
18//! sink's scan (`egress`), the distro manifest (`distro`), the kernel's
19//! registries (`kernel`), the core's half of the catalogue (`messages`), the
20//! API (`api`) and the C surface (`abi`). The three-crate order is
21//! Alonzo/CHARTER.md section 4, rule 1: an engine consumes `vla-lang` and
22//! never this crate.
23//!
24//! SD-18 governs what this crate may claim: the VBA in src/ is the reference
25//! implementation, and this crate follows the goldens in scripts/ and never
26//! leads them. conformance/README.md is the treaty; tools/prove.ps1 scores an
27//! implementation against it.
28//!
29//! The API a door calls is VLA_Browser.bas's pair, text in and text out:
30//! `api::english_translate_text_to_vla` and `api::english_translate_text_to_vba`
31//! (PORT.6, slice 6g), and `abi` exports the pair with C linkage for a wasm
32//! host or a native embedding (6h): an allocator pair, the two functions, the
33//! door's gate and the version, every answer one record in the module's
34//! memory. The version and the ABI number were exported from the first
35//! commit, so that CI held the zero-import property before anything else
36//! existed.
37//!
38//! The writer (PORT.7) is `build` over `sheet`: a translated program to a
39//! workbook's bytes, deterministic, with no clock and no dependency outside
40//! the repository; `api::english_build_xlsx` is its surface.
41//!
42//! The reader (PORT.8) is `reflect`: a workbook's bytes, OOXML first, read
43//! as the relations of `REFLECT` with no host, streamed sheet by sheet;
44//! `api::reflect_relations` is its surface. `refers` (slice 8b, the
45//! language's since the cut) is the formula-reference reader,
46//! `VLA_Refers.bas` ported and held to its golden: the `refers` rows, the
47//! writer's mover and the R1C1 rendering all come off its one scan.
48//!
49//! `egress` (SEC.15) is the formula sink's scan, `VlaFormulaEgress` of
50//! `VLA_Runtime.bas` held to the egress golden: the writer asks it before
51//! it writes a formula, as the add-in's two backends do, and refuses one
52//! that reaches outside the workbook on its own.
53//!
54//! `kernel` (KERNEL.1) writes the kernel's boundary and its six seams down
55//! as data and names the engines trait; the projections seam's trait is the
56//! language's (`vla_lang::projection`) and is re-exported there. `view`
57//! (KERNEL.4, the language's) is the first implementation of that seam: one
58//! window of the sheet model as the view record, a pure function of the
59//! program and the books, the lines a viewport draws from;
60//! `api::english_view` is its surface. `distro` (KERNEL.2) reads a distro's
61//! manifest, the folder the build tools take: the prelude, the phrasebooks
62//! in their load order, the dialects, the libraries and an edition's chrome,
63//! by reference; the command-line door proves a distro whole with it.
64
65pub mod abi;
66pub mod api;
67pub mod build;
68pub mod distro;
69pub mod egress;
70pub mod emit;
71pub mod english;
72pub mod excel;
73pub mod kernel;
74pub mod messages;
75pub mod reflect;
76pub mod sha256;
77pub mod sheet;
78
79// The language, re-exported whole (PORT.12): `frazaro_core::form`,
80// `crate::view::Grid` and every other path a door or a test used before
81// the cut resolve as they did. The modules are vla-lang's, documented there.
82pub use vla_lang::{
83    calc, expand, form, formula_syntax, headtable, intrinsics, printer, reader, refers, view,
84};
85
86/// The version predicates (`parse`, `compare`, `at_least`), the language's,
87/// re-exported as the module they were; the function `version` below is
88/// the core's own.
89pub mod version {
90    pub use vla_lang::version::*;
91}
92
93/// The crate's version, which tools/check_version_twin.ps1 holds equal to
94/// VLA_RELEASE_VERSION in src/VLA.bas and to the language crate's: one
95/// corpus, one version.
96pub const VERSION: &str = env!("CARGO_PKG_VERSION");
97
98/// The number a door checks before calling anything else. It changes only
99/// when an exported signature changes its meaning.
100pub const ABI_VERSION: u32 = 1;
101
102/// The version as text.
103pub fn version() -> &'static str {
104    VERSION
105}
106
107/// The ABI number, exported with C linkage so that a wasm host or a native
108/// embedding can read it without any binding layer.
109#[no_mangle]
110pub extern "C" fn frazaro_abi_version() -> u32 {
111    ABI_VERSION
112}
113
114#[cfg(test)]
115mod tests {
116    use super::*;
117
118    #[test]
119    fn version_is_major_minor_patch() {
120        let parts: Vec<&str> = version().split('.').collect();
121        assert_eq!(parts.len(), 3, "SD-14 numbers releases MAJOR.MINOR.PATCH");
122        for part in parts {
123            assert!(
124                part.parse::<u32>().is_ok(),
125                "non-numeric version part: {part}"
126            );
127        }
128    }
129
130    #[test]
131    fn abi_version_is_one() {
132        assert_eq!(frazaro_abi_version(), 1);
133        assert_eq!(ABI_VERSION, 1);
134    }
135
136    #[test]
137    fn the_language_and_the_core_are_one_version() {
138        assert_eq!(vla_lang::VERSION, VERSION, "one corpus, one version");
139    }
140}