From 5426d9e2a6b820e34809d639838b26643df9ab17 Mon Sep 17 00:00:00 2001 From: JSDurand Date: Tue, 8 Feb 2022 00:29:10 +0800 Subject: fix errors There are multiple subtle errors in the previous version, both in the codes and in the description of the BNF format. This version should fix some problems now. This version can successfully parse the grammar of its own grammar format, which is quite nice. See test/check_reader.c for parsing this format. --- src/tuple.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/tuple.c') diff --git a/src/tuple.c b/src/tuple.c index 92f2e6a..190aa19 100644 --- a/src/tuple.c +++ b/src/tuple.c @@ -185,7 +185,9 @@ LONSTRUCT(6); static void destroy_tuple1(tuple1 tup, NUM * UNUSED len) { + /* fleprintf0("hi\n"); */ if (!(tup.initialized)) return; + /* fleprintf0("hi\n"); */ free(tup.array); } @@ -196,8 +198,11 @@ void destroy_tuple4(tuple4 tup, NUM *len) { if (!(tup.initialized)) return; - for (NUM i4 = 0; i4 < *len; i4++) + /* fleprintf("len = %ld\n", *len); */ + for (NUM i4 = 0; i4 < *len; i4++) { + /* fleprintf("i4 = %ld\n", i4); */ destroy_tuple3(*(tup.array+i4), len+1); + } free(tup.array); } @@ -296,7 +301,7 @@ add_to_tuple_6_pt_2(tuple6 *tup, NUM *len, pair2 label) if (!(((tup->array+label.x)->array+label.y)->initialized)) { SAFE_CALLOC(tuple3, ((tup->array+label.x)->array+label.y)->array, - *(len+1), goto cleanup;); + *(len+2), goto cleanup;); ((tup->array+label.x)->array+label.y)->initialized = 1; } @@ -610,6 +615,7 @@ luple5_free_1(luple5 *lup, NUM label) if (!((tuple->array+label)->initialized)) return; destroy_tuple4(*(tuple->array+label), lup->lengths+1); + /* fleprintf("label = %ld\n", label); */ (tuple->array+label)->initialized = 0; } -- cgit v1.2.3-18-g5258