Skip to main content

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>`).
9//!
10//! ```
11//! let seq = muon::parse("a b, c").unwrap();
12//! assert_eq!(
13//!     seq.to_json(),
14//!     r#"{"seq":[{"chain":[{"sym":"a"},{"sym":"b"}]},{"chain":[{"sym":"c"}]}]}"#,
15//! );
16//! ```
17
18#![no_std]
19
20extern crate alloc;
21
22mod parse;
23mod tree;
24
25pub use parse::{parse, ErrorKind, ParseError};
26pub use tree::{Chain, Item, Seq};