Compare commits
2 Commits
13bb7399aa
...
b98579699d
Author | SHA1 | Date | |
---|---|---|---|
b98579699d | |||
74d20d9f37 |
@ -343,6 +343,29 @@ char* compile(tSyntaxElement* syntaxtree) {
|
||||
|
||||
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) {
|
||||
|
||||
compile_enter_tag(&result);
|
||||
@ -416,6 +439,29 @@ char* compile(tSyntaxElement* syntaxtree) {
|
||||
|
||||
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) {
|
||||
|
||||
compile_enter_tag(&result);
|
||||
|
@ -26,9 +26,10 @@ bool replace(tSyntaxElement* tree, tProcessingData* pd) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void process_mod(tSyntaxElement* tree, tProcessingData* pdata) {
|
||||
bool process_mod(tSyntaxElement* tree, tProcessingData* pdata) {
|
||||
|
||||
tProcessingData* pd = pdata;
|
||||
bool b = false;
|
||||
|
||||
while (1) {
|
||||
|
||||
@ -38,7 +39,8 @@ void process_mod(tSyntaxElement* tree, tProcessingData* pdata) {
|
||||
if (tree->type == TOKEN) {
|
||||
switch (pd->type) {
|
||||
case REPLACE:
|
||||
replace(tree,pd);
|
||||
if (replace(tree,pd))
|
||||
b = true;
|
||||
break;
|
||||
case FUNCTION:
|
||||
break;
|
||||
@ -52,6 +54,8 @@ void process_mod(tSyntaxElement* tree, tProcessingData* pdata) {
|
||||
|
||||
}
|
||||
|
||||
return b;
|
||||
|
||||
}
|
||||
|
||||
bool process_find(tSyntaxElement* tree, tProcessingData** p_pdata) {
|
||||
@ -129,11 +133,12 @@ bool process_find(tSyntaxElement* tree, tProcessingData** p_pdata) {
|
||||
}
|
||||
|
||||
|
||||
void process(tSyntaxElement* tree, tProcessingData* pdata) {
|
||||
bool process(tSyntaxElement* tree, tProcessingData* pdata) {
|
||||
|
||||
tProcessingData* pd = pdata;
|
||||
|
||||
bool deffound = false;
|
||||
bool didreplace = false;
|
||||
|
||||
tProcessingData* firstpd = NULL;
|
||||
|
||||
@ -147,22 +152,29 @@ void process(tSyntaxElement* tree, tProcessingData* pdata) {
|
||||
deffound = process_find(tree, &pd);
|
||||
|
||||
if (tree->next != NULL) {
|
||||
process(tree->next, pd);
|
||||
if (process(tree->next, pd))
|
||||
didreplace = true;
|
||||
}
|
||||
|
||||
if (!deffound) {
|
||||
|
||||
if (se_istraversable(tree))
|
||||
process(tree->content.syntax, pd);
|
||||
if (process(tree->content.syntax, pd))
|
||||
didreplace = true;
|
||||
|
||||
process_mod(tree, pd);
|
||||
if (process_mod(tree, pd))
|
||||
didreplace = true;
|
||||
|
||||
}
|
||||
|
||||
if (pd != pdata)
|
||||
free(pd);
|
||||
|
||||
if (firstpd != pd && firstpd != NULL)
|
||||
if (firstpd != pd && firstpd != NULL) {
|
||||
free(firstpd);
|
||||
if (didreplace)
|
||||
process(tree, NULL);
|
||||
}
|
||||
|
||||
return didreplace;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user