generator -- Import Statements (: import java.util.LinkedList; import comp.codegen.Reg; import comp.ast.Node; :) declarations -- General Declarations (: public LinkedList instrList = new LinkedList(); :) operators -- Operators (our Node Kinds) CONST(:E_CONST:), ADD(:E_ADD:), SUB(:E_SUB:), MULT(:E_MULT:) rules -- Production Rules reg = CONST c1 (: c1.result = Reg.getNextReg(); instrList.add("loadI " + c1.val + "," + c1.result); :) : 1 | ADD a1 ( reg r1, reg r2, reg r3) (: a1.result = Reg.getNextReg(); instrList.add("add " + r1.result + "," + r2.result + "," + a1.result); :) : 1 | SUB s1 ( reg r1, reg r2, reg r3 ) (: s1.result = Reg.getNextReg(); instrList.add("sub " + r1.result + "," + r2.result + "," + s1.result); :) : 1 | MULT m1 ( reg r1, reg r2, reg r3 ) (: ... :) : 2 . end