From e8ca2af9bc837cbcf28fd8968f0d2093e6570b73 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 05:32:55 +0500 Subject: [PATCH] Add if as an expression --- src/compile.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/compile.c b/src/compile.c index 72c5374..a8753c4 100644 --- a/src/compile.c +++ b/src/compile.c @@ -158,8 +158,23 @@ char* compile_expression(tSyntaxElement* syntaxelement) { } else { - string_append(&result,token->content.string); - compile_genexec(&result, token); + if (strcmp(token->content.string, "if") == 0) { + + string_append(&result,compile_expression_wrapped(token->next)); + string_append(&result,"?"); + + string_append(&result,compile_expression_wrapped(token->next->next)); + string_append(&result,":"); + + string_append(&result,compile_expression_wrapped(token->next->next->next)); + + } + else { + + string_append(&result,token->content.string); + compile_genexec(&result, token); + + } } break;