From 620a8e09aca9e882466523840bc8f0e430c92c5b Mon Sep 17 00:00:00 2001 From: Kyle Lin Date: Sun, 19 Jan 2025 03:08:06 +0800 Subject: [PATCH] Codebase cleanup Due to current shecc's implementation, modern editors with common lsp such as VSCode with C/C++ plugin is unable to properly analyze from main.c, even though the code is correct. Thus we adds some system header inclusion in certain files to resolve and suppress error message. Notice that due to current frontend's limitation, including defs.h in C source files other than main.c would result weird error, thus this is not introduced in this commit. In addition, it's annoying that VSCode always generate .vscode folder with some plugin-specific setting config files. Therefore, we also ignore it to prevent accidentally adding the config file to stage. --- .gitignore | 3 +++ src/globals.c | 3 +++ src/lexer.c | 2 ++ src/parser.c | 3 +++ 4 files changed, 11 insertions(+) diff --git a/.gitignore b/.gitignore index cb36b61b..e88b119f 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,6 @@ a.out config src/codegen.c .session.mk + +# vscode C/C++ plugin generated files +.vscode diff --git a/src/globals.c b/src/globals.c index 992bb781..b6631df1 100644 --- a/src/globals.c +++ b/src/globals.c @@ -5,6 +5,9 @@ * file "LICENSE" for information on usage and redistribution of this file. */ +#include +#include + /* Global objects */ block_list_t BLOCKS; diff --git a/src/lexer.c b/src/lexer.c index f23517df..4933ea63 100644 --- a/src/lexer.c +++ b/src/lexer.c @@ -5,6 +5,8 @@ * file "LICENSE" for information on usage and redistribution of this file. */ +#include + /* lexer tokens */ typedef enum { T_start, /* FIXME: it was intended to start the state machine. */ diff --git a/src/parser.c b/src/parser.c index 862fe4ae..1c341868 100644 --- a/src/parser.c +++ b/src/parser.c @@ -5,6 +5,9 @@ * file "LICENSE" for information on usage and redistribution of this file. */ +#include +#include + /* C language syntactic analyzer */ int global_var_idx = 0; int global_label_idx = 0;