Moved lambda from rules[0] to its own memory

This commit is contained in:
Devine Lu Linvega 2024-04-22 20:15:33 -07:00
parent 701d2c43a5
commit f7e0e74888
1 changed files with 6 additions and 6 deletions

View File

@ -6,7 +6,7 @@ typedef struct {
} Rule; } Rule;
static int flip, quiet, rmin = 0xff, rmax = 0x00, cycles = 0x10000; static int flip, quiet, rmin = 0xff, rmax = 0x00, cycles = 0x10000;
static Rule rules[0x1000], *rules_ = rules + 1; static Rule rules[0x1000], *rules_ = rules, lambda;
static char dict[0x8000], *dict_ = dict; static char dict[0x8000], *dict_ = dict;
static char bank_a[0x4000], *src_ = bank_a; static char bank_a[0x4000], *src_ = bank_a;
static char bank_b[0x4000], *dst_ = bank_b; static char bank_b[0x4000], *dst_ = bank_b;
@ -179,14 +179,14 @@ rewrite(void)
} }
if(c == '?' && s[1] == '(') { /* lambda */ if(c == '?' && s[1] == '(') { /* lambda */
cap = walk(s + 1); cap = walk(s + 1);
r = &rules[0], r->id = -1; lambda.id = -1;
r->a = dict_, s = parse_frag(s + 2); lambda.a = dict_, s = parse_frag(s + 2);
r->b = dict_, parse_frag(s), s = cap; lambda.b = dict_, parse_frag(s), s = cap;
while(*s == ' ') s++; while(*s == ' ') s++;
return run_rule(r, s); return run_rule(&lambda, s);
} }
for(r = rules + 1; r < rules_; r++) for(r = rules; r < rules_; r++)
if(run_rule(r, s)) return 1; if(run_rule(r, s)) return 1;
} }
*dst_++ = last = c; *dst_++ = last = c;