Fixed issue with walking beyond rule

This commit is contained in:
Devine Lu Linvega 2024-04-04 20:35:31 -07:00
parent b7bdc5d8cb
commit 70d567011e
2 changed files with 3 additions and 3 deletions

View File

@ -1,4 +1,3 @@
<> (?x dup) (?x ?x) <> (copy ?x) (?x ?x)
<> (?x ?y swap) (?y ?x)
(A B swap) dup (copy ABC)

View File

@ -36,6 +36,7 @@ match(char *p, Rule *r)
char c, *a = r->a, *b = p; char c, *a = r->a, *b = p;
while((c = *a)) { while((c = *a)) {
if(c == '?') regs[(int)*(++a)] = b, a++, b = walk(b), c = *b; if(c == '?') regs[(int)*(++a)] = b, a++, b = walk(b), c = *b;
if(!a[0]) return b;
if(c != *b) return NULL; if(c != *b) return NULL;
a++, b++; a++, b++;
} }