我无法删除错误 - 错误:在以下程序中的EOF中发现语法错误

时间:2013-11-17 10:46:49

标签: sml

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;

1 个答案:

答案 0 :(得分:2)

您忘记使用end关闭结构。 另外,在声明结构时,您为签名(Expression而不是Algebra)指定了错误的名称。

structure EXPR : Algebra =
struct
    (* contents of structure *)
end (* <- this was missing *)