pub enum TokenKind {
Show 13 variants
BooleanLiteral(bool),
EOF,
Identifier(Box<str>),
Keyword(Keyword),
NullLiteral,
NumericLiteral(Numeric),
Punctuator(Punctuator),
StringLiteral(Box<str>),
TemplateNoSubstitution(TemplateString),
TemplateMiddle(TemplateString),
RegularExpressionLiteral(Box<str>, RegExpFlags),
LineTerminator,
Comment,
}Expand description
Represents the type of Token and the data it has inside.
Variants§
BooleanLiteral(bool)
A boolean literal, which is either true or false.
EOF
The end of the file.
Identifier(Box<str>)
An identifier.
Keyword(Keyword)
A keyword.
see: Keyword
NullLiteral
A null literal.
NumericLiteral(Numeric)
A numeric literal.
Punctuator(Punctuator)
A piece of punctuation
see: Punctuator
StringLiteral(Box<str>)
A string literal.
TemplateNoSubstitution(TemplateString)
A part of a template literal without substitution.
TemplateMiddle(TemplateString)
The part of a template literal between substitutions
RegularExpressionLiteral(Box<str>, RegExpFlags)
A regular expression, consisting of body and flags.
LineTerminator
Indicates the end of a line (\n).
Comment
Indicates a comment, the content isn’t stored.
Implementations§
Source§impl TokenKind
impl TokenKind
Sourcepub fn boolean_literal(lit: bool) -> Self
pub fn boolean_literal(lit: bool) -> Self
Creates a BooleanLiteral token kind.
Sourcepub fn identifier<I>(ident: I) -> Self
pub fn identifier<I>(ident: I) -> Self
Creates an Identifier token type.
Sourcepub fn numeric_literal<L>(lit: L) -> Self
pub fn numeric_literal<L>(lit: L) -> Self
Creates a NumericLiteral token kind.
Sourcepub fn punctuator(punc: Punctuator) -> Self
pub fn punctuator(punc: Punctuator) -> Self
Creates a Punctuator token type.
Sourcepub fn string_literal<S>(lit: S) -> Self
pub fn string_literal<S>(lit: S) -> Self
Creates a StringLiteral token type.
pub fn template_middle(template_string: TemplateString) -> Self
pub fn template_no_substitution(template_string: TemplateString) -> Self
Sourcepub fn regular_expression_literal<B, R>(body: B, flags: R) -> Self
pub fn regular_expression_literal<B, R>(body: B, flags: R) -> Self
Creates a RegularExpressionLiteral token kind.
Sourcepub fn line_terminator() -> Self
pub fn line_terminator() -> Self
Creates a LineTerminator token kind.
Trait Implementations§
Source§impl From<Punctuator> for TokenKind
impl From<Punctuator> for TokenKind
Source§fn from(punc: Punctuator) -> Self
fn from(punc: Punctuator) -> Self
Converts to this type from the input type.
impl StructuralPartialEq for TokenKind
Auto Trait Implementations§
impl Freeze for TokenKind
impl RefUnwindSafe for TokenKind
impl !Send for TokenKind
impl !Sync for TokenKind
impl Unpin for TokenKind
impl UnwindSafe for TokenKind
Blanket Implementations§
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