Add for loops

This commit is contained in:
bʰedoh₂ swé 2024-06-11 18:55:20 +05:00
parent 099bb1d600
commit 74bf888a84

View File

@ -399,6 +399,50 @@ char* compile(tSyntaxElement* syntaxtree) {
compile_exit_tag(&result); compile_exit_tag(&result);
} else if (strcmp(token->content.string, "for") == 0) {
compile_enter_tag(&result);
string_append(&result, "for ");
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));
compile_exit_tag(&result);
string_append_free(&result, compile(token->next->next));
compile_enter_tag(&result);
string_append(&result, "endfor");
compile_exit_tag(&result);
} else if (strcmp(token->content.string, "formap") == 0) {
compile_enter_tag(&result);
string_append(&result, "for ");
string_append_free(&result, compile_expression(token->next->content.syntax));
string_append(&result, ", ");
string_append_free(&result, compile_expression(token->next->content.syntax->next));
string_append(&result, " in ");
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, "endfor");
compile_exit_tag(&result);
} else if (strcmp(token->content.string, "verbatim") == 0) { } else if (strcmp(token->content.string, "verbatim") == 0) {
compile_enter_tag(&result); compile_enter_tag(&result);