diff --git a/src/modal.c b/src/modal.c index a9596e7..71276c2 100644 --- a/src/modal.c +++ b/src/modal.c @@ -131,24 +131,15 @@ commit_rule(Rule *r, char *s, int create) } static char * -parse_rule_frag(char *s) +parse_frag(char *s) { - char *ss = walk(s); + char c, *ss; + while((c = *s) && c <= ' ') s++; + ss = walk(s); if(*s == '(') s++, ss--; while((s < ss)) *dict_++ = *s++; *dict_++ = 0; - return s; -} - -static char * -parse_rule(Rule *r, char *s){ - char c; - while((c = *s) && c <= ' ') s++; - r->a = dict_; - s = parse_rule_frag(s), s++; - while((c = *s) && c <= ' ') s++; - r->b = dict_; - s = parse_rule_frag(s), s++; + s++; return s; } @@ -158,10 +149,12 @@ rewrite(void) char c, last = 0, *p = direction ? bank_b : bank_a; while((c = *p) && c <= ' ') p++; while((c = *p)) { - if(p[0] == '<' && p[1] == '>'){ + if(p[0] == '<' && p[1] == '>') { Rule *r = rules_++; r->id = rules_ - rules - 1, p += 2; - return commit_rule(r, parse_rule(r, p), 1); + r->a = dict_, p = parse_frag(p); + r->b = dict_, p = parse_frag(p); + return commit_rule(r, p, 1); } if(spacer(last)) { Rule *r;