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 /src | |
parent | 991d4095ba596c55ef4d043a496d5cf63fd667d1 (diff) |
Add a check stub
Diffstat (limited to 'src')
-rw-r--r-- | src/check.c | 42 | ||||
-rw-r--r-- | src/main.c | 3 |
2 files changed, 45 insertions, 0 deletions
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; |