summaryrefslogtreecommitdiff
path: root/src/dfa.c
diff options
context:
space:
mode:
authorJSDurand <mmemmew@gmail.com>2022-02-08 00:29:10 +0800
committerJSDurand <mmemmew@gmail.com>2022-02-08 12:33:05 +0800
commit5426d9e2a6b820e34809d639838b26643df9ab17 (patch)
tree111f2b478b671092e3f2e64a6171970b8a5cdf99 /src/dfa.c
parentaaa12504c6095b2cdfa213a3d4b269bbd5e7038a (diff)
fix errorsHEADmaster
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.
Diffstat (limited to 'src/dfa.c')
-rw-r--r--src/dfa.c11
1 files changed, 6 insertions, 5 deletions
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: