muon/lib.rs
1//! Muon — the Mu object notation.
2//!
3//! A `no_std` scannerless parser that turns Muon text into a Muon tree,
4//! following `docs/muon-spec.md`. Nesting is driven by an explicit heap stack
5//! (see `parse.rs`), so depth is bounded only by memory. Leaves borrow from the input
6//! (`&'a str`, zero-copy); structure is `alloc`ated. Symbols are lexed by
7//! maximal munch, so the whitespace-merge rules of the spec fall out naturally
8//! (a run of symchars is one `<sym>`). Every node knows where it stands in the
9//! input: a leaf through its slice, a bracket group through a stored [`Span`];
10//! [`Item::span`] answers for either.
11//!
12//! ```
13//! let seq = muon::parse("a b, c").unwrap();
14//! assert_eq!(
15//! seq.to_json(),
16//! r#"{"seq":[{"chain":[{"sym":"a"},{"sym":"b"}]},{"chain":[{"sym":"c"}]}]}"#,
17//! );
18//! ```
19
20#![no_std]
21
22extern crate alloc;
23
24mod parse;
25mod tree;
26
27pub use parse::{is_sym, parse, ErrorKind, ParseError};
28pub use tree::{Chain, Group, Item, Seq, Span};