| Goal | ::= | "MAIN" StmtList "END" ( Procedure )* <EOF> |
| StmtList | ::= | ( ( Label )? Stmt )* |
| Procedure | ::= | Label "[" IntegerLiteral "]" StmtExp |
| Stmt | ::= | NoOpStmt |
| | | ErrorStmt | |
| | | CJumpStmt | |
| | | JumpStmt | |
| | | HStoreStmt | |
| | | HLoadStmt | |
| | | MoveStmt | |
| | | PrintStmt | |
| | | ALoadStmt | |
| NoOpStmt | ::= | "NOOP" |
| ErrorStmt | ::= | "ERROR" |
| CJumpStmt | ::= | "CJUMP" Reg Label |
| JumpStmt | ::= | "JUMP" Label |
| HStoreStmt | ::= | "HSTORE" Reg IntegerLiteral Reg |
| HLoadStmt | ::= | "HLOAD" Reg Reg IntegerLiteral |
| MoveStmt | ::= | "MOVE" Reg Exp |
| PrintStmt | ::= | "PRINT" SimpleExp |
| ALoadStmt | ::= | "ALOAD" Reg SpilledArg |
| Exp | ::= | Call |
| | | HAllocate | |
| | | BinOp | |
| | | SimpleExp | |
| StmtExp | ::= | "BEGIN" StmtList "RETURN" SimpleExp "END" |
| Call | ::= | "CALL" SimpleExp "(" ( Reg )* ")" |
| HAllocate | ::= | "HALLOCATE" SimpleExp |
| BinOp | ::= | Operator Reg SimpleExp |
| Operator | ::= | "AND" |
| | | "LT" | |
| | | "PLUS" | |
| | | "MINUS" | |
| | | "TIMES" | |
| SpilledArg | ::= | "SPILLEDARG" IntegerLiteral |
| SimpleExp | ::= | Reg |
| | | IntegerLiteral | |
| | | Label | |
| Reg | ::= | "a0" |
| | | "a1" | |
| | | "a2" | |
| | | "a3" | |
| | | "t0" | |
| | | "t1" | |
| | | "t2" | |
| | | "t3" | |
| | | "t4" | |
| | | "t5" | |
| | | "t6" | |
| | | "t7" | |
| | | "s0" | |
| | | "s1" | |
| | | "s2" | |
| | | "s3" | |
| | | "s4" | |
| | | "s5" | |
| | | "s6" | |
| | | "s7" | |
| | | "t8" | |
| | | "t9" | |
| IntegerLiteral | ::= | <INTEGER_LITERAL> |
| Label | ::= | <IDENTIFIER> |