pub struct TerminalToken<'t, AT: Default> {
    pub sym: &'t str,
    pub value: AT,
    pub line: usize,
    pub column: usize,
}
Expand description

This the token type required by Rustlr while parsing. A TerminalToken must correspond to a terminal symbol of the grammar being parsed. The sym field of the struct must correspond to the name of the terminal as defined by the grammar and the value must be of type AT, which the is abstract syntax type (valuetype) of the grammar. It also includes the starting line and column positions of the token. These tokens are generated by implementing Tokenizer::nextsym.

This struct is intended to replace Lextoken, and does not use owned strings. Currently this structure lives side-by side with Lextoken for compatibility.

Fields§

§sym: &'t str§value: AT§line: usize§column: usize

Implementations§

source§

impl<'t, AT: Default> TerminalToken<'t, AT>

source

pub fn new(s: &'t str, v: AT, ln: usize, cl: usize) -> TerminalToken<'t, AT>

creates new lexical token with sym s, value v, line ln and column cl

source

pub fn transfer(&self, s: &'t str, v: AT) -> TerminalToken<'t, AT>

transfers lexical information (line/column) to new TerminalToken

source

pub fn from_raw( rt: (RawToken<'t>, usize, usize), s: &'t str, v: AT ) -> TerminalToken<'t, AT>

transfers lexical information from a (RawToken,line,column) triple returned by StrTokenizer::next_token to a new TerminalToken with sym s and value v.

source

pub fn lb<T>(&self, e: T) -> LBox<T>

creates an LBox vale using lexical information contained in the token.

source

pub fn lba<T: 'static>(&self, e: T) -> LBox<dyn Any>

creates a LBox<dyn Any>, which allows attributes of different types to be associated with grammar symbols.

source

pub fn lrc<T>(&self, e: T) -> LRc<T>

similar to crate::ZCParser::lb, but creates a LRc instead of LBox

source

pub fn lrca<T: 'static>(&self, e: T) -> LRc<dyn Any>

similar to crate::ZCParser::lba but creates a LRc

source§

impl<'t, AT: Default + 'static> TerminalToken<'t, AT>

source

pub fn raw_to_lba( rt: (RawToken<'t>, usize, usize), s: &'t str, v: AT ) -> TerminalToken<'t, LBox<dyn Any>>

creates a TerminalToken from a RawToken with value of type LBox<dyn Any>

Auto Trait Implementations§

§

impl<'t, AT> RefUnwindSafe for TerminalToken<'t, AT>
where AT: RefUnwindSafe,

§

impl<'t, AT> Send for TerminalToken<'t, AT>
where AT: Send,

§

impl<'t, AT> Sync for TerminalToken<'t, AT>
where AT: Sync,

§

impl<'t, AT> Unpin for TerminalToken<'t, AT>
where AT: Unpin,

§

impl<'t, AT> UnwindSafe for TerminalToken<'t, AT>
where AT: 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>,

§

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>,

§

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.