Skip to main content

Token

Enum Token 

Source
pub enum Token {
Show 65 variants And, Break, Do, Else, Elseif, End, False, For, Function, Global, Goto, If, In, Local, Nil, Not, Or, Repeat, Return, Then, True, Until, While, Plus, Minus, Star, Slash, DSlash, Percent, Caret, Hash, Amp, Tilde, Pipe, Shl, Shr, Eq, Ne, Le, Ge, Lt, Gt, Assign, LParen, RParen, LBrace, RBrace, LBracket, RBracket, DColon, Semi, Colon, Comma, Dot, Concat, Ellipsis, Int(i64), Float(f64), Str(Vec<u8>), Name(Box<str>), At, MacroBraceOpen, MacroBraceClose, MacroQuote(Box<[TokenInfo]>), Eof,
}
Expand description

One lexical token produced by the lexer.

Variants§

§

And

and keyword.

§

Break

break keyword.

§

Do

do keyword.

§

Else

else keyword.

§

Elseif

elseif keyword.

§

End

end keyword.

§

False

false keyword.

§

For

for keyword.

§

Function

function keyword.

§

Global

5.5 global keyword.

§

Goto

goto keyword.

§

If

if keyword.

§

In

in keyword.

§

Local

local keyword.

§

Nil

nil keyword.

§

Not

not keyword.

§

Or

or keyword.

§

Repeat

repeat keyword.

§

Return

return keyword.

§

Then

then keyword.

§

True

true keyword.

§

Until

until keyword.

§

While

while keyword.

§

Plus

+ symbol.

§

Minus

- symbol.

§

Star

* symbol.

§

Slash

/ symbol.

§

DSlash

// symbol (floor division).

§

Percent

% symbol.

§

Caret

^ symbol.

§

Hash

# symbol.

§

Amp

& symbol.

§

Tilde

~ symbol (bitwise xor / unary bnot).

§

Pipe

| symbol.

§

Shl

<< symbol.

§

Shr

>> symbol.

§

Eq

== symbol.

§

Ne

~= symbol.

§

Le

<= symbol.

§

Ge

>= symbol.

§

Lt

< symbol.

§

Gt

> symbol.

§

Assign

= symbol (assignment).

§

LParen

( symbol.

§

RParen

) symbol.

§

LBrace

{ symbol.

§

RBrace

} symbol.

§

LBracket

[ symbol.

§

RBracket

] symbol.

§

DColon

:: symbol (label delimiter).

§

Semi

; symbol.

§

Colon

: symbol.

§

Comma

, symbol.

§

Dot

. symbol.

§

Concat

.. symbol (concatenation).

§

Ellipsis

... symbol (vararg).

§

Int(i64)

Integer literal.

Tuple Fields

§0: i64

Decoded 64-bit signed value.

§

Float(f64)

Floating-point literal.

Tuple Fields

§0: f64

Decoded IEEE-754 double value.

§

Str(Vec<u8>)

String literal (raw bytes; Lua strings are 8-bit clean).

Tuple Fields

§0: Vec<u8>

Decoded byte contents.

§

Name(Box<str>)

Identifier.

Tuple Fields

§0: Box<str>

Source text of the identifier.

§

At

MacroLua @ sigil (v1.3 Phase ML). Lexed only when version.is_macro_lua(); PUC 5.1-5.5 sources continue to error unexpected symbol near '@'.

§

MacroBraceOpen

MacroLua explicit quote-block opener @{. Lexed only when version.is_macro_lua(); pairs with Token::MacroBraceClose.

§

MacroBraceClose

MacroLua explicit quote-block closer }@. Lexed only when version.is_macro_lua(); pairs with Token::MacroBraceOpen.

§

MacroQuote(Box<[TokenInfo]>)

Synthetic token produced by the macro expander pre-pass: a captured token run (the body of a @quote{...} or @{...}@ block). The lexer never emits this. After the expander runs it splices these back into the stream as raw token sequences before the parser proper sees them.

Tuple Fields

§0: Box<[TokenInfo]>

Captured token run.

§

Eof

End-of-file marker.

Implementations§

Source§

impl Token

Source

pub fn describe(&self, src: &[u8], span: Span, version: LuaVersion) -> String

The near-token shown in ... near <tok> error messages. Every concrete token (names, literals, symbols, keywords) is wrapped in single quotes per PUC’s txtToken/luaX_token2str. The pseudo-token <eof> is unquoted under 5.2+ — those suites’ checksyntax has a ^<%a guard that adds quotes only when the expected token doesn’t already start with <. 5.1’s checksyntax has no such guard and unconditionally wraps the expected token, so <eof> must come through quoted there to match the ... near '<eof>' shape (5.1 errors.lua :20-:21 pin this; PUC’s 5.1 luaX_lexerror output is the same).

Trait Implementations§

Source§

impl Clone for Token

Source§

fn clone(&self) -> Token

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Token

Source§

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

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

impl PartialEq for Token

Source§

fn eq(&self, other: &Token) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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 StructuralPartialEq for Token

Auto Trait Implementations§

§

impl Freeze for Token

§

impl RefUnwindSafe for Token

§

impl Send for Token

§

impl Sync for Token

§

impl Unpin for Token

§

impl UnsafeUnpin for Token

§

impl UnwindSafe for Token

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.