pub trait ErrorRecovery {
// Required methods
fn create_error_node(
&mut self,
message: String,
expected: Vec<String>,
partial: Option<Node>,
) -> Node;
fn synchronize(&mut self, sync_points: &[SyncPoint]) -> bool;
fn recover_with_node(&mut self, error: ParseError) -> Node;
fn skip_until(&mut self, sync_points: &[SyncPoint]) -> usize;
fn skip_until_with_budget(
&mut self,
sync_points: &[SyncPoint],
budget: &ParseBudget,
tracker: &mut BudgetTracker,
) -> RecoveryResult;
fn is_sync_point(&self, sync_point: SyncPoint) -> bool;
}Expand description
Error recovery strategies
Required Methods§
Sourcefn create_error_node(
&mut self,
message: String,
expected: Vec<String>,
partial: Option<Node>,
) -> Node
fn create_error_node( &mut self, message: String, expected: Vec<String>, partial: Option<Node>, ) -> Node
Create an error node and recover
Sourcefn synchronize(&mut self, sync_points: &[SyncPoint]) -> bool
fn synchronize(&mut self, sync_points: &[SyncPoint]) -> bool
Synchronize to a recovery point
Sourcefn recover_with_node(&mut self, error: ParseError) -> Node
fn recover_with_node(&mut self, error: ParseError) -> Node
Try to recover from an error
Sourcefn skip_until(&mut self, sync_points: &[SyncPoint]) -> usize
fn skip_until(&mut self, sync_points: &[SyncPoint]) -> usize
Skip tokens until a sync point.
§Progress Invariant
This method guarantees forward progress: it will consume at least one token on each call (unless already at EOF or a sync point), preventing infinite recovery loops.
Sourcefn skip_until_with_budget(
&mut self,
sync_points: &[SyncPoint],
budget: &ParseBudget,
tracker: &mut BudgetTracker,
) -> RecoveryResult
fn skip_until_with_budget( &mut self, sync_points: &[SyncPoint], budget: &ParseBudget, tracker: &mut BudgetTracker, ) -> RecoveryResult
Budget-aware skip that respects limits.
§Progress Invariant
Consumes at least one token per call (unless at sync point, EOF, or budget exhausted).
Sourcefn is_sync_point(&self, sync_point: SyncPoint) -> bool
fn is_sync_point(&self, sync_point: SyncPoint) -> bool
Check if current token is a sync point