Break out of compilation early
This commit is contained in:
parent
dfe9b076dc
commit
3dbb23319e
33
src/modal.c
33
src/modal.c
|
@ -162,15 +162,21 @@ static char *
|
|||
compile_rule(Rule *r, int id, char *src)
|
||||
{
|
||||
int wrapped, reg;
|
||||
char c, *cap, *s, *s2;
|
||||
char c, *cap, *s2;
|
||||
r->id = id, r->ptr = 0;
|
||||
|
||||
/* left ==================================== */
|
||||
|
||||
r->a = dict_;
|
||||
s2 = src;
|
||||
|
||||
while((c = *s2) && c == ' ') s2++;
|
||||
if(c != ')' && !(c == '<' && s2[1] == '>')) {
|
||||
if(c == ')' || (c == '<' && s2[1] == '>')) {
|
||||
r->b = dict_;
|
||||
*dict_++ = 0;
|
||||
return s2;
|
||||
}
|
||||
|
||||
cap = walk(s2);
|
||||
wrapped = c == '(';
|
||||
if(wrapped) s2++, cap--;
|
||||
|
@ -185,7 +191,7 @@ compile_rule(Rule *r, int id, char *src)
|
|||
*dict_++ = *s2++;
|
||||
}
|
||||
s2 += wrapped;
|
||||
}
|
||||
|
||||
*dict_++ = 0;
|
||||
src = s2;
|
||||
|
||||
|
@ -193,23 +199,30 @@ compile_rule(Rule *r, int id, char *src)
|
|||
|
||||
r->b = dict_;
|
||||
s2 = src;
|
||||
|
||||
while((c = *s2) && c == ' ') s2++;
|
||||
if(c != ')' && !(c == '<' && s2[1] == '>')) {
|
||||
if(c == ')' || (c == '<' && s2[1] == '>')) {
|
||||
*dict_++ = 0;
|
||||
return s2;
|
||||
}
|
||||
|
||||
cap = walk(s2);
|
||||
wrapped = c == '(';
|
||||
if(wrapped) s2++, cap--;
|
||||
while(s2 < cap) *dict_++ = *s2++;
|
||||
s2 += wrapped;
|
||||
while(s2 < cap) {
|
||||
*dict_++ = *s2++;
|
||||
}
|
||||
s2 += wrapped;
|
||||
|
||||
*dict_++ = 0;
|
||||
src = s2;
|
||||
|
||||
s = r->b;
|
||||
while((c = *s++)) { /* right */
|
||||
s2 = r->b;
|
||||
while((c = *s2++)) { /* right */
|
||||
if(c == '?') {
|
||||
reg = find_register(r, *s);
|
||||
reg = find_register(r, *s2);
|
||||
if(reg >= 0)
|
||||
*s = '0' + reg;
|
||||
*s2 = '0' + reg;
|
||||
}
|
||||
}
|
||||
return src;
|
||||
|
|
Loading…
Reference in New Issue