Skip to main content

big_code_analysis_ast/languages/
language_bash.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 Bash {
14    End = 0,
15    Word = 1,
16    For = 2,
17    Select = 3,
18    In = 4,
19    LPARENLPAREN = 5,
20    RPARENRPAREN = 6,
21    SEMI = 7,
22    COMMA = 8,
23    EQ = 9,
24    PLUSPLUS = 10,
25    DASHDASH = 11,
26    PLUSEQ = 12,
27    DASHEQ = 13,
28    STAREQ = 14,
29    SLASHEQ = 15,
30    PERCENTEQ = 16,
31    STARSTAREQ = 17,
32    LTLTEQ = 18,
33    GTGTEQ = 19,
34    AMPEQ = 20,
35    CARETEQ = 21,
36    PIPEEQ = 22,
37    PIPEPIPE = 23,
38    DASHo = 24,
39    AMPAMP = 25,
40    DASHa = 26,
41    PIPE = 27,
42    CARET = 28,
43    AMP = 29,
44    EQEQ = 30,
45    BANGEQ = 31,
46    LT = 32,
47    GT = 33,
48    LTEQ = 34,
49    GTEQ = 35,
50    LTLT = 36,
51    GTGT = 37,
52    PLUS = 38,
53    DASH = 39,
54    STAR = 40,
55    SLASH = 41,
56    PERCENT = 42,
57    STARSTAR = 43,
58    LPAREN = 44,
59    RPAREN = 45,
60    Word2 = 46,
61    While = 47,
62    Until = 48,
63    Do = 49,
64    Done = 50,
65    If = 51,
66    Then = 52,
67    Fi = 53,
68    Elif = 54,
69    Else = 55,
70    Case = 56,
71    Esac = 57,
72    SEMISEMI = 58,
73    SEMIAMP = 59,
74    SEMISEMIAMP = 60,
75    Function = 61,
76    LBRACE = 62,
77    RBRACE = 63,
78    PIPEAMP = 64,
79    BANG = 65,
80    LBRACK = 66,
81    RBRACK = 67,
82    LBRACKLBRACK = 68,
83    RBRACKRBRACK = 69,
84    Declare = 70,
85    Typeset = 71,
86    Export = 72,
87    Readonly = 73,
88    Local = 74,
89    Unset = 75,
90    Unsetenv = 76,
91    EQTILDE = 77,
92    AMPGT = 78,
93    AMPGTGT = 79,
94    LTAMP = 80,
95    GTAMP = 81,
96    GTPIPE = 82,
97    LTAMPDASH = 83,
98    GTAMPDASH = 84,
99    LTLTDASH = 85,
100    HeredocRedirectToken1 = 86,
101    LTLTLT = 87,
102    QMARK = 88,
103    COLON = 89,
104    PLUSPLUS2 = 90,
105    DASHDASH2 = 91,
106    DASH2 = 92,
107    PLUS2 = 93,
108    TILDE = 94,
109    DOLLARLPARENLPAREN = 95,
110    DOLLARLBRACK = 96,
111    Number = 97,
112    DOTDOT = 98,
113    RBRACE2 = 99,
114    BQUOTEBQUOTE = 100,
115    DOLLAR = 101,
116    SpecialCharacter = 102,
117    DQUOTE = 103,
118    StringContent = 104,
119    RawString = 105,
120    AnsiCString = 106,
121    NumberToken1 = 107,
122    NumberToken2 = 108,
123    HASH = 109,
124    DOLLARLBRACE = 110,
125    RBRACE3 = 111,
126    BANG2 = 112,
127    AT = 113,
128    STAR2 = 114,
129    HASH2 = 115,
130    EQ2 = 116,
131    COLONEQ = 117,
132    DASH3 = 118,
133    COLONDASH = 119,
134    PLUS3 = 120,
135    COLONPLUS = 121,
136    QMARK2 = 122,
137    COLONQMARK = 123,
138    PERCENTPERCENT = 124,
139    Regex = 125,
140    SLASHSLASH = 126,
141    SLASHHASH = 127,
142    SLASHPERCENT = 128,
143    COMMACOMMA = 129,
144    CARETCARET = 130,
145    U = 131,
146    U2 = 132,
147    L = 133,
148    Q = 134,
149    E = 135,
150    P = 136,
151    A = 137,
152    K = 138,
153    A2 = 139,
154    K2 = 140,
155    DOLLARLPAREN = 141,
156    BQUOTE = 142,
157    DOLLARBQUOTE = 143,
158    LTLPAREN = 144,
159    GTLPAREN = 145,
160    Comment = 146,
161    Word3 = 147,
162    VariableName = 148,
163    VariableName2 = 149,
164    SpecialVariableName = 150,
165    SpecialVariableName2 = 151,
166    HeredocStart = 152,
167    HeredocBody = 153,
168    HeredocBodyBeginning = 154,
169    HeredocContent = 155,
170    HeredocEnd = 156,
171    FileDescriptor = 157,
172    EmptyValue = 158,
173    Concat = 159,
174    VariableName3 = 160,
175    TestOperator = 161,
176    Regex2 = 162,
177    Regex3 = 163,
178    Regex4 = 164,
179    Word4 = 165,
180    ExtglobPattern = 166,
181    DOLLAR2 = 167,
182    LBRACE2 = 168,
183    HASHHASH = 169,
184    HASH3 = 170,
185    BANG3 = 171,
186    EQ3 = 172,
187    ErrorRecovery = 173,
188    Program = 174,
189    Statements = 175,
190    TerminatedStatement = 176,
191    StatementNotPipeline = 177,
192    RedirectedStatement = 178,
193    ForStatement = 179,
194    CStyleForStatement = 180,
195    ForBody = 181,
196    CExpression = 182,
197    CExpressionNotAssignment = 183,
198    VariableAssignment = 184,
199    UnaryExpression = 185,
200    BinaryExpression = 186,
201    PostfixExpression = 187,
202    ParenthesizedExpression = 188,
203    WhileStatement = 189,
204    DoGroup = 190,
205    IfStatement = 191,
206    ElifClause = 192,
207    ElseClause = 193,
208    CaseStatement = 194,
209    CaseItem = 195,
210    CaseItem2 = 196,
211    FunctionDefinition = 197,
212    CompoundStatement = 198,
213    Subshell = 199,
214    Pipeline = 200,
215    List = 201,
216    NegatedCommand = 202,
217    TestCommand = 203,
218    BinaryExpression2 = 204,
219    DeclarationCommand = 205,
220    UnsetCommand = 206,
221    Command = 207,
222    CommandName = 208,
223    VariableAssignment2 = 209,
224    VariableAssignments = 210,
225    Subscript = 211,
226    FileRedirect = 212,
227    HeredocRedirect = 213,
228    Pipeline2 = 214,
229    HeredocExpression = 215,
230    HeredocCommand = 216,
231    HeredocBody3 = 217,
232    HeredocBody2 = 218,
233    SimpleHeredocBody = 219,
234    HerestringRedirect = 220,
235    Expression = 221,
236    BinaryExpression3 = 222,
237    TernaryExpression = 223,
238    UnaryExpression2 = 224,
239    PostfixExpression2 = 225,
240    ParenthesizedExpression2 = 226,
241    ArithmeticExpansion = 227,
242    BraceExpression = 228,
243    ArithmeticExpression = 229,
244    ArithmeticLiteral = 230,
245    BinaryExpression4 = 231,
246    TernaryExpression2 = 232,
247    UnaryExpression3 = 233,
248    PostfixExpression3 = 234,
249    ParenthesizedExpression3 = 235,
250    Concatenation = 236,
251    String = 237,
252    TranslatedString = 238,
253    Array = 239,
254    Number2 = 240,
255    SimpleExpansion = 241,
256    Expansion = 242,
257    ExpansionBody = 243,
258    ExpansionExpression = 244,
259    ExpansionRegex = 245,
260    ExpansionRegexReplacement = 246,
261    ExpansionRegexRemoval = 247,
262    ExpansionMaxLength = 248,
263    ExpansionMaxLengthExpression = 249,
264    BinaryExpression5 = 250,
265    ExpansionOperator = 251,
266    Concatenation2 = 252,
267    CommandSubstitution = 253,
268    ProcessSubstitution = 254,
269    ExtglobBlob = 255,
270    CTerminator = 256,
271    StatementsRepeat1 = 257,
272    RedirectedStatementRepeat1 = 258,
273    RedirectedStatementRepeat2 = 259,
274    ForStatementRepeat1 = 260,
275    ForBodyRepeat1 = 261,
276    IfStatementRepeat1 = 262,
277    CaseStatementRepeat1 = 263,
278    CaseItemRepeat1 = 264,
279    CompoundStatementRepeat1 = 265,
280    PipelineRepeat1 = 266,
281    DeclarationCommandRepeat1 = 267,
282    UnsetCommandRepeat1 = 268,
283    CommandRepeat1 = 269,
284    CommandRepeat2 = 270,
285    VariableAssignmentsRepeat1 = 271,
286    HeredocBodyRepeat1 = 272,
287    LiteralRepeat1 = 273,
288    ArithmeticExpansionRepeat1 = 274,
289    ConcatenationRepeat1 = 275,
290    StringRepeat1 = 276,
291    ExpansionBodyRepeat1 = 277,
292    ExpansionRegexRepeat1 = 278,
293    ConcatenationInExpansionRepeat1 = 279,
294    Error = 280,
295}
296
297impl From<Bash> for &'static str {
298    #[inline]
299    fn from(tok: Bash) -> Self {
300        match tok {
301            Bash::End => "end",
302            Bash::Word => "word",
303            Bash::For => "for",
304            Bash::Select => "select",
305            Bash::In => "in",
306            Bash::LPARENLPAREN => "((",
307            Bash::RPARENRPAREN => "))",
308            Bash::SEMI => ";",
309            Bash::COMMA => ",",
310            Bash::EQ => "=",
311            Bash::PLUSPLUS => "++",
312            Bash::DASHDASH => "--",
313            Bash::PLUSEQ => "+=",
314            Bash::DASHEQ => "-=",
315            Bash::STAREQ => "*=",
316            Bash::SLASHEQ => "/=",
317            Bash::PERCENTEQ => "%=",
318            Bash::STARSTAREQ => "**=",
319            Bash::LTLTEQ => "<<=",
320            Bash::GTGTEQ => ">>=",
321            Bash::AMPEQ => "&=",
322            Bash::CARETEQ => "^=",
323            Bash::PIPEEQ => "|=",
324            Bash::PIPEPIPE => "||",
325            Bash::DASHo => "-o",
326            Bash::AMPAMP => "&&",
327            Bash::DASHa => "-a",
328            Bash::PIPE => "|",
329            Bash::CARET => "^",
330            Bash::AMP => "&",
331            Bash::EQEQ => "==",
332            Bash::BANGEQ => "!=",
333            Bash::LT => "<",
334            Bash::GT => ">",
335            Bash::LTEQ => "<=",
336            Bash::GTEQ => ">=",
337            Bash::LTLT => "<<",
338            Bash::GTGT => ">>",
339            Bash::PLUS => "+",
340            Bash::DASH => "-",
341            Bash::STAR => "*",
342            Bash::SLASH => "/",
343            Bash::PERCENT => "%",
344            Bash::STARSTAR => "**",
345            Bash::LPAREN => "(",
346            Bash::RPAREN => ")",
347            Bash::Word2 => "word",
348            Bash::While => "while",
349            Bash::Until => "until",
350            Bash::Do => "do",
351            Bash::Done => "done",
352            Bash::If => "if",
353            Bash::Then => "then",
354            Bash::Fi => "fi",
355            Bash::Elif => "elif",
356            Bash::Else => "else",
357            Bash::Case => "case",
358            Bash::Esac => "esac",
359            Bash::SEMISEMI => ";;",
360            Bash::SEMIAMP => ";&",
361            Bash::SEMISEMIAMP => ";;&",
362            Bash::Function => "function",
363            Bash::LBRACE => "{",
364            Bash::RBRACE => "}",
365            Bash::PIPEAMP => "|&",
366            Bash::BANG => "!",
367            Bash::LBRACK => "[",
368            Bash::RBRACK => "]",
369            Bash::LBRACKLBRACK => "[[",
370            Bash::RBRACKRBRACK => "]]",
371            Bash::Declare => "declare",
372            Bash::Typeset => "typeset",
373            Bash::Export => "export",
374            Bash::Readonly => "readonly",
375            Bash::Local => "local",
376            Bash::Unset => "unset",
377            Bash::Unsetenv => "unsetenv",
378            Bash::EQTILDE => "=~",
379            Bash::AMPGT => "&>",
380            Bash::AMPGTGT => "&>>",
381            Bash::LTAMP => "<&",
382            Bash::GTAMP => ">&",
383            Bash::GTPIPE => ">|",
384            Bash::LTAMPDASH => "<&-",
385            Bash::GTAMPDASH => ">&-",
386            Bash::LTLTDASH => "<<-",
387            Bash::HeredocRedirectToken1 => "heredoc_redirect_token1",
388            Bash::LTLTLT => "<<<",
389            Bash::QMARK => "?",
390            Bash::COLON => ":",
391            Bash::PLUSPLUS2 => "++",
392            Bash::DASHDASH2 => "--",
393            Bash::DASH2 => "-",
394            Bash::PLUS2 => "+",
395            Bash::TILDE => "~",
396            Bash::DOLLARLPARENLPAREN => "$((",
397            Bash::DOLLARLBRACK => "$[",
398            Bash::Number => "number",
399            Bash::DOTDOT => "..",
400            Bash::RBRACE2 => "}",
401            Bash::BQUOTEBQUOTE => "``",
402            Bash::DOLLAR => "$",
403            Bash::SpecialCharacter => "_special_character",
404            Bash::DQUOTE => "\"",
405            Bash::StringContent => "string_content",
406            Bash::RawString => "raw_string",
407            Bash::AnsiCString => "ansi_c_string",
408            Bash::NumberToken1 => "number_token1",
409            Bash::NumberToken2 => "number_token2",
410            Bash::HASH => "#",
411            Bash::DOLLARLBRACE => "${",
412            Bash::RBRACE3 => "}",
413            Bash::BANG2 => "!",
414            Bash::AT => "@",
415            Bash::STAR2 => "*",
416            Bash::HASH2 => "#",
417            Bash::EQ2 => "=",
418            Bash::COLONEQ => ":=",
419            Bash::DASH3 => "-",
420            Bash::COLONDASH => ":-",
421            Bash::PLUS3 => "+",
422            Bash::COLONPLUS => ":+",
423            Bash::QMARK2 => "?",
424            Bash::COLONQMARK => ":?",
425            Bash::PERCENTPERCENT => "%%",
426            Bash::Regex => "regex",
427            Bash::SLASHSLASH => "//",
428            Bash::SLASHHASH => "/#",
429            Bash::SLASHPERCENT => "/%",
430            Bash::COMMACOMMA => ",,",
431            Bash::CARETCARET => "^^",
432            Bash::U => "U",
433            Bash::U2 => "u",
434            Bash::L => "L",
435            Bash::Q => "Q",
436            Bash::E => "E",
437            Bash::P => "P",
438            Bash::A => "A",
439            Bash::K => "K",
440            Bash::A2 => "a",
441            Bash::K2 => "k",
442            Bash::DOLLARLPAREN => "$(",
443            Bash::BQUOTE => "`",
444            Bash::DOLLARBQUOTE => "$`",
445            Bash::LTLPAREN => "<(",
446            Bash::GTLPAREN => ">(",
447            Bash::Comment => "comment",
448            Bash::Word3 => "word",
449            Bash::VariableName => "variable_name",
450            Bash::VariableName2 => "variable_name",
451            Bash::SpecialVariableName => "special_variable_name",
452            Bash::SpecialVariableName2 => "special_variable_name",
453            Bash::HeredocStart => "heredoc_start",
454            Bash::HeredocBody => "heredoc_body",
455            Bash::HeredocBodyBeginning => "_heredoc_body_beginning",
456            Bash::HeredocContent => "heredoc_content",
457            Bash::HeredocEnd => "heredoc_end",
458            Bash::FileDescriptor => "file_descriptor",
459            Bash::EmptyValue => "_empty_value",
460            Bash::Concat => "_concat",
461            Bash::VariableName3 => "variable_name",
462            Bash::TestOperator => "test_operator",
463            Bash::Regex2 => "regex",
464            Bash::Regex3 => "regex",
465            Bash::Regex4 => "regex",
466            Bash::Word4 => "word",
467            Bash::ExtglobPattern => "extglob_pattern",
468            Bash::DOLLAR2 => "$",
469            Bash::LBRACE2 => "{",
470            Bash::HASHHASH => "##",
471            Bash::HASH3 => "#",
472            Bash::BANG3 => "!",
473            Bash::EQ3 => "=",
474            Bash::ErrorRecovery => "__error_recovery",
475            Bash::Program => "program",
476            Bash::Statements => "_statements",
477            Bash::TerminatedStatement => "_terminated_statement",
478            Bash::StatementNotPipeline => "_statement_not_pipeline",
479            Bash::RedirectedStatement => "redirected_statement",
480            Bash::ForStatement => "for_statement",
481            Bash::CStyleForStatement => "c_style_for_statement",
482            Bash::ForBody => "_for_body",
483            Bash::CExpression => "_c_expression",
484            Bash::CExpressionNotAssignment => "_c_expression_not_assignment",
485            Bash::VariableAssignment => "variable_assignment",
486            Bash::UnaryExpression => "unary_expression",
487            Bash::BinaryExpression => "binary_expression",
488            Bash::PostfixExpression => "postfix_expression",
489            Bash::ParenthesizedExpression => "parenthesized_expression",
490            Bash::WhileStatement => "while_statement",
491            Bash::DoGroup => "do_group",
492            Bash::IfStatement => "if_statement",
493            Bash::ElifClause => "elif_clause",
494            Bash::ElseClause => "else_clause",
495            Bash::CaseStatement => "case_statement",
496            Bash::CaseItem => "case_item",
497            Bash::CaseItem2 => "case_item",
498            Bash::FunctionDefinition => "function_definition",
499            Bash::CompoundStatement => "compound_statement",
500            Bash::Subshell => "subshell",
501            Bash::Pipeline => "pipeline",
502            Bash::List => "list",
503            Bash::NegatedCommand => "negated_command",
504            Bash::TestCommand => "test_command",
505            Bash::BinaryExpression2 => "binary_expression",
506            Bash::DeclarationCommand => "declaration_command",
507            Bash::UnsetCommand => "unset_command",
508            Bash::Command => "command",
509            Bash::CommandName => "command_name",
510            Bash::VariableAssignment2 => "variable_assignment",
511            Bash::VariableAssignments => "variable_assignments",
512            Bash::Subscript => "subscript",
513            Bash::FileRedirect => "file_redirect",
514            Bash::HeredocRedirect => "heredoc_redirect",
515            Bash::Pipeline2 => "pipeline",
516            Bash::HeredocExpression => "_heredoc_expression",
517            Bash::HeredocCommand => "_heredoc_command",
518            Bash::HeredocBody3 => "_heredoc_body",
519            Bash::HeredocBody2 => "heredoc_body",
520            Bash::SimpleHeredocBody => "_simple_heredoc_body",
521            Bash::HerestringRedirect => "herestring_redirect",
522            Bash::Expression => "_expression",
523            Bash::BinaryExpression3 => "binary_expression",
524            Bash::TernaryExpression => "ternary_expression",
525            Bash::UnaryExpression2 => "unary_expression",
526            Bash::PostfixExpression2 => "postfix_expression",
527            Bash::ParenthesizedExpression2 => "parenthesized_expression",
528            Bash::ArithmeticExpansion => "arithmetic_expansion",
529            Bash::BraceExpression => "brace_expression",
530            Bash::ArithmeticExpression => "_arithmetic_expression",
531            Bash::ArithmeticLiteral => "_arithmetic_literal",
532            Bash::BinaryExpression4 => "binary_expression",
533            Bash::TernaryExpression2 => "ternary_expression",
534            Bash::UnaryExpression3 => "unary_expression",
535            Bash::PostfixExpression3 => "postfix_expression",
536            Bash::ParenthesizedExpression3 => "parenthesized_expression",
537            Bash::Concatenation => "concatenation",
538            Bash::String => "string",
539            Bash::TranslatedString => "translated_string",
540            Bash::Array => "array",
541            Bash::Number2 => "number",
542            Bash::SimpleExpansion => "simple_expansion",
543            Bash::Expansion => "expansion",
544            Bash::ExpansionBody => "_expansion_body",
545            Bash::ExpansionExpression => "_expansion_expression",
546            Bash::ExpansionRegex => "_expansion_regex",
547            Bash::ExpansionRegexReplacement => "_expansion_regex_replacement",
548            Bash::ExpansionRegexRemoval => "_expansion_regex_removal",
549            Bash::ExpansionMaxLength => "_expansion_max_length",
550            Bash::ExpansionMaxLengthExpression => "_expansion_max_length_expression",
551            Bash::BinaryExpression5 => "binary_expression",
552            Bash::ExpansionOperator => "_expansion_operator",
553            Bash::Concatenation2 => "concatenation",
554            Bash::CommandSubstitution => "command_substitution",
555            Bash::ProcessSubstitution => "process_substitution",
556            Bash::ExtglobBlob => "_extglob_blob",
557            Bash::CTerminator => "_c_terminator",
558            Bash::StatementsRepeat1 => "_statements_repeat1",
559            Bash::RedirectedStatementRepeat1 => "redirected_statement_repeat1",
560            Bash::RedirectedStatementRepeat2 => "redirected_statement_repeat2",
561            Bash::ForStatementRepeat1 => "for_statement_repeat1",
562            Bash::ForBodyRepeat1 => "_for_body_repeat1",
563            Bash::IfStatementRepeat1 => "if_statement_repeat1",
564            Bash::CaseStatementRepeat1 => "case_statement_repeat1",
565            Bash::CaseItemRepeat1 => "case_item_repeat1",
566            Bash::CompoundStatementRepeat1 => "compound_statement_repeat1",
567            Bash::PipelineRepeat1 => "pipeline_repeat1",
568            Bash::DeclarationCommandRepeat1 => "declaration_command_repeat1",
569            Bash::UnsetCommandRepeat1 => "unset_command_repeat1",
570            Bash::CommandRepeat1 => "command_repeat1",
571            Bash::CommandRepeat2 => "command_repeat2",
572            Bash::VariableAssignmentsRepeat1 => "variable_assignments_repeat1",
573            Bash::HeredocBodyRepeat1 => "heredoc_body_repeat1",
574            Bash::LiteralRepeat1 => "_literal_repeat1",
575            Bash::ArithmeticExpansionRepeat1 => "arithmetic_expansion_repeat1",
576            Bash::ConcatenationRepeat1 => "concatenation_repeat1",
577            Bash::StringRepeat1 => "string_repeat1",
578            Bash::ExpansionBodyRepeat1 => "_expansion_body_repeat1",
579            Bash::ExpansionRegexRepeat1 => "_expansion_regex_repeat1",
580            Bash::ConcatenationInExpansionRepeat1 => "_concatenation_in_expansion_repeat1",
581            Bash::Error => "ERROR",
582        }
583    }
584}
585
586impl From<u16> for Bash {
587    #[inline]
588    fn from(x: u16) -> Self {
589        num_traits::FromPrimitive::from_u16(x).unwrap_or(Self::Error)
590    }
591}
592
593// Bash == u16
594impl PartialEq<u16> for Bash {
595    #[inline]
596    fn eq(&self, x: &u16) -> bool {
597        *self == Into::<Self>::into(*x)
598    }
599}
600
601// u16 == Bash
602impl PartialEq<Bash> for u16 {
603    #[inline]
604    fn eq(&self, x: &Bash) -> bool {
605        *x == *self
606    }
607}