Standardizing the add_rule funciton

This commit is contained in:
Devine Lu Linvega 2024-04-10 11:30:26 -07:00
parent 9f7faa41b5
commit 37c92c4914
1 changed files with 6 additions and 4 deletions

View File

@ -133,20 +133,22 @@ commit_rule(Rule *r, char *s, int create)
static char * static char *
parse_rule_frag(char *s) parse_rule_frag(char *s)
{ {
char *ss = walk(s), *d = dict_; char *ss = walk(s);
if(*s == '(') s++, ss--; if(*s == '(') s++, ss--;
while((s < ss)) *dict_++ = *s++; while((s < ss)) *dict_++ = *s++;
*dict_++ = 0; *dict_++ = 0;
return d; return s;
} }
static char * static char *
parse_rule(Rule *r, char *s){ parse_rule(Rule *r, char *s){
char c; char c;
while((c = *s) && c <= ' ') s++; while((c = *s) && c <= ' ') s++;
r->a = parse_rule_frag(s), s = walk(s); r->a = dict_;
s = parse_rule_frag(s), s++;
while((c = *s) && c <= ' ') s++; while((c = *s) && c <= ' ') s++;
r->b = parse_rule_frag(s), s = walk(s); r->b = dict_;
s = parse_rule_frag(s), s++;
return s; return s;
} }