summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2020-08-24 13:13:08 +0200
committerJo-Philipp Wich <jo@mein.io>2020-08-25 20:38:15 +0200
commitba38eff1c22cab91fc1a47a24dc7c03a458640aa (patch)
treec518e0c53d4c8ff3a36c516cfe5b33619847ed29
parent4861601872a5c7f0d10c94251f7a2c3a08da05d4 (diff)
lexer.c, eval.c: move T_EXCEPTION definition to lexer header
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
-rw-r--r--eval.c3
-rw-r--r--lexer.c2
-rw-r--r--lexer.h5
3 files changed, 5 insertions, 5 deletions
diff --git a/eval.c b/eval.c
index d49356b..8860078 100644
--- a/eval.c
+++ b/eval.c
@@ -25,9 +25,6 @@
#include <stdlib.h>
#include <stdarg.h>
-#define T_MAX (sizeof(tokennames) / sizeof(tokennames[0]))
-#define T_EXCEPTION (T_MAX + 0)
-
static struct ut_opcode exception_tag = { .type = T_EXCEPTION };
diff --git a/lexer.c b/lexer.c
index c0fd154..67d390a 100644
--- a/lexer.c
+++ b/lexer.c
@@ -136,7 +136,7 @@ static const struct token reserved_words[] = {
{ T_IN, "in", 2 },
};
-const char *tokennames[69] = {
+const char *tokennames[__T_MAX] = {
[0] = "End of file",
[T_FUNC] = "'function'",
[T_LOCAL] = "'local'",
diff --git a/lexer.h b/lexer.h
index b8ed7bc..ff653bd 100644
--- a/lexer.h
+++ b/lexer.h
@@ -19,7 +19,10 @@
#include "ast.h"
-extern const char *tokennames[69];
+#define __T_MAX 69
+#define T_EXCEPTION (__T_MAX + 0)
+
+extern const char *tokennames[__T_MAX];
bool
utf8enc(char **out, int *rem, int code);