pub struct ParseRecoveryTokenSet<K: SyntaxKind> { /* private fields */ }Expand description
Recovers the parser by finding a token/point (depending on the configuration) from where
the caller knows how to proceed parsing. The recovery wraps all the skipped tokens inside a Bogus node.
A safe recovery point for an array element could by finding the next , or ].
Implementations§
Source§impl<K: SyntaxKind> ParseRecoveryTokenSet<K>
impl<K: SyntaxKind> ParseRecoveryTokenSet<K>
Sourcepub fn new(node_kind: K, recovery_set: TokenSet<K>) -> Self
pub fn new(node_kind: K, recovery_set: TokenSet<K>) -> Self
Creates a new parse recovery that eats all tokens until it finds any token in the passed recovery set.
Sourcepub fn enable_recovery_on_line_break(self) -> Self
pub fn enable_recovery_on_line_break(self) -> Self
Enable recovery on line breaks
Sourcepub fn recover<P>(&self, p: &mut P) -> RecoveryResultwhere
P: Parser<Kind = K>,
pub fn recover<P>(&self, p: &mut P) -> RecoveryResultwhere
P: Parser<Kind = K>,
Tries to recover by parsing all tokens into an Bogus* node until the parser finds any token
specified in the recovery set, the EOF, or a line break (depending on configuration).
Returns Ok(bogus_node) if recovery was successful, and Err(RecoveryError::Eof) if the parser
is at the end of the file (before starting recovery).
Auto Trait Implementations§
impl<K> Freeze for ParseRecoveryTokenSet<K>where
K: Freeze,
impl<K> RefUnwindSafe for ParseRecoveryTokenSet<K>where
K: RefUnwindSafe,
impl<K> Send for ParseRecoveryTokenSet<K>where
K: Send,
impl<K> Sync for ParseRecoveryTokenSet<K>where
K: Sync,
impl<K> Unpin for ParseRecoveryTokenSet<K>where
K: Unpin,
impl<K> UnwindSafe for ParseRecoveryTokenSet<K>where
K: UnwindSafe,
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