pub struct CompiledGrammar {
pub rules: Vec<RuleDef>,
pub ast_config: AstConfig,
}Expand description
Compiled grammar ready for code generation
Fields§
§rules: Vec<RuleDef>§ast_config: AstConfigImplementations§
Source§impl CompiledGrammar
impl CompiledGrammar
Sourcepub fn analyze_backtracking(&self) -> Vec<BacktrackingWarning>
pub fn analyze_backtracking(&self) -> Vec<BacktrackingWarning>
Analyze the grammar for backtracking issues.
Returns warnings for each Choice node that has alternatives sharing a common prefix containing recursive rules (causing O(2^n) parsing).
Sourcepub fn optimize_backtracking(self) -> Self
pub fn optimize_backtracking(self) -> Self
Optimize the grammar by factoring out common prefixes in Choice nodes.
This transforms patterns like:
Choice([Seq([A, B, C]), Seq([A, B, D])])Into:
Seq([A, B, Choice([C, D])])Only transforms choices with Exponential severity (shared prefix
containing recursive rules).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CompiledGrammar
impl RefUnwindSafe for CompiledGrammar
impl Send for CompiledGrammar
impl Sync for CompiledGrammar
impl Unpin for CompiledGrammar
impl UnsafeUnpin for CompiledGrammar
impl UnwindSafe for CompiledGrammar
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more