pub struct Parser { /* private fields */ }
parser
only.Expand description
Implementations§
Source§impl Parser
impl Parser
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 peek_next_not_whitespace(&mut self) -> Option<&Token>
pub fn peek_next_not_whitespace(&mut self) -> Option<&Token>
Peek the next token that’s not whitespace.
Sourcepub fn bytes_remaining(&self) -> usize
pub fn bytes_remaining(&self) -> usize
Get the number of remaining bytes on this parser. This is potentially useful for checking if a parser has advanced between two calls (or checking if a parser has reached end of input).
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.
Skips any non-document comments encountered via the lexer implementation.
Return an error if a Token with TokenTy::Unknown is encountered.
Sourcepub fn peek_fragment_or_rest_cloned(&mut self) -> Fragment
pub fn peek_fragment_or_rest_cloned(&mut self) -> Fragment
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 consume_optional_whitespace(&mut self)
pub fn consume_optional_whitespace(&mut self)
Consume & remove all whitespace tokens from the front of the parser.
Sourcepub fn consume_at_least_one_whitespace(&mut self) -> Result<(), ParserError>
pub fn consume_at_least_one_whitespace(&mut self) -> Result<(), ParserError>
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
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>
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>
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