Struct lrpar::Lexeme [−][src]
pub struct Lexeme<StorageT> { /* fields omitted */ }
Expand description
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]
impl<StorageT: Copy> Lexeme<StorageT>
[src]pub fn new(tok_id: StorageT, start: usize, len: Option<usize>) -> Self
[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 start(&self) -> usize
[src]
👎 Deprecated since 0.6.1: Please use span().start() instead
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]
👎 Deprecated since 0.6.1: Please use span().end() instead
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()
).
Trait Implementations
impl<StorageT: Copy + Debug> Error for Lexeme<StorageT>
[src]
impl<StorageT: Copy + Debug> Error for Lexeme<StorageT>
[src]fn source(&self) -> Option<&(dyn Error + 'static)>
1.30.0[src]
fn source(&self) -> Option<&(dyn Error + 'static)>
1.30.0[src]The lower-level source of this error, if any. Read more
fn backtrace(&self) -> Option<&Backtrace>
[src]
fn backtrace(&self) -> Option<&Backtrace>
[src]backtrace
)Returns a stack backtrace, if available, of where this error occurred. Read more
fn description(&self) -> &str
1.0.0[src]
fn description(&self) -> &str
1.0.0[src]use the Display impl or to_string()
impl<StorageT: Copy> Copy for Lexeme<StorageT>
[src]
impl<StorageT: Eq> Eq for Lexeme<StorageT>
[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,
StorageT: RefUnwindSafe,
impl<StorageT> Send for Lexeme<StorageT> where
StorageT: Send,
StorageT: Send,
impl<StorageT> Sync for Lexeme<StorageT> where
StorageT: Sync,
StorageT: Sync,
impl<StorageT> Unpin for Lexeme<StorageT> where
StorageT: Unpin,
StorageT: Unpin,
impl<StorageT> UnwindSafe for Lexeme<StorageT> where
StorageT: UnwindSafe,
StorageT: UnwindSafe,
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
[src]
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
[src]pub fn equivalent(&self, key: &K) -> bool
[src]
pub fn equivalent(&self, key: &K) -> bool
[src]Compare self to key
and return true
if they are equal.
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn to_owned(&self) -> T
[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)
[src]
pub fn clone_into(&self, target: &mut T)
[src]🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more