Enum rhai::Token

source ·
#[non_exhaustive]
pub enum Token {
Show 91 variants IntegerConstant(INT), FloatConstant(FloatWrapper<FLOAT>), DecimalConstant(Box<Decimal>), Identifier(Box<Identifier>), CharConstant(char), StringConstant(Box<SmartString<LazyCompact>>), InterpolatedString(Box<SmartString<LazyCompact>>), LeftBrace, RightBrace, LeftParen, RightParen, LeftBracket, RightBracket, Unit, Plus, UnaryPlus, Minus, UnaryMinus, Multiply, Divide, Modulo, PowerOf, LeftShift, RightShift, SemiColon, Colon, DoubleColon, DoubleArrow, Underscore, Comma, Period, Elvis, DoubleQuestion, QuestionBracket, ExclusiveRange, InclusiveRange, MapStart, Equals, True, False, Let, Const, If, Else, Switch, Do, While, Until, Loop, For, In, NotIn, LessThan, GreaterThan, LessThanEqualsTo, GreaterThanEqualsTo, EqualsTo, NotEqualsTo, Bang, Pipe, Or, XOr, Ampersand, And, Fn, Continue, Break, Return, Throw, Try, Catch, PlusAssign, MinusAssign, MultiplyAssign, DivideAssign, LeftShiftAssign, RightShiftAssign, AndAssign, OrAssign, XOrAssign, ModuloAssign, PowerOfAssign, Private, Import, Export, As, LexError(Box<LexError>), Comment(Box<String>), Reserved(Box<SmartString<LazyCompact>>), Custom(Box<SmartString<LazyCompact>>), EOF,
}
Expand description

(internals) A Rhai language token. Exported under the internals feature only.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

IntegerConstant(INT)

An INT constant.

§

FloatConstant(FloatWrapper<FLOAT>)

A FLOAT constant.

Reserved under the no_float feature.

§

DecimalConstant(Box<Decimal>)

A Decimal constant.

Requires the decimal feature.

§

Identifier(Box<Identifier>)

An identifier.

§

CharConstant(char)

A character constant.

§

StringConstant(Box<SmartString<LazyCompact>>)

A string constant.

§

InterpolatedString(Box<SmartString<LazyCompact>>)

An interpolated string.

§

LeftBrace

{

§

RightBrace

}

§

LeftParen

(

§

RightParen

)

§

LeftBracket

[

§

RightBracket

]

§

Unit

()

§

Plus

+

§

UnaryPlus

+ (unary)

§

Minus

-

§

UnaryMinus

- (unary)

§

Multiply

*

§

Divide

/

§

Modulo

%

§

PowerOf

**

§

LeftShift

<<

§

RightShift

>>

§

SemiColon

;

§

Colon

:

§

DoubleColon

::

§

DoubleArrow

=>

§

Underscore

_

§

Comma

,

§

Period

.

§

Elvis

?.

Reserved under the no_object feature.

§

DoubleQuestion

??

§

QuestionBracket

?[

Reserved under the no_object feature.

§

ExclusiveRange

..

§

InclusiveRange

..=

§

MapStart

#{

§

Equals

=

§

True

true

§

False

false

§

Let

let

§

Const

const

§

If

if

§

Else

else

§

Switch

switch

§

Do

do

§

While

while

§

Until

until

§

Loop

loop

§

For

for

§

In

in

§

NotIn

!in

§

LessThan

<

§

GreaterThan

>

§

LessThanEqualsTo

<=

§

GreaterThanEqualsTo

>=

§

EqualsTo

==

§

NotEqualsTo

!=

§

Bang

!

§

Pipe

|

§

Or

||

§

XOr

^

§

Ampersand

&

§

And

&&

§

Fn

fn

Reserved under the no_function feature.

§

Continue

continue

§

Break

break

§

Return

return

§

Throw

throw

§

Try

try

§

Catch

catch

§

PlusAssign

+=

§

MinusAssign

-=

§

MultiplyAssign

*=

§

DivideAssign

/=

§

LeftShiftAssign

<<=

§

RightShiftAssign

>>=

§

AndAssign

&=

§

OrAssign

|=

§

XOrAssign

^=

§

ModuloAssign

%=

§

PowerOfAssign

**=

§

Private

private

Reserved under the no_function feature.

§

Import

import

Reserved under the no_module feature.

§

Export

export

Reserved under the no_module feature.

§

As

as

Reserved under the no_module feature.

§

LexError(Box<LexError>)

A lexer error.

§

Comment(Box<String>)

A comment block.

§

Reserved(Box<SmartString<LazyCompact>>)

A reserved symbol.

§

Custom(Box<SmartString<LazyCompact>>)

A custom keyword.

Not available under no_custom_syntax.

§

EOF

End of the input stream. Used as a placeholder for the end of input.

Implementations§

source§

impl Token

source

pub const fn is_literal(&self) -> bool

Is the token a literal symbol?

source

pub const fn literal_syntax(&self) -> &'static str

Get the literal syntax of the token.

Panics

Panics if the token is not a literal symbol.

source

pub const fn is_op_assignment(&self) -> bool

Is this token an op-assignment operator?

source

pub const fn get_base_op_from_assignment(&self) -> Option<Self>

Get the corresponding operator of the token if it is an op-assignment operator.

source

pub const fn has_op_assignment(&self) -> bool

Has this token a corresponding op-assignment operator?

source

pub const fn convert_to_op_assignment(&self) -> Option<Self>

Get the corresponding op-assignment operator of the token.

source

pub fn lookup_symbol_from_syntax(syntax: &str) -> Option<Self>

Reverse lookup a symbol token from a piece of syntax.

source

pub const fn is_next_unary(&self) -> bool

If another operator is after these, it’s probably a unary operator (not sure about fn name).

source

pub const fn precedence(&self) -> Option<NonZeroU8>

Get the precedence number of the token.

source

pub const fn is_bind_right(&self) -> bool

Does an expression bind to the right (instead of left)?

source

pub const fn is_standard_symbol(&self) -> bool

Is this token a standard symbol used in the language?

source

pub const fn is_standard_keyword(&self) -> bool

Is this token a standard keyword?

source

pub const fn is_reserved(&self) -> bool

Is this token a reserved keyword or symbol?

source

pub const fn is_custom(&self) -> bool

Is this token a custom keyword?

Trait Implementations§

source§

impl Clone for Token

source§

fn clone(&self) -> Token

Returns a copy of the value. Read more
1.0.0 · 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 Display for Token

source§

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

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

impl From<Token> for String

source§

fn from(token: Token) -> Self

Converts to this type from the input type.
source§

impl Hash for Token

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq<Token> for Token

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method 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 RefUnwindSafe for Token

§

impl Send for Token

§

impl Sync for Token

§

impl Unpin for Token

§

impl UnwindSafe for Token

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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 Twhere T: Clone,

§

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> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.