pub struct Parser { /* private fields */ }
Available on crate feature
parser
only.Expand description
Implementations§
Source§impl Parser
impl Parser
Sourcepub fn next_token(&mut self) -> Result<Option<Token>, ParserError>
pub fn next_token(&mut self) -> Result<Option<Token>, ParserError>
Get the next Token from this Parser. This may be a token that’s already been peeked. Return an error if a Token with TokenTy::Unknown is encountered.
Sourcepub fn peek(&mut self) -> Option<&Token>
pub fn peek(&mut self) -> Option<&Token>
Peek at the next token from the Lexer (cached in the lookahead queue if peeked before).
Sourcepub fn lookahead_window(&mut self, n: usize) -> Option<&[Token]>
pub fn lookahead_window(&mut self, n: usize) -> Option<&[Token]>
Sourcepub fn next_if_is(&mut self, token_ty: TokenTy) -> Option<Token>
pub fn next_if_is(&mut self, token_ty: TokenTy) -> Option<Token>
Get the next Token from this parser if its Token::variant is the given token_ty
.
Sourcepub fn matches(&mut self, seq: &[TokenTy]) -> bool
pub fn matches(&mut self, seq: &[TokenTy]) -> bool
Peek at the next Tokens of this Parser and determine if the Token::variants match this sequence of TokenTys.
Sourcepub fn ignore_whitespace(&mut self)
pub fn ignore_whitespace(&mut self)
Peek at the next Token, remove it if it’s a TokenTy::Whitespace.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Parser
impl RefUnwindSafe for Parser
impl Send for Parser
impl Sync for Parser
impl Unpin for Parser
impl UnwindSafe for Parser
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more