From 8f611a400d08a46a80a4e98b0b189b19acc4779e Mon Sep 17 00:00:00 2001 From: Christoffer Lerno Date: Sat, 27 Jul 2019 17:20:31 +0200 Subject: [PATCH] Lexing up and running. --- CMakeLists.txt | 7 +- src/build/build_options.c | 16 +- src/build/build_options.h | 3 + src/build/project_creation.c | 2 +- src/compiler/compiler.c | 15 + .../string_utils.c => compiler/compiler.h} | 4 +- src/compiler/compiler_common.h | 38 + src/compiler/lexer.c | 1249 +++++++++-------- src/compiler/lexer.h | 179 +-- src/compiler/malloc.c | 106 ++ src/compiler/malloc.h | 16 + src/compiler/symtab.c | 213 +++ src/compiler/symtab.h | 30 + src/compiler/tokens.c | 336 +++++ src/compiler/tokens.h | 200 +++ src/compiler_tests/shorttest.c | 97 ++ src/compiler_tests/tests.c | 93 +- src/main.c | 5 +- src/utils/errors.h | 4 +- src/utils/lib.h | 183 +++ src/utils/string_utils.h | 26 - 21 files changed, 1983 insertions(+), 839 deletions(-) create mode 100644 src/compiler/compiler.c rename src/{utils/string_utils.c => compiler/compiler.h} (82%) create mode 100644 src/compiler/compiler_common.h create mode 100644 src/compiler/malloc.c create mode 100644 src/compiler/malloc.h create mode 100644 src/compiler/symtab.c create mode 100644 src/compiler/symtab.h create mode 100644 src/compiler/tokens.c create mode 100644 src/compiler/tokens.h create mode 100644 src/compiler_tests/shorttest.c create mode 100644 src/utils/lib.h delete mode 100644 src/utils/string_utils.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 7b2ccf434..8443aad82 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,5 +14,8 @@ add_executable(c3c src/build/project_creation.c src/utils/errors.c src/utils/file_utils.c - src/utils/string_utils.c - src/compiler/lexer.c src/compiler/lexer.h src/compiler_tests/tests.c src/compiler_tests/tests.h src/compiler_tests/benchmark.c src/compiler_tests/benchmark.h) \ No newline at end of file + src/compiler/lexer.c + src/compiler/tokens.c + src/compiler/symtab.c + src/compiler_tests/tests.c + src/compiler_tests/benchmark.c src/compiler/malloc.c src/compiler/malloc.h src/compiler/compiler.c src/compiler/compiler.h) \ No newline at end of file diff --git a/src/build/build_options.c b/src/build/build_options.c index bc0cab9bf..8e7e56765 100644 --- a/src/build/build_options.c +++ b/src/build/build_options.c @@ -13,6 +13,8 @@ #include "../utils/errors.h" static const char* DEFAULT_TARGET = "default"; +static const int DEFAULT_SYMTAB_SIZE = 64 * 1024; +static const int MAX_SYMTAB_SIZE = 1024 * 1024; BuildOptions build_options; static int arg_index; @@ -46,6 +48,7 @@ static void usage(void) OUTPUT(" --path - Use this as the base directory for the current command."); OUTPUT(" --template