diff options
author | Preston Pan <preston@nullring.xyz> | 2023-01-06 20:48:56 -0800 |
---|---|---|
committer | Preston Pan <preston@nullring.xyz> | 2023-01-06 20:48:56 -0800 |
commit | c620d528fb9d9efbac559002d23857623e71df05 (patch) | |
tree | d8d6ee788cc4688a3c4a4401906fe3ce25307855 /src/visitor.c | |
parent | 0771dd0e1a143c17920d65d5de8d010aa433ce1c (diff) |
whoops, fixed concat. Include in the making
Diffstat (limited to 'src/visitor.c')
-rw-r--r-- | src/visitor.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/visitor.c b/src/visitor.c index 14ea404..25fb7cd 100644 --- a/src/visitor.c +++ b/src/visitor.c @@ -60,6 +60,10 @@ bool is_built_in(ast_t *e) { strcmp(cmp, "atof") == 0 || strcmp(cmp, "ftoa") == 0) return true; + /* I/O and other operating system stuff */ + if (strcmp(cmp, "exit") == 0 || strcmp(cmp, "readin") == 0 || + strcmp(cmp, "read") == 0) + return true; return false; } @@ -422,10 +426,22 @@ ast_t *eval_list(visitor_t *v, ast_t *e) { char *ret = malloc((string_len1 + string_len2) * sizeof(char)); strcat(ret, arg1->string_value); strcat(ret, arg2->string_value); - return ret; + return init_ast_string(ret); + } else + eval_error(v, e); + } else if (strcmp(function->string_value, "exit") == 0) { + if (cmp != 1) + eval_error(v, e); + + ast_t *arg1 = eval_expr(v, args->car); + + if (arg1->type == AST_INT) { + int code = arg1->int_value; + exit(code); } else eval_error(v, e); } + return NULL; } /* printf("debug 2\n"); */ |