Skip to main content

big_code_analysis_ast/languages/
language_go.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 Go {
14    End = 0,
15    Identifier = 1,
16    SourceFileToken1 = 2,
17    SEMI = 3,
18    Anon4 = 4,
19    Package = 5,
20    Import = 6,
21    DOT = 7,
22    BlankIdentifier = 8,
23    LPAREN = 9,
24    RPAREN = 10,
25    Const = 11,
26    COMMA = 12,
27    EQ = 13,
28    Var = 14,
29    Func = 15,
30    LBRACK = 16,
31    RBRACK = 17,
32    DOTDOTDOT = 18,
33    Type = 19,
34    STAR = 20,
35    Struct = 21,
36    TILDE = 22,
37    LBRACE = 23,
38    RBRACE = 24,
39    Interface = 25,
40    PIPE = 26,
41    Map = 27,
42    Chan = 28,
43    LTDASH = 29,
44    COLONEQ = 30,
45    PLUSPLUS = 31,
46    DASHDASH = 32,
47    STAREQ = 33,
48    SLASHEQ = 34,
49    PERCENTEQ = 35,
50    LTLTEQ = 36,
51    GTGTEQ = 37,
52    AMPEQ = 38,
53    AMPCARETEQ = 39,
54    PLUSEQ = 40,
55    DASHEQ = 41,
56    PIPEEQ = 42,
57    CARETEQ = 43,
58    COLON = 44,
59    Fallthrough = 45,
60    Break = 46,
61    Continue = 47,
62    Goto = 48,
63    Return = 49,
64    Go = 50,
65    Defer = 51,
66    If = 52,
67    Else = 53,
68    For = 54,
69    Range = 55,
70    Switch = 56,
71    Case = 57,
72    Default = 58,
73    Select = 59,
74    Identifier2 = 60,
75    Identifier3 = 61,
76    PLUS = 62,
77    DASH = 63,
78    BANG = 64,
79    CARET = 65,
80    AMP = 66,
81    SLASH = 67,
82    PERCENT = 68,
83    LTLT = 69,
84    GTGT = 70,
85    AMPCARET = 71,
86    EQEQ = 72,
87    BANGEQ = 73,
88    LT = 74,
89    LTEQ = 75,
90    GT = 76,
91    GTEQ = 77,
92    AMPAMP = 78,
93    PIPEPIPE = 79,
94    BQUOTE = 80,
95    RawStringLiteralContent = 81,
96    DQUOTE = 82,
97    InterpretedStringLiteralContent = 83,
98    DQUOTE2 = 84,
99    EscapeSequence = 85,
100    IntLiteral = 86,
101    FloatLiteral = 87,
102    ImaginaryLiteral = 88,
103    RuneLiteral = 89,
104    Nil = 90,
105    True = 91,
106    False = 92,
107    Iota = 93,
108    Comment = 94,
109    SourceFile = 95,
110    PackageClause = 96,
111    ImportDeclaration = 97,
112    ImportSpec = 98,
113    Dot = 99,
114    ImportSpecList = 100,
115    Declaration = 101,
116    ConstDeclaration = 102,
117    ConstSpec = 103,
118    VarDeclaration = 104,
119    VarSpec = 105,
120    VarSpecList = 106,
121    FunctionDeclaration = 107,
122    MethodDeclaration = 108,
123    TypeParameterList = 109,
124    TypeParameterDeclaration = 110,
125    ParameterList = 111,
126    ParameterDeclaration = 112,
127    VariadicParameterDeclaration = 113,
128    TypeAlias = 114,
129    TypeDeclaration = 115,
130    TypeSpec = 116,
131    ExpressionList = 117,
132    ParenthesizedType = 118,
133    SimpleType = 119,
134    GenericType = 120,
135    TypeArguments = 121,
136    PointerType = 122,
137    ArrayType = 123,
138    ImplicitLengthArrayType = 124,
139    SliceType = 125,
140    StructType = 126,
141    NegatedType = 127,
142    FieldDeclarationList = 128,
143    FieldDeclaration = 129,
144    InterfaceType = 130,
145    MethodElem = 131,
146    TypeElem = 132,
147    MapType = 133,
148    ChannelType = 134,
149    FunctionType = 135,
150    Block = 136,
151    StatementList = 137,
152    Statement = 138,
153    EmptyStatement = 139,
154    SimpleStatement = 140,
155    ExpressionStatement = 141,
156    SendStatement = 142,
157    ReceiveStatement = 143,
158    IncStatement = 144,
159    DecStatement = 145,
160    AssignmentStatement = 146,
161    ShortVarDeclaration = 147,
162    LabeledStatement = 148,
163    LabeledStatement2 = 149,
164    FallthroughStatement = 150,
165    BreakStatement = 151,
166    ContinueStatement = 152,
167    GotoStatement = 153,
168    ReturnStatement = 154,
169    GoStatement = 155,
170    DeferStatement = 156,
171    IfStatement = 157,
172    ForStatement = 158,
173    ForClause = 159,
174    RangeClause = 160,
175    ExpressionSwitchStatement = 161,
176    ExpressionCase = 162,
177    DefaultCase = 163,
178    TypeSwitchStatement = 164,
179    TypeSwitchHeader = 165,
180    TypeCase = 166,
181    SelectStatement = 167,
182    CommunicationCase = 168,
183    Expression = 169,
184    ParenthesizedExpression = 170,
185    CallExpression = 171,
186    VariadicArgument = 172,
187    ArgumentList = 173,
188    ArgumentList2 = 174,
189    SelectorExpression = 175,
190    IndexExpression = 176,
191    SliceExpression = 177,
192    TypeAssertionExpression = 178,
193    TypeConversionExpression = 179,
194    TypeInstantiationExpression = 180,
195    CompositeLiteral = 181,
196    LiteralValue = 182,
197    LiteralElement = 183,
198    KeyedElement = 184,
199    FuncLiteral = 185,
200    UnaryExpression = 186,
201    BinaryExpression = 187,
202    QualifiedType = 188,
203    RawStringLiteral = 189,
204    InterpretedStringLiteral = 190,
205    SourceFileRepeat1 = 191,
206    ImportSpecListRepeat1 = 192,
207    ConstDeclarationRepeat1 = 193,
208    ConstSpecRepeat1 = 194,
209    VarSpecRepeat1 = 195,
210    VarSpecListRepeat1 = 196,
211    TypeParameterListRepeat1 = 197,
212    ParameterListRepeat1 = 198,
213    TypeDeclarationRepeat1 = 199,
214    ExpressionListRepeat1 = 200,
215    TypeArgumentsRepeat1 = 201,
216    FieldDeclarationListRepeat1 = 202,
217    FieldDeclarationRepeat1 = 203,
218    InterfaceTypeRepeat1 = 204,
219    TypeElemRepeat1 = 205,
220    StatementListRepeat1 = 206,
221    ExpressionSwitchStatementRepeat1 = 207,
222    TypeSwitchStatementRepeat1 = 208,
223    TypeCaseRepeat1 = 209,
224    SelectStatementRepeat1 = 210,
225    ArgumentListRepeat1 = 211,
226    LiteralValueRepeat1 = 212,
227    InterpretedStringLiteralRepeat1 = 213,
228    FieldIdentifier = 214,
229    LabelName = 215,
230    PackageIdentifier = 216,
231    TypeConstraint = 217,
232    TypeIdentifier = 218,
233    Error = 219,
234}
235
236/// Each runtime kind id of `Go` with tree-sitter's `named` and
237/// `visible` flags, in id order. A label for the id the enum identifies,
238/// read by the role-coverage gate; the generator's ERROR sentinel has no
239/// entry.
240pub const GO_KIND_FLAGS: &[(u16, bool, bool)] = &[
241    (0, false, false),
242    (1, true, true),
243    (2, false, false),
244    (3, false, true),
245    (4, false, true),
246    (5, false, true),
247    (6, false, true),
248    (7, false, true),
249    (8, true, true),
250    (9, false, true),
251    (10, false, true),
252    (11, false, true),
253    (12, false, true),
254    (13, false, true),
255    (14, false, true),
256    (15, false, true),
257    (16, false, true),
258    (17, false, true),
259    (18, false, true),
260    (19, false, true),
261    (20, false, true),
262    (21, false, true),
263    (22, false, true),
264    (23, false, true),
265    (24, false, true),
266    (25, false, true),
267    (26, false, true),
268    (27, false, true),
269    (28, false, true),
270    (29, false, true),
271    (30, false, true),
272    (31, false, true),
273    (32, false, true),
274    (33, false, true),
275    (34, false, true),
276    (35, false, true),
277    (36, false, true),
278    (37, false, true),
279    (38, false, true),
280    (39, false, true),
281    (40, false, true),
282    (41, false, true),
283    (42, false, true),
284    (43, false, true),
285    (44, false, true),
286    (45, false, true),
287    (46, false, true),
288    (47, false, true),
289    (48, false, true),
290    (49, false, true),
291    (50, false, true),
292    (51, false, true),
293    (52, false, true),
294    (53, false, true),
295    (54, false, true),
296    (55, false, true),
297    (56, false, true),
298    (57, false, true),
299    (58, false, true),
300    (59, false, true),
301    (60, true, true),
302    (61, true, true),
303    (62, false, true),
304    (63, false, true),
305    (64, false, true),
306    (65, false, true),
307    (66, false, true),
308    (67, false, true),
309    (68, false, true),
310    (69, false, true),
311    (70, false, true),
312    (71, false, true),
313    (72, false, true),
314    (73, false, true),
315    (74, false, true),
316    (75, false, true),
317    (76, false, true),
318    (77, false, true),
319    (78, false, true),
320    (79, false, true),
321    (80, false, true),
322    (81, true, true),
323    (82, false, true),
324    (83, true, true),
325    (84, false, true),
326    (85, true, true),
327    (86, true, true),
328    (87, true, true),
329    (88, true, true),
330    (89, true, true),
331    (90, true, true),
332    (91, true, true),
333    (92, true, true),
334    (93, true, true),
335    (94, true, true),
336    (95, true, true),
337    (96, true, true),
338    (97, true, true),
339    (98, true, true),
340    (99, true, true),
341    (100, true, true),
342    (101, false, false),
343    (102, true, true),
344    (103, true, true),
345    (104, true, true),
346    (105, true, true),
347    (106, true, true),
348    (107, true, true),
349    (108, true, true),
350    (109, true, true),
351    (110, true, true),
352    (111, true, true),
353    (112, true, true),
354    (113, true, true),
355    (114, true, true),
356    (115, true, true),
357    (116, true, true),
358    (117, true, true),
359    (118, true, true),
360    (119, false, false),
361    (120, true, true),
362    (121, true, true),
363    (122, true, true),
364    (123, true, true),
365    (124, true, true),
366    (125, true, true),
367    (126, true, true),
368    (127, true, true),
369    (128, true, true),
370    (129, true, true),
371    (130, true, true),
372    (131, true, true),
373    (132, true, true),
374    (133, true, true),
375    (134, true, true),
376    (135, true, true),
377    (136, true, true),
378    (137, true, true),
379    (138, false, false),
380    (139, true, true),
381    (140, false, false),
382    (141, true, true),
383    (142, true, true),
384    (143, true, true),
385    (144, true, true),
386    (145, true, true),
387    (146, true, true),
388    (147, true, true),
389    (148, true, true),
390    (149, true, true),
391    (150, true, true),
392    (151, true, true),
393    (152, true, true),
394    (153, true, true),
395    (154, true, true),
396    (155, true, true),
397    (156, true, true),
398    (157, true, true),
399    (158, true, true),
400    (159, true, true),
401    (160, true, true),
402    (161, true, true),
403    (162, true, true),
404    (163, true, true),
405    (164, true, true),
406    (165, false, false),
407    (166, true, true),
408    (167, true, true),
409    (168, true, true),
410    (169, false, false),
411    (170, true, true),
412    (171, true, true),
413    (172, true, true),
414    (173, true, true),
415    (174, true, true),
416    (175, true, true),
417    (176, true, true),
418    (177, true, true),
419    (178, true, true),
420    (179, true, true),
421    (180, true, true),
422    (181, true, true),
423    (182, true, true),
424    (183, true, true),
425    (184, true, true),
426    (185, true, true),
427    (186, true, true),
428    (187, true, true),
429    (188, true, true),
430    (189, true, true),
431    (190, true, true),
432    (191, false, false),
433    (192, false, false),
434    (193, false, false),
435    (194, false, false),
436    (195, false, false),
437    (196, false, false),
438    (197, false, false),
439    (198, false, false),
440    (199, false, false),
441    (200, false, false),
442    (201, false, false),
443    (202, false, false),
444    (203, false, false),
445    (204, false, false),
446    (205, false, false),
447    (206, false, false),
448    (207, false, false),
449    (208, false, false),
450    (209, false, false),
451    (210, false, false),
452    (211, false, false),
453    (212, false, false),
454    (213, false, false),
455    (214, true, true),
456    (215, true, true),
457    (216, true, true),
458    (217, true, true),
459    (218, true, true),
460];
461
462impl From<Go> for &'static str {
463    #[inline]
464    fn from(tok: Go) -> Self {
465        match tok {
466            Go::End => "end",
467            Go::Identifier => "identifier",
468            Go::SourceFileToken1 => "source_file_token1",
469            Go::SEMI => ";",
470            Go::Anon4 => "",
471            Go::Package => "package",
472            Go::Import => "import",
473            Go::DOT => ".",
474            Go::BlankIdentifier => "blank_identifier",
475            Go::LPAREN => "(",
476            Go::RPAREN => ")",
477            Go::Const => "const",
478            Go::COMMA => ",",
479            Go::EQ => "=",
480            Go::Var => "var",
481            Go::Func => "func",
482            Go::LBRACK => "[",
483            Go::RBRACK => "]",
484            Go::DOTDOTDOT => "...",
485            Go::Type => "type",
486            Go::STAR => "*",
487            Go::Struct => "struct",
488            Go::TILDE => "~",
489            Go::LBRACE => "{",
490            Go::RBRACE => "}",
491            Go::Interface => "interface",
492            Go::PIPE => "|",
493            Go::Map => "map",
494            Go::Chan => "chan",
495            Go::LTDASH => "<-",
496            Go::COLONEQ => ":=",
497            Go::PLUSPLUS => "++",
498            Go::DASHDASH => "--",
499            Go::STAREQ => "*=",
500            Go::SLASHEQ => "/=",
501            Go::PERCENTEQ => "%=",
502            Go::LTLTEQ => "<<=",
503            Go::GTGTEQ => ">>=",
504            Go::AMPEQ => "&=",
505            Go::AMPCARETEQ => "&^=",
506            Go::PLUSEQ => "+=",
507            Go::DASHEQ => "-=",
508            Go::PIPEEQ => "|=",
509            Go::CARETEQ => "^=",
510            Go::COLON => ":",
511            Go::Fallthrough => "fallthrough",
512            Go::Break => "break",
513            Go::Continue => "continue",
514            Go::Goto => "goto",
515            Go::Return => "return",
516            Go::Go => "go",
517            Go::Defer => "defer",
518            Go::If => "if",
519            Go::Else => "else",
520            Go::For => "for",
521            Go::Range => "range",
522            Go::Switch => "switch",
523            Go::Case => "case",
524            Go::Default => "default",
525            Go::Select => "select",
526            Go::Identifier2 => "identifier",
527            Go::Identifier3 => "identifier",
528            Go::PLUS => "+",
529            Go::DASH => "-",
530            Go::BANG => "!",
531            Go::CARET => "^",
532            Go::AMP => "&",
533            Go::SLASH => "/",
534            Go::PERCENT => "%",
535            Go::LTLT => "<<",
536            Go::GTGT => ">>",
537            Go::AMPCARET => "&^",
538            Go::EQEQ => "==",
539            Go::BANGEQ => "!=",
540            Go::LT => "<",
541            Go::LTEQ => "<=",
542            Go::GT => ">",
543            Go::GTEQ => ">=",
544            Go::AMPAMP => "&&",
545            Go::PIPEPIPE => "||",
546            Go::BQUOTE => "`",
547            Go::RawStringLiteralContent => "raw_string_literal_content",
548            Go::DQUOTE => "\"",
549            Go::InterpretedStringLiteralContent => "interpreted_string_literal_content",
550            Go::DQUOTE2 => "\"",
551            Go::EscapeSequence => "escape_sequence",
552            Go::IntLiteral => "int_literal",
553            Go::FloatLiteral => "float_literal",
554            Go::ImaginaryLiteral => "imaginary_literal",
555            Go::RuneLiteral => "rune_literal",
556            Go::Nil => "nil",
557            Go::True => "true",
558            Go::False => "false",
559            Go::Iota => "iota",
560            Go::Comment => "comment",
561            Go::SourceFile => "source_file",
562            Go::PackageClause => "package_clause",
563            Go::ImportDeclaration => "import_declaration",
564            Go::ImportSpec => "import_spec",
565            Go::Dot => "dot",
566            Go::ImportSpecList => "import_spec_list",
567            Go::Declaration => "_declaration",
568            Go::ConstDeclaration => "const_declaration",
569            Go::ConstSpec => "const_spec",
570            Go::VarDeclaration => "var_declaration",
571            Go::VarSpec => "var_spec",
572            Go::VarSpecList => "var_spec_list",
573            Go::FunctionDeclaration => "function_declaration",
574            Go::MethodDeclaration => "method_declaration",
575            Go::TypeParameterList => "type_parameter_list",
576            Go::TypeParameterDeclaration => "type_parameter_declaration",
577            Go::ParameterList => "parameter_list",
578            Go::ParameterDeclaration => "parameter_declaration",
579            Go::VariadicParameterDeclaration => "variadic_parameter_declaration",
580            Go::TypeAlias => "type_alias",
581            Go::TypeDeclaration => "type_declaration",
582            Go::TypeSpec => "type_spec",
583            Go::ExpressionList => "expression_list",
584            Go::ParenthesizedType => "parenthesized_type",
585            Go::SimpleType => "_simple_type",
586            Go::GenericType => "generic_type",
587            Go::TypeArguments => "type_arguments",
588            Go::PointerType => "pointer_type",
589            Go::ArrayType => "array_type",
590            Go::ImplicitLengthArrayType => "implicit_length_array_type",
591            Go::SliceType => "slice_type",
592            Go::StructType => "struct_type",
593            Go::NegatedType => "negated_type",
594            Go::FieldDeclarationList => "field_declaration_list",
595            Go::FieldDeclaration => "field_declaration",
596            Go::InterfaceType => "interface_type",
597            Go::MethodElem => "method_elem",
598            Go::TypeElem => "type_elem",
599            Go::MapType => "map_type",
600            Go::ChannelType => "channel_type",
601            Go::FunctionType => "function_type",
602            Go::Block => "block",
603            Go::StatementList => "statement_list",
604            Go::Statement => "_statement",
605            Go::EmptyStatement => "empty_statement",
606            Go::SimpleStatement => "_simple_statement",
607            Go::ExpressionStatement => "expression_statement",
608            Go::SendStatement => "send_statement",
609            Go::ReceiveStatement => "receive_statement",
610            Go::IncStatement => "inc_statement",
611            Go::DecStatement => "dec_statement",
612            Go::AssignmentStatement => "assignment_statement",
613            Go::ShortVarDeclaration => "short_var_declaration",
614            Go::LabeledStatement => "labeled_statement",
615            Go::LabeledStatement2 => "labeled_statement",
616            Go::FallthroughStatement => "fallthrough_statement",
617            Go::BreakStatement => "break_statement",
618            Go::ContinueStatement => "continue_statement",
619            Go::GotoStatement => "goto_statement",
620            Go::ReturnStatement => "return_statement",
621            Go::GoStatement => "go_statement",
622            Go::DeferStatement => "defer_statement",
623            Go::IfStatement => "if_statement",
624            Go::ForStatement => "for_statement",
625            Go::ForClause => "for_clause",
626            Go::RangeClause => "range_clause",
627            Go::ExpressionSwitchStatement => "expression_switch_statement",
628            Go::ExpressionCase => "expression_case",
629            Go::DefaultCase => "default_case",
630            Go::TypeSwitchStatement => "type_switch_statement",
631            Go::TypeSwitchHeader => "_type_switch_header",
632            Go::TypeCase => "type_case",
633            Go::SelectStatement => "select_statement",
634            Go::CommunicationCase => "communication_case",
635            Go::Expression => "_expression",
636            Go::ParenthesizedExpression => "parenthesized_expression",
637            Go::CallExpression => "call_expression",
638            Go::VariadicArgument => "variadic_argument",
639            Go::ArgumentList => "argument_list",
640            Go::ArgumentList2 => "argument_list",
641            Go::SelectorExpression => "selector_expression",
642            Go::IndexExpression => "index_expression",
643            Go::SliceExpression => "slice_expression",
644            Go::TypeAssertionExpression => "type_assertion_expression",
645            Go::TypeConversionExpression => "type_conversion_expression",
646            Go::TypeInstantiationExpression => "type_instantiation_expression",
647            Go::CompositeLiteral => "composite_literal",
648            Go::LiteralValue => "literal_value",
649            Go::LiteralElement => "literal_element",
650            Go::KeyedElement => "keyed_element",
651            Go::FuncLiteral => "func_literal",
652            Go::UnaryExpression => "unary_expression",
653            Go::BinaryExpression => "binary_expression",
654            Go::QualifiedType => "qualified_type",
655            Go::RawStringLiteral => "raw_string_literal",
656            Go::InterpretedStringLiteral => "interpreted_string_literal",
657            Go::SourceFileRepeat1 => "source_file_repeat1",
658            Go::ImportSpecListRepeat1 => "import_spec_list_repeat1",
659            Go::ConstDeclarationRepeat1 => "const_declaration_repeat1",
660            Go::ConstSpecRepeat1 => "const_spec_repeat1",
661            Go::VarSpecRepeat1 => "var_spec_repeat1",
662            Go::VarSpecListRepeat1 => "var_spec_list_repeat1",
663            Go::TypeParameterListRepeat1 => "type_parameter_list_repeat1",
664            Go::ParameterListRepeat1 => "parameter_list_repeat1",
665            Go::TypeDeclarationRepeat1 => "type_declaration_repeat1",
666            Go::ExpressionListRepeat1 => "expression_list_repeat1",
667            Go::TypeArgumentsRepeat1 => "type_arguments_repeat1",
668            Go::FieldDeclarationListRepeat1 => "field_declaration_list_repeat1",
669            Go::FieldDeclarationRepeat1 => "field_declaration_repeat1",
670            Go::InterfaceTypeRepeat1 => "interface_type_repeat1",
671            Go::TypeElemRepeat1 => "type_elem_repeat1",
672            Go::StatementListRepeat1 => "statement_list_repeat1",
673            Go::ExpressionSwitchStatementRepeat1 => "expression_switch_statement_repeat1",
674            Go::TypeSwitchStatementRepeat1 => "type_switch_statement_repeat1",
675            Go::TypeCaseRepeat1 => "type_case_repeat1",
676            Go::SelectStatementRepeat1 => "select_statement_repeat1",
677            Go::ArgumentListRepeat1 => "argument_list_repeat1",
678            Go::LiteralValueRepeat1 => "literal_value_repeat1",
679            Go::InterpretedStringLiteralRepeat1 => "interpreted_string_literal_repeat1",
680            Go::FieldIdentifier => "field_identifier",
681            Go::LabelName => "label_name",
682            Go::PackageIdentifier => "package_identifier",
683            Go::TypeConstraint => "type_constraint",
684            Go::TypeIdentifier => "type_identifier",
685            Go::Error => "ERROR",
686        }
687    }
688}
689
690impl From<u16> for Go {
691    #[inline]
692    fn from(x: u16) -> Self {
693        num_traits::FromPrimitive::from_u16(x).unwrap_or(Self::Error)
694    }
695}
696
697// Go == u16
698impl PartialEq<u16> for Go {
699    #[inline]
700    fn eq(&self, x: &u16) -> bool {
701        *self == Into::<Self>::into(*x)
702    }
703}
704
705// u16 == Go
706impl PartialEq<Go> for u16 {
707    #[inline]
708    fn eq(&self, x: &Go) -> bool {
709        *x == *self
710    }
711}