Guest User

Untitled

a guest
Jan 23rd, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. grammar mpinter;
  2.  
  3. prog :
  4. ;
  5.  
  6. MethodDecl
  7. : public Type id ( ParamList?) {VarDecl* Statement* return Exp;}
  8.  
  9. ParamList
  10. : Type id ParamRest*
  11. ;
  12.  
  13. ParamRest
  14. : ',' Type id
  15. ;
  16.  
  17. Type
  18. : 'int'[]
  19. | 'boolean'
  20. | 'int'
  21. | 'id'
  22. ;
  23.  
  24. Statement
  25. : '{' Statement* '}'
  26. | 'if' '(' Exp ')' Statement 'else' Statement
  27. | 'while' '(' Exp' )' Statement
  28. | 'System.out.println''(' Exp ')';
  29. | id = Exp;
  30. | id '[' Exp ']' = Exp;
  31. ;
  32.  
  33.  
  34.  
  35. Exp
  36. : Exp op Exp
  37. | Exp '[' Exp ']'
  38. | Exp . length
  39. | Exp . id ( ExpList )?
  40. | 'true'
  41. | 'false'
  42. | id
  43. | 'hinteger' [+|-]? [0-9]*
  44. | 'this'
  45. | 'new' 'int' [ Exp ]
  46. | 'new' id '(' _ ')'
  47. | '!' Exp
  48. | '(' Exp ')'
  49. ;
  50.  
  51.  
  52. ExpList
  53. : Exp ExpRest*
  54. ;
  55.  
  56. ExpRest
  57. : ',' Exp
  58. ;
  59.  
  60. id
  61. : ('a-z' | 'A-Z') ('a-z'|'_'|'0-9')*
  62. ;
  63.  
  64. op
  65. : &&
  66. | +
  67. | -
  68. | *
  69. | <
  70. ;
Add Comment
Please, Sign In to add comment