G2A Many GEOs
SHARE
TWEET

Untitled

a guest Mar 23rd, 2018 17 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Original EBNF grammar
  2.  
  3. prog         -> {classDecl} {funcDef} 'program' funcBody ';'
  4. classDecl    -> 'class' 'id' '{' {varDecl} {funcDecl} '}' ';'
  5. funcDecl     -> type 'id' '(' fParams ')' ';'
  6. funcHead     -> type ['id' 'sr'] 'id' '(' fParams ')'
  7. funcDef      -> funcHead funcBody ';'
  8. funcBody     -> '{' {varDecl} {statement} '}'
  9. varDecl      -> type 'id' {arraySize} ';'
  10. statement    -> assignStat ';'
  11.               | 'if' '(' expr ')' 'then' statBlock 'else' statBlock ';'
  12.               | 'for' '(' type 'id' assignOp expr ';' relExpr ';' assignStat ')' statBlock ';'
  13.               | 'get' '(' variable ')' ';'
  14.               | 'put' '(' expr ')' ';'
  15.               | 'return' '(' expr ')' ';'
  16. assignStat   -> variable assignOp expr
  17. statBlock    -> '{' {statement} '}' | statement | EPSILON
  18. expr         -> arithExpr | relExpr
  19. relExpr      -> arithExpr relOp arithExpr
  20. arithExpr    -> arithExpr addOp term | term
  21. sign         -> '+' | '-'
  22. term         -> term multOp factor | factor
  23. factor       -> variable
  24.               | functionCall
  25.               | 'intNum' | 'floatNum'
  26.               | '(' arithExpr ')'
  27.               | 'not' factor
  28.               | sign factor
  29. variable     -> {idnest} 'id' {indice}
  30. functionCall -> {idnest} 'id' '(' aParams ')'
  31. idnest       -> 'id' {indice} '.'
  32.               | 'id' '(' aParams ')' '.'
  33. indice       -> '[' arithExpr ']'
  34. arraySize    -> '[' 'intNum' ']'
  35. type         -> 'int' | 'float' | 'id'
  36. fParams      -> type 'id' {arraySize} {fParamsTail} | EPSILON
  37. aParams      -> expr {aParamsTail} | EPSILON
  38. fParamsTail  -> ',' type 'id' {arraySize}
  39. aParamsTail  -> ',' expr
  40. assignOp     -> '='
  41. relOp        -> 'eq' | 'neq' | 'lt' | 'gt' | 'leq' | 'geq'
  42. addOp        -> '+' | '-' | 'or'
  43. multOp       -> '*' | '/' | 'and'
  44.  
  45.  
  46.  
  47. The point at which I am right now
  48.  
  49. prog            -> multClassDecl multFuncDef_ 'program' funcBody ';'
  50. classDecl       -> 'class' 'id'  '{' multVarDecl multFuncDecl '}' ';'
  51. multClassDecl   -> classDecl multClassDecl | EPSILON
  52. funcDecl        -> type 'id' '(' fParams ')' ';'
  53. multFuncDecl    -> funcDecl multFuncDecl | EPSILON
  54. funcHead        -> type 'id' funcHead_
  55. funcHead_       -> 'sr' 'id' '(' fParams ')'
  56.                  | '(' fParams ')'
  57. funcDef         -> funcHead funcBody ';'
  58. multFuncDef_    -> funcDef multFuncDef_ | EPSILON
  59. funcBody        -> '{' multVarDecl multStatement '}'
  60. varDecl         -> type 'id' multArraySize ';'
  61. multVarDecl     -> varDecl multVarDecl | EPSILON
  62. statement       -> assignStat ';'
  63.                  | 'if' '(' expr ')' 'then' statBlock 'else' statBlock ';'
  64.                  | 'for' '(' type 'id' assignOp expr ';' relExpr ';' assignStat ')' statBlock ';'
  65.                  | 'get' '(' variable ')' ';'
  66.                  | 'put' '(' expr ')' ';'
  67.                  | 'return' '(' expr ')' ';'
  68. multStatement   -> statement multStatement | EPSILON
  69. assignStat      -> variable assignOp expr
  70. statBlock       -> '{' multStatement '}' | statement | EPSILON
  71. expr            -> arithExpr expr_
  72. expr_           -> relOp arithExpr | EPSILON
  73. relExpr         -> arithExpr relOp arithExpr
  74. arithExpr       -> term arithExpr_
  75. arithExpr_      -> addOp term arithExpr_ | EPSILON
  76. sign            -> '+' | '-'
  77. term            -> factor term_
  78. term_           -> multOp factor term_ | EPSILON
  79. postCall        -> multIndice | '(' aParams ')'
  80. factor          -> multIdnest 'id' postCall
  81.                  | 'intNum' | 'floatNum'
  82.                  | '(' arithExpr ')'
  83.                  | 'not' factor
  84.                  | sign factor
  85. variable        -> multIdnest 'id' multIndice
  86. functionCall    -> multIdnest 'id' '(' aParams ')'
  87. multIdnest      -> idnest multIdnest | EPSILON
  88. idnest          -> 'id' idnest_
  89. idnest_         -> multIndice '.' | '(' aParams ')' '.'
  90. indice          -> '[' arithExpr ']'
  91. multIndice      -> indice multIndice | EPSILON
  92. arraySize       -> '[' 'intNum' ']'
  93. multArraySize   -> arraySize multArraySize | EPSILON
  94. type            -> 'int' | 'float' | 'id'
  95. fParams         -> type 'id' multArraySize multFParamsTail | EPSILON
  96. aParams         -> expr multAParamsTail | EPSILON
  97. fParamsTail     -> ',' type 'id' multArraySize
  98. multFParamsTail -> fParamsTail multFParamsTail | EPSILON
  99. aParamsTail     -> ',' expr
  100. multAParamsTail -> aParamsTail multAParamsTail | EPSILON
  101. assignOp        -> '='
  102. relOp           -> 'eq' | 'neq' | 'lt' | 'gt' | 'leq' | 'geq'
  103. addOp           -> '+' | '-' | 'or'
  104. multOp          -> '*' | '/' | 'and'
RAW Paste Data
Ledger Nano X - The secure hardware wallet
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top