pub struct Parser<'a> { /* private fields */ }Expand description
A cursor over tokens. Shared by the expression parser (this task) and the section parser (Task 4).
Implementations§
Source§impl<'a> Parser<'a>
impl<'a> Parser<'a>
Sourcepub fn peek_at(&self, n: usize) -> &Tok
pub fn peek_at(&self, n: usize) -> &Tok
The token n positions ahead of the cursor; peek_at(0) is Parser::peek.
Clamped to the trailing Eof, like peek and peek2.
Sourcepub fn prev_span(&self) -> Span
pub fn prev_span(&self) -> Span
Span of the token just consumed, or of the current one at the start of input.
Expr::span() cannot serve here: a parenthesised expression carries the span of
its contents, so !(a | b) ends before the closing parens. This gives the real
end of whatever was last read, which is what quoting a construct back to the
author needs.
Sourcepub fn eat(&mut self, want: &Tok) -> bool
pub fn eat(&mut self, want: &Tok) -> bool
Consumes the current token if it matches, reporting whether it did.
Sourcepub fn expect(
&mut self,
want: &Tok,
what: &str,
diags: &mut Diagnostics,
) -> bool
pub fn expect( &mut self, want: &Tok, what: &str, diags: &mut Diagnostics, ) -> bool
Consumes the current token if it matches, otherwise records a diagnostic.
Sourcepub fn parse_expr(&mut self, diags: &mut Diagnostics) -> Expr
pub fn parse_expr(&mut self, diags: &mut Diagnostics) -> Expr
Parses a formula.
Auto Trait Implementations§
impl<'a> Freeze for Parser<'a>
impl<'a> RefUnwindSafe for Parser<'a>
impl<'a> Send for Parser<'a>
impl<'a> Sync for Parser<'a>
impl<'a> Unpin for Parser<'a>
impl<'a> UnsafeUnpin for Parser<'a>
impl<'a> UnwindSafe for Parser<'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