diff --git a/src/compile.c b/src/compile.c index 2344d2b..76e90bf 100644 --- a/src/compile.c +++ b/src/compile.c @@ -136,7 +136,7 @@ void compile_genexec(char** result, tSyntaxElement* se){ string_append(result,")"); } -char* compile_gensplit(tSyntaxElement* se, char* operator) { +char* compile_gensplit(tSyntaxElement* se, char* operator, bool dosplit) { tSyntaxElement* token = se; char* result = malloc(sizeof(char)); result[0] = '\0'; @@ -151,9 +151,11 @@ char* compile_gensplit(tSyntaxElement* se, char* operator) { if (token->next->next != NULL) { - string_append(&result," "); + if (dosplit) + string_append(&result," "); string_append(&result,operator); - string_append(&result," "); + if (dosplit) + string_append(&result," "); } @@ -198,7 +200,7 @@ char* compile_expression(tSyntaxElement* syntaxelement) { char* operator = token->content.string; - string_append_free(&result, compile_gensplit(token, operator)); + string_append_free(&result, compile_gensplit(token, operator, !!strcmp(".", token->content.string))); } else { @@ -232,13 +234,13 @@ char* compile_expression(tSyntaxElement* syntaxelement) { } else if (strcmp(token->content.string, "list") == 0) { string_append(&result,"["); - string_append_free(&result,compile_gensplit(token, ",")); + string_append_free(&result,compile_gensplit(token, ",", true)); string_append(&result,"]"); } else if (strcmp(token->content.string, "range") == 0) { string_append(&result,"["); - string_append_free(&result,compile_gensplit(token, "..")); + string_append_free(&result,compile_gensplit(token, "..", true)); string_append(&result,"]"); } else if (strcmp(token->content.string, "map") == 0) {