aboutsummaryrefslogtreecommitdiff
path: root/cljcc-compiler/src/cljcc/core/exception.clj
diff options
context:
space:
mode:
Diffstat (limited to 'cljcc-compiler/src/cljcc/core/exception.clj')
-rw-r--r--cljcc-compiler/src/cljcc/core/exception.clj21
1 files changed, 21 insertions, 0 deletions
diff --git a/cljcc-compiler/src/cljcc/core/exception.clj b/cljcc-compiler/src/cljcc/core/exception.clj
new file mode 100644
index 0000000..412dfff
--- /dev/null
+++ b/cljcc-compiler/src/cljcc/core/exception.clj
@@ -0,0 +1,21 @@
+(ns cljcc.core.exception)
+
+(defn lex-error [{line :line col :col :as data}]
+ (throw (ex-info
+ (format "Invalid token at line: %s, col: %s." line col)
+ (merge {:error/type :lexer} data))))
+
+(defn parser-error [msg data]
+ (throw (ex-info msg (merge {:error/type :parser} data))))
+
+(defn analyzer-error [msg data]
+ (throw (ex-info msg (merge {:error/type :analyzer} data))))
+
+(defn tacky-error [msg data]
+ (throw (ex-info msg (merge {:error/type :tacky} data))))
+
+(defn compiler-error [msg data]
+ (throw (ex-info msg (merge {:error/type :compiler} data))))
+
+(defn emit-error [msg data]
+ (throw (ex-info msg (merge {:error/type :emit} data))))