Progress on rules compilation
This commit is contained in:
parent
53ef87a4b9
commit
97d406c3a8
23
src/modal.c
23
src/modal.c
|
@ -161,21 +161,21 @@ find_register(Rule *r, char reg)
|
|||
static char *
|
||||
compile_rule(Rule *r, int id, char *src)
|
||||
{
|
||||
int wrapped;
|
||||
char c, *cap, *s, *s2;
|
||||
r->id = id, r->ptr = 0;
|
||||
|
||||
/* left */
|
||||
/* left ==================================== */
|
||||
|
||||
r->a = dict_;
|
||||
s2 = src;
|
||||
while((c = *s2) && c == ' ') s2++;
|
||||
if(c != ')' && !(c == '<' && s2[1] == '>')) {
|
||||
cap = walk(s2);
|
||||
if(c == '(') {
|
||||
s2++;
|
||||
while(s2 < cap - 1) *dict_++ = *s2++;
|
||||
s2++;
|
||||
} else
|
||||
wrapped = c == '(';
|
||||
if(wrapped) s2++, cap--;
|
||||
while(s2 < cap) *dict_++ = *s2++;
|
||||
s2 += wrapped;
|
||||
}
|
||||
*dict_++ = 0;
|
||||
src = s2;
|
||||
|
@ -190,18 +190,17 @@ compile_rule(Rule *r, int id, char *src)
|
|||
}
|
||||
}
|
||||
|
||||
/* right */
|
||||
/* right ==================================== */
|
||||
|
||||
r->b = dict_;
|
||||
s2 = src;
|
||||
while((c = *s2) && c == ' ') s2++;
|
||||
if(c != ')' && !(c == '<' && s2[1] == '>')) {
|
||||
cap = walk(s2);
|
||||
if(c == '(') {
|
||||
s2++;
|
||||
while(s2 < cap - 1) *dict_++ = *s2++;
|
||||
s2++;
|
||||
} else
|
||||
wrapped = c == '(';
|
||||
if(wrapped) s2++, cap--;
|
||||
while(s2 < cap) *dict_++ = *s2++;
|
||||
s2 += wrapped;
|
||||
}
|
||||
*dict_++ = 0;
|
||||
src = s2;
|
||||
|
|
Loading…
Reference in New Issue