Eagle Legacy Modernization, LLC

Bash Grammar

Main program: Bash_Program

Bash syntax:

 Count  Terminals:
  Bash_ChmodLetters: Literal
7 Bash_Comment: # comment
21 Bash_EchoWhat: Literal quotes:'" escape:\ doubled:no multiline:no
18 Bash_Filename: file name
  Bash_Function_Definition: An identifier
  Bash_Identifier: An identifier
117 Bash_Identifier_Reference: An identifier
64 Bash_Literal: Literal quotes:'"` escape:\ doubled:no multiline:no
24 Bash_Number: Number exponent_chars:none suffix_chars:none trailing_period:no ignore_char:none
125 Bash_RealEndOfLine: End of line
 Count  Statistics(*) Tokens:
11 (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)
164 all 93% Bash_Element: Bash_Statement [Bash_EndOfLine]
164 (2% | none | none | none | none | 4% | 1% | none | 4% | none | 24% | none | none | 1% | 4% | 1% | 2% | none | 2% | none | none | none | none | none | none | none | 2% | none | 1% | 12% | none | none | none | none | 3% | 1% | none | 18% | 12% | 7% | 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)
154 1.00(1%) all Bash_EndOfLine: [Bash_Redirect]* Bash_LineEnder
154 (21% | 79%) |   Bash_LineEnder: (Bash_Piper | Bash_RealEndOfLine)
32 all 6% |   |   Bash_Piper: (","|"|"|";"|"||"|"&&") [Bash_RealEndOfLine]
1 all all |   Bash_Redirect: ("<"|">"|">>"|"&>"|"&>>"|"1>"|"2>") Bash_RedirectTo
1 (none | all | none) |   |   Bash_RedirectTo: (Bash_RedirectToNumber | Bash_Literal | Bash_Filename)
    |   |   |   Bash_RedirectToNumber: ['&'] Bash_Number
201 (11% | 25% | none | none | none | none | none | none | 4% | none | 32% | none | none | none | none | 12% | 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)
45 (4% | none | 96%) Bash_FilenameOrLiteral: (Bash_Filename | ("*") | Bash_Expression)
7 23.00 Bash_Program: Bash_Element*
108 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
5 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_CaseClause: '[' Bash_Identifier ']' ')' Bash_Element ';' [';'] Bash_EndOfLine
    |   Bash_CaseDefault: '*' ')' Bash_Element ';' [';'] Bash_EndOfLine
    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*
40 all none 53% Bash_EchoCommand: "echo" [Bash_EchoOption]* [Bash_EchoWhat]
    |   Bash_EchoOption: ("-n")
    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* '}'
20 all 1.00(35%) Bash_FunctionCall: Bash_WhatFunction [Bash_FunctionArg]*
7 (57% | none | none | 43%) |   Bash_FunctionArg: (Bash_Literal | Bash_Number | Bash_Filename | Bash_Variable)
20 (50% | 50%) |   Bash_WhatFunction: (Bash_Filename | Bash_Variable)
7 all 1.00(43%) all none Bash_GccCommand: ("gcc"|"gfortran") [Bash_GccOption]* Bash_FilenameOrLiteral [Bash_GccOption]*
3 (none | all) |   Bash_GccOption: (Bash_GccOptionO | ("-c"|"-g"|"-lm"|"-Wall"))
    |   |   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"))
3 all 1.00(all) all none none Bash_GrepCommand: ("grep"|"egrep") [Bash_GrepOption]* [Bash_Literal] [Bash_FilenameOrLiteral] [Bash_GrepOption]*
3 (all) |   Bash_GrepOption: (("-c"|"-E"|"-i"|"-o"|"-q"|"-qE"|"-r"|"-v"|"--extended-regex"|"--line-regex"|"--silent"|"--text"))
    Bash_IfStatement: "if" 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
    Bash_PythonProgram: (Bash_PythonExec | Bash_PythonScript)
    |   Bash_PythonExec: ['/']* ['/'] ("python"|"python3") [Bash_PythonOption]* Bash_FilenameOrLiteral [Bash_FilenameOrLiteral]* Bash_EndOfLine
    |   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]
    Bash_RmCommand: [Bash_RmBin] "rm" [Bash_RmOption]* Bash_FilenameOrLiteral* [Bash_RmOption]*
    |   Bash_RmBin: '/' "bin" '/'
    |   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")
1 all 3.00(all) none Bash_SortCommand: "sort" [Bash_SortOption]* [Bash_Comment]
3 (33% | 67%) |   Bash_SortOption: (Bash_SortOptionK | ("-r"|"-n"))
1 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" 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
11 all Bash_ExpressionCondition: Bash_Expression
    Bash_GrepCondition: Bash_GrepCommand
    Bash_LogicalAndCondition: Bash_Condition Bash_AndOperator Bash_Condition
    |   Bash_AndOperator: (Bash_AndOperatorLiteral | "&&")
    |   |   Bash_AndOperatorLiteral: '-' "and"
    Bash_LogicalOrCondition: Bash_Condition '-' "or" Bash_Condition
    Bash_NotCondition: '!' Bash_Condition
    Bash_ReadCondition: Bash_ReadCommand
30 all all all Bash_AdditiveExpression: Bash_Expression ("+"|"-") Bash_Expression
    Bash_Array: '(' Bash_Expression* ')'
    Bash_Assignment_Expression: Bash_Variable ("=") 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_Expression
    Bash_LogicalNotExpression: '!' Bash_Expression
    Bash_LogicalOr_Expression: Bash_Expression "||" Bash_Expression
25 all all all Bash_MultiplicativeExpression: Bash_Expression ("*"|"/"|"%") Bash_Expression
8 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
65 all Bash_VariableExpression: Bash_Variable

Terminals = 10 (instances=376)
Tokens = 139 (instances=1,428)

(*) 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.