Eagle Legacy Modernization, LLC

Python3 Grammar

Main program: Python3_Program

Python syntax:

 Count  Terminals:
  Python_BackQuote: back quote literal
  Python_BinaryNumber: A binary number
25 Python_Class_Definition: An identifier
423 Python_Comment: /* comment */ or # comment to end of line
186 Python_ElseStartOfLine: Start of line
11,092 Python_EndOfLine: End of line
476 Python_Function_Definition: An identifier
  Python_HexNumber: A hex number
21,146 Python_Identifier_Reference: An identifier
3,208 Python_Literal: python literal
6,981 Python_Number: exponent_chars:Ee suffix_chars:JjLl trailing_period:yes ignore_char:none
  Python_OctalNumber: A octal number
9,827 Python_StartOfLine: Start of line
922 Python_Variable_Definition: An identifier
 Count  Statistics(*) Tokens:
1,753 all all all Python_Additive_Expression: Python_Expression ("+"|"-") Python_Expression
149 all all all all Python_Assignment_Expression: Python_Expression ("="|"+="|"-="|":=") ["await"] Python_Expression
    Python_BackQuotes: Python_BackQuote*
16 all all all Python_Bitwise_And_Expression: Python_Expression '&' Python_Expression
5 all all all Python_Bitwise_Or_Expression: Python_Expression '|' Python_Expression
5 all all all Python_Bitwise_Xor_Expression: Python_Expression '^' Python_Expression
163 all 4% all none all Python_BracesColons: '{' [Python_EndOfLine] [Python_Dictionary] [Python_EndOfLine] '}'
163 none 16% 6.79(12%) 1% none |   Python_Dictionary: [Python_Comment]* [Python_DictionaryElement] [Python_MoreDictionaryElement]* [','] [Python_Comment]*
155 all all none none all |   |   Python_DictionaryElement: Python_Expression ':' [Python_EndOfLine] [Python_Comment] Python_Expression
129 all none all |   |   Python_MoreDictionaryElement: ',' [Python_Comment]* Python_DictionaryElement
    Python_BracesNoColons: '{' [Python_EndOfLine] Python_Set [Python_EndOfLine] '}'
    |   Python_Set: [Python_Comment]* Python_Expression [Python_MoreSetElement]* [','] [Python_Comment]*
    |   |   Python_MoreSetElement: ',' [Python_Comment]* Python_Expression
183 all 1% none none 69% all Python_Brackets: '[' [Python_EndOfLine] [Python_Comment]* [Python_EndOfLine] [Python_List] ']'
471 all Python_BuiltIn: ("None"|"False"|"True")
56 all all all all all all Python_For_In_Expression: Python_Expression ["async"] "for" Python_VariableList "in" Python_Expression
2,820 all all 2.47(91%) none all Python_Function_Call: Python_Variable '(' [Python_Expression]* [','] ')'
    Python_FunnyConstructor: '(' Python_Type '*' Python_Expression ')' '(' ')'
60 all all all all all Python_If_Else_Expression: Python_Expression "if" Python_Expression "else" Python_Expression
10 all all all Python_If_Expression: Python_Expression "if" Python_Expression
5 all none all none all all Python_Lambda_Expression: "lambda" ['('] [Python_Variable_List] [')'] ':' Python_Expression
5 all all none none |   Python_Variable_List: [("*"|"**")] Python_Variable [Python_Variable_Default] [Python_MoreVariablesInList]*
    |   |   Python_MoreVariablesInList: ',' [Python_Comment]* [("*"|"**")] Python_Variable [Python_Variable_Default]
    |   |   Python_Variable_Default: '=' Python_Expression
3,200 1.00 Python_Literals: Python_Literal*
265 all all none all Python_Logical_And_Expression: Python_Expression "and" [Python_Comment]* Python_Expression
118 all all Python_Logical_Not_Expression: "not" Python_Expression
144 all all none all Python_Logical_Or_Expression: Python_Expression Python_Or_Operation [Python_Comment]* Python_Expression
144 (all | none) |   Python_Or_Operation: ("or" | '^')
2,068 all all all Python_Multiplicative_Expression: Python_Expression ("//"|"*"|"/"|"%") Python_Expression
20 all all Python_Negative_Expression: ("*"|"-"|"+"|"~") Python_Expression
1,465 all none 100% all Python_Parenthesized_Expression: '(' [Python_CommentEoln]* [Python_List] ')'
84 all all all Python_Power_Expression: Python_Expression "**" Python_Expression
77 all all all all all 8% all Python_RangeExpression: "range" '(' Python_Expression ',' Python_Expression [Python_RangeIncr] ')'
6 all all |   Python_RangeIncr: ',' Python_Expression
1,744 all all all Python_Relational_Expression: Python_Expression Python_Relational_Operator Python_Expression
178 all all |   Python_IN_Operator: ["not"] "in"
5 all all |   Python_IS_Operator: "is" ["not"]
1,744 (90% | 10% | 0%) |   Python_Relational_Operator: (("=="|"!="|"<>"|"<="|">="|"<"|">") | Python_IN_Operator | Python_IS_Operator)
13 all all all Python_Shift_Expression: Python_Expression ("<<"|">>") Python_Expression
    Python_StarStar_Expression: "**" Python_Expression
    Python_Star_Expression: '*' Python_Expression
1,098 all all all Python_SubfieldExpression: Python_Expression '.' Python_Expression
142 all all Python_SubscriptExpression: Python_Expression Python_Subscript
12,595 all 8% Python_VariableExpression: Python_Variable [Python_Subscript]
    Python_Yield: "yield" Python_Expression
6 all all all all all 33% all Python_Find_Function: Python_Variable '.' "find" '(' Python_Expression [Python_Find_SC] ')'
2 all all |   Python_Find_SC: ',' Python_Expression
220 all all all all Python_Int_Function: "int" '(' Python_Expression ')'
152 all all all all Python_Len_Function: "len" '(' Python_Expression ')'
    Python_Locals_Function: ("globals"|"locals") '(' ')'
16 all all 1.00 all Python_Print_Function: "print" '(' Python_Expression* ')'
1 all all all all all none all Python_StartsWith_Function: Python_Variable '.' "startswith" '(' Python_Expression [Python_Index_SC] ')'
    |   Python_Index_SC: ',' Python_Expression
224 all all all all Python_Str_Function: "str" '(' Python_Expression ')'
    Python_Strip_Method: Python_Expression '.' "strip" '(' ')'
3 all all all all all Python_Upper_Method: Python_Expression '.' ("lower"|"upper") '(' ')'
23 1.22(39%) none 6.22(all) Python3_Program: [Python_CommentEoln]* [Python_EndOfLine]* [Python_ComplexStatement]*
909 (55% | none | none | none | 1% | 2% | none | none | none | 2% | 0% | 6% | 0% | 11% | 6% | none | none | 0% | 4% | 0% | none | 0% | 1% | none | 11%) |   Python3_Simple_Statement: (Python_Assignment | Python_AssertStatement | Python_AwaitStatement | Python_BreakStatement | Python_ClassDeclaration | Python_ContinueStatement | Python_Data | Python_DeleteStatement | Python_ExecStatement | Python_ForStatement | Python_FromStatement | Python_Function | Python_GlobalStatement | Python_IfStatement | Python_ImportStatement | Python_PassStatement | Python_QuitStatement | Python_RaiseStatement | Python_ReturnStatement | Python_TryStatement | Python_TypeDeclaration | Python_WhileStatement | Python_WithStatement | Python_YieldStatement | Python_ExpressionStatement)
27 all all Python_CommentEoln: Python_Comment [Python_EndOfLine]
9,827 all all 0% none none 1.14(75%) Python_ComplexStatement: Python_StartOfLine Python_StatementOrComment [';'] [','] [Python_Comment] [Python_EndOfLine]*
9,827 (1% | 99%) |   Python_StatementOrComment: (Python_Comment | Python_SameLineStatement)
    Python_Data: Python_Variable_Definition ':' Python_Type [Python_DataInitialValue]
    |   Python_DataInitialValue: '=' Python_Expression
22 all none Python_Decorators: Python_Decorator [Python_MoreDecorators]*
22 all all none all |   Python_Decorator: '@' Python_Expression [Python_CommentEoln] [Python_EndOfLine]
    |   Python_MoreDecorators: (Python_Decorator | Python_CommentEoln)
36,332 (none | none | none | 19% | 0% | none | 4% | 0% | none | 1% | 0% | 0% | 9% | none | 0% | 1% | 1% | 0% | 0% | none | 0% | 8% | 1% | 35% | none | none | 0% | none | 0% | 0% | none | 3% | 0% | 6% | 5% | 0% | 0% | 0% | 0% | 5% | 1% | 0% | 0% | 0% | 0% | 0%) Python_Expression: (Python_BinaryNumber | Python_OctalNumber | Python_HexNumber | Python_Number | Python_RangeExpression | Python_FunnyConstructor | Python_Parenthesized_Expression | Python_BracesColons | Python_BracesNoColons | Python_Brackets | Python_Negative_Expression | Python_Logical_Not_Expression | Python_Literals | Python_BackQuotes | Python_Len_Function | Python_Str_Function | Python_Int_Function | Python_Find_Function | Python_StartsWith_Function | Python_Locals_Function | Python_Print_Function | Python_Function_Call | Python_BuiltIn | Python_VariableExpression | Python_Star_Expression | Python_StarStar_Expression | Python_Lambda_Expression | Python_Yield | Python_SubscriptExpression | Python_Upper_Method | Python_Strip_Method | Python_SubfieldExpression | Python_Power_Expression | Python_Multiplicative_Expression | Python_Additive_Expression | Python_Shift_Expression | Python_Bitwise_And_Expression | Python_Bitwise_Xor_Expression | Python_Bitwise_Or_Expression | Python_Relational_Expression | Python_Logical_And_Expression | Python_Logical_Or_Expression | Python_For_In_Expression | Python_If_Else_Expression | Python_If_Expression | Python_Assignment_Expression)
1,484 1.00 none Python_ExpressionList: Python_Expression* [',']
1,589 none all 3.15(59%) 0% none Python_List: [Python_Comment]* Python_Expression [Python_MoreListItem]* [','] [Python_Comment]*
2,953 all none all |   Python_MoreListItem: ',' [Python_Comment]* Python_Expression
476 all none 90% none all Python_Parameter_List: '(' [Python_Comment] [Python_Params] [Python_EndOfLine] ')'
14 all all |   Python_InitValue: '=' Python_Expression
429 all 1% 0% 1.71(58%) none Python_Params: Python_Parameter [Python_ParamType] [Python_InitValue] [Python_MoreParams]* [',']
423 all none all 6% 3% |   Python_MoreParams: ',' [Python_Comment] Python_Parameter [Python_ParamType] [Python_InitValue]
30 all all |   Python_ParamType: ':' Python_Type
852 (0% | 100% | none | none) |   Python_Parameter: (PythonParamStar | Python_Variable_Definition | '/' | '*')
2 all all |   |   PythonParamStar: ("*"|"**") Python_Variable_Definition
1,497 all none all all Python_Subscript: '[' [Python_EndOfLine] Python_SubscrExpr ']'
123 all none 60% |   Python_ColonSubscript: ':' [Python_EndOfLine] [Python_Expression]
1,497 98% 7% 1% |   Python_SubscrExpr: [Python_Expression] [Python_ColonSubscript] [Python_ColonSubscript]
102 (none | 68% | 20% | none | none | 4% | 1% | 8%) Python_Type: (Python_MetaClass | Python_Regular_Class | Python_StructuredType | Python_TypeBrackets | Python_TypeParens | Python_Literal | "..." | ("Any"|"None"|"bool"|"bytes"|"float"|"int"|"object"|"str"|"Text"))
    |   Python_MetaClass: "metaclass" '=' Python_Variable
69 1.03 |   Python_Regular_Class: Python_TypeName*
70 (none | all) |   |   Python_TypeName: ("self" | Python_Identifier_Reference)
20 none all all |   Python_StructuredType: [Python_TypeTyping] ("Awaitable"|"awaitable"|"Callable"|"callable"|"Coroutine"|"coroutine"|"DefaultDict"|"defaultdict"|"Dict"|"dict"|"Generic"|"generic"|"Iterable"|"iterable"|"Iterator"|"iterator"|"List"|"list"|"Map"|"map"|"Mapping"|"mapping"|"MutableMapping"|"mutablemapping"|"Optional"|"optional"|"Sequence"|"sequence"|"Set"|"set"|"Tuple"|"tuple"|"Type"|"type"|"Union"|"union") Python_TypeBrackets
    |   |   Python_TypeTyping: "typing" '.'
20 all all all |   Python_TypeBrackets: '[' [Python_TypeList] ']'
    |   Python_TypeParens: '(' [Python_TypeList] ')'
20 none all 1.29(35%) none Python_TypeList: [Python_EndOfLine] Python_Type [Python_MoreCommaList]* [Python_EndOfLine]
9 all none all |   Python_MoreCommaList: ',' [Python_EndOfLine] Python_Type
21,247 all Python_Variable: Python_SelfOrVariable
21,247 (1% | 99%) |   Python_SelfOrVariable: ("self" | Python_Identifier_Reference)
5,212 1.04 none Python_VariableList: Python_VariableOrList* [',']
5,267 1.03 |   Python_Just_Var: Python_VariableAndSubscript*
57 all all all |   Python_Var_List: '(' [Python_VariableList] ')'
5,345 all 5% |   Python_VariableAndSubscript: Python_Variable [Python_Subscript]
5,324 (99% | 1%) |   Python_VariableOrList: (Python_Just_Var | Python_Var_List)
1 all all none Python_AssertStatement: "assert" Python_Expression [Python_AssertMessage]
    |   Python_AssertMessage: ',' Python_Expression
4,175 all 1.13(1%) 0% all all all 1.20(0%) 4% Python_Assignment: Python_VariableList [Python_Subscript]* [Python_ResultType] ("="|"+="|"-="|"*="|"/="|"%="|"&="|"|="|"^="|"<<="|">>="|"**="|"//=") ["await"] Python_Expression [Python_MoreAsgExpressions]* [Python_Comment]
6 all all |   Python_MoreAsgExpressions: ',' [Python_Expression]
1 all all |   Python_ResultType: ':' Python_Type
    Python_AwaitStatement: [Python_IfAwait] "await" Python_Expression
    |   Python_IfAwait: "if" ["not"]
154 all Python_BreakStatement: "break"
25 none all all 68% all all Python_ClassDeclaration: [Python_Decorators]* "class" Python_Class_Definition [Python_ClassSuper] ':' Python_StatementBlock
17 all none 53% all |   Python_ClassSuper: '(' [Python_EndOfLine] [Python_WhatSuper] ')'
    |   |   Python_MoreTypes: ',' Python_Type
9 all none none |   |   Python_WhatSuper: Python_Type [Python_ClassSuper] [Python_MoreTypes]*
170 all Python_ContinueStatement: "continue"
    Python_DeleteStatement: "del" Python_ExpressionList
    Python_ExecStatement: "exec" Python_Expression*
882 all none 3% Python_ExpressionStatement: Python_Expression [Python_ExpressionType] [Python_Comment]
    |   Python_ExpressionType: ':' Python_Type
924 all all all all all all 2% all 0% Python_ForStatement: ["async"] "for" Python_ForWhat "in" Python_ExpressionList ':' [Python_Comment] Python_StatementBlock [Python_ForElse]
1 none all all all all |   Python_ForElse: [Python_EndOfLine] Python_ElseStartOfLine "else" ':' Python_StatementBlock
924 (none | all) |   Python_ForWhat: (Python_ForList | Python_VariableList)
    |   |   Python_ForList: '[' Python_VariableList ']'
119 all all 1.15(all) all Python_FromStatement: "from" [("."|"..")] [Python_Variable]* Python_ImportStatement
476 5% all all all all Python_Function: [Python_Decorators] ["async"] "def" Python_FunctionName Python_FunctionHeader
476 all 7% all none all |   Python_FunctionHeader: Python_Parameter_List [Python_ReturnType] ':' [Python_Comment]* Python_StatementBlock
476 (all | none) |   Python_FunctionName: (Python_Function_Definition | "__init__")
33 all all |   Python_ReturnType: "->" Python_Type
44 all 2.18 Python_GlobalStatement: ("global"|"nonlocal") Python_Variable_Definition*
1,522 all all all all 2.85(2%) 6% none Python_IfStatement: "if" Python_Expression ':' Python_StatementBlock [Python_IfElif]* [Python_IfElse] [Python_Comment]*
74 76% all all all all all |   Python_IfElif: [Python_EndOfLine] Python_ElseStartOfLine "elif" Python_Expression ':' Python_StatementBlock
97 5% all all all all |   Python_IfElse: [Python_EndOfLine] Python_ElseStartOfLine "else" ':' Python_StatementBlock
284 all all 3% 2.88(3%) none Python_ImportStatement: "import" Python_ImportWhat [Python_FromImportAs] [Python_MoreImports]* [Python_Comment]
9 all all |   Python_FromImportAs: "as" Python_Variable
303 1.17 |   Python_ImportFile: Python_Variable*
284 (none | 99% | 1%) |   Python_ImportWhat: (Python_ImportList | Python_ImportFile | '*')
    |   |   Python_ImportList: '(' Python_ImportListItem [Python_FromImportAs] ')'
    |   |   |   Python_ImportListItem: [Python_Expression] [Python_FromImportAs] [Python_MoreImportListItem]* [',']
    |   |   |   |   Python_MoreImportListItem: ',' Python_Expression [Python_FromImportAs]
23 all all none |   Python_MoreImports: ',' Python_ImportFile [Python_FromImportAs]
10 all Python_PassStatement: "pass"
2 all all Python_QuitStatement: "quit" [Python_Expression]
12 all 1.00(all) Python_RaiseStatement: "raise" [Python_RaiseCondition]*
12 all none |   Python_RaiseCondition: Python_Expression [Python_RaiseFrom]
    |   |   Python_RaiseFrom: "from" Python_Expression
594 all all 94% 2% Python_ReturnStatement: "return" ["await"] [Python_ExpressionList] [Python_Comment]
3,289 (78% | 22% | 0%) Python_StatementBlock: (Python_MultilineStatement | Python_SameLineStatement | "...")
2,557 1% all 2.79 |   Python_MultilineStatement: [Python_Comment] Python_EndOfLine Python_ComplexStatement*
10,443 1.01 0% |   Python_SameLineStatement: Python_Statement* [Python_Comment]
13 all all none all 1.00(all) 8% none Python_TryStatement: "try" ':' [Python_Comment] Python_StatementBlock [Python_TryExcept]* [Python_TryElse] [Python_TryFinally]
1 none all all all all |   Python_TryElse: [Python_EndOfLine] Python_ElseStartOfLine "else" ':' Python_StatementBlock
13 none all all 1.00(92%) all all |   Python_TryExcept: [Python_EndOfLine] Python_ElseStartOfLine "except" [Python_TryExceptClause]* ':' Python_StatementBlock
12 all 75% |   |   Python_TryExceptClause: Python_Expression [Python_TryExceptAs]
9 all all |   |   |   Python_TryExceptAs: "as" Python_Variable
    |   Python_TryFinally: [Python_EndOfLine] Python_ElseStartOfLine "finally" ':' Python_StatementBlock
    Python_TypeDeclaration: Python_Variable ':' Python_Type
115 all all all all none Python_WhileStatement: "while" Python_Expression ':' Python_StatementBlock [Python_WhileElse]
    |   Python_WhileElse: [Python_EndOfLine] Python_ElseStartOfLine "else" ':' Python_StatementBlock
28 all all 1.00 all all Python_WithStatement: ["async"] "with" Python_WithItem* ':' Python_StatementBlock
28 all all |   Python_WithItem: Python_Expression [Python_WithItemAs]
28 all all |   |   Python_WithItemAs: "as" Python_Expression
4 all all Python_YieldStatement: "yield" [Python_YieldWhat]
4 (none | all) |   Python_YieldWhat: (Python_YieldFrom | Python_ExpressionList)
    |   |   Python_YieldFrom: "from" Python_Expression

Terminals = 14 (instances=54,286)
Tokens = 160 (instances=192,932)

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