Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program -> declaration-list { int void }
- declaration-list -> declaration declaration-list` { int void }
- declaration-list` -> declaration declaration-list` | empty { int void empty }
- declaration -> type-specfier "ID" declaration` { int void }
- declaration` -> var-declaration` | "(" params ")" compound-stmt { ; [ ( }
- var-declaration` -> ";" | "[" "NUM" "]" ";" { ; [ }
- type-specfier -> "int" | "void" { int void }
- fun-declaration -> type-specifier "ID" "(" params ")" compound-stmt { int void }
- params -> "int" "ID" param` params-list` | "void" { int void }
- params` -> "ID" param` params-list` | empty { ID empty }
- params-list` -> "," type-specifier "ID" param` params-list` | empty { , empty }
- param` -> "[" "]" | empty { [ empty }
- compound-stmt -> "{" local-declarations statement-list "}" { { }
- local-declarations -> local-declarations` { empty int void }
- local-declarations` -> type-specfier "ID" var-declaration` local-declarations` | empty { empty int void }
- statement-list -> statement-list` { ; ID ( NUM { if while return empty }
- statement-list` -> statement statement-list` | empty { ; ID ( NUM { if while return empty }
- statement -> expression-stmt | compound-stmt | selection-stmt | iteration-stmt | return-stmt { ; ID ( NUM { if while return }
- expression-stmt -> expression ";" | ";" { ; ID ( NUM }
- selection-stmt -> "if" "(" expression ")" statement selection-stmt` { if }
- selection-stmt` -> empty | "else" statement { empty else }
- iteration-stmt -> "while" "(" expression ")" statement { while }
- return-stmt -> "return" return-stmt` { return }
- return-stmt` -> ";" | expression ";" { ; ID ( NUM }
- expression -> "ID" expression` | "(" expression ")" term` additive-expression` simple-expression` | "NUM" term` additive-expression` simple-expression` { ID ( NUM }
- expression` -> var` expression`` | "(" args ")" term` additive-expression` simple-expression` { empty [ ( }
- expression`` -> "=" expression | term` additive-expression` simple-expression` { = empty * / }
- var` -> empty | "[" expression "]" { empty [ }
- simple-expression` -> relop additive-expression | empty { empty <= < > >= == != }
- relop -> "<=" | "<" | ">" | ">=" | "==" | "!=" { <= < > >= == != }
- additive-expression -> term additive-expression` { ( NUM ID }
- additive-expression` -> addop term additive-expression` | empty { empty + - }
- addop -> "+" | "-" { + - }
- term -> factor term` { ( NUM ID }
- term` -> mulop factor term` | empty { empty * / }
- mulop -> "*" | "/" { * / }
- factor -> "(" expression ")" | "ID" factor` | "NUM" { ( NUM ID }
- factor` -> var` | "(" args ")" { empty [ ( }
- args -> arg-list | empty { ID ( NUM empty }
- arg-list -> expression arg-list` { ID ( NUM }
- arg-list` -> "," expression arg-list` | empty { , empty}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement