metrale_grammar/earley/
mod.rs

1// SPDX-License-Identifier: MIT OR Apache-2.0
2
3//! 2026-09-26: Earley parser for grammar matching. `EarleyParser` holds the Earley
4//! items, advances them one byte at a time (`advance`), expands rule references
5//! (`predict`, `predict_fsm`), completes finished rules (`complete`), reports the
6//! acceptable next bytes (`accept`), and pushes or rolls back steps for the matcher.
7//!
8//! Owner: grammar.
9//! Invariants: `completable`, `is_completed` and `scanable_history` hold one entry per
10//! step. `new`, an accepted `advance`, `push_state_and_expand` and
11//! `push_one_state_to_check` add one to each; `pop_last_states(count)` removes `count`
12//! from each and panics rather than remove the first step; `reset` clears all three.
13
14mod accept;
15mod complete;
16mod fsm_view;
17mod parser;
18mod parser_api;
19mod predict;
20mod predict_fsm;
21mod prune;
22mod queue;
23mod scan;
24mod scan_charclass;
25mod state;
26
27pub use parser::{CompletableEntry, EarleyParser};
28pub use queue::ProcessQueue;
29pub use state::{NO_PREV_INPUT_POS, ParserState, UNEXPANDED_RULE_START_SEQUENCE_ID, cache_key};
30
31#[cfg(test)]
32mod tests;