functor Eval(ImpAst : IMPAST) : EVAL = struct

structure ImpAst = ImpAst
type store = ImpAst.var -> int
exception RuntimeError of string
			 
local 
    open ImpAst
in
(* This function is the empty store, that maps every variable to 0 *)
val empty_store = (fn (x:var) => 0)

(* You are required to implement the following function that maps an 
 * input store and a command to an output store.
 * The evaluation function must raise a RuntimeError exception when it 
 * encounters an error.
 *)		 
fun eval(c:com, s:store) = raise RuntimeError("unimplemented");
	

(* For your convenience, here is a small step evaluation function for
 * arithmetic expressions.
 *)
fun onestep_aexp(Var(x), s) = Int(s(x))
  | onestep_aexp(Plus(Int(n1), Int(n2)), s) = Int(n1 + n2)
  | onestep_aexp(Plus(Int(n), a2), s) = Plus(Int(n), onestep_aexp(a2, s))
  | onestep_aexp(Plus(a1, a2), s) = Plus(onestep_aexp(a1, s), a2)
  | onestep_aexp(Int(n), s) = raise RuntimeError("trying to take a step for Int(n)")
end      
end


