Store lambda in rules[0]
This commit is contained in:
parent
e153eb797b
commit
8e7bbb51d7
16
src/modal.c
16
src/modal.c
|
@ -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], lambda, *rules_ = rules;
|
static Rule rules[0x1000], *rules_ = rules + 1;
|
||||||
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;
|
||||||
|
@ -173,23 +173,23 @@ rewrite(void)
|
||||||
while((c = *s)) {
|
while((c = *s)) {
|
||||||
if(spacer(last)) {
|
if(spacer(last)) {
|
||||||
Rule *r;
|
Rule *r;
|
||||||
if(c == '<' && s[1] == '>') {
|
if(c == '<' && s[1] == '>') { /* rule */
|
||||||
r = rules_++, r->id = rules_ - rules - 1;
|
r = rules_++, r->id = rules_ - rules - 1;
|
||||||
r->a = dict_, s = parse_frag(s + 2);
|
r->a = dict_, s = parse_frag(s + 2);
|
||||||
r->b = dict_, s = parse_frag(s);
|
r->b = dict_, s = parse_frag(s);
|
||||||
while(*s == ' ') s++;
|
while(*s == ' ') s++;
|
||||||
return commit_rule(r, s, 1);
|
return commit_rule(r, s, 1);
|
||||||
}
|
}
|
||||||
if(c == '?' && s[1] == '(') {
|
if(c == '?' && s[1] == '(') { /* lambda */
|
||||||
cap = walk(s + 1);
|
cap = walk(s + 1);
|
||||||
r = &lambda, r->id = -1;
|
r = &rules[0], r->id = -1;
|
||||||
r->a = dict_, s = parse_frag(s + 2);
|
r->a = dict_, s = parse_frag(s + 2);
|
||||||
r->b = dict_, parse_frag(s), s = cap;
|
r->b = dict_, parse_frag(s), s = cap;
|
||||||
while(*s == ' ') s++;
|
while(*s == ' ') s++;
|
||||||
if((res = match_rule(&lambda, s)) != NULL)
|
r = rules;
|
||||||
return write_rule(&lambda, res);
|
} else
|
||||||
}
|
r = rules + 1;
|
||||||
for(r = rules; r < rules_; r++)
|
for(; r < rules_; r++)
|
||||||
if((res = match_rule(r, s)) != NULL)
|
if((res = match_rule(r, s)) != NULL)
|
||||||
return write_rule(r, res);
|
return write_rule(r, res);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue