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 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
236impl From<Go> for &'static str {
237 #[inline]
238 fn from(tok: Go) -> Self {
239 match tok {
240 Go::End => "end",
241 Go::Identifier => "identifier",
242 Go::SourceFileToken1 => "source_file_token1",
243 Go::SEMI => ";",
244 Go::Anon4 => "",
245 Go::Package => "package",
246 Go::Import => "import",
247 Go::DOT => ".",
248 Go::BlankIdentifier => "blank_identifier",
249 Go::LPAREN => "(",
250 Go::RPAREN => ")",
251 Go::Const => "const",
252 Go::COMMA => ",",
253 Go::EQ => "=",
254 Go::Var => "var",
255 Go::Func => "func",
256 Go::LBRACK => "[",
257 Go::RBRACK => "]",
258 Go::DOTDOTDOT => "...",
259 Go::Type => "type",
260 Go::STAR => "*",
261 Go::Struct => "struct",
262 Go::TILDE => "~",
263 Go::LBRACE => "{",
264 Go::RBRACE => "}",
265 Go::Interface => "interface",
266 Go::PIPE => "|",
267 Go::Map => "map",
268 Go::Chan => "chan",
269 Go::LTDASH => "<-",
270 Go::COLONEQ => ":=",
271 Go::PLUSPLUS => "++",
272 Go::DASHDASH => "--",
273 Go::STAREQ => "*=",
274 Go::SLASHEQ => "/=",
275 Go::PERCENTEQ => "%=",
276 Go::LTLTEQ => "<<=",
277 Go::GTGTEQ => ">>=",
278 Go::AMPEQ => "&=",
279 Go::AMPCARETEQ => "&^=",
280 Go::PLUSEQ => "+=",
281 Go::DASHEQ => "-=",
282 Go::PIPEEQ => "|=",
283 Go::CARETEQ => "^=",
284 Go::COLON => ":",
285 Go::Fallthrough => "fallthrough",
286 Go::Break => "break",
287 Go::Continue => "continue",
288 Go::Goto => "goto",
289 Go::Return => "return",
290 Go::Go => "go",
291 Go::Defer => "defer",
292 Go::If => "if",
293 Go::Else => "else",
294 Go::For => "for",
295 Go::Range => "range",
296 Go::Switch => "switch",
297 Go::Case => "case",
298 Go::Default => "default",
299 Go::Select => "select",
300 Go::Identifier2 => "identifier",
301 Go::Identifier3 => "identifier",
302 Go::PLUS => "+",
303 Go::DASH => "-",
304 Go::BANG => "!",
305 Go::CARET => "^",
306 Go::AMP => "&",
307 Go::SLASH => "/",
308 Go::PERCENT => "%",
309 Go::LTLT => "<<",
310 Go::GTGT => ">>",
311 Go::AMPCARET => "&^",
312 Go::EQEQ => "==",
313 Go::BANGEQ => "!=",
314 Go::LT => "<",
315 Go::LTEQ => "<=",
316 Go::GT => ">",
317 Go::GTEQ => ">=",
318 Go::AMPAMP => "&&",
319 Go::PIPEPIPE => "||",
320 Go::BQUOTE => "`",
321 Go::RawStringLiteralContent => "raw_string_literal_content",
322 Go::DQUOTE => "\"",
323 Go::InterpretedStringLiteralContent => "interpreted_string_literal_content",
324 Go::DQUOTE2 => "\"",
325 Go::EscapeSequence => "escape_sequence",
326 Go::IntLiteral => "int_literal",
327 Go::FloatLiteral => "float_literal",
328 Go::ImaginaryLiteral => "imaginary_literal",
329 Go::RuneLiteral => "rune_literal",
330 Go::Nil => "nil",
331 Go::True => "true",
332 Go::False => "false",
333 Go::Iota => "iota",
334 Go::Comment => "comment",
335 Go::SourceFile => "source_file",
336 Go::PackageClause => "package_clause",
337 Go::ImportDeclaration => "import_declaration",
338 Go::ImportSpec => "import_spec",
339 Go::Dot => "dot",
340 Go::ImportSpecList => "import_spec_list",
341 Go::Declaration => "_declaration",
342 Go::ConstDeclaration => "const_declaration",
343 Go::ConstSpec => "const_spec",
344 Go::VarDeclaration => "var_declaration",
345 Go::VarSpec => "var_spec",
346 Go::VarSpecList => "var_spec_list",
347 Go::FunctionDeclaration => "function_declaration",
348 Go::MethodDeclaration => "method_declaration",
349 Go::TypeParameterList => "type_parameter_list",
350 Go::TypeParameterDeclaration => "type_parameter_declaration",
351 Go::ParameterList => "parameter_list",
352 Go::ParameterDeclaration => "parameter_declaration",
353 Go::VariadicParameterDeclaration => "variadic_parameter_declaration",
354 Go::TypeAlias => "type_alias",
355 Go::TypeDeclaration => "type_declaration",
356 Go::TypeSpec => "type_spec",
357 Go::ExpressionList => "expression_list",
358 Go::ParenthesizedType => "parenthesized_type",
359 Go::SimpleType => "_simple_type",
360 Go::GenericType => "generic_type",
361 Go::TypeArguments => "type_arguments",
362 Go::PointerType => "pointer_type",
363 Go::ArrayType => "array_type",
364 Go::ImplicitLengthArrayType => "implicit_length_array_type",
365 Go::SliceType => "slice_type",
366 Go::StructType => "struct_type",
367 Go::NegatedType => "negated_type",
368 Go::FieldDeclarationList => "field_declaration_list",
369 Go::FieldDeclaration => "field_declaration",
370 Go::InterfaceType => "interface_type",
371 Go::MethodElem => "method_elem",
372 Go::TypeElem => "type_elem",
373 Go::MapType => "map_type",
374 Go::ChannelType => "channel_type",
375 Go::FunctionType => "function_type",
376 Go::Block => "block",
377 Go::StatementList => "statement_list",
378 Go::Statement => "_statement",
379 Go::EmptyStatement => "empty_statement",
380 Go::SimpleStatement => "_simple_statement",
381 Go::ExpressionStatement => "expression_statement",
382 Go::SendStatement => "send_statement",
383 Go::ReceiveStatement => "receive_statement",
384 Go::IncStatement => "inc_statement",
385 Go::DecStatement => "dec_statement",
386 Go::AssignmentStatement => "assignment_statement",
387 Go::ShortVarDeclaration => "short_var_declaration",
388 Go::LabeledStatement => "labeled_statement",
389 Go::LabeledStatement2 => "labeled_statement",
390 Go::FallthroughStatement => "fallthrough_statement",
391 Go::BreakStatement => "break_statement",
392 Go::ContinueStatement => "continue_statement",
393 Go::GotoStatement => "goto_statement",
394 Go::ReturnStatement => "return_statement",
395 Go::GoStatement => "go_statement",
396 Go::DeferStatement => "defer_statement",
397 Go::IfStatement => "if_statement",
398 Go::ForStatement => "for_statement",
399 Go::ForClause => "for_clause",
400 Go::RangeClause => "range_clause",
401 Go::ExpressionSwitchStatement => "expression_switch_statement",
402 Go::ExpressionCase => "expression_case",
403 Go::DefaultCase => "default_case",
404 Go::TypeSwitchStatement => "type_switch_statement",
405 Go::TypeSwitchHeader => "_type_switch_header",
406 Go::TypeCase => "type_case",
407 Go::SelectStatement => "select_statement",
408 Go::CommunicationCase => "communication_case",
409 Go::Expression => "_expression",
410 Go::ParenthesizedExpression => "parenthesized_expression",
411 Go::CallExpression => "call_expression",
412 Go::VariadicArgument => "variadic_argument",
413 Go::ArgumentList => "argument_list",
414 Go::ArgumentList2 => "argument_list",
415 Go::SelectorExpression => "selector_expression",
416 Go::IndexExpression => "index_expression",
417 Go::SliceExpression => "slice_expression",
418 Go::TypeAssertionExpression => "type_assertion_expression",
419 Go::TypeConversionExpression => "type_conversion_expression",
420 Go::TypeInstantiationExpression => "type_instantiation_expression",
421 Go::CompositeLiteral => "composite_literal",
422 Go::LiteralValue => "literal_value",
423 Go::LiteralElement => "literal_element",
424 Go::KeyedElement => "keyed_element",
425 Go::FuncLiteral => "func_literal",
426 Go::UnaryExpression => "unary_expression",
427 Go::BinaryExpression => "binary_expression",
428 Go::QualifiedType => "qualified_type",
429 Go::RawStringLiteral => "raw_string_literal",
430 Go::InterpretedStringLiteral => "interpreted_string_literal",
431 Go::SourceFileRepeat1 => "source_file_repeat1",
432 Go::ImportSpecListRepeat1 => "import_spec_list_repeat1",
433 Go::ConstDeclarationRepeat1 => "const_declaration_repeat1",
434 Go::ConstSpecRepeat1 => "const_spec_repeat1",
435 Go::VarSpecRepeat1 => "var_spec_repeat1",
436 Go::VarSpecListRepeat1 => "var_spec_list_repeat1",
437 Go::TypeParameterListRepeat1 => "type_parameter_list_repeat1",
438 Go::ParameterListRepeat1 => "parameter_list_repeat1",
439 Go::TypeDeclarationRepeat1 => "type_declaration_repeat1",
440 Go::ExpressionListRepeat1 => "expression_list_repeat1",
441 Go::TypeArgumentsRepeat1 => "type_arguments_repeat1",
442 Go::FieldDeclarationListRepeat1 => "field_declaration_list_repeat1",
443 Go::FieldDeclarationRepeat1 => "field_declaration_repeat1",
444 Go::InterfaceTypeRepeat1 => "interface_type_repeat1",
445 Go::TypeElemRepeat1 => "type_elem_repeat1",
446 Go::StatementListRepeat1 => "statement_list_repeat1",
447 Go::ExpressionSwitchStatementRepeat1 => "expression_switch_statement_repeat1",
448 Go::TypeSwitchStatementRepeat1 => "type_switch_statement_repeat1",
449 Go::TypeCaseRepeat1 => "type_case_repeat1",
450 Go::SelectStatementRepeat1 => "select_statement_repeat1",
451 Go::ArgumentListRepeat1 => "argument_list_repeat1",
452 Go::LiteralValueRepeat1 => "literal_value_repeat1",
453 Go::InterpretedStringLiteralRepeat1 => "interpreted_string_literal_repeat1",
454 Go::FieldIdentifier => "field_identifier",
455 Go::LabelName => "label_name",
456 Go::PackageIdentifier => "package_identifier",
457 Go::TypeConstraint => "type_constraint",
458 Go::TypeIdentifier => "type_identifier",
459 Go::Error => "ERROR",
460 }
461 }
462}
463
464impl From<u16> for Go {
465 #[inline]
466 fn from(x: u16) -> Self {
467 num_traits::FromPrimitive::from_u16(x).unwrap_or(Self::Error)
468 }
469}
470
471impl PartialEq<u16> for Go {
473 #[inline]
474 fn eq(&self, x: &u16) -> bool {
475 *self == Into::<Self>::into(*x)
476 }
477}
478
479impl PartialEq<Go> for u16 {
481 #[inline]
482 fn eq(&self, x: &Go) -> bool {
483 *x == *self
484 }
485}