Small fix

This commit is contained in:
Krzosa Karol
2024-06-06 13:38:11 +02:00
parent 322f9f27a8
commit 73ebb34787
5 changed files with 16 additions and 6 deletions

View File

@@ -1,6 +1,6 @@
# Compiler front-end in a single-header-file C library # 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!** - **User has full control over compilation!**
- **No dependencies, permissive license, single file that compile both in C and C++!** - **No dependencies, permissive license, single file that compile both in C and C++!**

View File

@@ -184,6 +184,7 @@ int main(int argc, char **argv) {
else IO_Printf("%-50s - ERROR\n", "add_instrumentation"); else IO_Printf("%-50s - ERROR\n", "add_instrumentation");
} }
#if 0
if (!ShouldRun("wasm_playground") && UseClang) { if (!ShouldRun("wasm_playground") && UseClang) {
OS_MakeDir("wasm_playground"); 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"); 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"); if (result == 0) IO_Printf("%-50s - OK\n", "wasm_playground");
else IO_Printf("%-50s - ERROR\n", "wasm_playground"); else IO_Printf("%-50s - ERROR\n", "wasm_playground");
} }
#endif
if (ShouldRun("use_as_data_format_with_typechecking")) { if (ShouldRun("use_as_data_format_with_typechecking")) {
bool result = use_as_data_format_with_typechecking(); bool result = use_as_data_format_with_typechecking();

View File

@@ -7763,7 +7763,11 @@ LC_FUNCTION LC_Token *LC_MatchKeyword(LC_Intern intern) {
// Pratt expression parser // Pratt expression parser
// Based on this really good article: https://matklad.github.io/2020/04/13/simple-but-powerful-pratt-parsing.html // Based on this really good article: https://matklad.github.io/2020/04/13/simple-but-powerful-pratt-parsing.html
// clang-format off // 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) { LC_FUNCTION LC_Precedence LC_GetPrecedence(LC_PrecedenceKind p, LC_TokenKind kind) {
if (p == LC_PrecedenceKind_Prefix) goto Prefix; if (p == LC_PrecedenceKind_Prefix) goto Prefix;
if (p == LC_PrecedenceKind_Infix) goto Infix; if (p == LC_PrecedenceKind_Infix) goto Infix;

View File

@@ -102,7 +102,11 @@ LC_FUNCTION LC_Token *LC_MatchKeyword(LC_Intern intern) {
// Pratt expression parser // Pratt expression parser
// Based on this really good article: https://matklad.github.io/2020/04/13/simple-but-powerful-pratt-parsing.html // Based on this really good article: https://matklad.github.io/2020/04/13/simple-but-powerful-pratt-parsing.html
// clang-format off // 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) { LC_FUNCTION LC_Precedence LC_GetPrecedence(LC_PrecedenceKind p, LC_TokenKind kind) {
if (p == LC_PrecedenceKind_Prefix) goto Prefix; if (p == LC_PrecedenceKind_Prefix) goto Prefix;
if (p == LC_PrecedenceKind_Infix) goto Infix; if (p == LC_PrecedenceKind_Infix) goto Infix;

View File

@@ -115,12 +115,12 @@ void WASM_EXPORT(test)(void) {
LC_Intern name = LC_ILit("file"); LC_Intern name = LC_ILit("file");
LC_AddSingleFilePackage(name, LC_Lit("file.lc")); LC_AddSingleFilePackage(name, LC_Lit("file.lc"));
LC_ASTRefList packages = LC_ParseAndResolve(name); LC_ParseAndResolve(name);
if (L->errors == 0) { if (L->errors == 0) {
LC_BeginStringGen(L->arena); LC_BeginStringGen(L->arena);
for (LC_ASTRef *it = packages.first; it; it = it->next) LC_GenCHeader(it->ast); for (LC_ASTRef *it = L->ordered_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.last; it; it = it->next) LC_GenCImpl(it->ast);
LC_String result = LC_EndStringGen(L->arena); LC_String result = LC_EndStringGen(L->arena);
LC_String code_output = LC_Lit("//\n// Code output\n//"); LC_String code_output = LC_Lit("//\n// Code output\n//");