pub enum Token {
Show 132 variants
Eof,
Identifier(String),
String(String),
Number(String, NumberSuffix),
RegExp {
body: String,
flags: String,
},
CssNumber {
value: f64,
unit: Option<String>,
},
CssHashWord(String),
CssBeginsWith,
CssEndsWith,
CssContains,
CssListMatch,
CssHreflangMatch,
CssAtNamespace,
CssAtMedia,
CssAtFontFace,
CssAtImport,
CssImportant,
CssSemicolons,
ColonColon,
Attribute,
Descendants,
Ellipsis,
ParenOpen,
ParenClose,
SquareOpen,
SquareClose,
BlockOpen,
BlockClose,
Dot,
Semicolon,
Comma,
Lt,
Gt,
Le,
Ge,
Equals,
NotEquals,
StrictEquals,
StrictNotEquals,
Plus,
Minus,
Times,
Div,
Percent,
Increment,
Decrement,
LeftShift,
RightShift,
UnsignedRightShift,
Ampersand,
Hat,
Pipe,
Tilde,
LogicalAnd,
LogicalXor,
LogicalOr,
Question,
Exclamation,
Colon,
Assign,
AddAssign,
SubtractAssign,
MultiplyAssign,
DivideAssign,
RemainderAssign,
LeftShiftAssign,
RightShiftAssign,
UnsignedRightShiftAssign,
BitwiseAndAssign,
BitwiseXorAssign,
BitwiseOrAssign,
LogicalAndAssign,
LogicalXorAssign,
LogicalOrAssign,
Power,
PowerAssign,
NullCoalescing,
NullCoalescingAssign,
OptionalChaining,
As,
Await,
Break,
Case,
Catch,
Class,
Const,
Continue,
Default,
Delete,
Do,
Else,
Extends,
False,
Finally,
For,
Function,
If,
Implements,
Import,
In,
Instanceof,
Interface,
Internal,
Is,
New,
Not,
Null,
Package,
Private,
Protected,
Public,
Return,
Super,
Switch,
This,
Throw,
True,
Try,
Typeof,
Use,
Var,
Void,
While,
With,
Yield,
XmlWhitespace,
XmlLtSlash,
XmlSlashGt,
XmlText(String),
XmlName(String),
XmlMarkup(String),
XmlAttributeValue(String),
}
Expand description
Represents a lexical token.
Variants§
Eof
Identifier(String)
String(String)
Number(String, NumberSuffix)
Numeric literal token.
The numeric value is in character representation, which may be parsed
through data type specific methods such as NumericLiteral::parse_double()
.
RegExp
CssNumber
CssHashWord(String)
CssBeginsWith
CssEndsWith
CssContains
CssListMatch
CssHreflangMatch
CssAtNamespace
CssAtMedia
CssAtFontFace
CssAtImport
CssImportant
CssSemicolons
ColonColon
Attribute
The @
token.
Descendants
The ..
token.
Ellipsis
The ...
token.
ParenOpen
ParenClose
SquareOpen
SquareClose
BlockOpen
BlockClose
Dot
Semicolon
Comma
Lt
Gt
Le
<=
Ge
>=
Equals
NotEquals
StrictEquals
StrictNotEquals
Plus
Minus
Times
Div
Percent
Increment
Decrement
LeftShift
RightShift
UnsignedRightShift
Ampersand
Hat
Pipe
Tilde
LogicalAnd
LogicalXor
LogicalOr
Question
Exclamation
Colon
Assign
AddAssign
SubtractAssign
MultiplyAssign
DivideAssign
RemainderAssign
LeftShiftAssign
RightShiftAssign
UnsignedRightShiftAssign
BitwiseAndAssign
BitwiseXorAssign
BitwiseOrAssign
LogicalAndAssign
LogicalXorAssign
LogicalOrAssign
Power
**
PowerAssign
**=
NullCoalescing
??
NullCoalescingAssign
??=
OptionalChaining
?.
As
Await
Break
Case
Catch
Class
Const
Continue
Default
Delete
Do
Else
Extends
False
Finally
For
Function
If
Implements
Import
In
Instanceof
Interface
Internal
Is
New
Not
Null
Package
Private
Protected
Public
Return
Super
Switch
This
Throw
True
Try
Typeof
Use
Var
Void
While
With
Yield
XmlWhitespace
XmlLtSlash
XmlSlashGt
XmlText(String)
XmlName(String)
XmlMarkup(String)
XmlAttributeValue(String)
Implementations§
Source§impl Token
impl Token
pub fn is_context_keyword(token: &(Token, Location), keyword: &str) -> bool
Sourcepub fn is_reserved_word(&self) -> bool
pub fn is_reserved_word(&self) -> bool
Indicates whether the token is a reserved word.
pub fn is_identifier_name(&self) -> bool
Sourcepub fn reserved_word_name(&self) -> Option<String>
pub fn reserved_word_name(&self) -> Option<String>
Tests whether the token is a reserved word and returns its IdentifierName string.
Sourcepub fn compound_assignment(&self) -> Option<Operator>
pub fn compound_assignment(&self) -> Option<Operator>
Converts a compound assignment, a logical assignment, or a nullish coalescing assignment to an Operator value.
Sourcepub fn to_binary_operator(&self) -> Option<Operator>
pub fn to_binary_operator(&self) -> Option<Operator>
Converts this token into a binary operator, excluding
not in
, and is not
.
Trait Implementations§
Source§impl ToString for Token
impl ToString for Token
Source§fn to_string(&self) -> String
fn to_string(&self) -> String
Converts the token into a readable string.
The method Token::to_string
returns the following possible values:
"end of program"
"identifier"
"string"
for string literal"number"
for numeric literal"regular expression"
for regular expression literal"'keyword'"
for reserved words"'punctuator'"
for various punctuators"punctuator"
for various punctuators"XML whitespace"
"'</'"
"'/>'"
"XML text"
"XML name"
"XML markup"
"XML attribute value"
impl DiagnosticArgument for Token
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 UnwindSafe for Token
Blanket Implementations§
Source§impl<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere
Scheme: ApproxScheme,
impl<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere
Scheme: ApproxScheme,
Source§fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
Convert the given value into an approximately equivalent representation.
Source§impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Srcwhere
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Srcwhere
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
Source§type Err = <Dst as ApproxFrom<Src, Scheme>>::Err
type Err = <Dst as ApproxFrom<Src, Scheme>>::Err
The error type produced by a failed conversion.
Source§fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
Convert the subject into an approximately equivalent representation.
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, Dst> ConvAsUtil<Dst> for T
impl<T, Dst> ConvAsUtil<Dst> for T
Source§impl<T> ConvUtil for T
impl<T> ConvUtil for T
Source§fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
Approximate the subject to a given type with the default scheme.
Source§fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>
fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>
Approximate the subject to a given type with a specific scheme.