frazaro_core/lib.rs
1//! frazaro-core: the host-free home of the Frazaro language.
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//! SD-18 governs what this crate may claim: the VBA in src/ is the reference
9//! implementation, and this crate follows the goldens in scripts/ and never
10//! leads them. conformance/README.md is the treaty; tools/prove.ps1 scores an
11//! implementation against it.
12//!
13//! The API a door calls is VLA_Browser.bas's pair, text in and text out:
14//! `api::english_translate_text_to_vla` and `api::english_translate_text_to_vba`
15//! (PORT.6, slice 6g), and `abi` exports the pair with C linkage for a wasm
16//! host or a native embedding (6h): an allocator pair, the two functions, the
17//! door's gate and the version, every answer one record in the module's
18//! memory. The version and the ABI number were exported from the first
19//! commit, so that CI held the zero-import property before anything else
20//! existed.
21//!
22//! The writer (PORT.7) is `build` over `sheet`: a translated program to a
23//! workbook's bytes, deterministic, with no clock and no dependency;
24//! `api::english_build_xlsx` is its surface.
25//!
26//! The reader (PORT.8) is `reflect`: a workbook's bytes, OOXML first, read
27//! as the relations of `REFLECT` with no host, streamed sheet by sheet;
28//! `api::reflect_relations` is its surface. `refers` (slice 8b) is the
29//! formula-reference reader, `VLA_Refers.bas` ported and held to its
30//! golden: the `refers` rows, the writer's mover and the R1C1 rendering
31//! all come off its one scan.
32//!
33//! `egress` (SEC.15) is the formula sink's scan, `VlaFormulaEgress` of
34//! `VLA_Runtime.bas` held to the egress golden: the writer asks it before
35//! it writes a formula, as the add-in's two backends do, and refuses one
36//! that reaches outside the workbook on its own.
37
38pub mod abi;
39pub mod api;
40pub mod build;
41pub mod egress;
42pub mod emit;
43pub mod english;
44pub mod expand;
45pub mod form;
46pub mod headtable;
47pub mod intrinsics;
48pub mod kernel;
49pub mod messages;
50pub mod printer;
51pub mod reader;
52pub mod refers;
53pub mod reflect;
54pub mod sha256;
55pub mod sheet;
56pub mod version;
57
58/// The crate's version, which tools/check_version_twin.ps1 holds equal to
59/// VLA_RELEASE_VERSION in src/VLA.bas: one corpus, one version.
60pub const VERSION: &str = env!("CARGO_PKG_VERSION");
61
62/// The number a door checks before calling anything else. It changes only
63/// when an exported signature changes its meaning.
64pub const ABI_VERSION: u32 = 1;
65
66/// The version as text.
67pub fn version() -> &'static str {
68 VERSION
69}
70
71/// The ABI number, exported with C linkage so that a wasm host or a native
72/// embedding can read it without any binding layer.
73#[no_mangle]
74pub extern "C" fn frazaro_abi_version() -> u32 {
75 ABI_VERSION
76}
77
78#[cfg(test)]
79mod tests {
80 use super::*;
81
82 #[test]
83 fn version_is_major_minor_patch() {
84 let parts: Vec<&str> = version().split('.').collect();
85 assert_eq!(parts.len(), 3, "SD-14 numbers releases MAJOR.MINOR.PATCH");
86 for part in parts {
87 assert!(
88 part.parse::<u32>().is_ok(),
89 "non-numeric version part: {part}"
90 );
91 }
92 }
93
94 #[test]
95 fn abi_version_is_one() {
96 assert_eq!(frazaro_abi_version(), 1);
97 assert_eq!(ABI_VERSION, 1);
98 }
99}