X-Git-Url: https://git.hcoop.net/hcoop/domtool2.git/blobdiff_plain/42198578566be256bbdebf22757f41edef4aa6ee..06bd821502f57dcb4ef89295b221fc2b9a4f1ae3:/src/errormsg.sml diff --git a/src/errormsg.sml b/src/errormsg.sml index 25b7161..5c04589 100644 --- a/src/errormsg.sml +++ b/src/errormsg.sml @@ -6,6 +6,7 @@ structure ErrorMsg :> ERRORMSG = struct (* Initial values of compiler state variables *) val anyErrors = ref false + val anyWarnings = ref false val errorText = ref "" val fileName = ref "" val lineNum = ref 1 @@ -17,14 +18,14 @@ structure ErrorMsg :> ERRORMSG = (* Reset compiler to initial state *) fun reset() = (anyErrors:=false; + anyWarnings:=false; errorText:=""; fileName:=""; lineNum:=1; linePos:=[1]; sourceStream:=TextIO.stdIn) - (* Print the given error message *) - fun error posopt (msg:string) = + fun notify f prefix posopt (msg:string) = let val (startpos, endpos) = Option.getOpt (posopt, (0, 0)) fun look(pos,a::rest,n) = @@ -34,13 +35,16 @@ structure ErrorMsg :> ERRORMSG = else look(pos,rest,n-1) | look _ = print "0.0" in - anyErrors := true; + f (); print (!fileName); print ":"; look(startpos, !linePos, !lineNum); if startpos=endpos then () else (print "-"; look(endpos, !linePos, !lineNum)); - app print [":error: ", msg, "\n"] + app print [":", prefix, ": ", msg, "\n"] end + val error = notify (fn () => anyErrors := true) "error" + val warning = notify (fn () => anyWarnings := true) "warning" + val dummyLoc = (0, 0) exception Error