Struct menhir_runtime::lexing::IteratorLexer
[−]
[src]
pub struct IteratorLexer<Iter, Loc, Tok> where
Iter: Iterator<Item = (Loc, Tok)>, { /* fields omitted */ }
Adapter type to convert an iterator into a lexer.
Lexing tools that implement an interface based on Iterator
can be
converted to Menhir's more advanced Lexer
interface by using this
type.
If the iterator returns None
while the parser still needs tokens,
input
will return an UnexpectedEof
error. If one wants the parser
to consume exactly all the tokens, one should manually check that the
underlying iterator is empty once parsing succeeded.
Methods
impl<Iter, Loc, Tok> IteratorLexer<Iter, Loc, Tok> where
Loc: Default,
Iter: Iterator<Item = (Loc, Tok)>,
[src]
Loc: Default,
Iter: Iterator<Item = (Loc, Tok)>,
fn new(lex: Iter) -> Self
[src]
Builds a new adapter from the given iterator.
This function takes the iterator by-value. If the iterator is not,
Copy
, it won't be usable anymore after the parsing process. If this
is not desired, one should give to this function a mutable reference
to the iterator instead.
Trait Implementations
impl<Iter, Loc, Tok> Lexer for IteratorLexer<Iter, Loc, Tok> where
Loc: Clone,
Iter: Iterator<Item = (Loc, Tok)>,
[src]
Loc: Clone,
Iter: Iterator<Item = (Loc, Tok)>,
type Location = Loc
A type that describes the position of a token in the input source, for example a line and column number. Read more
type Token = Tok
The type of tokens returned by this lexer.
type Error = UnexpectedEof<Self::Location>
A type that describes the possible errors that the lexer might encounter while processing the input source. Read more
fn input(&mut self) -> Result<(Loc, Tok), Self::Error>
[src]
Reads the next token from the input. Read more