From 74d20d9f3795e05f8b31fb38e4040f9d7bb96cea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?b=CA=B0edoh=E2=82=82=20sw=C3=A9?= Date: Tue, 11 Jun 2024 19:44:40 +0500 Subject: [PATCH] Add some more keywords --- src/compile.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/src/compile.c b/src/compile.c index 2399cb5..fe3bf47 100644 --- a/src/compile.c +++ b/src/compile.c @@ -343,6 +343,29 @@ char* compile(tSyntaxElement* syntaxtree) { compile_exit_tag(&result); + } else if (strcmp(token->content.string, "return") == 0) { + + compile_enter_tag(&result); + + string_append(&result, "return "); + string_append_free(&result,compile_expression(token->next)); + + compile_exit_tag(&result); + + } else if (strcmp(token->content.string, "run") == 0) { + + compile_enter_tag(&result); + + string_append(&result, "run "); + string_append_free(&result,compile_expression(token->next)); + + if (token->next->next != NULL) { + string_append(&result, " with "); + string_append_free(&result,compile_expression(token->next->next)); + } + + compile_exit_tag(&result); + } else if (strcmp(token->content.string, "if") == 0) { compile_enter_tag(&result); @@ -416,6 +439,29 @@ char* compile(tSyntaxElement* syntaxtree) { compile_exit_tag(&result); + } else if (strcmp(token->content.string, "transform") == 0) { + + compile_enter_tag(&result); + + string_append(&result, "transform "); + string_append_free(&result, compile_expression(token->next->content.syntax)); + string_append(&result, " in "); + string_append_free(&result, compile_expression(token->next->content.syntax->next)); + string_append(&result, " as "); + string_append_free(&result, compile_expression(token->next->content.syntax->next->next)); + + compile_exit_tag(&result); + + + string_append_free(&result, compile(token->next->next)); + + + compile_enter_tag(&result); + + string_append(&result, "endtransform"); + + compile_exit_tag(&result); + } else if (strcmp(token->content.string, "for") == 0) { compile_enter_tag(&result);