pub struct Parser<'t> {
pub lexer: Lexer<'t>,
pub next_tok: Option<PResult<Token>>,
pub last_loc: Span,
pub elide_do: bool,
}Fields§
§lexer: Lexer<'t>§next_tok: Option<PResult<Token>>§last_loc: Span§elide_do: boolImplementations§
Source§impl<'t> Parser<'t>
impl<'t> Parser<'t>
Sourcepub const fn then<T>(&self, t: T) -> T
pub const fn then<T>(&self, t: T) -> T
The identity function. This exists to make production chaining easier.
Sourcepub fn parse<T: Parse<'t>>(&mut self, level: T::Prec) -> PResult<T>
pub fn parse<T: Parse<'t>>(&mut self, level: T::Prec) -> PResult<T>
Parses a value that implements the Parse trait.
Sourcepub fn parse_entire<T: Parse<'t>>(&mut self, level: T::Prec) -> PResult<T>
pub fn parse_entire<T: Parse<'t>>(&mut self, level: T::Prec) -> PResult<T>
Parses a value that implements the Parse trait, and asserts the entire input has been consumed.
Sourcepub fn peek(&mut self) -> PResult<&Token>
pub fn peek(&mut self) -> PResult<&Token>
Peeks the next Token. Returns ParseError::FromLexer on lexer error.
Sourcepub fn peek_if(&mut self, expected: TKind) -> PResult<Option<&Token>>
pub fn peek_if(&mut self, expected: TKind) -> PResult<Option<&Token>>
Peeks the next token if it matches the expected TKind
Sourcepub fn take_lexeme(&mut self) -> PResult<Lexeme>
pub fn take_lexeme(&mut self) -> PResult<Lexeme>
Consumes the currently-peeked Token, returning its lexeme without cloning.
pub fn next(&mut self) -> PResult<Token>
Sourcepub fn list<P: Parse<'t>>(
&mut self,
elems: Vec<P>,
level: P::Prec,
sep: TKind,
end: TKind,
) -> PResult<Vec<P>>
pub fn list<P: Parse<'t>>( &mut self, elems: Vec<P>, level: P::Prec, sep: TKind, end: TKind, ) -> PResult<Vec<P>>
Parses a list of P separated by sep tokens, ending in an end token.
ⓘ
List<T> = (T sep)* T? end ;Sourcepub fn list_bare<P: Parse<'t>>(
&mut self,
elems: Vec<P>,
level: P::Prec,
sep: TKind,
) -> PResult<Vec<P>>
pub fn list_bare<P: Parse<'t>>( &mut self, elems: Vec<P>, level: P::Prec, sep: TKind, ) -> PResult<Vec<P>>
Parses a list of one or more P at level level, separated by sep tokens
ⓘ
UnterminatedList<P> = P (sep P)*Sourcepub fn opt_if<P: Parse<'t>>(
&mut self,
level: P::Prec,
next: TKind,
) -> PResult<Option<P>>
pub fn opt_if<P: Parse<'t>>( &mut self, level: P::Prec, next: TKind, ) -> PResult<Option<P>>
Parses into an Option<P> if the next token is next
Trait Implementations§
Auto Trait Implementations§
impl<'t> Freeze for Parser<'t>
impl<'t> RefUnwindSafe for Parser<'t>
impl<'t> Send for Parser<'t>
impl<'t> Sync for Parser<'t>
impl<'t> Unpin for Parser<'t>
impl<'t> UnwindSafe for Parser<'t>
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