summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorLLLL Colonq <llll@colonq>2026-04-26 22:55:20 -0400
committerLLLL Colonq <llll@colonq>2026-04-26 22:55:20 -0400
commit63051c6f1cf59e468cb4175deea83c82888d18c2 (patch)
tree8b43f64dd8a1932aa886283a63d49688b149b5a6 /src/main.c
parente38591e34fb46b433485e8decbe0ea3ec964fdbe (diff)
Working assemblerHEADmaster
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c47
1 files changed, 6 insertions, 41 deletions
diff --git a/src/main.c b/src/main.c
index 5ca07f2..4728f11 100644
--- a/src/main.c
+++ b/src/main.c
@@ -14,49 +14,14 @@ int main(int argc, char **argv) {
pit_install_library_essential(rt);
pit_install_library_io(rt);
pit_install_library_plist(rt);
+ pit_install_library_alist(rt);
pit_install_library_bytestring(rt);
rj_install_library(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) {
- pit_eval(rt, p);
- if (pit_runtime_print_error(rt)) {
- exit(1);
- }
- }
+ if (argc < 2) {
+ pit_repl(rt);
+ } else {
+ pit_load_file(rt, argv[1]);
+ if (pit_runtime_print_error(rt)) return -1;
}
return 0;
}