Skip to main content

big_code_analysis_ast/languages/
language_lua.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 Lua {
14    End = 0,
15    Identifier = 1,
16    HashBangLine = 2,
17    Return = 3,
18    SEMI = 4,
19    EQ = 5,
20    COMMA = 6,
21    COLONCOLON = 7,
22    BreakStatement = 8,
23    Goto = 9,
24    Do = 10,
25    End2 = 11,
26    While = 12,
27    Repeat = 13,
28    Until = 14,
29    If = 15,
30    Then = 16,
31    Elseif = 17,
32    Else = 18,
33    For = 19,
34    In = 20,
35    Function = 21,
36    Local = 22,
37    Global = 23,
38    DOT = 24,
39    COLON = 25,
40    STAR = 26,
41    LT = 27,
42    GT = 28,
43    Nil = 29,
44    False = 30,
45    True = 31,
46    Number = 32,
47    DQUOTE = 33,
48    SQUOTE = 34,
49    DoublequoteStringContentToken1 = 35,
50    SinglequoteStringContentToken1 = 36,
51    EscapeSequence = 37,
52    VarargExpression = 38,
53    LPAREN = 39,
54    RPAREN = 40,
55    LBRACK = 41,
56    RBRACK = 42,
57    LBRACE = 43,
58    RBRACE = 44,
59    Or = 45,
60    And = 46,
61    LTEQ = 47,
62    EQEQ = 48,
63    TILDEEQ = 49,
64    GTEQ = 50,
65    PIPE = 51,
66    TILDE = 52,
67    AMP = 53,
68    LTLT = 54,
69    GTGT = 55,
70    PLUS = 56,
71    DASH = 57,
72    SLASH = 58,
73    SLASHSLASH = 59,
74    PERCENT = 60,
75    DOTDOT = 61,
76    CARET = 62,
77    Not = 63,
78    HASH = 64,
79    DASHDASH = 65,
80    CommentContent = 66,
81    LBRACKLBRACK = 67,
82    CommentContent2 = 68,
83    RBRACKRBRACK = 69,
84    LBRACKLBRACK2 = 70,
85    StringContent = 71,
86    RBRACKRBRACK2 = 72,
87    Chunk = 73,
88    Block = 74,
89    Statement = 75,
90    ReturnStatement = 76,
91    EmptyStatement = 77,
92    AssignmentStatement = 78,
93    VariableList = 79,
94    ExpressionList = 80,
95    LabelStatement = 81,
96    GotoStatement = 82,
97    DoStatement = 83,
98    WhileStatement = 84,
99    RepeatStatement = 85,
100    IfStatement = 86,
101    ElseifStatement = 87,
102    ElseStatement = 88,
103    ForStatement = 89,
104    ForGenericClause = 90,
105    ForNumericClause = 91,
106    VariableList2 = 92,
107    Declaration = 93,
108    FunctionDeclaration = 94,
109    FunctionDeclaration2 = 95,
110    FunctionDeclaration3 = 96,
111    FunctionName = 97,
112    FunctionNamePrefixExpression = 98,
113    DotIndexExpression = 99,
114    MethodIndexExpression = 100,
115    VariableDeclaration = 101,
116    VariableDeclaration2 = 102,
117    AssignmentStatement2 = 103,
118    VariableList3 = 104,
119    ImplicitVariableDeclaration = 105,
120    Attribute = 106,
121    ExpressionList2 = 107,
122    Expression = 108,
123    String = 109,
124    QuoteString = 110,
125    DoublequoteStringContent = 111,
126    SinglequoteStringContent = 112,
127    BlockString = 113,
128    FunctionDefinition = 114,
129    FunctionBody = 115,
130    Parameters = 116,
131    ParameterList = 117,
132    VarargParameter = 118,
133    PrefixExpression = 119,
134    Variable = 120,
135    BracketIndexExpression = 121,
136    DotIndexExpression2 = 122,
137    FunctionCall = 123,
138    MethodIndexExpression2 = 124,
139    Arguments = 125,
140    ParenthesizedExpression = 126,
141    TableConstructor = 127,
142    FieldList = 128,
143    FieldSep = 129,
144    Field = 130,
145    BinaryExpression = 131,
146    UnaryExpression = 132,
147    Comment = 133,
148    ContextualKeyword = 134,
149    ChunkRepeat1 = 135,
150    VariableAssignmentVarlistRepeat1 = 136,
151    VariableAssignmentExplistRepeat1 = 137,
152    IfStatementRepeat1 = 138,
153    NameListRepeat1 = 139,
154    AttNameListRepeat1 = 140,
155    ExpressionListRepeat1 = 141,
156    FieldListRepeat1 = 142,
157    Error = 143,
158}
159
160/// Each runtime kind id of `Lua` with tree-sitter's `named` and
161/// `visible` flags, in id order. A label for the id the enum identifies,
162/// read by the role-coverage gate; the generator's ERROR sentinel has no
163/// entry.
164pub const LUA_KIND_FLAGS: &[(u16, bool, bool)] = &[
165    (0, false, false),
166    (1, true, true),
167    (2, true, true),
168    (3, false, true),
169    (4, false, true),
170    (5, false, true),
171    (6, false, true),
172    (7, false, true),
173    (8, true, true),
174    (9, false, true),
175    (10, false, true),
176    (11, false, true),
177    (12, false, true),
178    (13, false, true),
179    (14, false, true),
180    (15, false, true),
181    (16, false, true),
182    (17, false, true),
183    (18, false, true),
184    (19, false, true),
185    (20, false, true),
186    (21, false, true),
187    (22, false, true),
188    (23, false, true),
189    (24, false, true),
190    (25, false, true),
191    (26, false, true),
192    (27, false, true),
193    (28, false, true),
194    (29, true, true),
195    (30, true, true),
196    (31, true, true),
197    (32, true, true),
198    (33, false, true),
199    (34, false, true),
200    (35, false, false),
201    (36, false, false),
202    (37, true, true),
203    (38, true, true),
204    (39, false, true),
205    (40, false, true),
206    (41, false, true),
207    (42, false, true),
208    (43, false, true),
209    (44, false, true),
210    (45, false, true),
211    (46, false, true),
212    (47, false, true),
213    (48, false, true),
214    (49, false, true),
215    (50, false, true),
216    (51, false, true),
217    (52, false, true),
218    (53, false, true),
219    (54, false, true),
220    (55, false, true),
221    (56, false, true),
222    (57, false, true),
223    (58, false, true),
224    (59, false, true),
225    (60, false, true),
226    (61, false, true),
227    (62, false, true),
228    (63, false, true),
229    (64, false, true),
230    (65, false, true),
231    (66, true, true),
232    (67, false, true),
233    (68, true, true),
234    (69, false, true),
235    (70, false, true),
236    (71, true, true),
237    (72, false, true),
238    (73, true, true),
239    (74, true, true),
240    (75, false, false),
241    (76, true, true),
242    (77, true, true),
243    (78, true, true),
244    (79, true, true),
245    (80, true, true),
246    (81, true, true),
247    (82, true, true),
248    (83, true, true),
249    (84, true, true),
250    (85, true, true),
251    (86, true, true),
252    (87, true, true),
253    (88, true, true),
254    (89, true, true),
255    (90, true, true),
256    (91, true, true),
257    (92, true, true),
258    (93, false, false),
259    (94, true, true),
260    (95, true, true),
261    (96, true, true),
262    (97, false, false),
263    (98, false, false),
264    (99, true, true),
265    (100, true, true),
266    (101, true, true),
267    (102, true, true),
268    (103, true, true),
269    (104, true, true),
270    (105, true, true),
271    (106, true, true),
272    (107, true, true),
273    (108, false, false),
274    (109, true, true),
275    (110, false, false),
276    (111, false, false),
277    (112, false, false),
278    (113, false, false),
279    (114, true, true),
280    (115, false, false),
281    (116, true, true),
282    (117, false, false),
283    (118, false, false),
284    (119, false, false),
285    (120, false, false),
286    (121, true, true),
287    (122, true, true),
288    (123, true, true),
289    (124, true, true),
290    (125, true, true),
291    (126, true, true),
292    (127, true, true),
293    (128, false, false),
294    (129, false, false),
295    (130, true, true),
296    (131, true, true),
297    (132, true, true),
298    (133, true, true),
299    (134, false, false),
300    (135, false, false),
301    (136, false, false),
302    (137, false, false),
303    (138, false, false),
304    (139, false, false),
305    (140, false, false),
306    (141, false, false),
307    (142, false, false),
308];
309
310impl From<Lua> for &'static str {
311    #[inline]
312    fn from(tok: Lua) -> Self {
313        match tok {
314            Lua::End => "end",
315            Lua::Identifier => "identifier",
316            Lua::HashBangLine => "hash_bang_line",
317            Lua::Return => "return",
318            Lua::SEMI => ";",
319            Lua::EQ => "=",
320            Lua::COMMA => ",",
321            Lua::COLONCOLON => "::",
322            Lua::BreakStatement => "break_statement",
323            Lua::Goto => "goto",
324            Lua::Do => "do",
325            Lua::End2 => "end",
326            Lua::While => "while",
327            Lua::Repeat => "repeat",
328            Lua::Until => "until",
329            Lua::If => "if",
330            Lua::Then => "then",
331            Lua::Elseif => "elseif",
332            Lua::Else => "else",
333            Lua::For => "for",
334            Lua::In => "in",
335            Lua::Function => "function",
336            Lua::Local => "local",
337            Lua::Global => "global",
338            Lua::DOT => ".",
339            Lua::COLON => ":",
340            Lua::STAR => "*",
341            Lua::LT => "<",
342            Lua::GT => ">",
343            Lua::Nil => "nil",
344            Lua::False => "false",
345            Lua::True => "true",
346            Lua::Number => "number",
347            Lua::DQUOTE => "\"",
348            Lua::SQUOTE => "'",
349            Lua::DoublequoteStringContentToken1 => "_doublequote_string_content_token1",
350            Lua::SinglequoteStringContentToken1 => "_singlequote_string_content_token1",
351            Lua::EscapeSequence => "escape_sequence",
352            Lua::VarargExpression => "vararg_expression",
353            Lua::LPAREN => "(",
354            Lua::RPAREN => ")",
355            Lua::LBRACK => "[",
356            Lua::RBRACK => "]",
357            Lua::LBRACE => "{",
358            Lua::RBRACE => "}",
359            Lua::Or => "or",
360            Lua::And => "and",
361            Lua::LTEQ => "<=",
362            Lua::EQEQ => "==",
363            Lua::TILDEEQ => "~=",
364            Lua::GTEQ => ">=",
365            Lua::PIPE => "|",
366            Lua::TILDE => "~",
367            Lua::AMP => "&",
368            Lua::LTLT => "<<",
369            Lua::GTGT => ">>",
370            Lua::PLUS => "+",
371            Lua::DASH => "-",
372            Lua::SLASH => "/",
373            Lua::SLASHSLASH => "//",
374            Lua::PERCENT => "%",
375            Lua::DOTDOT => "..",
376            Lua::CARET => "^",
377            Lua::Not => "not",
378            Lua::HASH => "#",
379            Lua::DASHDASH => "--",
380            Lua::CommentContent => "comment_content",
381            Lua::LBRACKLBRACK => "[[",
382            Lua::CommentContent2 => "comment_content",
383            Lua::RBRACKRBRACK => "]]",
384            Lua::LBRACKLBRACK2 => "[[",
385            Lua::StringContent => "string_content",
386            Lua::RBRACKRBRACK2 => "]]",
387            Lua::Chunk => "chunk",
388            Lua::Block => "block",
389            Lua::Statement => "statement",
390            Lua::ReturnStatement => "return_statement",
391            Lua::EmptyStatement => "empty_statement",
392            Lua::AssignmentStatement => "assignment_statement",
393            Lua::VariableList => "variable_list",
394            Lua::ExpressionList => "expression_list",
395            Lua::LabelStatement => "label_statement",
396            Lua::GotoStatement => "goto_statement",
397            Lua::DoStatement => "do_statement",
398            Lua::WhileStatement => "while_statement",
399            Lua::RepeatStatement => "repeat_statement",
400            Lua::IfStatement => "if_statement",
401            Lua::ElseifStatement => "elseif_statement",
402            Lua::ElseStatement => "else_statement",
403            Lua::ForStatement => "for_statement",
404            Lua::ForGenericClause => "for_generic_clause",
405            Lua::ForNumericClause => "for_numeric_clause",
406            Lua::VariableList2 => "variable_list",
407            Lua::Declaration => "declaration",
408            Lua::FunctionDeclaration => "function_declaration",
409            Lua::FunctionDeclaration2 => "function_declaration",
410            Lua::FunctionDeclaration3 => "function_declaration",
411            Lua::FunctionName => "_function_name",
412            Lua::FunctionNamePrefixExpression => "_function_name_prefix_expression",
413            Lua::DotIndexExpression => "dot_index_expression",
414            Lua::MethodIndexExpression => "method_index_expression",
415            Lua::VariableDeclaration => "variable_declaration",
416            Lua::VariableDeclaration2 => "variable_declaration",
417            Lua::AssignmentStatement2 => "assignment_statement",
418            Lua::VariableList3 => "variable_list",
419            Lua::ImplicitVariableDeclaration => "implicit_variable_declaration",
420            Lua::Attribute => "attribute",
421            Lua::ExpressionList2 => "expression_list",
422            Lua::Expression => "expression",
423            Lua::String => "string",
424            Lua::QuoteString => "_quote_string",
425            Lua::DoublequoteStringContent => "_doublequote_string_content",
426            Lua::SinglequoteStringContent => "_singlequote_string_content",
427            Lua::BlockString => "_block_string",
428            Lua::FunctionDefinition => "function_definition",
429            Lua::FunctionBody => "_function_body",
430            Lua::Parameters => "parameters",
431            Lua::ParameterList => "_parameter_list",
432            Lua::VarargParameter => "_vararg_parameter",
433            Lua::PrefixExpression => "_prefix_expression",
434            Lua::Variable => "variable",
435            Lua::BracketIndexExpression => "bracket_index_expression",
436            Lua::DotIndexExpression2 => "dot_index_expression",
437            Lua::FunctionCall => "function_call",
438            Lua::MethodIndexExpression2 => "method_index_expression",
439            Lua::Arguments => "arguments",
440            Lua::ParenthesizedExpression => "parenthesized_expression",
441            Lua::TableConstructor => "table_constructor",
442            Lua::FieldList => "_field_list",
443            Lua::FieldSep => "_field_sep",
444            Lua::Field => "field",
445            Lua::BinaryExpression => "binary_expression",
446            Lua::UnaryExpression => "unary_expression",
447            Lua::Comment => "comment",
448            Lua::ContextualKeyword => "_contextual_keyword",
449            Lua::ChunkRepeat1 => "chunk_repeat1",
450            Lua::VariableAssignmentVarlistRepeat1 => "_variable_assignment_varlist_repeat1",
451            Lua::VariableAssignmentExplistRepeat1 => "_variable_assignment_explist_repeat1",
452            Lua::IfStatementRepeat1 => "if_statement_repeat1",
453            Lua::NameListRepeat1 => "_name_list_repeat1",
454            Lua::AttNameListRepeat1 => "_att_name_list_repeat1",
455            Lua::ExpressionListRepeat1 => "_expression_list_repeat1",
456            Lua::FieldListRepeat1 => "_field_list_repeat1",
457            Lua::Error => "ERROR",
458        }
459    }
460}
461
462impl From<u16> for Lua {
463    #[inline]
464    fn from(x: u16) -> Self {
465        num_traits::FromPrimitive::from_u16(x).unwrap_or(Self::Error)
466    }
467}
468
469// Lua == u16
470impl PartialEq<u16> for Lua {
471    #[inline]
472    fn eq(&self, x: &u16) -> bool {
473        *self == Into::<Self>::into(*x)
474    }
475}
476
477// u16 == Lua
478impl PartialEq<Lua> for u16 {
479    #[inline]
480    fn eq(&self, x: &Lua) -> bool {
481        *x == *self
482    }
483}