diff options
author | Himbeer <himbeer@disroot.org> | 2024-10-08 13:09:33 +0200 |
---|---|---|
committer | Himbeer <himbeer@disroot.org> | 2024-10-08 13:10:53 +0200 |
commit | 35b55292a4aa99bc72c6f97290c15c139f027706 (patch) | |
tree | 28676804fd44490a04cd7f5d6a71468fdeefad87 | |
parent | 991d4095ba596c55ef4d043a496d5cf63fd667d1 (diff) |
Add a check stub
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | include/check.h | 7 | ||||
-rw-r--r-- | src/check.c | 42 | ||||
-rw-r--r-- | src/main.c | 3 |
4 files changed, 54 insertions, 0 deletions
@@ -2,6 +2,7 @@ BINOUT = .bin HDR = \ + include/check.h \ include/expr.h \ include/lex.h \ include/parse.h \ @@ -9,6 +10,7 @@ HDR = \ include/utf8.h \ include/util.h OBJ = \ + src/check.o \ src/lex.o \ src/main.o \ src/parse.o \ diff --git a/include/check.h b/include/check.h new file mode 100644 index 0000000..c36909e --- /dev/null +++ b/include/check.h @@ -0,0 +1,7 @@ +#ifndef CERC_CHECK_H +#define CERC_CHECK_H +#include "parse.h" + +void check(struct ast_unit *ast); + +#endif diff --git a/src/check.c b/src/check.c new file mode 100644 index 0000000..f6a8576 --- /dev/null +++ b/src/check.c @@ -0,0 +1,42 @@ +#define _POSIX_C_SOURCE 200809L + +#include <stdarg.h> +#include <stdio.h> +#include <stdlib.h> +#include <stdnoreturn.h> +#include "lex.h" +#include "parse.h" +#include "util.h" + +static noreturn void +error(struct location loc, const char *fmt, ...) +{ + fprintf(stderr, "%s:%d:%d ", loc.file, loc.line, loc.column); + + va_list ap; + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); + + fprintf(stderr, "\n"); + exit(EXIT_CHECK); +} + +static void +check_imports(struct ast_import *imports, int n) +{ + /* TODO */ +} + +static void +check_toplevels(struct ast_toplevel *tops, int n) +{ + /* TODO */ +} + +void +check(struct ast_unit *ast) +{ + check_imports(ast->imports, ast->implen); + check_toplevels(ast->tops, ast->toplen); +} @@ -5,6 +5,7 @@ #include <stdlib.h> #include <string.h> #include <sys/stat.h> +#include "check.h" #include "lex.h" #include "parse.h" #include "util.h" @@ -44,6 +45,8 @@ main(int argc, char *argv[]) lex_init(&lexer, in, path); parse(&lexer, &ast); lex_finish(&lexer); + + check(&ast); } return EXIT_SUCCESS; |