From 97f84ccace4e634b4e02178a702818e69292dc9f Mon Sep 17 00:00:00 2001 From: Malte Voos Date: Mon, 8 Jul 2024 22:01:42 +0200 Subject: implement top-level definitions --- src/error/Error.ml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/error') diff --git a/src/error/Error.ml b/src/error/Error.ml index 555d41c..9a5ea9e 100644 --- a/src/error/Error.ml +++ b/src/error/Error.ml @@ -1,6 +1,7 @@ module Message = struct type t = + | FileError | IllegalCharacter | SyntaxError | UnboundVariable @@ -10,6 +11,7 @@ struct let default_severity : t -> Asai.Diagnostic.severity = function + | FileError -> Error | IllegalCharacter -> Error | SyntaxError -> Error | UnboundVariable -> Error @@ -19,19 +21,23 @@ struct let short_code : t -> string = function + (* operating system errors *) + | FileError -> "E101" (* parser errors *) - | IllegalCharacter -> "E101" - | SyntaxError -> "E102" + | IllegalCharacter -> "E201" + | SyntaxError -> "E202" (* elaboration errors *) - | UnboundVariable -> "E201" - | TypeMismatch -> "E202" - | NotInferable -> "E203" + | UnboundVariable -> "E301" + | TypeMismatch -> "E302" + | NotInferable -> "E303" (* misc *) | Bug -> "E900" end include Asai.Reporter.Make(Message) +let file_open_error ~path ~msg = fatalf FileError + "unable to open file '%s': %s" path msg let illegal_character ~loc char = fatalf ~loc IllegalCharacter "illegal character '%s'" (Char.escaped char) let syntax_error ~loc = fatalf ~loc SyntaxError -- cgit 1.4.1