Skip to main content

sim_codec_python/
lib.rs

1//! Bounded, lossless Python 3.14 syntax and general-purpose codec.
2//!
3//! This crate deliberately stops at syntax. [`parse_module`] returns a concrete
4//! source tree whose leaves partition the original bytes; it never creates
5//! runtime instructions or evaluates Python code.
6
7#![forbid(unsafe_code)]
8#![deny(missing_docs)]
9
10mod codec;
11mod grammar;
12mod lexer;
13mod lower;
14mod parser;
15mod types;
16
17pub use codec::{PythonCodec, PythonCodecLib};
18pub use grammar::{CORPUS_SHA256, GRAMMAR_SHA256, PYTHON_VERSION, frozen_productions};
19pub use lexer::{tokenize, tokenize_with_limits};
20pub use lower::{
21    decode_python, decode_python_located, decode_python_tree, encode_python, lower_python,
22};
23pub use parser::{parse_module, parse_module_with_limits};
24pub use types::{
25    Diagnostic, DiagnosticCode, Limits, Node, NodeKind, Span, SyntaxTree, Token, TokenKind,
26};
27
28/// Stable local id used before a host assigns `codec/python` an id.
29pub const PYTHON_CODEC_ID: sim_kernel::CodecId = sim_kernel::CodecId(0x50_59_00_00);
30
31/// Cookbook recipes embedded at build time.
32pub static RECIPES: sim_cookbook::EmbeddedDir =
33    include!(concat!(env!("OUT_DIR"), "/cookbook_recipes.rs"));
34
35#[cfg(test)]
36mod tests;