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
160impl From<Lua> for &'static str {
161    #[inline]
162    fn from(tok: Lua) -> Self {
163        match tok {
164            Lua::End => "end",
165            Lua::Identifier => "identifier",
166            Lua::HashBangLine => "hash_bang_line",
167            Lua::Return => "return",
168            Lua::SEMI => ";",
169            Lua::EQ => "=",
170            Lua::COMMA => ",",
171            Lua::COLONCOLON => "::",
172            Lua::BreakStatement => "break_statement",
173            Lua::Goto => "goto",
174            Lua::Do => "do",
175            Lua::End2 => "end",
176            Lua::While => "while",
177            Lua::Repeat => "repeat",
178            Lua::Until => "until",
179            Lua::If => "if",
180            Lua::Then => "then",
181            Lua::Elseif => "elseif",
182            Lua::Else => "else",
183            Lua::For => "for",
184            Lua::In => "in",
185            Lua::Function => "function",
186            Lua::Local => "local",
187            Lua::Global => "global",
188            Lua::DOT => ".",
189            Lua::COLON => ":",
190            Lua::STAR => "*",
191            Lua::LT => "<",
192            Lua::GT => ">",
193            Lua::Nil => "nil",
194            Lua::False => "false",
195            Lua::True => "true",
196            Lua::Number => "number",
197            Lua::DQUOTE => "\"",
198            Lua::SQUOTE => "'",
199            Lua::DoublequoteStringContentToken1 => "_doublequote_string_content_token1",
200            Lua::SinglequoteStringContentToken1 => "_singlequote_string_content_token1",
201            Lua::EscapeSequence => "escape_sequence",
202            Lua::VarargExpression => "vararg_expression",
203            Lua::LPAREN => "(",
204            Lua::RPAREN => ")",
205            Lua::LBRACK => "[",
206            Lua::RBRACK => "]",
207            Lua::LBRACE => "{",
208            Lua::RBRACE => "}",
209            Lua::Or => "or",
210            Lua::And => "and",
211            Lua::LTEQ => "<=",
212            Lua::EQEQ => "==",
213            Lua::TILDEEQ => "~=",
214            Lua::GTEQ => ">=",
215            Lua::PIPE => "|",
216            Lua::TILDE => "~",
217            Lua::AMP => "&",
218            Lua::LTLT => "<<",
219            Lua::GTGT => ">>",
220            Lua::PLUS => "+",
221            Lua::DASH => "-",
222            Lua::SLASH => "/",
223            Lua::SLASHSLASH => "//",
224            Lua::PERCENT => "%",
225            Lua::DOTDOT => "..",
226            Lua::CARET => "^",
227            Lua::Not => "not",
228            Lua::HASH => "#",
229            Lua::DASHDASH => "--",
230            Lua::CommentContent => "comment_content",
231            Lua::LBRACKLBRACK => "[[",
232            Lua::CommentContent2 => "comment_content",
233            Lua::RBRACKRBRACK => "]]",
234            Lua::LBRACKLBRACK2 => "[[",
235            Lua::StringContent => "string_content",
236            Lua::RBRACKRBRACK2 => "]]",
237            Lua::Chunk => "chunk",
238            Lua::Block => "block",
239            Lua::Statement => "statement",
240            Lua::ReturnStatement => "return_statement",
241            Lua::EmptyStatement => "empty_statement",
242            Lua::AssignmentStatement => "assignment_statement",
243            Lua::VariableList => "variable_list",
244            Lua::ExpressionList => "expression_list",
245            Lua::LabelStatement => "label_statement",
246            Lua::GotoStatement => "goto_statement",
247            Lua::DoStatement => "do_statement",
248            Lua::WhileStatement => "while_statement",
249            Lua::RepeatStatement => "repeat_statement",
250            Lua::IfStatement => "if_statement",
251            Lua::ElseifStatement => "elseif_statement",
252            Lua::ElseStatement => "else_statement",
253            Lua::ForStatement => "for_statement",
254            Lua::ForGenericClause => "for_generic_clause",
255            Lua::ForNumericClause => "for_numeric_clause",
256            Lua::VariableList2 => "variable_list",
257            Lua::Declaration => "declaration",
258            Lua::FunctionDeclaration => "function_declaration",
259            Lua::FunctionDeclaration2 => "function_declaration",
260            Lua::FunctionDeclaration3 => "function_declaration",
261            Lua::FunctionName => "_function_name",
262            Lua::FunctionNamePrefixExpression => "_function_name_prefix_expression",
263            Lua::DotIndexExpression => "dot_index_expression",
264            Lua::MethodIndexExpression => "method_index_expression",
265            Lua::VariableDeclaration => "variable_declaration",
266            Lua::VariableDeclaration2 => "variable_declaration",
267            Lua::AssignmentStatement2 => "assignment_statement",
268            Lua::VariableList3 => "variable_list",
269            Lua::ImplicitVariableDeclaration => "implicit_variable_declaration",
270            Lua::Attribute => "attribute",
271            Lua::ExpressionList2 => "expression_list",
272            Lua::Expression => "expression",
273            Lua::String => "string",
274            Lua::QuoteString => "_quote_string",
275            Lua::DoublequoteStringContent => "_doublequote_string_content",
276            Lua::SinglequoteStringContent => "_singlequote_string_content",
277            Lua::BlockString => "_block_string",
278            Lua::FunctionDefinition => "function_definition",
279            Lua::FunctionBody => "_function_body",
280            Lua::Parameters => "parameters",
281            Lua::ParameterList => "_parameter_list",
282            Lua::VarargParameter => "_vararg_parameter",
283            Lua::PrefixExpression => "_prefix_expression",
284            Lua::Variable => "variable",
285            Lua::BracketIndexExpression => "bracket_index_expression",
286            Lua::DotIndexExpression2 => "dot_index_expression",
287            Lua::FunctionCall => "function_call",
288            Lua::MethodIndexExpression2 => "method_index_expression",
289            Lua::Arguments => "arguments",
290            Lua::ParenthesizedExpression => "parenthesized_expression",
291            Lua::TableConstructor => "table_constructor",
292            Lua::FieldList => "_field_list",
293            Lua::FieldSep => "_field_sep",
294            Lua::Field => "field",
295            Lua::BinaryExpression => "binary_expression",
296            Lua::UnaryExpression => "unary_expression",
297            Lua::Comment => "comment",
298            Lua::ContextualKeyword => "_contextual_keyword",
299            Lua::ChunkRepeat1 => "chunk_repeat1",
300            Lua::VariableAssignmentVarlistRepeat1 => "_variable_assignment_varlist_repeat1",
301            Lua::VariableAssignmentExplistRepeat1 => "_variable_assignment_explist_repeat1",
302            Lua::IfStatementRepeat1 => "if_statement_repeat1",
303            Lua::NameListRepeat1 => "_name_list_repeat1",
304            Lua::AttNameListRepeat1 => "_att_name_list_repeat1",
305            Lua::ExpressionListRepeat1 => "_expression_list_repeat1",
306            Lua::FieldListRepeat1 => "_field_list_repeat1",
307            Lua::Error => "ERROR",
308        }
309    }
310}
311
312impl From<u16> for Lua {
313    #[inline]
314    fn from(x: u16) -> Self {
315        num_traits::FromPrimitive::from_u16(x).unwrap_or(Self::Error)
316    }
317}
318
319// Lua == u16
320impl PartialEq<u16> for Lua {
321    #[inline]
322    fn eq(&self, x: &u16) -> bool {
323        *self == Into::<Self>::into(*x)
324    }
325}
326
327// u16 == Lua
328impl PartialEq<Lua> for u16 {
329    #[inline]
330    fn eq(&self, x: &Lua) -> bool {
331        *x == *self
332    }
333}