diff options
Diffstat (limited to 'interpreter')
-rw-r--r-- | interpreter/eval.c | 21 | ||||
-rw-r--r-- | interpreter/graphs.c | 1 | ||||
-rw-r--r-- | interpreter/lex.c | 1 | ||||
-rw-r--r-- | interpreter/parse.c | 5 | ||||
-rw-r--r-- | interpreter/print.c | 4 | ||||
-rw-r--r-- | interpreter/syntax.c | 1 | ||||
-rw-r--r-- | interpreter/syntax.h | 2 |
7 files changed, 6 insertions, 29 deletions
diff --git a/interpreter/eval.c b/interpreter/eval.c index f220435..080938c 100644 --- a/interpreter/eval.c +++ b/interpreter/eval.c @@ -11,7 +11,6 @@ typedef struct { char* name; struct node* node; - unsigned is_strict; } replacement; typedef struct replacements { @@ -21,12 +20,11 @@ typedef struct replacements { void eval(fuspel* rules, struct node** node, unsigned to_rnf); -void push_repl(replacements* repls, char* name, struct node* node, unsigned is_strict) { +void push_repl(replacements* repls, char* name, struct node* node) { while (repls->rest) repls = repls->rest; repls->rest = my_calloc(1, sizeof(replacements)); repls->rest->replacement.name = name; repls->rest->replacement.node = node; - repls->rest->replacement.is_strict = is_strict; repls->rest->rest = NULL; } @@ -39,7 +37,6 @@ void free_repls(replacements* repls) { } repls->replacement.name = NULL; repls->replacement.node = NULL; - repls->replacement.is_strict = 0; } } @@ -77,10 +74,6 @@ void replace_all(fuspel *rules, replacements* repls, struct node** node) { (*node)->var2 = NULL; use_node(*node, org_used_count - 1); } - if (repls->replacement.is_strict) { - eval(rules, node, 1); - free_node(*node, 1, 0); - } break; } } @@ -127,14 +120,12 @@ struct node*** flatten_app_args(struct node** from) { } unsigned match_expr(fuspel* rules, expression* expr, struct node** node, - replacements* repls, unsigned is_strict) { + replacements* repls) { replacements* _repls; for (_repls = repls; _repls->rest; _repls = _repls->rest); remove_redirects(*node); - is_strict |= expr->is_strict; - if (expr->kind == EXPR_INT || expr->kind == EXPR_LIST || expr->kind == EXPR_TUPLE) @@ -145,7 +136,7 @@ unsigned match_expr(fuspel* rules, expression* expr, struct node** node, return *((int*) (*node)->var1) == *((int*) expr->var1); case EXPR_NAME: - push_repl(_repls, (char*) expr->var1, *node, is_strict); + push_repl(_repls, (char*) expr->var1, *node); return 1; case EXPR_LIST: @@ -157,8 +148,8 @@ unsigned match_expr(fuspel* rules, expression* expr, struct node** node, return (*node)->var1 == NULL; return - match_expr(rules, expr->var1, (struct node**) &(*node)->var1, _repls, is_strict) && - match_expr(rules, expr->var2, (struct node**) &(*node)->var2, _repls, is_strict); + match_expr(rules, expr->var1, (struct node**) &(*node)->var1, _repls) && + match_expr(rules, expr->var2, (struct node**) &(*node)->var2, _repls); default: return 0; @@ -186,7 +177,7 @@ int match_rule(fuspel* rules, rewrite_rule* rule, struct node** node, printf("RULE: %s\n", rule->name); while (!empty_args_list(args)) { - if (!match_expr(rules, &args->elem, node, repls, 0)) { + if (!match_expr(rules, &args->elem, node, repls)) { my_free(node_args); return -1; } diff --git a/interpreter/graphs.c b/interpreter/graphs.c index d793efb..1f0dcb4 100644 --- a/interpreter/graphs.c +++ b/interpreter/graphs.c @@ -119,7 +119,6 @@ void cpy_node_to_expression(expression* dst, struct node* src) { return; free_expression(dst); - dst->is_strict = 0; dst->kind = src->kind; switch (src->kind) { diff --git a/interpreter/lex.c b/interpreter/lex.c index 8946252..94820ca 100644 --- a/interpreter/lex.c +++ b/interpreter/lex.c @@ -64,7 +64,6 @@ token_list* lex(token_list* list, char* input) { case ']': list->elem.kind = TOKEN_CLOSE_SQ; break; case '=': list->elem.kind = TOKEN_EQUALS; break; case ',': list->elem.kind = TOKEN_COMMA; break; - case '!': list->elem.kind = TOKEN_STRICT; break; default: if (input[0] == '/' && input[1] == '/') { while (input && input[0] != '\n') input++; diff --git a/interpreter/parse.c b/interpreter/parse.c index f751321..3a611e8 100644 --- a/interpreter/parse.c +++ b/interpreter/parse.c @@ -21,11 +21,6 @@ token_list* parse_name(char** name, token_list* list) { token_list* parse_simple_expression(expression* expr, token_list* list) { expression* _expr; - if (list->elem.kind == TOKEN_STRICT) { - expr->is_strict = 1; - list = list->rest; - } - switch (list->elem.kind) { case TOKEN_INT: expr->kind = EXPR_INT; diff --git a/interpreter/print.c b/interpreter/print.c index 2fb6e4b..470f133 100644 --- a/interpreter/print.c +++ b/interpreter/print.c @@ -17,7 +17,6 @@ void print_token(token* tk) { case TOKEN_CLOSE_SQ: c = ']'; break; case TOKEN_EQUALS: c = '='; break; case TOKEN_COMMA: c = ','; break; - case TOKEN_STRICT: c = '!'; break; case TOKEN_CODE: printf("code "); return; case TOKEN_IMPORT: printf("import "); return; case TOKEN_NAME: @@ -42,9 +41,6 @@ void print_expression(expression* expr) { if (!expr) return; - if (expr->is_strict) - printf("!"); - switch (expr->kind) { case EXPR_INT: printf("%d", *((int*) expr->var1)); diff --git a/interpreter/syntax.c b/interpreter/syntax.c index 00c9554..03bc2d4 100644 --- a/interpreter/syntax.c +++ b/interpreter/syntax.c @@ -32,7 +32,6 @@ unsigned char len_arg_list(arg_list* list) { void cpy_expression(expression* dst, expression* src) { free_expression(dst); dst->kind = src->kind; - dst->is_strict = src->is_strict; switch (dst->kind) { case EXPR_INT: dst->var1 = my_calloc(1, sizeof(int)); diff --git a/interpreter/syntax.h b/interpreter/syntax.h index 9153492..7fae574 100644 --- a/interpreter/syntax.h +++ b/interpreter/syntax.h @@ -12,7 +12,6 @@ typedef enum { TOKEN_CLOSE_P, /* ) */ TOKEN_COMMA, /* , */ TOKEN_COLON, /* : */ - TOKEN_STRICT, /* ! */ TOKEN_CODE, /* code */ TOKEN_IMPORT, /* import */ TOKEN_NAME, @@ -46,7 +45,6 @@ typedef enum { typedef struct { expr_kind kind; - unsigned is_strict; void* var1; void* var2; } expression; |