Compare commits

..

No commits in common. "b98579699db53d8d72a3128405d4d70ff36b8266" and "13bb7399aa36b375ce3bb2c4ce03333cdb071e10" have entirely different histories.

2 changed files with 8 additions and 66 deletions

View File

@ -343,29 +343,6 @@ char* compile(tSyntaxElement* syntaxtree) {
compile_exit_tag(&result); compile_exit_tag(&result);
} else if (strcmp(token->content.string, "return") == 0) {
compile_enter_tag(&result);
string_append(&result, "return ");
string_append_free(&result,compile_expression(token->next));
compile_exit_tag(&result);
} else if (strcmp(token->content.string, "run") == 0) {
compile_enter_tag(&result);
string_append(&result, "run ");
string_append_free(&result,compile_expression(token->next));
if (token->next->next != NULL) {
string_append(&result, " with ");
string_append_free(&result,compile_expression(token->next->next));
}
compile_exit_tag(&result);
} else if (strcmp(token->content.string, "if") == 0) { } else if (strcmp(token->content.string, "if") == 0) {
compile_enter_tag(&result); compile_enter_tag(&result);
@ -439,29 +416,6 @@ char* compile(tSyntaxElement* syntaxtree) {
compile_exit_tag(&result); compile_exit_tag(&result);
} else if (strcmp(token->content.string, "transform") == 0) {
compile_enter_tag(&result);
string_append(&result, "transform ");
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));
string_append(&result, " as ");
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, "endtransform");
compile_exit_tag(&result);
} else if (strcmp(token->content.string, "for") == 0) { } else if (strcmp(token->content.string, "for") == 0) {
compile_enter_tag(&result); compile_enter_tag(&result);

View File

@ -26,10 +26,9 @@ bool replace(tSyntaxElement* tree, tProcessingData* pd) {
return false; return false;
} }
bool process_mod(tSyntaxElement* tree, tProcessingData* pdata) { void process_mod(tSyntaxElement* tree, tProcessingData* pdata) {
tProcessingData* pd = pdata; tProcessingData* pd = pdata;
bool b = false;
while (1) { while (1) {
@ -39,8 +38,7 @@ bool process_mod(tSyntaxElement* tree, tProcessingData* pdata) {
if (tree->type == TOKEN) { if (tree->type == TOKEN) {
switch (pd->type) { switch (pd->type) {
case REPLACE: case REPLACE:
if (replace(tree,pd)) replace(tree,pd);
b = true;
break; break;
case FUNCTION: case FUNCTION:
break; break;
@ -54,8 +52,6 @@ bool process_mod(tSyntaxElement* tree, tProcessingData* pdata) {
} }
return b;
} }
bool process_find(tSyntaxElement* tree, tProcessingData** p_pdata) { bool process_find(tSyntaxElement* tree, tProcessingData** p_pdata) {
@ -133,12 +129,11 @@ bool process_find(tSyntaxElement* tree, tProcessingData** p_pdata) {
} }
bool process(tSyntaxElement* tree, tProcessingData* pdata) { void process(tSyntaxElement* tree, tProcessingData* pdata) {
tProcessingData* pd = pdata; tProcessingData* pd = pdata;
bool deffound = false; bool deffound = false;
bool didreplace = false;
tProcessingData* firstpd = NULL; tProcessingData* firstpd = NULL;
@ -152,29 +147,22 @@ bool process(tSyntaxElement* tree, tProcessingData* pdata) {
deffound = process_find(tree, &pd); deffound = process_find(tree, &pd);
if (tree->next != NULL) { if (tree->next != NULL) {
if (process(tree->next, pd)) process(tree->next, pd);
didreplace = true;
} }
if (!deffound) { if (!deffound) {
if (se_istraversable(tree)) if (se_istraversable(tree))
if (process(tree->content.syntax, pd)) process(tree->content.syntax, pd);
didreplace = true;
if (process_mod(tree, pd)) process_mod(tree, pd);
didreplace = true;
} }
if (pd != pdata) if (pd != pdata)
free(pd); free(pd);
if (firstpd != pd && firstpd != NULL) { if (firstpd != pd && firstpd != NULL)
free(firstpd); free(firstpd);
if (didreplace)
process(tree, NULL);
}
return didreplace;
} }