Enum rustlr::lexer_interface::RawToken

source ·
pub enum RawToken<'t> {
Show 16 variants Num(i64), Float(f64), BigNumber(&'t str), Char(char), Strlit(&'t str), Alphanum(&'t str), Symbol(&'t str), Byte(u8), Bytes(&'t [u8]), Newline, Whitespace(usize), Verbatim(&'t str), Custom(&'static str, &'t str), Skipto(&'t str), Skipmatched(&'t str), LexError,
}
Expand description

structure produced by StrTokenizer. TerminalTokens must be created from RawTokens (in the Tokenizer::nextsym function) once the grammar’s terminal symbols and abstract syntax type are known.

Variants§

§

Num(i64)

an unsigned integer, though for convenience it is interpreted as a signed number. Negative numbers must be recognized by higher-level parser. Both decimal and hexadecimal numbers prefixed by 0x are recognized.

§

Float(f64)

floating point number

§

BigNumber(&'t str)

Numbers too large for i64 or f64 are represented verbatim

§

Char(char)

single character inside single quotes.

§

Strlit(&'t str)

String literal, allows for nested quotes. String literals always contain the enclosing double quotes

§

Alphanum(&'t str)

Alphanumeric sequence, staring with an alphabetical character or ‘_’, and followed by arbitrary numbers of alphabetical, numeric or _.

§

Symbol(&'t str)

non-alphanumeric characters, either identified as triples, doubles, singles, or unrecognized sequences (refering to length of symbol)

§

Byte(u8)

a single byte (intended for binary data): this variant is currently not recognized by StrTokenizer

§

Bytes(&'t [u8])

slice of bytes (intended for binary data): this variant is currently not recognized by StrTokenizer

§

Newline

newline, returned optionally

§

Whitespace(usize)

number of consecutive whitespaces, returned optionally

§

Verbatim(&'t str)

usually used to represent comments, if returned optionally

§

Custom(&'static str, &'t str)

Custom token type, allows for user extension. The first string should define the type of the token while the second should carry raw text. This token type is intended to be enabled with lexattribute add_custom directives, which correspond to the function StrTokenizer::add_custom

§

Skipto(&'t str)

special token triggered by StrTokenizer::skip_to, returns skipped text

§

Skipmatched(&'t str)

special token triggered by StrTokenizer::skip_match, returns matched text

§

LexError

tokenizer error

Implementations§

source§

impl<'t> RawToken<'t>

source

pub fn to_staticstr(&self) -> &'static str

Trait Implementations§

source§

impl<'t> Debug for RawToken<'t>

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'t> Freeze for RawToken<'t>

§

impl<'t> RefUnwindSafe for RawToken<'t>

§

impl<'t> Send for RawToken<'t>

§

impl<'t> Sync for RawToken<'t>

§

impl<'t> Unpin for RawToken<'t>

§

impl<'t> UnwindSafe for RawToken<'t>

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.