pub struct Lexeme<StorageT> { /* private fields */ }
Expand description
A Lexeme
represents a segment of the user’s input that conforms to a known type. All lexemes
have a starting position in the user’s input: lexemes that result from error recovery, however,
do not have a length (or, therefore, an end). This allows us to differentiate between lexemes
that are always of zero length (which are required in some grammars) from lexemes that result
from error recovery (where an error recovery algorithm can know the type that a lexeme should
have been, but can’t know what its contents should have been).
Implementations§
source§impl<StorageT: Copy> Lexeme<StorageT>
impl<StorageT: Copy> Lexeme<StorageT>
sourcepub fn new(tok_id: StorageT, start: usize, len: Option<usize>) -> Self
pub fn new(tok_id: StorageT, start: usize, len: Option<usize>) -> Self
Create a new token with ID tok_id
and a starting position in the input start
. If the
token is the result of user input, then Some(n)
should be passed to len
; if the token
is the result of error recovery, then None
should be passed to len
.