Advertisement
Guest User

Untitled

a guest
Sep 21st, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.78 KB | None | 0 0
  1. program -> declaration-list { int void }
  2. declaration-list -> declaration declaration-list` { int void }
  3. declaration-list` -> declaration declaration-list` | empty { int void empty }
  4. declaration -> type-specfier "ID" declaration` { int void }
  5. declaration` -> var-declaration` | "(" params ")" compound-stmt { ; [ ( }
  6. var-declaration` -> ";" | "[" "NUM" "]" ";" { ; [ }
  7. type-specfier -> "int" | "void" { int void }
  8. fun-declaration -> type-specifier "ID" "(" params ")" compound-stmt { int void }
  9. params -> "int" "ID" param` params-list` | "void" { int void }
  10. params` -> "ID" param` params-list` | empty { ID empty }
  11. params-list` -> "," type-specifier "ID" param` params-list` | empty { , empty }
  12. param` -> "[" "]" | empty { [ empty }
  13. compound-stmt -> "{" local-declarations statement-list "}" { { }
  14. local-declarations -> local-declarations` { empty int void }
  15. local-declarations` -> type-specfier "ID" var-declaration` local-declarations` | empty { empty int void }
  16. statement-list -> statement-list` { ; ID ( NUM { if while return empty }
  17. statement-list` -> statement statement-list` | empty { ; ID ( NUM { if while return empty }
  18. statement -> expression-stmt | compound-stmt | selection-stmt | iteration-stmt | return-stmt { ; ID ( NUM { if while return }
  19. expression-stmt -> expression ";" | ";" { ; ID ( NUM }
  20. selection-stmt -> "if" "(" expression ")" statement selection-stmt` { if }
  21. selection-stmt` -> empty | "else" statement { empty else }
  22. iteration-stmt -> "while" "(" expression ")" statement { while }
  23. return-stmt -> "return" return-stmt` { return }
  24. return-stmt` -> ";" | expression ";" { ; ID ( NUM }
  25. expression -> "ID" expression` | "(" expression ")" term` additive-expression` simple-expression` | "NUM" term` additive-expression` simple-expression` { ID ( NUM }
  26. expression` -> var` expression`` | "(" args ")" term` additive-expression` simple-expression` { empty [ ( }
  27. expression`` -> "=" expression | term` additive-expression` simple-expression` { = empty * / }
  28. var` -> empty | "[" expression "]" { empty [ }
  29. simple-expression` -> relop additive-expression | empty { empty <= < > >= == != }
  30. relop -> "<=" | "<" | ">" | ">=" | "==" | "!=" { <= < > >= == != }
  31. additive-expression -> term additive-expression` { ( NUM ID }
  32. additive-expression` -> addop term additive-expression` | empty { empty + - }
  33. addop -> "+" | "-" { + - }
  34. term -> factor term` { ( NUM ID }
  35. term` -> mulop factor term` | empty { empty * / }
  36. mulop -> "*" | "/" { * / }
  37. factor -> "(" expression ")" | "ID" factor` | "NUM" { ( NUM ID }
  38. factor` -> var` | "(" args ")" { empty [ ( }
  39. args -> arg-list | empty { ID ( NUM empty }
  40. arg-list -> expression arg-list` { ID ( NUM }
  41. arg-list` -> "," expression arg-list` | empty { , empty}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement