sim_codec_algol/lib.rs
1//! General-purpose Algol codec for the SIM runtime: the infix, Pratt-parsed
2//! surface that round-trips every expression through the shared `Expr` graph.
3//!
4//! A decoder tokenizes infix source and parses it with a precedence-driven
5//! Pratt parser into checked `Expr` forms; an encoder serializes any `Expr`
6//! back to infix text, inserting parentheses according to operator binding
7//! power. Like the Lisp codec, it covers the full expression graph rather than
8//! a single domain, so any value the kernel can hold round-trips through it.
9//!
10//! # Module map
11//!
12//! All submodules are private; their public items are re-exported at the crate
13//! root. `parse` tokenizes and decodes infix source into located expression
14//! trees and exposes `ParseCx`, `SpannedToken`, and the `decode_algol_located`
15//! family. `pratt` holds the precedence-climbing parser (`PrattParser`) and the
16//! operator table (`default_pratt_table`, `supports_pratt`). `encode` renders
17//! any `Expr` back to infix text (`encode_algol`). `runtime` provides the `Lib`
18//! registration (`AlgolCodec`, `AlgolCodecLib`) that wires the codec into the
19//! runtime.
20#![forbid(unsafe_code)]
21#![deny(missing_docs)]
22
23mod encode;
24mod parse;
25mod pratt;
26mod runtime;
27
28pub use encode::encode_algol;
29pub use parse::{
30 ParseCx, SpannedToken, decode_algol_located, decode_algol_located_with_budget,
31 parse_algol_expr_with_table, parse_algol_expr_with_table_and_budget, tokenize_algol_spanned,
32 tokenize_algol_spanned_with_budget,
33};
34pub use pratt::{PrattParser, default_pratt_table, supports_pratt};
35pub use runtime::{AlgolCodec, AlgolCodecLib};
36
37#[cfg(test)]
38mod tests;