Struct Lexeme

Source
pub struct Lexeme<LexemeType> {
    pub lexeme_type: LexemeType,
    pub contents: String,
}
Expand description

A lexeme extracted from input text by a lexical analyzers.

Lexemes, also known as “tokens”, are sequences of consecutive characters separated from input text, and classified into categories (such as keywords, identifiers, operators), during the lexical analysis phase of the syntax-parsing pipeline. They represent atomic units of syntactic meaning.

Fields§

§lexeme_type: LexemeType

The type (category) of the lexeme.

§contents: String

The original text that constituted the lexeme.

Implementations§

Source§

impl<LexemeType> Lexeme<LexemeType>

Source

pub fn new(lexeme_type: LexemeType, contents: &str) -> Self

Creates a new Lexeme of the given lexeme_type with the given contents.

Trait Implementations§

Source§

impl<LexemeType: Debug> Debug for Lexeme<LexemeType>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<LexemeType: PartialEq> PartialEq for Lexeme<LexemeType>

Source§

fn eq(&self, other: &Lexeme<LexemeType>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<LexemeType: Eq> Eq for Lexeme<LexemeType>

Source§

impl<LexemeType> StructuralPartialEq for Lexeme<LexemeType>

Auto Trait Implementations§

§

impl<LexemeType> Freeze for Lexeme<LexemeType>
where LexemeType: Freeze,

§

impl<LexemeType> RefUnwindSafe for Lexeme<LexemeType>
where LexemeType: RefUnwindSafe,

§

impl<LexemeType> Send for Lexeme<LexemeType>
where LexemeType: Send,

§

impl<LexemeType> Sync for Lexeme<LexemeType>
where LexemeType: Sync,

§

impl<LexemeType> Unpin for Lexeme<LexemeType>
where LexemeType: Unpin,

§

impl<LexemeType> UnwindSafe for Lexeme<LexemeType>
where LexemeType: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

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

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.