signature Algebra =
sig
datatype Symex = ICOEFF of int
| COEFF of string
| VAR of string
| POWER of Symex * int
| NEG of Symex
| PLUS of Symex * Symex
| MULT of Symex * Symex
val showSymex : Symex -> unit
end;
structure EXPR : Expression =
struct
datatype Symex = ICOEFF of int
| COEFF of string
| VAR of string
| POWER of Symex * int
| NEG of Symex
| PLUS of Symex * Symex
| MULT of Symex * Symex
fun showSymex("")= ""
| showSymex(PLUS (x,y)) = "(" ^ showSymex(x) ^ " + " ^ showSymex(y) ^ ")"
| showSymex(MULT (x,y)) = "(" ^ showSymex(x) ^ " * " ^ showSymex(y) ^ ")"
| showSymex(ICOEFF (x)) = "(" ^ showSymex(x) ^ ")"
| showSymex(VAR (x) ) = "(" ^ showSymex(x) ^ ")"
| showSymex(COEFF (x)) = "(" ^ showSymex(x) ^ ")"
| showSymex(POWER(x,y)) = "(" ^ showSymex(x) ^ " ^ " ^ showSymex(y) ^ ")"
| showSymex(NEG (x,y) ) = "(" ^ "-" ^ showSymex(x) ^ ")"
| showSymex(x) = a;
答案 0 :(得分:2)
您忘记使用end
关闭结构。
另外,在声明结构时,您为签名(Expression
而不是Algebra
)指定了错误的名称。
structure EXPR : Algebra =
struct
(* contents of structure *)
end (* <- this was missing *)