diff options
author | Marvin Borner | 2023-04-13 16:44:53 +0200 |
---|---|---|
committer | Marvin Borner | 2023-04-13 16:44:53 +0200 |
commit | 43996255f614ac57deb2fc0666f221853c60b343 (patch) | |
tree | 0d7837a2522ded082a17722f7b51fd305918bac4 /src/parse.c | |
parent | 3fec61c52b2636397012b82219e1ae5d19fc9fc0 (diff) |
Options and fixes
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); } |