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
sourceimpl 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) -> Selfwhere
I: Into<Box<str>>,
pub fn identifier<I>(ident: I) -> Selfwhere
I: Into<Box<str>>,
Creates an Identifier
token type.
sourcepub fn numeric_literal<L>(lit: L) -> Selfwhere
L: Into<Numeric>,
pub fn numeric_literal<L>(lit: L) -> Selfwhere
L: Into<Numeric>,
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) -> Selfwhere
S: Into<Box<str>>,
pub fn string_literal<S>(lit: S) -> Selfwhere
S: Into<Box<str>>,
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) -> Selfwhere
B: Into<Box<str>>,
R: Into<RegExpFlags>,
pub fn regular_expression_literal<B, R>(body: B, flags: R) -> Selfwhere
B: Into<Box<str>>,
R: Into<RegExpFlags>,
Creates a RegularExpressionLiteral
token kind.
sourcepub fn line_terminator() -> Self
pub fn line_terminator() -> Self
Creates a LineTerminator
token kind.
Trait Implementations
sourceimpl From<Punctuator> for TokenKind
impl From<Punctuator> for TokenKind
sourcefn 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 RefUnwindSafe for TokenKind
impl !Send for TokenKind
impl !Sync for TokenKind
impl Unpin for TokenKind
impl UnwindSafe for TokenKind
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more