pub enum TokenKind {
Eof,
Ident(String),
Keyword(Keyword),
Number(NumberLiteral),
BigInt(BigIntLiteral),
String(String),
RegExp {
pattern: String,
flags: String,
},
Template(TemplateToken),
Punct(Punct),
}Expand description
A lexical token.
Variants§
Eof
End of input.
Ident(String)
Identifier (including context-sensitive words like let/await).
Keyword(Keyword)
Reserved word.
Number(NumberLiteral)
Numeric literal.
BigInt(BigIntLiteral)
BigInt literal.
String(String)
String literal with escapes already decoded.
RegExp
Regular expression literal (needs a re-scan from /).
Fields
Template(TemplateToken)
Template literal chunk.
Punct(Punct)
Punctuator.
Implementations§
Source§impl TokenKind
impl TokenKind
Sourcepub fn describe(&self) -> String
pub fn describe(&self) -> String
A short human readable description, used in parser error messages.
Sourcepub fn as_keyword(&self) -> Option<Keyword>
pub fn as_keyword(&self) -> Option<Keyword>
If this is a keyword, return it.
Sourcepub fn is_identifier(&self) -> bool
pub fn is_identifier(&self) -> bool
Whether the token starts an expression (used to decide / == division
versus regex in error recovery paths).
Trait Implementations§
impl StructuralPartialEq for TokenKind
Auto Trait Implementations§
impl Forget for TokenKind
impl Freeze for TokenKind
impl Move for TokenKind
impl RefUnwindSafe for TokenKind
impl Send for TokenKindwhere
RawVecInner: Send,
impl Sync for TokenKindwhere
RawVecInner: Sync,
impl Unpin for TokenKind
impl UnsafeUnpin for TokenKind
impl UnwindSafe for TokenKindwhere
RawVecInner: UnwindSafe,
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