Struct rustlr::lexer_interface::TerminalToken
source · [−]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 (absyntype) 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
sourceimpl<'t, AT: Default> TerminalToken<'t, AT>
impl<'t, AT: Default> TerminalToken<'t, AT>
sourcepub fn new(s: &'t str, v: AT, ln: usize, cl: usize) -> TerminalToken<'t, AT>
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
sourcepub fn transfer(&self, s: &'t str, v: AT) -> TerminalToken<'t, AT>
pub fn transfer(&self, s: &'t str, v: AT) -> TerminalToken<'t, AT>
transfers lexical information (line/column) to new TerminalToken
sourcepub fn from_raw(
rt: (RawToken<'t>, usize, usize),
s: &'t str,
v: AT
) -> TerminalToken<'t, AT>
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.
sourcepub fn lb<T>(&self, e: T) -> LBox<T>
pub fn lb<T>(&self, e: T) -> LBox<T>
creates an LBox vale using lexical information contained in the token.
sourcepub fn lba<T: 'static>(&self, e: T) -> LBox<dyn Any>
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.
sourceimpl<'t, AT: Default + 'static> TerminalToken<'t, AT>
impl<'t, AT: Default + 'static> TerminalToken<'t, AT>
sourcepub fn raw_to_lba(
rt: (RawToken<'t>, usize, usize),
s: &'t str,
v: AT
) -> TerminalToken<'t, LBox<dyn Any>>
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more