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/dfa.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/dfa.c') diff --git a/src/dfa.c b/src/dfa.c index 2edda77..f3f62fb 100644 --- a/src/dfa.c +++ b/src/dfa.c @@ -717,8 +717,8 @@ run_dfa(const dfa * const restrict table, const NUM code) if (code >= (table->data.sp.ranges+i)->beg && code <= (table->data.sp.ranges+i)->end) { #ifdef DEBUG - fleprintf("code = %ld, beg = %ld, end = %ld\n", - code, + fleprintf("i = %d, code = %ld, beg = %ld, end = %ld\n", + i, code, (table->data.sp.ranges+i)->beg, (table->data.sp.ranges+i)->end); #endif @@ -727,17 +727,18 @@ run_dfa(const dfa * const restrict table, const NUM code) return 0; break; case DFA_TYPE_SPECIAL_NEG: - for (int i = 0; i < table->data.sp.len; i++) + for (int i = 0; i < table->data.sp.len; i++) { if (code >= (table->data.sp.ranges+i)->beg && code <= (table->data.sp.ranges+i)->end) { #ifdef DEBUG - fleprintf("code = %ld, beg = %ld, end = %ld\n", - code, + fleprintf("code = %ld, i = %d, beg = %ld, end = %ld\n", + code, i, (table->data.sp.ranges+i)->beg, (table->data.sp.ranges+i)->end); #endif return 0; } + } return 1; break; case DFA_TYPE_SPECIAL_BOTH: -- cgit v1.2.3-18-g5258