Housekeeping

This commit is contained in:
Devine Lu Linvega 2024-04-11 09:40:04 -07:00
parent 64e8bc30ab
commit 30690c1d83
1 changed files with 11 additions and 11 deletions

View File

@ -168,28 +168,28 @@ create_rule(Rule *r, int id, char *s)
static int static int
rewrite(void) rewrite(void)
{ {
char c, last = 0, *p = dst ? bank_b : bank_a, *res; char c, last = 0, *s = dst ? bank_b : bank_a, *res;
while((c = *p) && c <= ' ') p++; while((c = *s) && c <= ' ') s++;
while((c = *p)) { while((c = *s)) {
if(spacer(last)) { if(spacer(last)) {
Rule *r; Rule *r;
if(p[0] == '<' && p[1] == '>') { if(s[0] == '<' && s[1] == '>') {
r = rules_++; r = rules_++;
p = create_rule(r, rules_ - rules - 1, p); s = create_rule(r, rules_ - rules - 1, s);
return commit_rule(r, p, 1); return commit_rule(r, s, 1);
} }
if(p[0] == '?' && p[1] == '(') { if(s[0] == '?' && s[1] == '(') {
r = &lambda; r = &lambda;
p = create_rule(&lambda, -1, p) + 1; s = create_rule(&lambda, -1, s) + 1;
if((res = match_rule(&lambda, p)) != NULL) if((res = match_rule(&lambda, s)) != NULL)
return write_rule(&lambda, last, res); return write_rule(&lambda, last, res);
} }
for(r = rules; r < rules_; r++) for(r = rules; r < rules_; r++)
if((res = match_rule(r, p)) != NULL) if((res = match_rule(r, s)) != NULL)
return write_rule(r, last, res); return write_rule(r, last, res);
} }
*outp_++ = last = c; *outp_++ = last = c;
p++; s++;
} }
*outp_++ = 0; *outp_++ = 0;
return 0; return 0;