ox_mf2_parser
High performance MessageFormat 2 parser core for the intlify ox-mf2 packages.
This crate parses Unicode MessageFormat 2 messages into a recovering, lossless concrete syntax tree (CST). It also exposes diagnostics, optional semantic lowering, and a Binary AST snapshot format used by the N-API and WASM bindings.
Installation
[]
= "0.1"
Quick Start
use parse_message;
let result = parse_message;
assert!;
assert!;
parse_message is the one-shot convenience API. It owns the returned ParseResult, including CST tables and diagnostics.
Diagnostics
Malformed input is parsed with recovery enabled by default. Diagnostics carry stable codes, severity, source spans, and messages.
use ;
let result = parse_message;
assert!;
assert_eq!;
Semantic Model
The parser can optionally lower CST data into a semantic model.
use ;
let mut sources = new;
let source = sources.add;
let result = parse_source;
assert!;
Use parse_source_session with ParseWorkspace when repeated parsing should reuse allocations.
Binary AST Snapshot
The snapshot module encodes parse results into a compact binary format and decodes that format into zero-copy views.
use ;
let snapshot = parse_message_to_snapshot
.unwrap;
let view = decode_snapshot.unwrap;
assert_eq!;
The snapshot format is intended for language bindings, persistence, and cross-process transfer. For in-process Rust usage, prefer ParseResult and CstView.
Relationship to npm packages
This crate is the Rust parser core used by:
@intlify/ox-mf2-napi@intlify/ox-mf2-wasm
Most JavaScript users should install one of those npm packages instead of using this crate directly.
Stability
ox_mf2_parser is pre-1.0. Public APIs are documented and intended to be usable, but minor releases may still refine names, shape, and snapshot details while MessageFormat 2 integration work continues.
License
MIT