diff --git a/src/compile.c b/src/compile.c index eefbaf1..bfd8828 100644 --- a/src/compile.c +++ b/src/compile.c @@ -135,37 +135,45 @@ char* compile(tSyntaxElement* syntaxtree) { 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) { - } else + tSyntaxElement* token = syntaxtree->content.syntax; - 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 "); - string_append(&result,token->next->content.string); - string_append(&result,"="); - string_append(&result,compile_expression(token->next->next)); + compile_enter_tag(&result); - 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, "{{"); - string_append(&result,compile_expression(token->next)); - string_append(&result, "}}"); + if (strcmp(token->content.string, "print") == 0) { + + string_append(&result, "{{"); + string_append(&result,compile_expression(token->next)); + string_append(&result, "}}"); + + } } } + + if (syntaxtree->next != NULL) + syntaxtree = syntaxtree->next; + else break; }