about summary refs log tree commit diff
path: root/lib/Reporter.ml
diff options
context:
space:
mode:
authorMalte Voos <git@mal.tc>2024-06-17 17:41:38 +0200
committerMalte Voos <git@mal.tc>2024-06-17 17:41:38 +0200
commit04d62df9fdd42c603fad7bb1b5e3fb49bf8550c1 (patch)
tree0a11c38a9f7bfad5624f0821b3a7041a9d4ff4d8 /lib/Reporter.ml
parentedcd6c17b873b11b18016c9fe6efbe47576574ae (diff)
downloadtoytt-04d62df9fdd42c603fad7bb1b5e3fb49bf8550c1.tar.gz
toytt-04d62df9fdd42c603fad7bb1b5e3fb49bf8550c1.zip
implement typechecking
Diffstat (limited to 'lib/Reporter.ml')
-rw-r--r--lib/Reporter.ml28
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/Reporter.ml b/lib/Reporter.ml
new file mode 100644
index 0000000..c86a04a
--- /dev/null
+++ b/lib/Reporter.ml
@@ -0,0 +1,28 @@
+module Message =
+struct
+  type t = 
+    | SyntaxError
+    | IllTyped
+    | UnboundVariable
+    | CannotInferType
+
+  let default_severity : t -> Asai.Diagnostic.severity =
+    function
+    | SyntaxError -> Error
+    | IllTyped -> Error
+    | UnboundVariable -> Error
+    | CannotInferType -> Error
+
+  let short_code : t -> string =
+    function
+    | SyntaxError -> "E0001"
+    | IllTyped -> "E0002"
+    | UnboundVariable -> "E0003"
+    | CannotInferType -> "E0004"
+end
+
+include Asai.Reporter.Make(Message)
+
+let invalid_local_name (name : Ast.raw_ident) = fatalf SyntaxError "invalid local variable name `%a`" Ast.dump_raw_ident name
+
+let expected_universe fmt x = fatalf IllTyped "expected a universe but got %a" fmt x
\ No newline at end of file