Add "assert" and "fn"
This commit is contained in:
parent
c8189f5ec1
commit
d30a715d06
@ -145,7 +145,7 @@ char* compile_gensplit(tSyntaxElement* se, char* operator) {
|
||||
if (token->next != NULL) {
|
||||
|
||||
if (token->next->type == TOKEN)
|
||||
string_append_free(&result,token->next->content.string);
|
||||
string_append(&result,token->next->content.string);
|
||||
else
|
||||
string_append(&result,compile_expression_wrapped(token->next));
|
||||
|
||||
@ -266,19 +266,23 @@ char* compile_expression(tSyntaxElement* syntaxelement) {
|
||||
}
|
||||
|
||||
case STRING:
|
||||
return NULL;
|
||||
case NONE:
|
||||
case NEWTREE:
|
||||
return NULL;
|
||||
string_append(&result, "()");
|
||||
break;
|
||||
}
|
||||
|
||||
} else {
|
||||
string_append(&result, "()");
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case NEWTREE:
|
||||
case NONE:
|
||||
free(result);
|
||||
return NULL;
|
||||
string_append(&result, "()");
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
@ -367,6 +371,25 @@ char* compile(tSyntaxElement* syntaxtree) {
|
||||
|
||||
}
|
||||
|
||||
} else if (strcmp(token->content.string, "fn") == 0) {
|
||||
|
||||
compile_enter_tag(&result);
|
||||
|
||||
string_append(&result, "macro ");
|
||||
string_append_free(&result, compile_expression(token->next));
|
||||
|
||||
compile_exit_tag(&result);
|
||||
|
||||
|
||||
string_append_free(&result, compile(token->next->next));
|
||||
|
||||
|
||||
compile_enter_tag(&result);
|
||||
|
||||
string_append(&result, "endmacro");
|
||||
|
||||
compile_exit_tag(&result);
|
||||
|
||||
} else if (strcmp(token->content.string, "verbatim") == 0) {
|
||||
|
||||
compile_enter_tag(&result);
|
||||
@ -383,6 +406,18 @@ char* compile(tSyntaxElement* syntaxtree) {
|
||||
string_append(&result, " endverbatim");
|
||||
compile_exit_tag(&result);
|
||||
|
||||
} else if (strcmp(token->content.string, "assert") == 0) {
|
||||
|
||||
compile_enter_tag(&result);
|
||||
string_append(&result, "require ");
|
||||
|
||||
string_append_free(&result, compile_expression(token->next));
|
||||
|
||||
string_append(&result, " returning ");
|
||||
|
||||
string_append_free(&result, compile_expression(token->next->next));
|
||||
compile_exit_tag(&result);
|
||||
|
||||
} else {
|
||||
|
||||
string_append(&result, "{#");
|
||||
|
@ -85,7 +85,7 @@ bool process_find(tSyntaxElement* tree, tProcessingData** p_pdata) {
|
||||
|
||||
deffound = true;
|
||||
|
||||
} else if (strcmp(token->content.string,"fn") == 0 &&
|
||||
} else if (strcmp(token->content.string,"#fn") == 0 &&
|
||||
token->next != NULL && token->next->type == TOKEN &&
|
||||
token->next->next != NULL && se_istraversable(token->next->next) &&
|
||||
token->next->next->next != NULL) {
|
||||
|
Loading…
Reference in New Issue
Block a user