#[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
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
impl Token
sourcepub const fn is_literal(&self) -> bool
pub const fn is_literal(&self) -> bool
Is the token a literal symbol?
sourcepub const fn literal_syntax(&self) -> &'static str
pub const fn literal_syntax(&self) -> &'static str
sourcepub const fn is_op_assignment(&self) -> bool
pub const fn is_op_assignment(&self) -> bool
Is this token an op-assignment operator?
sourcepub const fn get_base_op_from_assignment(&self) -> Option<Self>
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.
sourcepub const fn has_op_assignment(&self) -> bool
pub const fn has_op_assignment(&self) -> bool
Has this token a corresponding op-assignment operator?
sourcepub const fn convert_to_op_assignment(&self) -> Option<Self>
pub const fn convert_to_op_assignment(&self) -> Option<Self>
Get the corresponding op-assignment operator of the token.
sourcepub fn lookup_symbol_from_syntax(syntax: &str) -> Option<Self>
pub fn lookup_symbol_from_syntax(syntax: &str) -> Option<Self>
Reverse lookup a symbol token from a piece of syntax.
sourcepub const fn is_next_unary(&self) -> bool
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).
sourcepub const fn precedence(&self) -> Option<NonZeroU8>
pub const fn precedence(&self) -> Option<NonZeroU8>
Get the precedence number of the token.
sourcepub const fn is_bind_right(&self) -> bool
pub const fn is_bind_right(&self) -> bool
Does an expression bind to the right (instead of left)?
sourcepub const fn is_standard_symbol(&self) -> bool
pub const fn is_standard_symbol(&self) -> bool
Is this token a standard symbol used in the language?
sourcepub const fn is_standard_keyword(&self) -> bool
pub const fn is_standard_keyword(&self) -> bool
Is this token a standard keyword?
sourcepub const fn is_reserved(&self) -> bool
pub const fn is_reserved(&self) -> bool
Is this token a reserved keyword or symbol?