pub struct TokenStream<'a> { /* private fields */ }
Expand description
A stream of tokens. This is a wrapper around a logos::Lexer
. It implements Clone
, so it can be cloned and used to peek ahead. It also implements Iterator
, so it can be used to iterate over the tokens.
Implementations§
Source§impl<'a> TokenStream<'a>
impl<'a> TokenStream<'a>
Sourcepub fn new(input: &'a str) -> Self
pub fn new(input: &'a str) -> Self
Creates a new token stream from the given input string. The input string is not copied, so it must outlive the token stream.
Sourcepub fn peek(&self) -> Option<(Result<Token, ParserError>, &'a str)>
pub fn peek(&self) -> Option<(Result<Token, ParserError>, &'a str)>
Returns the next token in the stream, or None
if the stream is empty.
Trait Implementations§
Source§impl Clone for TokenStream<'_>
impl Clone for TokenStream<'_>
Source§impl<'a> Debug for TokenStream<'a>
impl<'a> Debug for TokenStream<'a>
Source§impl<'a> From<&'a String> for TokenStream<'a>
impl<'a> From<&'a String> for TokenStream<'a>
Source§impl<'a> From<&'a str> for TokenStream<'a>
impl<'a> From<&'a str> for TokenStream<'a>
Source§impl InputLength for TokenStream<'_>
impl InputLength for TokenStream<'_>
Source§impl<'a> Parser<TokenStream<'a>, &'a str, ParserError> for Token
impl<'a> Parser<TokenStream<'a>, &'a str, ParserError> for Token
Source§fn parse(
&mut self,
input: TokenStream<'a>,
) -> IResult<TokenStream<'a>, &'a str, ParserError>
fn parse( &mut self, input: TokenStream<'a>, ) -> IResult<TokenStream<'a>, &'a str, ParserError>
A parser takes in input type, and returns a
Result
containing
either the remaining input and the output value, or an errorSource§fn flat_map<G, H, O2>(self, g: G) -> FlatMap<Self, G, O>
fn flat_map<G, H, O2>(self, g: G) -> FlatMap<Self, G, O>
Creates a second parser from the output of the first one, then apply over the rest of the input
Source§fn and_then<G, O2>(self, g: G) -> AndThen<Self, G, O>
fn and_then<G, O2>(self, g: G) -> AndThen<Self, G, O>
Applies a second parser over the output of the first one
Source§fn and<G, O2>(self, g: G) -> And<Self, G>
fn and<G, O2>(self, g: G) -> And<Self, G>
Applies a second parser after the first one, return their results as a tuple
Auto Trait Implementations§
impl<'a> Freeze for TokenStream<'a>
impl<'a> RefUnwindSafe for TokenStream<'a>
impl<'a> Send for TokenStream<'a>
impl<'a> Sync for TokenStream<'a>
impl<'a> Unpin for TokenStream<'a>
impl<'a> UnwindSafe for TokenStream<'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