Eagle Legacy Modernization, LLC

Bash Grammar

Main program: Bash_Program

Bash syntax:

 Count  Terminals:
1 Bash_Argument: Literal quotes:'" escape:\ doubled:no multiline:no
  Bash_ChmodLetters: Literal
29 Bash_Comment: # comment
47 Bash_Filename: file name
  Bash_Function_Definition: An identifier
  Bash_Identifier: An identifier
212 Bash_Identifier_Reference: An identifier
106 Bash_Literal: Literal quotes:'"` escape:\ doubled:no multiline:no
33 Bash_Number: Number exponent_chars:none suffix_chars:none trailing_period:no ignore_char:none
184 Bash_RealEndOfLine: End of line
 Count  Statistics(*) Tokens:
15 (all | none | none | none | none | none | none | none | none | none) Bash_Condition: (Bash_ExpressionCondition | Bash_BracketCondition | Bash_BracketsCondition | Bash_ExistsCondition | Bash_NotCondition | Bash_ConditionConstants | Bash_GrepCondition | Bash_ReadCondition | Bash_LogicalAndCondition | Bash_LogicalOrCondition)
245 all 91% Bash_Element: Bash_Statement [Bash_EndOfLine]
245 (2% | none | none | none | none | 12% | 0% | none | 2% | none | 20% | none | none | 0% | 7% | 1% | 6% | none | 1% | none | none | none | none | none | none | 0% | 1% | none | 2% | 8% | none | none | none | none | 3% | 0% | 0% | 12% | 15% | 6% | none) |   Bash_Statement: (Bash_AwkCommand | Bash_BreakStatement | Bash_CaseCommand | Bash_CatCommand | Bash_ChmodCommand | Bash_Comment | Bash_CpCommand | Bash_CurlCommand | Bash_DiffCommand | Bash_DirnameCommand | Bash_EchoCommand | Bash_EvaluateCommand | Bash_ExportCommand | Bash_ForStatement | Bash_GccCommand | Bash_GitCommand | Bash_GrepCommand | Bash_IfStatement | Bash_LispCommand | Bash_LnCommand | Bash_MkdirCommand | Bash_MkTempCommand | Bash_PwdCommand | Bash_ReadCommand | Bash_ReturnCommand | Bash_RmCommand | Bash_SedCommand | Bash_SetCommand | Bash_SortCommand | Bash_TeeCommand | Bash_UniqCommand | Bash_WcCommand | Bash_WhileStatement | Bash_ZipCommand | Bash_BashProgram | Bash_PerlProgram | Bash_PythonProgram | Bash_Assignment | Bash_FunctionCall | Bash_Condition | Bash_Function)
226 1.00(1%) all Bash_EndOfLine: [Bash_Redirect]* Bash_LineEnder
226 (21% | 79%) |   Bash_LineEnder: (Bash_Piper | Bash_RealEndOfLine)
47 all 6% |   |   Bash_Piper: (","|"|"|";"|"||"|"&&") [Bash_RealEndOfLine]
3 all all |   Bash_Redirect: ("<"|">"|">>"|"&>"|"&>>"|"1>"|"2>") Bash_RedirectTo
3 (67% | 33% | none) |   |   Bash_RedirectTo: (Bash_RedirectToNumber | Bash_Literal | Bash_Filename)
2 all all |   |   |   Bash_RedirectToNumber: ['&'] Bash_Number
266 (10% | 30% | none | none | none | none | none | none | 5% | none | 30% | none | none | none | none | 9% | 15% | none | none | none | none) Bash_Expression: (Bash_Number | Bash_Literal | Bash_DollarNumber | Bash_DollarPound | Bash_DollarExpr | Bash_DollarSubstring | Bash_SizeExpression | Bash_ParenthesizedExpression | Bash_NegativeExpression | Bash_LogicalNotExpression | Bash_VariableExpression | Bash_Array | Bash_Evaluate1 | Bash_Evaluate2 | Bash_RangeExpression | Bash_MultiplicativeExpression | Bash_AdditiveExpression | Bash_Relational_Expression | Bash_LogicalAnd_Expression | Bash_LogicalOr_Expression | Bash_Assignment_Expression)
62 (23% | none | 77%) Bash_FilenameOrLiteral: (Bash_Filename | ("*") | Bash_Expression)
12 20.17 Bash_Program: Bash_Element*
198 all all none none Bash_Variable: ['$'] Bash_Identifier_Reference [Bash_DoubleSubscript] [Bash_Subscript]
    |   Bash_DoubleSubscript: ':' Bash_Number ':' Bash_Number
    |   Bash_Subscript: '[' Bash_Expression ']'
30 all all all all all Bash_Assignment: ["local"] ["let"] Bash_Variable ("="|"+="|"-=") [Bash_AssignWhat]
30 (80% | 20%) |   Bash_AssignWhat: (Bash_Expression | Bash_Filename)
4 all 1.00(75%) 25% Bash_AwkCommand: "awk" [Bash_AwkOption]* [Bash_FilenameOrLiteral]
3 (none | all) |   Bash_AwkOption: (Bash_AwkOptionCapitalF | Bash_AwkOptionSmallF)
    |   |   Bash_AwkOptionCapitalF: "-F" ','
3 all all |   |   Bash_AwkOptionSmallF: "-f" Bash_FilenameOrLiteral
8 all 3.00(all) none all all none Bash_BashProgram: "#!" ['/']* ['/'] ["env"] ("bash"|"csh"|"sh"|"tcsh"|"zsh") [Bash_BashOption]*
    |   Bash_BashOption: (("-e"|"-eu"|"-ex"|"-p"|"-v"|"-x"|"-xe"))
    Bash_BreakStatement: "break"
    Bash_CaseCommand: "case" Bash_Expression "in" Bash_EndOfLine Bash_CaseClause* [Bash_CaseDefault] "esac" Bash_EndOfLine
    |   Bash_CaseAction: ')' Bash_Element ';' [';'] Bash_EndOfLine
    |   Bash_CaseClause: (Bash_CaseNumber | Bash_CaseRegex)
    |   |   Bash_CaseNumber: Bash_Number Bash_CaseAction
    |   |   Bash_CaseRegex: '[' Bash_Identifier ']' Bash_CaseAction
    |   Bash_CaseDefault: '*' Bash_CaseAction
    Bash_CatCommand: "cat" Bash_FilenameOrLiteral*
    Bash_ChmodCommand: "chmod" [Bash_ChmodOption]* Bash_ChmodCode [Bash_ChmodMoreCodes]* Bash_FilenameOrLiteral
    |   Bash_ChmodCode: (Bash_Number | Bash_ChmodLetters)
    |   Bash_ChmodMoreCodes: [','] Bash_ChmodCode
    |   Bash_ChmodOption: (("-R"|"-e"))
1 all none 3.00 Bash_CpCommand: "cp" [Bash_CpOption]* Bash_FilenameOrLiteral*
    |   Bash_CpOption: (("-a"|"-r"|"-R"))
    Bash_CurlCommand: "curl" [Bash_CurlOption]* Bash_FilenameOrLiteral*
    |   Bash_CurlOption: (("-L"))
6 all 1.00(all) all all Bash_DiffCommand: "diff" [Bash_DiffOption]* Bash_FilenameOrLiteral Bash_FilenameOrLiteral
6 (all) |   Bash_DiffOption: (("-r"|"--strip-trailing-cr"))
    Bash_DirnameCommand: "dirname" Bash_FilenameOrLiteral*
50 all none 62% Bash_EchoCommand: "echo" [Bash_EchoOption]* [Bash_EchoWhat]
    |   Bash_EchoOption: ("-n")
31 (97% | 3%) |   Bash_EchoWhat: (Bash_Expression | Bash_Argument)
    Bash_EvaluateCommand: "((" Bash_Expression "))"
    Bash_ExportCommand: "export" [Bash_ExportOption]* Bash_Variable '=' Bash_Expression
    |   Bash_ExportOption: (("-n"))
1 all all all 5.00 all all all 3.00 all Bash_ForStatement: "for" Bash_Identifier_Reference "in" Bash_Expression* Bash_EndOfLine "do" [Bash_EndOfLine] Bash_Element* "done"
    Bash_Function: (Bash_Function_Explicit | Bash_Function_Implicit)
    |   Bash_Function_Explicit: "function" Bash_Function_Definition [Bash_FunctionParams] [Bash_EndOfLine] '{' Bash_EndOfLine Bash_Element* '}'
    |   |   Bash_FunctionParams: '(' ')'
    |   Bash_Function_Implicit: Bash_Function_Definition '(' ')' '{' Bash_EndOfLine Bash_Element* '}'
36 all 1.10(56%) Bash_FunctionCall: Bash_WhatFunction [Bash_FunctionArg]*
22 (18% | none | 68% | 14%) |   Bash_FunctionArg: (Bash_Literal | Bash_Number | Bash_Filename | Bash_Variable)
36 (33% | 67%) |   Bash_WhatFunction: (Bash_Filename | Bash_Variable)
16 all 6.00(75%) all 1.00(6%) Bash_GccCommand: ("gcc"|"gfortran") [Bash_GccOption]* Bash_FilenameOrLiteral [Bash_GccOption]*
73 (82% | 1% | 1% | 15%) |   Bash_GccOption: (Bash_GccOptionD | Bash_GccOptionI | Bash_GccOptionO | ("-c"|"-g"|"-lm"|"-Os"|"-Wall"))
60 all all 7% |   |   Bash_GccOptionD: "-D" Bash_Variable [Bash_OptionDinit]
4 all all |   |   |   Bash_OptionDinit: '=' Bash_FilenameOrLiteral
1 all all |   |   Bash_GccOptionI: "-I" Bash_FilenameOrLiteral
1 all all |   |   Bash_GccOptionO: "-o" Bash_FilenameOrLiteral
2 all 6.00(all) Bash_GitCommand: "git" [Bash_GitOption]*
12 (all) |   Bash_GitOption: (("clone"|"ls-tree"|"-r"|"-t"|"-l"|"--full-name"|"HEAD"))
15 all 1.00(47%) all none none Bash_GrepCommand: ("grep"|"egrep") [Bash_GrepOption]* [Bash_Literal] [Bash_FilenameOrLiteral] [Bash_GrepOption]*
7 (all) |   Bash_GrepOption: (("-c"|"-E"|"-i"|"-o"|"-q"|"-qE"|"-r"|"-v"|"--extended-regex"|"--line-regex"|"--silent"|"--text"))
    Bash_IfStatement: "if" ["test"] Bash_Condition Bash_EndOfLine "then" [Bash_EndOfLine] Bash_Element* [Bash_If_Elif]* [Bash_If_Else] "fi"
    |   Bash_If_Elif: "elif" Bash_Condition Bash_EndOfLine "then" [Bash_EndOfLine] Bash_Element*
    |   Bash_If_Else: "else" [Bash_EndOfLine] Bash_Element*
3 all 2.00(all) none Bash_LispCommand: "clisp" [Bash_LispOption]* [Bash_FilenameOrLiteral]
6 (50% | 50%) |   Bash_LispOption: (Bash_LispOptionX | "-q")
3 all all |   |   Bash_LispOptionX: "-x" Bash_Literal
    Bash_LnCommand: "ln" [Bash_LnOption]* Bash_FilenameOrLiteral*
    |   Bash_LnOption: (("-f"|"-fs"|"-s"|"-sf"))
    Bash_MkTempCommand: "mktemp" [Bash_MkTempOption]* Bash_FilenameOrLiteral
    |   Bash_MkTempOption: (("-d"|"-t"))
    Bash_MkdirCommand: "mkdir" [Bash_MkdirOption]* Bash_FilenameOrLiteral
    |   Bash_MkdirOption: (("-p"))
1 all 7.00(all) none all 1.00(all) all all Bash_PerlProgram: "#!" ['/']* ['/'] "perl" [Bash_PerlOption]* Bash_RealEndOfLine Perl_Program
1 (all) |   Bash_PerlOption: (("-e"|"-i"|"-lne"|"-pi"|"-w"))
    Bash_PwdCommand: "pwd"
    Bash_PythonOption: (Bash_PythonOptionM)
    |   Bash_PythonOptionM: "-m" Bash_Identifier_Reference
1 (none | all) Bash_PythonProgram: (Bash_PythonExec | Bash_PythonScript)
    |   Bash_PythonExec: ['/']* ['/'] ("python"|"python3") [Bash_PythonOption]* Bash_FilenameOrLiteral [Bash_FilenameOrLiteral]* Bash_EndOfLine
1 all 5.00(all) none all none all all |   Bash_PythonScript: "#!" ['/']* ['/'] ("python"|"python3") [Bash_PythonOption]* Bash_RealEndOfLine Python3_Program
    Bash_ReadCommand: "read" [Bash_ReadOption]* Bash_Identifier_Reference*
    |   Bash_ReadOption: (Bash_ReadPrompt)
    |   |   Bash_ReadPrompt: ("-p") Bash_Literal
    Bash_ReturnCommand: "return" [Bash_Expression]
1 none all 1.00(all) 2.00 none Bash_RmCommand: [Bash_RmBin] "rm" [Bash_RmOption]* Bash_FilenameOrLiteral* [Bash_RmOption]*
    |   Bash_RmBin: '/' "bin" '/'
1 (all) |   Bash_RmOption: (("-f"|"-fr"|"-r"|"-rf"))
3 all none all none Bash_SedCommand: "sed" [Bash_SedOption]* [Bash_Literal] [Bash_FilenameOrLiteral]
    |   Bash_SedOption: (Bash_SedOptionF | Bash_SedOptionPlus | ("-E"|"-e"|"-i"|"-r"))
    |   |   Bash_SedOptionF: "-f" Bash_FilenameOrLiteral
    |   |   Bash_SedOptionPlus: '+' ("e"|"ex"|"x")
    Bash_SetCommand: "set" [Bash_SetOption]* [Bash_Comment]
    |   Bash_SetOption: (Bash_SetAssignment | Bash_SetOptionO | Bash_SetPlus | ("-e"|"-eu"|"-ex"|"-eE"|"-eux"|"-u"|"-x"))
    |   |   Bash_SetAssignment: Bash_Variable '=' Bash_SetValue
    |   |   |   Bash_SetValue: (Bash_Filename | Bash_Expression)
    |   |   Bash_SetOptionO: ("-eo"|"-euox"|"-euxo"|"-o") Bash_Identifier_Reference
    |   |   Bash_SetPlus: '+' ("e"|"ex"|"x")
4 all 1.50(all) none Bash_SortCommand: "sort" [Bash_SortOption]* [Bash_Comment]
6 (67% | 33%) |   Bash_SortOption: (Bash_SortOptionK | ("-r"|"-n"))
4 all all |   |   Bash_SortOptionK: "-k" Bash_Number
19 all all Bash_TeeCommand: "tee" Bash_FilenameOrLiteral
    Bash_UniqCommand: "uniq" [Bash_UniqOption]* Bash_FilenameOrLiteral*
    |   Bash_UniqOption: (("-c"))
    Bash_WcCommand: "wc" [Bash_WcOption]* [Bash_FilenameOrLiteral]*
    |   Bash_WcOption: (("-l"|"-c"))
    Bash_WhileStatement: "while" ["test"] Bash_Condition Bash_EndOfLine "do" [Bash_EndOfLine] Bash_Element* "done"
    Bash_ZipCommand: "zip" [Bash_ZipOption]* Bash_FilenameOrLiteral*
    |   Bash_ZipOption: (("-r"|"-p"|"-P"|"-0"))
    Bash_BracketCondition: '[' Bash_Condition ']'
    Bash_BracketsCondition: "[[" Bash_Condition "]]"
    Bash_ConditionConstants: ("false"|"true")
    Bash_ExistsCondition: ("-d"|"-e"|"-f"|"-n"|"-x"|"-z") Bash_FilenameOrLiteral
15 all Bash_ExpressionCondition: Bash_Expression
    Bash_GrepCondition: Bash_GrepCommand
    Bash_LogicalAndCondition: Bash_Condition Bash_AndCond_Operator Bash_Condition
    |   Bash_AndCond_Operator: (Bash_AndOperatorLiteral | "&&")
    |   |   Bash_AndOperatorLiteral: '-' "and"
    Bash_LogicalOrCondition: Bash_Condition Bash_OrCond_Operator Bash_Condition
    |   Bash_OrCond_Operator: (Bash_OrOperatorLiteral | "||")
    |   |   Bash_OrOperatorLiteral: '-' "or"
    Bash_NotCondition: '!' Bash_Condition
    Bash_ReadCondition: Bash_ReadCommand
41 all all all Bash_AdditiveExpression: Bash_Expression ("+"|"-") Bash_Expression
    Bash_Array: '(' Bash_Expression* ')'
    Bash_Assignment_Expression: Bash_Expression ("=") Bash_Expression
    Bash_DollarExpr: '$' '{' Bash_Expression '}'
    Bash_DollarNumber: '$' Bash_Number
    Bash_DollarPound: ("$#"|"$?"|"$@"|"$*")
    Bash_DollarSubstring: '$' '{' Bash_Variable ':' Bash_Expression ':' Bash_Expression '}'
    Bash_Evaluate1: '$' '(' Bash_Element ')'
    Bash_Evaluate2: '$' "((" Bash_Expression "))"
    Bash_LogicalAnd_Expression: Bash_Expression Bash_AndExpr_Operator Bash_Expression
    |   Bash_AndExpr_Operator: ("&&" | "-a")
    Bash_LogicalNotExpression: '!' Bash_Expression
    Bash_LogicalOr_Expression: Bash_Expression Bash_OrExpr_Operator Bash_Expression
    |   Bash_OrExpr_Operator: ("||" | "-o")
25 all all all Bash_MultiplicativeExpression: Bash_Expression ("*"|"/"|"%") Bash_Expression
12 all all Bash_NegativeExpression: ("-") Bash_Expression
    Bash_ParenthesizedExpression: '(' [Bash_Expression] ')'
    Bash_RangeExpression: '{' Bash_Number ".." Bash_Number '}'
    Bash_Relational_Expression: Bash_Expression Bash_RelOp Bash_Expression
    |   Bash_RelOp: (("=="|"!="|"<"|">"|"<="|">=") | ("-eq"|"-ne"|"-lt"|"-gt"|"-le"|"-ge"))
    Bash_SizeExpression: '#' Bash_Variable
81 all Bash_VariableExpression: Bash_Variable

Terminals = 10 (instances=612)
Tokens = 150 (instances=2,236)

(*) Statistics are shown in the same order as the Tokens.
Percentages are rounded; 'all' and 'none' mean 100% and 0% before rounding.
For lists, it shows the average number of occurrences, excluding empty lists.