[−][src]Struct lrpar::Lexeme
A Lexeme
represents a segment of the user's input that conforms to a known type. Note that
even if the type of a lexeme seemingly requires it to have len() > 0
(e.g. integers might
match the regular expressions [0-9]+
), error recovery might cause a lexeme to have a length
of 0. Users can detect the difference between a lexeme with an intentionally zero length from a
lexeme with zero length due to error recovery through the
inserted
method.
Implementations
impl<StorageT: Copy> Lexeme<StorageT>
[src]
pub fn new(tok_id: StorageT, start: usize, len: Option<usize>) -> Self
[src]
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
.
pub fn tok_id(&self) -> StorageT
[src]
The token ID.
pub fn start(&self) -> usize
[src]
Please use span().start() instead
Byte offset of the start of the lexeme
pub fn end(&self) -> usize
[src]
Please use span().end() instead
Byte offset of the end of the lexeme.
Note that if this lexeme was inserted by error recovery, it will end at the same place it
started (i.e. self.start() == self.end()
).
pub fn len(&self) -> usize
[src]
Please use span().len() instead
Length in bytes of the lexeme.
Note that if this lexeme was inserted by error recovery, it will have a length of 0.
pub fn span(&self) -> Span
[src]
Obtain this Lexeme
's Span.
pub fn inserted(&self) -> bool
[src]
Returns true
if this lexeme was inserted as the result of error recovery, or false
otherwise.
Trait Implementations
impl<StorageT: Clone> Clone for Lexeme<StorageT>
[src]
impl<StorageT: Copy> Copy for Lexeme<StorageT>
[src]
impl<StorageT: Debug> Debug for Lexeme<StorageT>
[src]
impl<StorageT: Copy> Display for Lexeme<StorageT>
[src]
impl<StorageT: Eq> Eq for Lexeme<StorageT>
[src]
impl<StorageT: Copy + Debug> Error for Lexeme<StorageT>
[src]
pub fn source(&self) -> Option<&(dyn Error + 'static)>
1.30.0[src]
pub fn backtrace(&self) -> Option<&Backtrace>
[src]
pub fn description(&self) -> &str
1.0.0[src]
pub fn cause(&self) -> Option<&dyn Error>
1.0.0[src]
impl<StorageT: Hash> Hash for Lexeme<StorageT>
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<StorageT: PartialEq> PartialEq<Lexeme<StorageT>> for Lexeme<StorageT>
[src]
fn eq(&self, other: &Lexeme<StorageT>) -> bool
[src]
fn ne(&self, other: &Lexeme<StorageT>) -> bool
[src]
impl<StorageT> StructuralEq for Lexeme<StorageT>
[src]
impl<StorageT> StructuralPartialEq for Lexeme<StorageT>
[src]
Auto Trait Implementations
impl<StorageT> RefUnwindSafe for Lexeme<StorageT> where
StorageT: RefUnwindSafe,
[src]
StorageT: RefUnwindSafe,
impl<StorageT> Send for Lexeme<StorageT> where
StorageT: Send,
[src]
StorageT: Send,
impl<StorageT> Sync for Lexeme<StorageT> where
StorageT: Sync,
[src]
StorageT: Sync,
impl<StorageT> Unpin for Lexeme<StorageT> where
StorageT: Unpin,
[src]
StorageT: Unpin,
impl<StorageT> UnwindSafe for Lexeme<StorageT> where
StorageT: UnwindSafe,
[src]
StorageT: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
[src]
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
pub fn equivalent(&self, key: &K) -> bool
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
U: TryFrom<T>,