Created an awful hack for a clean exit on die().

This commit is contained in:
2025-08-26 18:30:08 -04:00
parent 0ef44be808
commit b7b90f528b
3 changed files with 12 additions and 3 deletions

View File

@@ -1,5 +1,7 @@
1. Differentiate parameters and arguments -- params for function definitions,
arguments for function calls
EXCEPTION HANDLING: exception ast type should have as data a giant enum of
possible types, rather than a char* message. A description of each type could be
handled under the exception type and print logic. For now, executor checks
message for special exceptions e.g. exit().
Change editor to GNU Readline.
Make variables persist through lines in the editor.

View File

@@ -136,5 +136,5 @@ AST* builtin_div(size_t argc, AST** argv, Scope* parent) {
}
AST* builtin_die(size_t argc, AST** argv, Scope* parent) {
return ast_init(AST_TYPE_EXC, ast_exc_data_init("exit", NULL));
return ast_init(AST_TYPE_EXC, ast_exc_data_init("8", NULL));
}

View File

@@ -62,6 +62,13 @@ int main(int argc, char** argv) {
AST* eval = exec_start(root);
ast_print(eval);
// Awful hack to exit when die() is called, until proper exception
// handling is implemented. TODO TODO TODO PLSFIX.
if (eval->type == AST_TYPE_EXC &&
((ASTExcData*)eval->data)->msg[0] == '8') {
gc_hack_free();
exit(1);
}
gc_hack_free();
}