diff options
Diffstat (limited to 'src/parse.c')
-rw-r--r-- | src/parse.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/parse.c b/src/parse.c index 5233354..ff01bf0 100644 --- a/src/parse.c +++ b/src/parse.c @@ -56,7 +56,7 @@ static struct term *parse_bloc_bblc(const char *term, size_t *bit) (*bit) += 2; res = new_term(ABS); res->u.abs.term = parse_bloc_bblc(term, bit); - } else if (!BIT_AT(*bit) && BIT_AT(*bit + 1) && !BIT_AT(*bit)) { + } else if (!BIT_AT(*bit) && BIT_AT(*bit + 1) && !BIT_AT(*bit + 2)) { (*bit) += 3; res = new_term(APP); res->u.app.lhs = parse_bloc_bblc(term, bit); @@ -68,14 +68,15 @@ static struct term *parse_bloc_bblc(const char *term, size_t *bit) res = new_term(VAR); res->u.var.index = *bit - cur - 1; (*bit)++; - } else if (!BIT_AT(*bit) && BIT_AT(*bit + 1) && BIT_AT(*bit)) { + } else if (!BIT_AT(*bit) && BIT_AT(*bit + 1) && BIT_AT(*bit + 2)) { (*bit) += 3; res = new_term(REF); short index = 0; - for (int i = 0; i < 16; i++) + for (int i = 0; i < 16; i++) { index |= (BIT_AT(*bit) >> (7 - (*bit % 8))) << i; + (*bit) += 1; + } res->u.ref.index = index; - (*bit) += 16; } else { (*bit)++; res = parse_bloc_bblc(term, bit); @@ -137,5 +138,6 @@ static struct term *rec_bloc(struct term *term, struct bloc_parsed *bloc) struct term *from_bloc(struct bloc_parsed *bloc) { - return rec_bloc(bloc->term, bloc); + struct term *last = bloc->entries[bloc->length - 1]; + return rec_bloc(last, bloc); } |