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]

[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]

A type that describes the position of a token in the input source, for example a line and column number. Read more

The type of tokens returned by this lexer.

A type that describes the possible errors that the lexer might encounter while processing the input source. Read more

[src]

Reads the next token from the input. Read more