Fix multiple statements

This commit is contained in:
bʰedoh₂ swé 2024-06-11 02:53:49 +05:00
parent eda259dfbf
commit b673f99433

View File

@ -135,38 +135,46 @@ char* compile(tSyntaxElement* syntaxtree) {
char* result = calloc(1,sizeof(char)); char* result = calloc(1,sizeof(char));
if (se_istraversable(syntaxtree)) { while (1) {
if (syntaxtree->content.syntax->type == TOKEN) { if (se_istraversable(syntaxtree)) {
tSyntaxElement* token = syntaxtree->content.syntax; if (syntaxtree->content.syntax->type == TOKEN) {
if (strcmp(token->content.string, "def") == 0) { tSyntaxElement* token = syntaxtree->content.syntax;
} else
if (strcmp(token->content.string, "set") == 0) { if (strcmp(token->content.string, "def") == 0) {
} else
compile_enter_tag(&result); if (strcmp(token->content.string, "set") == 0) {
string_append(&result, "set "); compile_enter_tag(&result);
string_append(&result,token->next->content.string);
string_append(&result,"=");
string_append(&result,compile_expression(token->next->next));
compile_exit_tag(&result); string_append(&result, "set ");
string_append(&result,token->next->content.string);
string_append(&result,"=");
string_append(&result,compile_expression(token->next->next));
} else compile_exit_tag(&result);
if (strcmp(token->content.string, "print") == 0) { } else
string_append(&result, "{{"); if (strcmp(token->content.string, "print") == 0) {
string_append(&result,compile_expression(token->next));
string_append(&result, "}}"); string_append(&result, "{{");
string_append(&result,compile_expression(token->next));
string_append(&result, "}}");
}
} }
} }
if (syntaxtree->next != NULL)
syntaxtree = syntaxtree->next;
else break;
} }
return result; return result;