[−][src]Trait lrpar::Lexer
The trait which all lexers which want to interact with lrpar
must implement.
Required methods
fn iter<'a>(
&'a self
) -> Box<dyn Iterator<Item = Result<Lexeme<StorageT>, LexError>> + 'a>
&'a self
) -> Box<dyn Iterator<Item = Result<Lexeme<StorageT>, LexError>> + 'a>
Iterate over all the lexemes in this lexer. Note that:
- The lexer may or may not stop after the first
LexError
is encountered. - There are no guarantees about whether the lexer caches anything if this method is called more than once (i.e. it might be slow to call this more than once).
fn lexeme_str(&self, lexeme: &Lexeme<StorageT>) -> &str
Return the user input associated with a lexeme. Panics if the lexeme is invalid (i.e. was not produced by next()).
fn line_col(&self, off: usize) -> (usize, usize)
Return the line and column number of the byte at position off
. Note that the column
number is a character -- not a byte! -- offset, relative to the beginning of the line.
Panics if the offset exceeds the known input.
fn surrounding_line_str(&self, off: usize) -> &str
Return the line containing the byte at position off
. Panics if the offset exceeds the
known input.