どこか間違っているかも知れないし、そうでなくても書き方がへぼいです。 そういうものとして読んでください。

fun interp(stm) =
    let
	datatype record = IntegerRecord of id * int

	fun interpStm(CompoundStm(s1, s2), tbl) =
	    let
		val tbl1 = interpStm(s1, tbl)
	    in
		interpStm(s2, tbl1)
	    end

	  | interpStm(AssignStm(id, exp), tbl) = 
	    let
		val (v, tbl1) = interpExp(exp, tbl)
	    in
		IntegerRecord(id, v) :: tbl1
	    end
	    
	  | interpStm(PrintStm(l), tbl) =
	    let
		val (v, tbl1) = interpExp(hd(l), tbl)
		val s = if (length l) > 1 then " " else "\n"
	    in
		print (Int.toString v);
		print s;
		if length l > 1 then
		    interpStm(PrintStm(List.drop(l, 1)), tbl1)
		else
		    tbl
	    end

	and interpExp(IdExp(id), tbl) =
	    let
		fun lookup(id, tbl) = 
		    let
			val IntegerRecord(n, v) = hd(tbl)
		    in
			if id = n then
			    v
			else if length tbl > 1 then
			    lookup(id, List.drop(tbl, 1))
			else
			    0
		    end
	    in
		(lookup(id, tbl), tbl)
	    end

	  | interpExp(NumExp(i), tbl) = (i, tbl)

	  | interpExp(OpExp(lhs, Plus,  rhs), tbl) =
	    let 
		val (lhs_value, tbl1) = interpExp(lhs, tbl)
		val (rhs_value, tbl2) = interpExp(rhs, tbl1)
	    in
		(lhs_value + rhs_value, tbl2)
	    end

	  | interpExp(OpExp(lhs, Minus, rhs), tbl) =
	    let
		val (lhs_value, tbl1) = interpExp(lhs, tbl)
		val (rhs_value, tbl2) = interpExp(rhs, tbl1)
	    in
		(lhs_value - rhs_value, tbl2)
	    end

	  | interpExp(OpExp(lhs, Times, rhs), tbl) =
	    let
		val (lhs_value, tbl1) = interpExp(lhs, tbl)
		val (rhs_value, tbl2) = interpExp(rhs, tbl1)
	    in
		(lhs_value * rhs_value, tbl2)
	    end

	  | interpExp(OpExp(lhs, Div,   rhs), tbl) =
	    let
		val (lhs_value, tbl1) = interpExp(lhs, tbl)
		val (rhs_value, tbl2) = interpExp(rhs, tbl1)
	    in
		(lhs_value div rhs_value, tbl2)
	    end

	  | interpExp(EseqExp(stm, exp), tbl) =
	    let
		val tbl1 = interpStm(stm, tbl)
	    in
		interpExp(exp, tbl1)
	    end

    in
	interpStm(stm, [])
    end