summaryrefslogtreecommitdiff
path: root/src/parser.c
diff options
context:
space:
mode:
authorLLLL Colonq <llll@colonq>2026-02-24 18:53:54 -0500
committerLLLL Colonq <llll@colonq>2026-02-24 18:53:54 -0500
commita525fadf516bc5aae2c0ec648d3b8c22e9f86293 (patch)
tree79f585f2ab2130c001529fbf46d88f9196336b25 /src/parser.c
parent2b47c650a161fe2c2c4c7f4d74a19c2c6fe6021e (diff)
Add PIT_DEFAULT_MAIN
Diffstat (limited to 'src/parser.c')
-rw-r--r--src/parser.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/parser.c b/src/parser.c
index 9c112c2..b2d0f31 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -86,8 +86,18 @@ pit_value pit_parse(pit_runtime *rt, pit_parser *st, bool *eof) {
i64 scratch_reset = rt->scratch->next;
pit_value ret = PIT_NIL;
while (!match(st, PIT_LEX_TOKEN_RPAREN)) {
- pit_value *cell = pit_arena_alloc_bulk(rt->scratch, sizeof(pit_value));
- *cell = pit_parse(rt, st, eof);
+ if (match(st, PIT_LEX_TOKEN_DOT)) {
+ ret = pit_parse(rt, st, eof);
+ if (match(st, PIT_LEX_TOKEN_RPAREN)) {
+ break;
+ } else {
+ pit_error(rt, "unterminated dotted list");
+ return PIT_NIL;
+ }
+ } else {
+ pit_value *cell = pit_arena_alloc_bulk(rt->scratch, sizeof(pit_value));
+ *cell = pit_parse(rt, st, eof);
+ }
if (rt->error != PIT_NIL || (eof != NULL && *eof)) {
pit_error(rt, "unterminated list");
return PIT_NIL; /* if we hit an error, stop!*/