Skip to main content

big_code_analysis_ast/languages/
language_javascript.rs

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