- type program = stm list
-
- structure Print =
- struct
-
- fun pp_binop ADD = "+"
- | pp_binop SUB = "-"
- | pp_binop MUL = "*"
- | pp_binop DIV = "/"
- | pp_binop MOD = "%"
-
- fun pp_exp (CONST(x)) = Word32Signed.toString x
- | pp_exp (TEMP(t)) = Temp.name t
- | pp_exp (BINOP (binop, e1, e2)) =
- "(" ^ pp_exp e1 ^ " " ^ pp_binop binop ^ " " ^ pp_exp e2 ^ ")"
-
- fun pp_stm (MOVE (e1,e2)) =
- pp_exp e1 ^ " <-- " ^ pp_exp e2
- | pp_stm (RETURN e) =
- "return " ^ pp_exp e
-
- fun pp_program (nil) = ""
- | pp_program (stm::stms) = pp_stm stm ^ "\n" ^ pp_program stms
- end