use num_derive::FromPrimitive;
#[derive(Clone, Debug, PartialEq, Eq, FromPrimitive)]
pub enum Mozjs {
End = 0,
Identifier = 1,
HashBangLine = 2,
Export = 3,
STAR = 4,
Default = 5,
LBRACE = 6,
COMMA = 7,
RBRACE = 8,
As = 9,
Import2 = 10,
From = 11,
Var = 12,
Let = 13,
Const = 14,
Else = 15,
If = 16,
Switch = 17,
For = 18,
LPAREN = 19,
RPAREN = 20,
Await = 21,
In = 22,
Of = 23,
While = 24,
Do = 25,
Try = 26,
With = 27,
Break = 28,
Continue = 29,
Debugger = 30,
Return = 31,
Throw = 32,
SEMI = 33,
COLON = 34,
Case = 35,
Catch = 36,
Finally = 37,
Yield = 38,
EQ = 39,
LBRACK = 40,
RBRACK = 41,
GlimmerTemplateContent = 42,
LTtemplateGT = 43,
LTSLASHtemplateGT = 44,
LT = 45,
GT = 46,
SLASH = 47,
JsxText = 48,
Identifier2 = 49,
DOT = 50,
Class2 = 51,
Extends = 52,
Async = 53,
Function2 = 54,
EQGT = 55,
OptionalChain = 56,
New = 57,
PLUSEQ = 58,
DASHEQ = 59,
STAREQ = 60,
SLASHEQ = 61,
PERCENTEQ = 62,
CARETEQ = 63,
AMPEQ = 64,
PIPEEQ = 65,
GTGTEQ = 66,
GTGTGTEQ = 67,
LTLTEQ = 68,
STARSTAREQ = 69,
AMPAMPEQ = 70,
PIPEPIPEEQ = 71,
QMARKQMARKEQ = 72,
DOTDOTDOT = 73,
AMPAMP = 74,
PIPEPIPE = 75,
GTGT = 76,
GTGTGT = 77,
LTLT = 78,
AMP = 79,
CARET = 80,
PIPE = 81,
PLUS = 82,
DASH = 83,
PERCENT = 84,
STARSTAR = 85,
LTEQ = 86,
EQEQ = 87,
EQEQEQ = 88,
BANGEQ = 89,
BANGEQEQ = 90,
GTEQ = 91,
QMARKQMARK = 92,
Instanceof = 93,
BANG = 94,
TILDE = 95,
Typeof = 96,
Void = 97,
Delete = 98,
PLUSPLUS = 99,
DASHDASH = 100,
DQUOTE = 101,
SQUOTE = 102,
StringFragment = 103,
StringFragment2 = 104,
EscapeSequence = 105,
Comment = 106,
BQUOTE = 107,
DOLLARLBRACE = 108,
SLASH2 = 109,
RegexPattern = 110,
RegexFlags = 111,
Number = 112,
PrivatePropertyIdentifier = 113,
Target = 114,
This = 115,
Super = 116,
True = 117,
False = 118,
Null = 119,
Undefined = 120,
AT = 121,
Static = 122,
Get = 123,
Set = 124,
Preproc = 125,
AutomaticSemicolon = 126,
TemplateChars = 127,
QMARK = 128,
Program = 129,
ExportStatement = 130,
ExportClause = 131,
ExportSpecifier = 132,
Declaration = 133,
Import = 134,
ImportStatement = 135,
ImportClause = 136,
FromClause = 137,
NamespaceImport = 138,
NamedImports = 139,
ExpressionStatement = 140,
VariableDeclaration = 141,
LexicalDeclaration = 142,
VariableDeclarator = 143,
StatementBlock = 144,
ElseClause = 145,
IfStatement = 146,
SwitchStatement = 147,
ForStatement = 148,
ForInStatement = 149,
ForHeader = 150,
WhileStatement = 151,
DoStatement = 152,
TryStatement = 153,
WithStatement = 154,
BreakStatement = 155,
ContinueStatement = 156,
DebuggerStatement = 157,
ReturnStatement = 158,
ThrowStatement = 159,
EmptyStatement = 160,
LabeledStatement = 161,
SwitchBody = 162,
SwitchCase = 163,
SwitchDefault = 164,
CatchClause = 165,
FinallyClause = 166,
ParenthesizedExpression = 167,
Expression = 168,
PrimaryExpression = 169,
YieldExpression = 170,
Object = 171,
ObjectPattern = 172,
AssignmentPattern = 173,
ObjectAssignmentPattern = 174,
Array = 175,
ArrayPattern = 176,
GlimmerTemplate = 177,
GlimmerOpeningTag = 178,
GlimmerClosingTag = 179,
JsxElement = 180,
JsxFragment = 181,
JsxExpression = 182,
JsxOpeningElement = 183,
NestedIdentifier = 184,
JsxNamespaceName = 185,
JsxClosingElement = 186,
JsxSelfClosingElement = 187,
JsxAttribute = 188,
Class = 189,
ClassDeclaration = 190,
ClassHeritage = 191,
Function = 192,
FunctionDeclaration = 193,
GeneratorFunction = 194,
GeneratorFunctionDeclaration = 195,
ArrowFunction = 196,
CallExpression = 197,
NewExpression = 198,
AwaitExpression = 199,
MemberExpression = 200,
SubscriptExpression = 201,
AssignmentExpression = 202,
AugmentedAssignmentLhs = 203,
AugmentedAssignmentExpression = 204,
Initializer = 205,
DestructuringPattern = 206,
SpreadElement = 207,
TernaryExpression = 208,
BinaryExpression = 209,
UnaryExpression = 210,
UpdateExpression = 211,
SequenceExpression = 212,
String = 213,
TemplateString = 214,
TemplateSubstitution = 215,
Regex = 216,
MetaProperty = 217,
Arguments = 218,
Decorator = 219,
MemberExpression2 = 220,
CallExpression2 = 221,
ClassBody = 222,
FieldDefinition = 223,
FormalParameters = 224,
Pattern = 225,
RestPattern = 226,
MethodDefinition = 227,
Pair = 228,
PairPattern = 229,
PropertyName = 230,
ComputedPropertyName = 231,
ProgramRepeat1 = 232,
ExportStatementRepeat1 = 233,
ExportClauseRepeat1 = 234,
NamedImportsRepeat1 = 235,
VariableDeclarationRepeat1 = 236,
SwitchBodyRepeat1 = 237,
ObjectRepeat1 = 238,
ObjectPatternRepeat1 = 239,
ArrayRepeat1 = 240,
ArrayPatternRepeat1 = 241,
GlimmerTemplateRepeat1 = 242,
JsxElementRepeat1 = 243,
JsxOpeningElementRepeat1 = 244,
StringRepeat1 = 245,
StringRepeat2 = 246,
TemplateStringRepeat1 = 247,
ClassBodyRepeat1 = 248,
FormalParametersRepeat1 = 249,
ImportSpecifier = 250,
NamespaceExport = 251,
PropertyIdentifier = 252,
ShorthandPropertyIdentifier = 253,
ShorthandPropertyIdentifierPattern = 254,
StatementIdentifier = 255,
Error = 256,
}
impl From<Mozjs> for &'static str {
#[inline(always)]
fn from(tok: Mozjs) -> Self {
match tok {
Mozjs::End => "end",
Mozjs::Identifier => "identifier",
Mozjs::HashBangLine => "hash_bang_line",
Mozjs::Export => "export",
Mozjs::STAR => "*",
Mozjs::Default => "default",
Mozjs::LBRACE => "{",
Mozjs::COMMA => ",",
Mozjs::RBRACE => "}",
Mozjs::As => "as",
Mozjs::Import2 => "import",
Mozjs::From => "from",
Mozjs::Var => "var",
Mozjs::Let => "let",
Mozjs::Const => "const",
Mozjs::Else => "else",
Mozjs::If => "if",
Mozjs::Switch => "switch",
Mozjs::For => "for",
Mozjs::LPAREN => "(",
Mozjs::RPAREN => ")",
Mozjs::Await => "await",
Mozjs::In => "in",
Mozjs::Of => "of",
Mozjs::While => "while",
Mozjs::Do => "do",
Mozjs::Try => "try",
Mozjs::With => "with",
Mozjs::Break => "break",
Mozjs::Continue => "continue",
Mozjs::Debugger => "debugger",
Mozjs::Return => "return",
Mozjs::Throw => "throw",
Mozjs::SEMI => ";",
Mozjs::COLON => ":",
Mozjs::Case => "case",
Mozjs::Catch => "catch",
Mozjs::Finally => "finally",
Mozjs::Yield => "yield",
Mozjs::EQ => "=",
Mozjs::LBRACK => "[",
Mozjs::RBRACK => "]",
Mozjs::GlimmerTemplateContent => "_glimmer_template_content",
Mozjs::LTtemplateGT => "<template>",
Mozjs::LTSLASHtemplateGT => "</template>",
Mozjs::LT => "<",
Mozjs::GT => ">",
Mozjs::SLASH => "/",
Mozjs::JsxText => "jsx_text",
Mozjs::Identifier2 => "identifier",
Mozjs::DOT => ".",
Mozjs::Class2 => "class",
Mozjs::Extends => "extends",
Mozjs::Async => "async",
Mozjs::Function2 => "function",
Mozjs::EQGT => "=>",
Mozjs::OptionalChain => "optional_chain",
Mozjs::New => "new",
Mozjs::PLUSEQ => "+=",
Mozjs::DASHEQ => "-=",
Mozjs::STAREQ => "*=",
Mozjs::SLASHEQ => "/=",
Mozjs::PERCENTEQ => "%=",
Mozjs::CARETEQ => "^=",
Mozjs::AMPEQ => "&=",
Mozjs::PIPEEQ => "|=",
Mozjs::GTGTEQ => ">>=",
Mozjs::GTGTGTEQ => ">>>=",
Mozjs::LTLTEQ => "<<=",
Mozjs::STARSTAREQ => "**=",
Mozjs::AMPAMPEQ => "&&=",
Mozjs::PIPEPIPEEQ => "||=",
Mozjs::QMARKQMARKEQ => "??=",
Mozjs::DOTDOTDOT => "...",
Mozjs::AMPAMP => "&&",
Mozjs::PIPEPIPE => "||",
Mozjs::GTGT => ">>",
Mozjs::GTGTGT => ">>>",
Mozjs::LTLT => "<<",
Mozjs::AMP => "&",
Mozjs::CARET => "^",
Mozjs::PIPE => "|",
Mozjs::PLUS => "+",
Mozjs::DASH => "-",
Mozjs::PERCENT => "%",
Mozjs::STARSTAR => "**",
Mozjs::LTEQ => "<=",
Mozjs::EQEQ => "==",
Mozjs::EQEQEQ => "===",
Mozjs::BANGEQ => "!=",
Mozjs::BANGEQEQ => "!==",
Mozjs::GTEQ => ">=",
Mozjs::QMARKQMARK => "??",
Mozjs::Instanceof => "instanceof",
Mozjs::BANG => "!",
Mozjs::TILDE => "~",
Mozjs::Typeof => "typeof",
Mozjs::Void => "void",
Mozjs::Delete => "delete",
Mozjs::PLUSPLUS => "++",
Mozjs::DASHDASH => "--",
Mozjs::DQUOTE => "\"",
Mozjs::SQUOTE => "'",
Mozjs::StringFragment => "string_fragment",
Mozjs::StringFragment2 => "string_fragment",
Mozjs::EscapeSequence => "escape_sequence",
Mozjs::Comment => "comment",
Mozjs::BQUOTE => "`",
Mozjs::DOLLARLBRACE => "${",
Mozjs::SLASH2 => "/",
Mozjs::RegexPattern => "regex_pattern",
Mozjs::RegexFlags => "regex_flags",
Mozjs::Number => "number",
Mozjs::PrivatePropertyIdentifier => "private_property_identifier",
Mozjs::Target => "target",
Mozjs::This => "this",
Mozjs::Super => "super",
Mozjs::True => "true",
Mozjs::False => "false",
Mozjs::Null => "null",
Mozjs::Undefined => "undefined",
Mozjs::AT => "@",
Mozjs::Static => "static",
Mozjs::Get => "get",
Mozjs::Set => "set",
Mozjs::Preproc => "preproc",
Mozjs::AutomaticSemicolon => "_automatic_semicolon",
Mozjs::TemplateChars => "_template_chars",
Mozjs::QMARK => "?",
Mozjs::Program => "program",
Mozjs::ExportStatement => "export_statement",
Mozjs::ExportClause => "export_clause",
Mozjs::ExportSpecifier => "export_specifier",
Mozjs::Declaration => "declaration",
Mozjs::Import => "import",
Mozjs::ImportStatement => "import_statement",
Mozjs::ImportClause => "import_clause",
Mozjs::FromClause => "_from_clause",
Mozjs::NamespaceImport => "namespace_import",
Mozjs::NamedImports => "named_imports",
Mozjs::ExpressionStatement => "expression_statement",
Mozjs::VariableDeclaration => "variable_declaration",
Mozjs::LexicalDeclaration => "lexical_declaration",
Mozjs::VariableDeclarator => "variable_declarator",
Mozjs::StatementBlock => "statement_block",
Mozjs::ElseClause => "else_clause",
Mozjs::IfStatement => "if_statement",
Mozjs::SwitchStatement => "switch_statement",
Mozjs::ForStatement => "for_statement",
Mozjs::ForInStatement => "for_in_statement",
Mozjs::ForHeader => "_for_header",
Mozjs::WhileStatement => "while_statement",
Mozjs::DoStatement => "do_statement",
Mozjs::TryStatement => "try_statement",
Mozjs::WithStatement => "with_statement",
Mozjs::BreakStatement => "break_statement",
Mozjs::ContinueStatement => "continue_statement",
Mozjs::DebuggerStatement => "debugger_statement",
Mozjs::ReturnStatement => "return_statement",
Mozjs::ThrowStatement => "throw_statement",
Mozjs::EmptyStatement => "empty_statement",
Mozjs::LabeledStatement => "labeled_statement",
Mozjs::SwitchBody => "switch_body",
Mozjs::SwitchCase => "switch_case",
Mozjs::SwitchDefault => "switch_default",
Mozjs::CatchClause => "catch_clause",
Mozjs::FinallyClause => "finally_clause",
Mozjs::ParenthesizedExpression => "parenthesized_expression",
Mozjs::Expression => "expression",
Mozjs::PrimaryExpression => "primary_expression",
Mozjs::YieldExpression => "yield_expression",
Mozjs::Object => "object",
Mozjs::ObjectPattern => "object_pattern",
Mozjs::AssignmentPattern => "assignment_pattern",
Mozjs::ObjectAssignmentPattern => "object_assignment_pattern",
Mozjs::Array => "array",
Mozjs::ArrayPattern => "array_pattern",
Mozjs::GlimmerTemplate => "glimmer_template",
Mozjs::GlimmerOpeningTag => "glimmer_opening_tag",
Mozjs::GlimmerClosingTag => "glimmer_closing_tag",
Mozjs::JsxElement => "jsx_element",
Mozjs::JsxFragment => "jsx_fragment",
Mozjs::JsxExpression => "jsx_expression",
Mozjs::JsxOpeningElement => "jsx_opening_element",
Mozjs::NestedIdentifier => "nested_identifier",
Mozjs::JsxNamespaceName => "jsx_namespace_name",
Mozjs::JsxClosingElement => "jsx_closing_element",
Mozjs::JsxSelfClosingElement => "jsx_self_closing_element",
Mozjs::JsxAttribute => "jsx_attribute",
Mozjs::Class => "class",
Mozjs::ClassDeclaration => "class_declaration",
Mozjs::ClassHeritage => "class_heritage",
Mozjs::Function => "function",
Mozjs::FunctionDeclaration => "function_declaration",
Mozjs::GeneratorFunction => "generator_function",
Mozjs::GeneratorFunctionDeclaration => "generator_function_declaration",
Mozjs::ArrowFunction => "arrow_function",
Mozjs::CallExpression => "call_expression",
Mozjs::NewExpression => "new_expression",
Mozjs::AwaitExpression => "await_expression",
Mozjs::MemberExpression => "member_expression",
Mozjs::SubscriptExpression => "subscript_expression",
Mozjs::AssignmentExpression => "assignment_expression",
Mozjs::AugmentedAssignmentLhs => "_augmented_assignment_lhs",
Mozjs::AugmentedAssignmentExpression => "augmented_assignment_expression",
Mozjs::Initializer => "_initializer",
Mozjs::DestructuringPattern => "_destructuring_pattern",
Mozjs::SpreadElement => "spread_element",
Mozjs::TernaryExpression => "ternary_expression",
Mozjs::BinaryExpression => "binary_expression",
Mozjs::UnaryExpression => "unary_expression",
Mozjs::UpdateExpression => "update_expression",
Mozjs::SequenceExpression => "sequence_expression",
Mozjs::String => "string",
Mozjs::TemplateString => "template_string",
Mozjs::TemplateSubstitution => "template_substitution",
Mozjs::Regex => "regex",
Mozjs::MetaProperty => "meta_property",
Mozjs::Arguments => "arguments",
Mozjs::Decorator => "decorator",
Mozjs::MemberExpression2 => "member_expression",
Mozjs::CallExpression2 => "call_expression",
Mozjs::ClassBody => "class_body",
Mozjs::FieldDefinition => "field_definition",
Mozjs::FormalParameters => "formal_parameters",
Mozjs::Pattern => "pattern",
Mozjs::RestPattern => "rest_pattern",
Mozjs::MethodDefinition => "method_definition",
Mozjs::Pair => "pair",
Mozjs::PairPattern => "pair_pattern",
Mozjs::PropertyName => "_property_name",
Mozjs::ComputedPropertyName => "computed_property_name",
Mozjs::ProgramRepeat1 => "program_repeat1",
Mozjs::ExportStatementRepeat1 => "export_statement_repeat1",
Mozjs::ExportClauseRepeat1 => "export_clause_repeat1",
Mozjs::NamedImportsRepeat1 => "named_imports_repeat1",
Mozjs::VariableDeclarationRepeat1 => "variable_declaration_repeat1",
Mozjs::SwitchBodyRepeat1 => "switch_body_repeat1",
Mozjs::ObjectRepeat1 => "object_repeat1",
Mozjs::ObjectPatternRepeat1 => "object_pattern_repeat1",
Mozjs::ArrayRepeat1 => "array_repeat1",
Mozjs::ArrayPatternRepeat1 => "array_pattern_repeat1",
Mozjs::GlimmerTemplateRepeat1 => "glimmer_template_repeat1",
Mozjs::JsxElementRepeat1 => "jsx_element_repeat1",
Mozjs::JsxOpeningElementRepeat1 => "jsx_opening_element_repeat1",
Mozjs::StringRepeat1 => "string_repeat1",
Mozjs::StringRepeat2 => "string_repeat2",
Mozjs::TemplateStringRepeat1 => "template_string_repeat1",
Mozjs::ClassBodyRepeat1 => "class_body_repeat1",
Mozjs::FormalParametersRepeat1 => "formal_parameters_repeat1",
Mozjs::ImportSpecifier => "import_specifier",
Mozjs::NamespaceExport => "namespace_export",
Mozjs::PropertyIdentifier => "property_identifier",
Mozjs::ShorthandPropertyIdentifier => "shorthand_property_identifier",
Mozjs::ShorthandPropertyIdentifierPattern => "shorthand_property_identifier_pattern",
Mozjs::StatementIdentifier => "statement_identifier",
Mozjs::Error => "ERROR",
}
}
}
impl From<u16> for Mozjs {
#[inline(always)]
fn from(x: u16) -> Self {
num::FromPrimitive::from_u16(x).unwrap_or(Self::Error)
}
}
impl PartialEq<u16> for Mozjs {
#[inline(always)]
fn eq(&self, x: &u16) -> bool {
*self == Mozjs::from(*x)
}
}
impl PartialEq<Mozjs> for u16 {
#[inline(always)]
fn eq(&self, x: &Mozjs) -> bool {
*x == *self
}
}