Eagle Legacy Modernization, LLC

Rust Grammar

Main program: Rust_Program

Rust syntax:

 Count  Terminals:
  Rust_BinaryNumber: A binary number
  Rust_Character_Literal: Literal quotes:' escape:\ doubled:no multiline:no
  Rust_Comment: /* comment */ or // comment to end of line
1 Rust_Function_Definition: An identifier
  Rust_HexNumber: A hex number
4 Rust_Identifier_Reference: An identifier
4 Rust_Literal: Literal quotes:" escape:\ doubled:no multiline:no
  Rust_Module_Definition: An identifier
8 Rust_Number: Number exponent_chars:Ee suffix_chars:LlFfDd trailing_period:yes ignore_char:_
  Rust_Variable_Definition: An identifier
 Count  Statistics(*) Tokens:
    Rust_AdditiveExpression: Rust_Expression ("+"|"-") Rust_Expression
    Rust_AsExpression: Rust_Expression "AS" Rust_Type
    Rust_AssignmentExpression: Rust_Expression ("="|"+="|"-=") Rust_Expression
    Rust_BitwiseExpression: Rust_Expression ("&"|"|"|"^") Rust_Expression
    Rust_BorrowExpression: '&' Rust_Expression
    Rust_BuiltIn: ("false"|"true")
    Rust_CastExpression: ("i32"|"f64") "::" "from" '(' Rust_Expression ')'
    Rust_EqualityExpression: Rust_Expression ("=="|"!=") Rust_Expression
    Rust_ExpressionArray: '&' '[' Rust_Expression* ']'
    Rust_LogicalAndExpression: Rust_Expression "&&" Rust_Expression
    Rust_LogicalOrExpression: Rust_Expression ("||"|"^") Rust_Expression
    Rust_MethodInvocation: Rust_MethodWhat ['!'] '(' [Rust_Expression]* ')'
    |   Rust_MethodClass: Rust_Identifier_Reference "::" Rust_Variable
    |   Rust_MethodWhat: (Rust_MethodClass | Rust_Variable)
2 all all all Rust_MultiplicativeExpression: Rust_Expression ("*"|"/"|"%") Rust_Expression
    Rust_NegativeExpression: '-' Rust_Expression
    Rust_NotExpression: '!' Rust_Expression
4 all 3.00 all Rust_ParenthesizedExpression: '(' Rust_Expression* ')'
1 all all all Rust_RangeExpression: Rust_Expression (".."|"..=") [Rust_Expression]
    Rust_RelationalExpression: Rust_Expression ("<"|">"|"<="|">=") Rust_Expression
    Rust_ShiftExpression: Rust_Expression (">>>"|"<<"|">>") Rust_Expression
    Rust_Subfield: Rust_Expression '.' Rust_Expression
    Rust_SubscriptExpression: Rust_Expression '[' Rust_Expression ']'
3 all Rust_VariableExpression: Rust_Variable
    Rust_FindMethod: Rust_Variable '.' "find" '(' Rust_Expression ')'
    Rust_FormatFunction: "format" '!' '(' Rust_Expression* ')'
    Rust_LenMethod: Rust_Expression '.' "len" '(' ')'
    Rust_PowMethod: Rust_Expression '.' ("pow"|"powf") '(' Rust_Expression ')'
4 all all all 1.50 all none Rust_PrintlnFunction: "println" '!' '(' Rust_Expression* ')' [';']
    Rust_RevMethod: Rust_Expression '.' "rev" '(' ')'
    Rust_StartsWithMethod: Rust_Expression '.' "starts_with" '(' Rust_Expression ')'
    Rust_ToStringMethod: Rust_Expression '.' ("as_str"|"to_string") '(' ')'
    Rust_TrimMethod: Rust_Expression '.' "trim" '(' ')'
29 (none | none | 28% | 14% | none | 10% | none | none | none | none | 10% | none | none | 14% | none | none | 14% | none | none | none | none | none | none | none | none | none | 7% | none | none | none | none | none | none | none | 3% | none | none) Rust_Expression: (Rust_BinaryNumber | Rust_HexNumber | Rust_Number | Rust_Literal | Rust_Character_Literal | Rust_Underscore | Rust_MethodInvocation | Rust_NegativeExpression | Rust_NotExpression | Rust_BuiltIn | Rust_VariableExpression | Rust_CastExpression | Rust_FormatFunction | Rust_ParenthesizedExpression | Rust_ExpressionArray | Rust_BorrowExpression | Rust_PrintlnFunction | Rust_FindMethod | Rust_SubscriptExpression | Rust_LenMethod | Rust_PowMethod | Rust_RevMethod | Rust_StartsWithMethod | Rust_ToStringMethod | Rust_TrimMethod | Rust_Subfield | Rust_MultiplicativeExpression | Rust_AdditiveExpression | Rust_ShiftExpression | Rust_RelationalExpression | Rust_EqualityExpression | Rust_BitwiseExpression | Rust_LogicalAndExpression | Rust_LogicalOrExpression | Rust_RangeExpression | Rust_AsExpression | Rust_AssignmentExpression)
1 all all all all none all none all Rust_Function: ["pub"] "fn" Rust_Function_Definition '(' [Rust_Parameter]* ')' [Rust_FunctionReturns] Rust_Block_Statement
    |   Rust_FunctionReturns: "->" Rust_Type
    |   Rust_Parameter: Rust_Variable_Definition ':' Rust_Type
    Rust_Module: ["pub"] "mod" Rust_Module_Definition Rust_Module_Body
    |   Rust_Module_Body: (';' | Rust_Block_Statement)
1 1.00 Rust_Program: Rust_TopElement*
1 (none | all | none | none | none) |   Rust_TopElement: (Rust_Comment | Rust_Function | Rust_Module | Rust_Use | Rust_Statement)
7 (none | 14% | none | none | none | 14% | none | 14% | none | none | none | none | 57%) Rust_Statement: (Rust_Comment | Rust_Block_Statement | Rust_ConstStatement | Rust_BreakStatement | Rust_IfStatement | Rust_ForStatement | Rust_LetStatement | Rust_MatchStatement | Rust_ReturnStatement | Rust_Use | Rust_WhileStatement | Rust_FunctionCall | Rust_ExpressionStatement)
    Rust_Type: (Rust_TypeArray | Rust_TypePrimitive)
    |   Rust_TypeArray: '&' ''' "static" '[' Rust_Type ']'
    |   Rust_TypePrimitive: [Rust_TypePrimitiveStatic] ("bool"|"f64"|"isize"|"i32"|"str"|"&str"|"String"|"usize"|"u32")
    |   |   Rust_TypePrimitiveStatic: '&' ''' "static"
    Rust_Use: ["pub"] "use" Rust_Identifier_Reference* ';'
4 all Rust_Variable: Rust_Identifier_Reference
2 all 1.00 all Rust_Block_Statement: '{' Rust_Statement* '}'
    Rust_BreakStatement: "break" [';']
    Rust_ConstStatement: ["pub"] ("const"|"static") Rust_Variable_Definition ':' Rust_Type [Rust_Data_Initial] ';'
    |   Rust_Data_Initial: '=' Rust_Expression
4 all none Rust_ExpressionStatement: Rust_Expression [';']
1 all all all all all Rust_ForStatement: "for" Rust_Variable "in" Rust_Expression Rust_Statement
    Rust_FunctionCall: Rust_MethodInvocation [';']
    Rust_IfStatement: "if" Rust_Expression Rust_Statement [Rust_IfElseClause]
    |   Rust_IfElseClause: "else" Rust_Statement
    Rust_LetStatement: "let" ["mut"] Rust_Variable [Rust_DataInitialize] [Rust_AsType] [';']
    |   Rust_AsOperator: (':' | "as")
    |   Rust_AsType: Rust_AsOperator Rust_Type
    |   Rust_DataInitialize: '=' Rust_Expression
1 all all all 4.00 all Rust_MatchStatement: "match" Rust_Expression '{' Rust_MatchClause* '}'
4 (all | none | none) |   Rust_MatchClause: (Rust_CaseClause | Rust_DefaultClause | Rust_Comment)
4 all all 1.00(all) all |   |   Rust_CaseClause: Rust_Expression "=>" [Rust_Statement]* [',']
    |   |   Rust_DefaultClause: '_' "=>" [Rust_Statement]* [',']
    Rust_ReturnStatement: "return" Rust_Expression [';']
    Rust_WhileStatement: "while" Rust_Expression [Rust_Comment] Rust_Statement

Terminals = 10 (instances=17)
Tokens = 67 (instances=73)

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