From 73ebb347879cc49d93954c429cdd2bd1433dc6a6 Mon Sep 17 00:00:00 2001 From: Krzosa Karol Date: Thu, 6 Jun 2024 13:38:11 +0200 Subject: [PATCH] Small fix --- README.md | 2 +- build_file.cpp | 2 ++ lib_compiler.h | 6 +++++- src/compiler/parse.c | 6 +++++- src/wasm_playground/wasm_main.c | 6 +++--- 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 388a948..0e7e663 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Compiler front-end in a single-header-file C library -I have no illusions here, this is not the next big language. What I propose is very simple, "a return to C", a language that is smaller but with modern features, distributed as a dependency free, easy to use single-header-file library. Add compiler checks, generate code, do whatever floats your boat. Enjoy. +I have no illusions here, this is not the next big language. What I propose is very simple - a return to C. Not to the language as it was, but a return to the ideal of 'C'. A return to something in it - that is more then it. A small language supplemented with modern ideas - distributed as a dependency free, easy to use single-header-file library. - **User has full control over compilation!** - **No dependencies, permissive license, single file that compile both in C and C++!** diff --git a/build_file.cpp b/build_file.cpp index 9de7d1f..1c130bd 100644 --- a/build_file.cpp +++ b/build_file.cpp @@ -184,6 +184,7 @@ int main(int argc, char **argv) { else IO_Printf("%-50s - ERROR\n", "add_instrumentation"); } +#if 0 if (!ShouldRun("wasm_playground") && UseClang) { OS_MakeDir("wasm_playground"); int result = Run("clang --target=wasm32 -mbulk-memory -Oz -Wno-writable-strings --no-standard-libraries -Wl,--strip-all -Wl,--import-memory -Wl,--no-entry -o wasm_playground/playground.wasm ../src/wasm_playground/wasm_main.c -DOS_WASM=1"); @@ -212,6 +213,7 @@ int main(int argc, char **argv) { if (result == 0) IO_Printf("%-50s - OK\n", "wasm_playground"); else IO_Printf("%-50s - ERROR\n", "wasm_playground"); } +#endif if (ShouldRun("use_as_data_format_with_typechecking")) { bool result = use_as_data_format_with_typechecking(); diff --git a/lib_compiler.h b/lib_compiler.h index 98eaaf0..7f80074 100644 --- a/lib_compiler.h +++ b/lib_compiler.h @@ -7763,7 +7763,11 @@ LC_FUNCTION LC_Token *LC_MatchKeyword(LC_Intern intern) { // Pratt expression parser // Based on this really good article: https://matklad.github.io/2020/04/13/simple-but-powerful-pratt-parsing.html // clang-format off -LC_FUNCTION LC_Precedence LC_MakePrecedence(int left, int right) { return {left, right}; } +LC_FUNCTION LC_Precedence LC_MakePrecedence(int left, int right) { + LC_Precedence result = {left, right}; + return result; +} + LC_FUNCTION LC_Precedence LC_GetPrecedence(LC_PrecedenceKind p, LC_TokenKind kind) { if (p == LC_PrecedenceKind_Prefix) goto Prefix; if (p == LC_PrecedenceKind_Infix) goto Infix; diff --git a/src/compiler/parse.c b/src/compiler/parse.c index d4da2d4..ad26786 100644 --- a/src/compiler/parse.c +++ b/src/compiler/parse.c @@ -102,7 +102,11 @@ LC_FUNCTION LC_Token *LC_MatchKeyword(LC_Intern intern) { // Pratt expression parser // Based on this really good article: https://matklad.github.io/2020/04/13/simple-but-powerful-pratt-parsing.html // clang-format off -LC_FUNCTION LC_Precedence LC_MakePrecedence(int left, int right) { return {left, right}; } +LC_FUNCTION LC_Precedence LC_MakePrecedence(int left, int right) { + LC_Precedence result = {left, right}; + return result; +} + LC_FUNCTION LC_Precedence LC_GetPrecedence(LC_PrecedenceKind p, LC_TokenKind kind) { if (p == LC_PrecedenceKind_Prefix) goto Prefix; if (p == LC_PrecedenceKind_Infix) goto Infix; diff --git a/src/wasm_playground/wasm_main.c b/src/wasm_playground/wasm_main.c index 4c899e5..16f82ad 100644 --- a/src/wasm_playground/wasm_main.c +++ b/src/wasm_playground/wasm_main.c @@ -115,12 +115,12 @@ void WASM_EXPORT(test)(void) { LC_Intern name = LC_ILit("file"); LC_AddSingleFilePackage(name, LC_Lit("file.lc")); - LC_ASTRefList packages = LC_ParseAndResolve(name); + LC_ParseAndResolve(name); if (L->errors == 0) { LC_BeginStringGen(L->arena); - for (LC_ASTRef *it = packages.first; it; it = it->next) LC_GenCHeader(it->ast); - for (LC_ASTRef *it = packages.first; it; it = it->next) LC_GenCImpl(it->ast); + for (LC_ASTRef *it = L->ordered_packages.first; it; it = it->next) LC_GenCHeader(it->ast); + for (LC_ASTRef *it = L->ordered_packages.last; it; it = it->next) LC_GenCImpl(it->ast); LC_String result = LC_EndStringGen(L->arena); LC_String code_output = LC_Lit("//\n// Code output\n//");