summaryrefslogtreecommitdiff
path: root/pit/src/parser.c
diff options
context:
space:
mode:
authorLLLL Colonq <llll@colonq>2026-10-23 20:47:43 -0400
committerLLLL Colonq <llll@colonq>2026-10-23 20:48:45 -0400
commitdb58f43065c3b397754bb9efcb4a7376b2538131 (patch)
tree81452d262163237e82821e0eb5e518e581fa9276 /pit/src/parser.c
parent62ab8e0b42a57bd794941f030b4c3140d6f7c744 (diff)
pit: Add tests, fix binding bugHEADmaster
Diffstat (limited to 'pit/src/parser.c')
-rw-r--r--pit/src/parser.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/pit/src/parser.c b/pit/src/parser.c
index 6c633c9..2541344 100644
--- a/pit/src/parser.c
+++ b/pit/src/parser.c
@@ -80,9 +80,10 @@ pit_value pit_parse(pit_runtime *rt, pit_parser *st, bool *eof) {
return PIT_NIL;
case PIT_LEX_TOKEN_LPAREN: {
pit_value ret = PIT_NIL;
+ pit_value term = PIT_NIL;
while (!match(st, PIT_LEX_TOKEN_RPAREN)) {
if (match(st, PIT_LEX_TOKEN_DOT)) {
- ret = pit_parse(rt, st, eof);
+ term = pit_parse(rt, st, eof);
if (match(st, PIT_LEX_TOKEN_RPAREN)) {
break;
} else {
@@ -97,14 +98,17 @@ pit_value pit_parse(pit_runtime *rt, pit_parser *st, bool *eof) {
return PIT_NIL; /* if we hit an error, stop!*/
}
}
- ret = pit_value_list_reverse(rt, ret);
- if (pit_value_sort(ret) == PIT_VALUE_SORT_REF) {
+ while (ret != PIT_NIL) {
+ term = pit_value_cons(rt, pit_value_cons_car(rt, ret), term);
+ ret = pit_value_cons_cdr(rt, ret);
+ }
+ if (pit_value_sort(term) == PIT_VALUE_SORT_REF) {
pit_annotation a = {0};
a.line = rt->source_line;
a.column = rt->source_column;
- pit_annotation_set(rt, pit_value_as_ref(rt, ret), a);
+ pit_annotation_set(rt, pit_value_as_ref(rt, term), a);
}
- return ret;
+ return term;
}
case PIT_LEX_TOKEN_LSQUARE: {
pit_value ret = PIT_NIL;