Skip to main content

ErrorRecovery

Trait ErrorRecovery 

Source
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§

Source

fn create_error_node( &mut self, message: String, expected: Vec<String>, partial: Option<Node>, ) -> Node

Create an error node and recover

Source

fn synchronize(&mut self, sync_points: &[SyncPoint]) -> bool

Synchronize to a recovery point

Source

fn recover_with_node(&mut self, error: ParseError) -> Node

Try to recover from an error

Source

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.

Source

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).

Source

fn is_sync_point(&self, sync_point: SyncPoint) -> bool

Check if current token is a sync point

Implementors§