Merged right hand side of compiler

This commit is contained in:
Devine Lu Linvega 2024-04-24 15:01:47 -07:00
parent 3dbb23319e
commit 3f5e099051
1 changed files with 8 additions and 11 deletions

View File

@ -167,12 +167,11 @@ compile_rule(Rule *r, int id, char *src)
/* left ==================================== */
r->a = dict_;
r->a = r->b = dict_;
s2 = src;
while((c = *s2) && c == ' ') s2++;
if(c == ')' || (c == '<' && s2[1] == '>')) {
r->b = dict_;
*dict_++ = 0;
return s2;
}
@ -210,6 +209,12 @@ compile_rule(Rule *r, int id, char *src)
wrapped = c == '(';
if(wrapped) s2++, cap--;
while(s2 < cap) {
if(*s2 == '?') {
*dict_++ = *s2++;
reg = find_register(r, *s2);
*dict_++ = reg >= 0 ? ('0' + reg) : *s2;
s2++;
} else
*dict_++ = *s2++;
}
s2 += wrapped;
@ -217,14 +222,6 @@ compile_rule(Rule *r, int id, char *src)
*dict_++ = 0;
src = s2;
s2 = r->b;
while((c = *s2++)) { /* right */
if(c == '?') {
reg = find_register(r, *s2);
if(reg >= 0)
*s2 = '0' + reg;
}
}
return src;
}