pub struct ParseContext<'a> { /* private fields */ }Expand description
Parser context: a cursor over the token stream.
Implementations§
Source§impl<'a> ParseContext<'a>
impl<'a> ParseContext<'a>
pub fn new(tokens: &'a [Token], source: &'a str) -> Self
pub fn source(&self) -> &'a str
Sourcepub fn record_error(&mut self, message: &str)
pub fn record_error(&mut self, message: &str)
Record a parse error at the current position.
Sourcepub fn record_error_at(&mut self, offset: u32, message: &str)
pub fn record_error_at(&mut self, offset: u32, message: &str)
Record a parse error at a specific byte offset.
Sourcepub fn take_diagnostics(&mut self) -> Vec<ParseDiagnostic>
pub fn take_diagnostics(&mut self) -> Vec<ParseDiagnostic>
Take collected diagnostics, leaving the internal list empty.
Sourcepub fn peek_non_trivia(&self) -> Option<&'a Token>
pub fn peek_non_trivia(&self) -> Option<&'a Token>
Peek at the next non-trivia token (skipping whitespace/comments).
Sourcepub fn peek_keyword(&self, kw: &str) -> bool
pub fn peek_keyword(&self, kw: &str) -> bool
Check if the next non-trivia token is a keyword matching kw (case-insensitive).
Sourcepub fn peek_keywords(&self, kws: &[&str]) -> bool
pub fn peek_keywords(&self, kws: &[&str]) -> bool
Check if next non-trivia tokens form a keyword sequence (e.g. “GROUP”, “BY”).
Sourcepub fn advance(&mut self) -> Option<&'a Token>
pub fn advance(&mut self) -> Option<&'a Token>
Consume and return the current token, advancing the cursor.
Sourcepub fn eat_trivia(&mut self) -> Vec<&'a Token>
pub fn eat_trivia(&mut self) -> Vec<&'a Token>
Consume all leading trivia tokens and return them.
Sourcepub fn eat_keyword(&mut self, kw: &str) -> Option<&'a Token>
pub fn eat_keyword(&mut self, kw: &str) -> Option<&'a Token>
Try to consume a keyword (case-insensitive). Returns the token if matched.
Auto Trait Implementations§
impl<'a> Freeze for ParseContext<'a>
impl<'a> RefUnwindSafe for ParseContext<'a>
impl<'a> Send for ParseContext<'a>
impl<'a> Sync for ParseContext<'a>
impl<'a> Unpin for ParseContext<'a>
impl<'a> UnsafeUnpin for ParseContext<'a>
impl<'a> UnwindSafe for ParseContext<'a>
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