From a525fadf516bc5aae2c0ec648d3b8c22e9f86293 Mon Sep 17 00:00:00 2001 From: LLLL Colonq Date: Tue, 24 Feb 2026 18:53:54 -0500 Subject: Add PIT_DEFAULT_MAIN --- src/main.c | 44 +------------------------------------------- 1 file changed, 1 insertion(+), 43 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 0b9a336..086f647 100644 --- a/src/main.c +++ b/src/main.c @@ -14,47 +14,5 @@ int main(int argc, char **argv) { pit_install_library_plist(rt); pit_install_library_alist(rt); pit_install_library_bytestring(rt); - if (argc < 2) { /* run repl */ - char buf[1024] = {0}; - i64 len = 0; - pit_runtime_freeze(rt); - if (pit_runtime_print_error(rt)) { exit(1); } - setbuf(stdout, NULL); - printf("> "); - while (len < (i64) sizeof(buf) && (buf[len++] = (char) getchar()) != EOF) { - if (buf[len - 1] == '\n') { - pit_value bs, prog, res; - buf[len - 1] = 0; - bs = pit_bytes_new_cstr(rt, buf); - prog = pit_read_bytes(rt, bs); - res = pit_eval(rt, prog); - if (pit_runtime_print_error(rt)) { - rt->error = PIT_NIL; - printf("> "); - } else { - char dumpbuf[1024] = {0}; - pit_dump(rt, dumpbuf, sizeof(dumpbuf) - 1, res, true); - printf("%s\n> ", dumpbuf); - } - len = 0; - } - } - } else { /* run file */ - pit_value bs = pit_bytes_new_file(rt, argv[1]); - pit_lexer lex; - pit_parser parse; - bool eof = false; - pit_value p = PIT_NIL; - if (!pit_lexer_from_bytes(rt, &lex, bs)) { - pit_error(rt, "failed to initialize lexer"); - } - pit_parser_from_lexer(&parse, &lex); - while (p = pit_parse(rt, &parse, &eof), !eof) { - if (pit_runtime_print_error(rt)) exit(1); - pit_eval(rt, p); - if (pit_runtime_print_error(rt)) exit(1); - } - if (pit_runtime_print_error(rt)) exit(1); - } - return 0; + PIT_DEFAULT_MAIN(rt); } -- cgit v1.2.3