pub fn parse(
g: &Grammar,
root_rule_name: &str,
tokens: &[Token],
guards: Rc<HashMap<String, Guard, FxBuildHasher>>,
hooks: Rc<HashMap<String, Hook, FxBuildHasher>>,
) -> Result<ASTNode, Box<PrdError>>Expand description
Worklist implementation: Parse the given token stream (produced by bnf::tokenize) into an AST, using the given bnf::Grammar, and taking the given root rule name as the starting point.
Guards and hooks are for advanced usage (e.g. parsing C).
This implementation is not vulnerable to deep recursion issues. Each level of nesting depth consumes only 64 more bytes of memory.
However, this version is about 4% slower than parse. I’m going to keep working on optimizing it.
This implementation does not yet support the “deep_errors” feature. When it does, adding support for it will not be considered a breaking change.
See also: ASTNode, parse_recursive