1#![allow(clippy::match_same_arms, clippy::too_many_lines)]
4#![allow(missing_docs)]
7
8use num_derive::FromPrimitive;
11
12#[derive(Clone, Debug, PartialEq, Eq, FromPrimitive)]
13pub enum Mozjs {
14 End = 0,
15 Identifier = 1,
16 HashBangLine = 2,
17 Export = 3,
18 STAR = 4,
19 Default = 5,
20 As = 6,
21 LBRACE = 7,
22 COMMA = 8,
23 RBRACE = 9,
24 Import2 = 10,
25 From = 11,
26 With = 12,
27 Var = 13,
28 Let = 14,
29 Const = 15,
30 Using = 16,
31 Await = 17,
32 Of = 18,
33 Else = 19,
34 If = 20,
35 Switch = 21,
36 For = 22,
37 LPAREN = 23,
38 SEMI = 24,
39 RPAREN = 25,
40 In = 26,
41 While = 27,
42 Do = 28,
43 Try = 29,
44 Break = 30,
45 Continue = 31,
46 Debugger = 32,
47 Return = 33,
48 Throw = 34,
49 COLON = 35,
50 Case = 36,
51 Catch = 37,
52 Finally = 38,
53 Yield = 39,
54 EQ = 40,
55 LBRACK = 41,
56 RBRACK = 42,
57 HtmlCharacterReference = 43,
58 LT = 44,
59 GT = 45,
60 Identifier2 = 46,
61 DOT = 47,
62 LTSLASH = 48,
63 SLASHGT = 49,
64 DQUOTE = 50,
65 SQUOTE = 51,
66 StringFragment = 52,
67 StringFragment2 = 53,
68 Class2 = 54,
69 Extends = 55,
70 Async = 56,
71 Function = 57,
72 EQGT = 58,
73 OptionalChain = 59,
74 New = 60,
75 PLUSEQ = 61,
76 DASHEQ = 62,
77 STAREQ = 63,
78 SLASHEQ = 64,
79 PERCENTEQ = 65,
80 CARETEQ = 66,
81 AMPEQ = 67,
82 PIPEEQ = 68,
83 GTGTEQ = 69,
84 GTGTGTEQ = 70,
85 LTLTEQ = 71,
86 STARSTAREQ = 72,
87 AMPAMPEQ = 73,
88 PIPEPIPEEQ = 74,
89 QMARKQMARKEQ = 75,
90 DOTDOTDOT = 76,
91 AMPAMP = 77,
92 PIPEPIPE = 78,
93 GTGT = 79,
94 GTGTGT = 80,
95 LTLT = 81,
96 AMP = 82,
97 CARET = 83,
98 PIPE = 84,
99 PLUS = 85,
100 DASH = 86,
101 SLASH = 87,
102 PERCENT = 88,
103 STARSTAR = 89,
104 LTEQ = 90,
105 EQEQ = 91,
106 EQEQEQ = 92,
107 BANGEQ = 93,
108 BANGEQEQ = 94,
109 GTEQ = 95,
110 QMARKQMARK = 96,
111 Instanceof = 97,
112 BANG = 98,
113 TILDE = 99,
114 Typeof = 100,
115 Void = 101,
116 Delete = 102,
117 PLUSPLUS = 103,
118 DASHDASH = 104,
119 StringFragment3 = 105,
120 StringFragment4 = 106,
121 EscapeSequence = 107,
122 Comment = 108,
123 BQUOTE = 109,
124 DOLLARLBRACE = 110,
125 SLASH2 = 111,
126 RegexPattern = 112,
127 RegexFlags = 113,
128 Number = 114,
129 PrivatePropertyIdentifier = 115,
130 Target = 116,
131 Meta = 117,
132 This = 118,
133 Super = 119,
134 True = 120,
135 False = 121,
136 Null = 122,
137 Undefined = 123,
138 AT = 124,
139 Static = 125,
140 Staticget = 126,
141 Get = 127,
142 Set = 128,
143 Preproc = 129,
144 AutomaticSemicolon = 130,
145 StringFragment5 = 131,
146 QMARK = 132,
147 HtmlComment = 133,
148 JsxText = 134,
149 Program = 135,
150 ExportStatement = 136,
151 NamespaceExport = 137,
152 ExportClause = 138,
153 ExportSpecifier = 139,
154 ModuleExportName = 140,
155 Declaration = 141,
156 Import = 142,
157 ImportStatement = 143,
158 ImportClause = 144,
159 FromClause = 145,
160 NamespaceImport = 146,
161 NamedImports = 147,
162 ImportSpecifier = 148,
163 ImportAttribute = 149,
164 Statement = 150,
165 ExpressionStatement = 151,
166 VariableDeclaration = 152,
167 LexicalDeclaration = 153,
168 UsingDeclaration = 154,
169 VariableDeclarator = 155,
170 StatementBlock = 156,
171 ElseClause = 157,
172 IfStatement = 158,
173 SwitchStatement = 159,
174 ForStatement = 160,
175 ForInStatement = 161,
176 ForHeader = 162,
177 WhileStatement = 163,
178 DoStatement = 164,
179 TryStatement = 165,
180 WithStatement = 166,
181 BreakStatement = 167,
182 ContinueStatement = 168,
183 DebuggerStatement = 169,
184 ReturnStatement = 170,
185 ThrowStatement = 171,
186 EmptyStatement = 172,
187 LabeledStatement = 173,
188 SwitchBody = 174,
189 SwitchCase = 175,
190 SwitchDefault = 176,
191 CatchClause = 177,
192 FinallyClause = 178,
193 ParenthesizedExpression = 179,
194 Expression = 180,
195 PrimaryExpression = 181,
196 YieldExpression = 182,
197 Object = 183,
198 ObjectPattern = 184,
199 AssignmentPattern = 185,
200 ObjectAssignmentPattern = 186,
201 Array = 187,
202 ArrayPattern = 188,
203 JsxElement = 189,
204 JsxExpression = 190,
205 JsxOpeningElement = 191,
206 MemberExpression = 192,
207 JsxNamespaceName = 193,
208 JsxClosingElement = 194,
209 JsxSelfClosingElement = 195,
210 JsxAttribute = 196,
211 String = 197,
212 Class = 198,
213 ClassDeclaration = 199,
214 ClassHeritage = 200,
215 FunctionExpression = 201,
216 FunctionDeclaration = 202,
217 GeneratorFunction = 203,
218 GeneratorFunctionDeclaration = 204,
219 ArrowFunction = 205,
220 CallExpression = 206,
221 NewExpression = 207,
222 AwaitExpression = 208,
223 MemberExpression2 = 209,
224 SubscriptExpression = 210,
225 AssignmentExpression = 211,
226 AugmentedAssignmentLhs = 212,
227 AugmentedAssignmentExpression = 213,
228 Initializer = 214,
229 DestructuringPattern = 215,
230 SpreadElement = 216,
231 TernaryExpression = 217,
232 BinaryExpression = 218,
233 UnaryExpression = 219,
234 UpdateExpression = 220,
235 SequenceExpression = 221,
236 String2 = 222,
237 TemplateString = 223,
238 TemplateSubstitution = 224,
239 Regex = 225,
240 MetaProperty = 226,
241 Arguments = 227,
242 Decorator = 228,
243 MemberExpression3 = 229,
244 CallExpression2 = 230,
245 ClassBody = 231,
246 FieldDefinition = 232,
247 FormalParameters = 233,
248 ClassStaticBlock = 234,
249 Pattern = 235,
250 RestPattern = 236,
251 MethodDefinition = 237,
252 Pair = 238,
253 PairPattern = 239,
254 PropertyName = 240,
255 ComputedPropertyName = 241,
256 ProgramRepeat1 = 242,
257 ExportStatementRepeat1 = 243,
258 ExportClauseRepeat1 = 244,
259 NamedImportsRepeat1 = 245,
260 VariableDeclarationRepeat1 = 246,
261 SwitchBodyRepeat1 = 247,
262 ObjectRepeat1 = 248,
263 ObjectPatternRepeat1 = 249,
264 ArrayRepeat1 = 250,
265 ArrayPatternRepeat1 = 251,
266 JsxElementRepeat1 = 252,
267 JsxOpeningElementRepeat1 = 253,
268 JsxStringRepeat1 = 254,
269 JsxStringRepeat2 = 255,
270 SequenceExpressionRepeat1 = 256,
271 StringRepeat1 = 257,
272 StringRepeat2 = 258,
273 TemplateStringRepeat1 = 259,
274 ClassBodyRepeat1 = 260,
275 FormalParametersRepeat1 = 261,
276 PropertyIdentifier = 262,
277 ShorthandPropertyIdentifier = 263,
278 ShorthandPropertyIdentifierPattern = 264,
279 StatementIdentifier = 265,
280 Error = 266,
281}
282
283impl From<Mozjs> for &'static str {
284 #[inline]
285 fn from(tok: Mozjs) -> Self {
286 match tok {
287 Mozjs::End => "end",
288 Mozjs::Identifier => "identifier",
289 Mozjs::HashBangLine => "hash_bang_line",
290 Mozjs::Export => "export",
291 Mozjs::STAR => "*",
292 Mozjs::Default => "default",
293 Mozjs::As => "as",
294 Mozjs::LBRACE => "{",
295 Mozjs::COMMA => ",",
296 Mozjs::RBRACE => "}",
297 Mozjs::Import2 => "import",
298 Mozjs::From => "from",
299 Mozjs::With => "with",
300 Mozjs::Var => "var",
301 Mozjs::Let => "let",
302 Mozjs::Const => "const",
303 Mozjs::Using => "using",
304 Mozjs::Await => "await",
305 Mozjs::Of => "of",
306 Mozjs::Else => "else",
307 Mozjs::If => "if",
308 Mozjs::Switch => "switch",
309 Mozjs::For => "for",
310 Mozjs::LPAREN => "(",
311 Mozjs::SEMI => ";",
312 Mozjs::RPAREN => ")",
313 Mozjs::In => "in",
314 Mozjs::While => "while",
315 Mozjs::Do => "do",
316 Mozjs::Try => "try",
317 Mozjs::Break => "break",
318 Mozjs::Continue => "continue",
319 Mozjs::Debugger => "debugger",
320 Mozjs::Return => "return",
321 Mozjs::Throw => "throw",
322 Mozjs::COLON => ":",
323 Mozjs::Case => "case",
324 Mozjs::Catch => "catch",
325 Mozjs::Finally => "finally",
326 Mozjs::Yield => "yield",
327 Mozjs::EQ => "=",
328 Mozjs::LBRACK => "[",
329 Mozjs::RBRACK => "]",
330 Mozjs::HtmlCharacterReference => "html_character_reference",
331 Mozjs::LT => "<",
332 Mozjs::GT => ">",
333 Mozjs::Identifier2 => "identifier",
334 Mozjs::DOT => ".",
335 Mozjs::LTSLASH => "</",
336 Mozjs::SLASHGT => "/>",
337 Mozjs::DQUOTE => "\"",
338 Mozjs::SQUOTE => "'",
339 Mozjs::StringFragment => "string_fragment",
340 Mozjs::StringFragment2 => "string_fragment",
341 Mozjs::Class2 => "class",
342 Mozjs::Extends => "extends",
343 Mozjs::Async => "async",
344 Mozjs::Function => "function",
345 Mozjs::EQGT => "=>",
346 Mozjs::OptionalChain => "optional_chain",
347 Mozjs::New => "new",
348 Mozjs::PLUSEQ => "+=",
349 Mozjs::DASHEQ => "-=",
350 Mozjs::STAREQ => "*=",
351 Mozjs::SLASHEQ => "/=",
352 Mozjs::PERCENTEQ => "%=",
353 Mozjs::CARETEQ => "^=",
354 Mozjs::AMPEQ => "&=",
355 Mozjs::PIPEEQ => "|=",
356 Mozjs::GTGTEQ => ">>=",
357 Mozjs::GTGTGTEQ => ">>>=",
358 Mozjs::LTLTEQ => "<<=",
359 Mozjs::STARSTAREQ => "**=",
360 Mozjs::AMPAMPEQ => "&&=",
361 Mozjs::PIPEPIPEEQ => "||=",
362 Mozjs::QMARKQMARKEQ => "??=",
363 Mozjs::DOTDOTDOT => "...",
364 Mozjs::AMPAMP => "&&",
365 Mozjs::PIPEPIPE => "||",
366 Mozjs::GTGT => ">>",
367 Mozjs::GTGTGT => ">>>",
368 Mozjs::LTLT => "<<",
369 Mozjs::AMP => "&",
370 Mozjs::CARET => "^",
371 Mozjs::PIPE => "|",
372 Mozjs::PLUS => "+",
373 Mozjs::DASH => "-",
374 Mozjs::SLASH => "/",
375 Mozjs::PERCENT => "%",
376 Mozjs::STARSTAR => "**",
377 Mozjs::LTEQ => "<=",
378 Mozjs::EQEQ => "==",
379 Mozjs::EQEQEQ => "===",
380 Mozjs::BANGEQ => "!=",
381 Mozjs::BANGEQEQ => "!==",
382 Mozjs::GTEQ => ">=",
383 Mozjs::QMARKQMARK => "??",
384 Mozjs::Instanceof => "instanceof",
385 Mozjs::BANG => "!",
386 Mozjs::TILDE => "~",
387 Mozjs::Typeof => "typeof",
388 Mozjs::Void => "void",
389 Mozjs::Delete => "delete",
390 Mozjs::PLUSPLUS => "++",
391 Mozjs::DASHDASH => "--",
392 Mozjs::StringFragment3 => "string_fragment",
393 Mozjs::StringFragment4 => "string_fragment",
394 Mozjs::EscapeSequence => "escape_sequence",
395 Mozjs::Comment => "comment",
396 Mozjs::BQUOTE => "`",
397 Mozjs::DOLLARLBRACE => "${",
398 Mozjs::SLASH2 => "/",
399 Mozjs::RegexPattern => "regex_pattern",
400 Mozjs::RegexFlags => "regex_flags",
401 Mozjs::Number => "number",
402 Mozjs::PrivatePropertyIdentifier => "private_property_identifier",
403 Mozjs::Target => "target",
404 Mozjs::Meta => "meta",
405 Mozjs::This => "this",
406 Mozjs::Super => "super",
407 Mozjs::True => "true",
408 Mozjs::False => "false",
409 Mozjs::Null => "null",
410 Mozjs::Undefined => "undefined",
411 Mozjs::AT => "@",
412 Mozjs::Static => "static",
413 Mozjs::Staticget => "static get",
414 Mozjs::Get => "get",
415 Mozjs::Set => "set",
416 Mozjs::Preproc => "preproc",
417 Mozjs::AutomaticSemicolon => "_automatic_semicolon",
418 Mozjs::StringFragment5 => "string_fragment",
419 Mozjs::QMARK => "?",
420 Mozjs::HtmlComment => "html_comment",
421 Mozjs::JsxText => "jsx_text",
422 Mozjs::Program => "program",
423 Mozjs::ExportStatement => "export_statement",
424 Mozjs::NamespaceExport => "namespace_export",
425 Mozjs::ExportClause => "export_clause",
426 Mozjs::ExportSpecifier => "export_specifier",
427 Mozjs::ModuleExportName => "_module_export_name",
428 Mozjs::Declaration => "declaration",
429 Mozjs::Import => "import",
430 Mozjs::ImportStatement => "import_statement",
431 Mozjs::ImportClause => "import_clause",
432 Mozjs::FromClause => "_from_clause",
433 Mozjs::NamespaceImport => "namespace_import",
434 Mozjs::NamedImports => "named_imports",
435 Mozjs::ImportSpecifier => "import_specifier",
436 Mozjs::ImportAttribute => "import_attribute",
437 Mozjs::Statement => "statement",
438 Mozjs::ExpressionStatement => "expression_statement",
439 Mozjs::VariableDeclaration => "variable_declaration",
440 Mozjs::LexicalDeclaration => "lexical_declaration",
441 Mozjs::UsingDeclaration => "using_declaration",
442 Mozjs::VariableDeclarator => "variable_declarator",
443 Mozjs::StatementBlock => "statement_block",
444 Mozjs::ElseClause => "else_clause",
445 Mozjs::IfStatement => "if_statement",
446 Mozjs::SwitchStatement => "switch_statement",
447 Mozjs::ForStatement => "for_statement",
448 Mozjs::ForInStatement => "for_in_statement",
449 Mozjs::ForHeader => "_for_header",
450 Mozjs::WhileStatement => "while_statement",
451 Mozjs::DoStatement => "do_statement",
452 Mozjs::TryStatement => "try_statement",
453 Mozjs::WithStatement => "with_statement",
454 Mozjs::BreakStatement => "break_statement",
455 Mozjs::ContinueStatement => "continue_statement",
456 Mozjs::DebuggerStatement => "debugger_statement",
457 Mozjs::ReturnStatement => "return_statement",
458 Mozjs::ThrowStatement => "throw_statement",
459 Mozjs::EmptyStatement => "empty_statement",
460 Mozjs::LabeledStatement => "labeled_statement",
461 Mozjs::SwitchBody => "switch_body",
462 Mozjs::SwitchCase => "switch_case",
463 Mozjs::SwitchDefault => "switch_default",
464 Mozjs::CatchClause => "catch_clause",
465 Mozjs::FinallyClause => "finally_clause",
466 Mozjs::ParenthesizedExpression => "parenthesized_expression",
467 Mozjs::Expression => "expression",
468 Mozjs::PrimaryExpression => "primary_expression",
469 Mozjs::YieldExpression => "yield_expression",
470 Mozjs::Object => "object",
471 Mozjs::ObjectPattern => "object_pattern",
472 Mozjs::AssignmentPattern => "assignment_pattern",
473 Mozjs::ObjectAssignmentPattern => "object_assignment_pattern",
474 Mozjs::Array => "array",
475 Mozjs::ArrayPattern => "array_pattern",
476 Mozjs::JsxElement => "jsx_element",
477 Mozjs::JsxExpression => "jsx_expression",
478 Mozjs::JsxOpeningElement => "jsx_opening_element",
479 Mozjs::MemberExpression => "member_expression",
480 Mozjs::JsxNamespaceName => "jsx_namespace_name",
481 Mozjs::JsxClosingElement => "jsx_closing_element",
482 Mozjs::JsxSelfClosingElement => "jsx_self_closing_element",
483 Mozjs::JsxAttribute => "jsx_attribute",
484 Mozjs::String => "string",
485 Mozjs::Class => "class",
486 Mozjs::ClassDeclaration => "class_declaration",
487 Mozjs::ClassHeritage => "class_heritage",
488 Mozjs::FunctionExpression => "function_expression",
489 Mozjs::FunctionDeclaration => "function_declaration",
490 Mozjs::GeneratorFunction => "generator_function",
491 Mozjs::GeneratorFunctionDeclaration => "generator_function_declaration",
492 Mozjs::ArrowFunction => "arrow_function",
493 Mozjs::CallExpression => "call_expression",
494 Mozjs::NewExpression => "new_expression",
495 Mozjs::AwaitExpression => "await_expression",
496 Mozjs::MemberExpression2 => "member_expression",
497 Mozjs::SubscriptExpression => "subscript_expression",
498 Mozjs::AssignmentExpression => "assignment_expression",
499 Mozjs::AugmentedAssignmentLhs => "_augmented_assignment_lhs",
500 Mozjs::AugmentedAssignmentExpression => "augmented_assignment_expression",
501 Mozjs::Initializer => "_initializer",
502 Mozjs::DestructuringPattern => "_destructuring_pattern",
503 Mozjs::SpreadElement => "spread_element",
504 Mozjs::TernaryExpression => "ternary_expression",
505 Mozjs::BinaryExpression => "binary_expression",
506 Mozjs::UnaryExpression => "unary_expression",
507 Mozjs::UpdateExpression => "update_expression",
508 Mozjs::SequenceExpression => "sequence_expression",
509 Mozjs::String2 => "string",
510 Mozjs::TemplateString => "template_string",
511 Mozjs::TemplateSubstitution => "template_substitution",
512 Mozjs::Regex => "regex",
513 Mozjs::MetaProperty => "meta_property",
514 Mozjs::Arguments => "arguments",
515 Mozjs::Decorator => "decorator",
516 Mozjs::MemberExpression3 => "member_expression",
517 Mozjs::CallExpression2 => "call_expression",
518 Mozjs::ClassBody => "class_body",
519 Mozjs::FieldDefinition => "field_definition",
520 Mozjs::FormalParameters => "formal_parameters",
521 Mozjs::ClassStaticBlock => "class_static_block",
522 Mozjs::Pattern => "pattern",
523 Mozjs::RestPattern => "rest_pattern",
524 Mozjs::MethodDefinition => "method_definition",
525 Mozjs::Pair => "pair",
526 Mozjs::PairPattern => "pair_pattern",
527 Mozjs::PropertyName => "_property_name",
528 Mozjs::ComputedPropertyName => "computed_property_name",
529 Mozjs::ProgramRepeat1 => "program_repeat1",
530 Mozjs::ExportStatementRepeat1 => "export_statement_repeat1",
531 Mozjs::ExportClauseRepeat1 => "export_clause_repeat1",
532 Mozjs::NamedImportsRepeat1 => "named_imports_repeat1",
533 Mozjs::VariableDeclarationRepeat1 => "variable_declaration_repeat1",
534 Mozjs::SwitchBodyRepeat1 => "switch_body_repeat1",
535 Mozjs::ObjectRepeat1 => "object_repeat1",
536 Mozjs::ObjectPatternRepeat1 => "object_pattern_repeat1",
537 Mozjs::ArrayRepeat1 => "array_repeat1",
538 Mozjs::ArrayPatternRepeat1 => "array_pattern_repeat1",
539 Mozjs::JsxElementRepeat1 => "jsx_element_repeat1",
540 Mozjs::JsxOpeningElementRepeat1 => "jsx_opening_element_repeat1",
541 Mozjs::JsxStringRepeat1 => "_jsx_string_repeat1",
542 Mozjs::JsxStringRepeat2 => "_jsx_string_repeat2",
543 Mozjs::SequenceExpressionRepeat1 => "sequence_expression_repeat1",
544 Mozjs::StringRepeat1 => "string_repeat1",
545 Mozjs::StringRepeat2 => "string_repeat2",
546 Mozjs::TemplateStringRepeat1 => "template_string_repeat1",
547 Mozjs::ClassBodyRepeat1 => "class_body_repeat1",
548 Mozjs::FormalParametersRepeat1 => "formal_parameters_repeat1",
549 Mozjs::PropertyIdentifier => "property_identifier",
550 Mozjs::ShorthandPropertyIdentifier => "shorthand_property_identifier",
551 Mozjs::ShorthandPropertyIdentifierPattern => "shorthand_property_identifier_pattern",
552 Mozjs::StatementIdentifier => "statement_identifier",
553 Mozjs::Error => "ERROR",
554 }
555 }
556}
557
558impl From<u16> for Mozjs {
559 #[inline]
560 fn from(x: u16) -> Self {
561 num_traits::FromPrimitive::from_u16(x).unwrap_or(Self::Error)
562 }
563}
564
565impl PartialEq<u16> for Mozjs {
567 #[inline]
568 fn eq(&self, x: &u16) -> bool {
569 *self == Into::<Self>::into(*x)
570 }
571}
572
573impl PartialEq<Mozjs> for u16 {
575 #[inline]
576 fn eq(&self, x: &Mozjs) -> bool {
577 *x == *self
578 }
579}