Store lambda in rules[0]

This commit is contained in:
Devine Lu Linvega 2024-04-22 17:27:34 -07:00
parent e153eb797b
commit 8e7bbb51d7
1 changed files with 8 additions and 8 deletions

View File

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