[][src]Struct lrpar::lex::Lexeme

pub struct Lexeme<StorageT> { /* fields omitted */ }

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).

Methods

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]

Byte offset of the start of the lexeme

pub fn end(&self) -> Option<usize>[src]

Byte offset of the end of the lexeme, or None if this lexeme is the result of error recovery.

pub fn len(&self) -> Option<usize>[src]

Length in bytes of the lexeme, or None if this lexeme is the result of error recovery.

pub fn is_empty(&self) -> bool[src]

Returns true if this lexeme is the result of error recovery, or false otherwise.

Trait Implementations

impl<StorageT: Copy> Copy for Lexeme<StorageT>[src]

impl<StorageT: PartialEq> PartialEq<Lexeme<StorageT>> for Lexeme<StorageT>[src]

impl<StorageT: Clone> Clone for Lexeme<StorageT>[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl<StorageT: Eq> Eq for Lexeme<StorageT>[src]

impl<StorageT: Debug> Debug for Lexeme<StorageT>[src]

impl<StorageT: Hash> Hash for Lexeme<StorageT>[src]

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0
[src]

Feeds a slice of this type into the given [Hasher]. Read more

Auto Trait Implementations

impl<StorageT> Send for Lexeme<StorageT> where
    StorageT: Send

impl<StorageT> Sync for Lexeme<StorageT> where
    StorageT: Sync

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<Q, K> Equivalent for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 

type Err = <U as TryFrom<T>>::Err