#[derive(Debug, PartialEq, Clone, Copy)]
pub enum Token {
EndOfProgram,
Semicolon,
Colon,
Comma,
ParenOpen,
ParenClose,
BracketOpen,
BracketClose,
BraceOpen,
BraceClose,
OperatorFatArrow, OperatorNew, OperatorIncrement, OperatorDecrement, OperatorLogicalNot, OperatorBitwiseNot, OperatorTypeof, OperatorVoid, OperatorDelete, OperatorMultiplication, OperatorDivision, OperatorRemainder, OperatorExponent, OperatorAddition, OperatorSubtraction, OperatorBitShiftLeft, OperatorBitShiftRight, OperatorUBitShiftRight, OperatorLesser, OperatorLesserEquals, OperatorGreater, OperatorGreaterEquals, OperatorInstanceof, OperatorIn, OperatorStrictEquality, OperatorStrictInequality, OperatorEquality, OperatorInequality, OperatorBitwiseAnd, OperatorBitwiseXor, OperatorBitwiseOr, OperatorLogicalAnd, OperatorLogicalOr, OperatorConditional, OperatorAssign, OperatorAddAssign, OperatorSubtractAssign, OperatorExponentAssign, OperatorMultiplyAssign, OperatorDivideAssign, OperatorRemainderAssign, OperatorBSLAssign, OperatorBSRAssign, OperatorUBSRAssign, OperatorBitAndAssign, OperatorBitXorAssign, OperatorBitOrAssign, OperatorSpread, DeclarationVar,
DeclarationLet,
DeclarationConst,
Break,
Do,
Case,
Else,
Catch,
Export,
Class,
Extends,
Return,
While,
Finally,
Super,
With,
Continue,
For,
Switch,
Yield,
Debugger,
Function,
This,
Default,
If,
Throw,
Import,
Try,
Static,
LiteralTrue,
LiteralFalse,
LiteralNull,
LiteralUndefined,
LiteralString,
LiteralNumber,
LiteralBinary,
LiteralRegEx,
ReservedEnum,
ReservedImplements,
ReservedPackage,
ReservedProtected,
ReservedInterface,
ReservedPrivate,
ReservedPublic,
Identifier,
Accessor,
TemplateOpen,
TemplateClosed,
UnexpectedToken,
UnexpectedEndOfProgram,
}
impl Token {
#[inline]
pub fn is_word(&self) -> bool {
use self::Token::*;
match self {
Identifier |
Break |
Do |
Case |
Else |
Catch |
Export |
Class |
Extends |
Return |
While |
Finally |
Super |
With |
Continue |
For |
Switch |
Yield |
Debugger |
Function |
This |
Default |
If |
Throw |
Import |
Try |
Static |
OperatorNew |
OperatorTypeof |
OperatorVoid |
OperatorDelete |
OperatorInstanceof |
LiteralTrue |
LiteralFalse |
LiteralNull |
LiteralUndefined => true,
_ => false,
}
}
}