Skip to main content

sim_codec_javascript/
lib.rs

1//! Bounded, lossless ECMAScript 2026 Script and Module frontend.
2//!
3//! The public model is deliberately neutral syntax data. It has no compiler IR,
4//! runtime, TypeScript, Shape, or kernel dependency. Parser extensions can wrap
5//! [`Node`] and attach their own [`Origin`] without changing JavaScript syntax.
6//!
7//! The frozen downstream extension seam is exactly [`Token`], [`SyntaxTree`],
8//! [`Node`], [`Origin`], and [`JavascriptBuilder`]. It carries syntax and
9//! lowering data only; TypeScript policy remains a one-way downstream concern.
10
11#![forbid(unsafe_code)]
12#![deny(missing_docs)]
13
14mod codec;
15mod lexer;
16mod lower;
17mod parser;
18mod types;
19
20pub use codec::{JavascriptCodec, JavascriptCodecLib};
21pub use lexer::{tokenize, tokenize_with_limits};
22pub use lower::{
23    JavascriptBuilder, decode_javascript, decode_javascript_located, decode_javascript_tree,
24    encode_javascript, lower_javascript,
25};
26pub use parser::{parse_module, parse_module_with_limits, parse_script, parse_script_with_limits};
27pub use types::{
28    Asi, Diagnostic, DiagnosticCode, Goal, LexicalGoal, Limits, Node, NodeKind, Origin, Span,
29    SyntaxTree, Token, TokenKind,
30};
31
32/// Frozen ECMA-262 edition.
33pub const ECMA262_EDITION: &str = "ECMA-262, 17th edition (ECMAScript 2026)";
34/// Immutable specification authority used by this frontend.
35pub const ECMA262_AUTHORITY: &str = "https://tc39.es/ecma262/2026/multipage/";
36/// Date on which the edition identity and grammar inventory were frozen.
37pub const ECMA262_FROZEN_ON: &str = "2026-08-01";
38/// Frozen Test262 evidence corpus revision. Test262 is an oracle, not a dependency.
39pub const TEST262_REVISION: &str = "tc39/test262@main as observed 2026-08-01";
40/// SHA-256 of the checked source corpus manifest.
41pub const CORPUS_MANIFEST_SHA256: &str =
42    "88b15b687f3741ba7c0145d1e2f09e05f0b1d8bf95656f257656fe3aefe416da";
43
44/// Stable local id used before a host assigns `codec/javascript` an id.
45pub const JAVASCRIPT_CODEC_ID: sim_kernel::CodecId = sim_kernel::CodecId(0x4a_53_00_00);
46
47#[cfg(test)]
48mod tests;