aboutsummaryrefslogtreecommitdiffstats
path: root/src/bytecode/errors.c
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2021-10-22 09:59:31 +0200
committerBad Diode <bd@badd10de.dev>2021-10-22 09:59:31 +0200
commiteeff5e273f22aa28e81ab080e9ffdce85ac394b8 (patch)
tree71d11c76be7c0bb649099bb55e6181f9b7c6c8a8 /src/bytecode/errors.c
parent5bd694fc7071bfb76b9f65c89d253b2b4e18cf63 (diff)
downloadbdl-eeff5e273f22aa28e81ab080e9ffdce85ac394b8.tar.gz
bdl-eeff5e273f22aa28e81ab080e9ffdce85ac394b8.zip
Prepare skeleton for bytecode interpreter
Diffstat (limited to 'src/bytecode/errors.c')
-rw-r--r--src/bytecode/errors.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/bytecode/errors.c b/src/bytecode/errors.c
new file mode 100644
index 0000000..d957cfa
--- /dev/null
+++ b/src/bytecode/errors.c
@@ -0,0 +1,29 @@
1#include "errors.h"
2
3static const char* error_msgs[] = {
4 [ERR_UNKNOWN] = "error: something unexpected happened",
5 [ERR_UNMATCHED_STRING] = "error: unmatched string delimiter",
6 [ERR_UNBALANCED_PAREN] = "error: unbalanced parentheses",
7 [ERR_NOT_IMPLEMENTED] = "error: not implemented",
8 [ERR_EOF_REACHED] = "error: EOF reached",
9 [ERR_UNKNOWN_TOKEN] = "error: unknown token",
10 [ERR_UNKNOWN_OBJ_TYPE] = "error: can't eval unknown object type",
11 [ERR_NOT_A_SYMBOL] = "error: object is not a symbol",
12 [ERR_SYMBOL_NOT_FOUND] = "error: symbol not found",
13 [ERR_OBJ_NOT_CALLABLE] = "error: object is not callable",
14 [ERR_NOT_ENOUGH_ARGS] = "error: not enough arguments",
15 [ERR_TOO_MANY_ARGS] = "error: too many arguments",
16 [ERR_WRONG_ARG_TYPE] = "error: wrong argument type",
17 [ERR_DIVISION_BY_ZERO] = "error: division by zero",
18};
19
20static Error errors[ERR_MAX_NUMBER];
21static size_t errors_n = 0;
22static bool supress_errors = false;
23
24void
25error_push(Error error) {
26 if (errors_n < ERR_MAX_NUMBER) {
27 errors[errors_n++] = error;
28 }
29}