Empty rules are leaving empty lists behind
This commit is contained in:
parent
a97e6b1963
commit
16cb1823c4
12
src/modal.c
12
src/modal.c
|
@ -225,9 +225,13 @@ parse_frag(char **side, char *s)
|
||||||
{
|
{
|
||||||
char c, *cap;
|
char c, *cap;
|
||||||
while((c = *s) && c == ' ') s++;
|
while((c = *s) && c == ' ') s++;
|
||||||
if(c == ')' || c == '<' || c == '>' || (c == '(' && s[1] == ')'))
|
if(c == ')') {
|
||||||
*side = NULL;
|
*side = NULL;
|
||||||
else {
|
return s;
|
||||||
|
} else if((c == '<' && s[1] == '>') || (c == '>' && s[1] == '<') || (c == '(' && s[1] == ')')) {
|
||||||
|
*side = NULL;
|
||||||
|
return s + 2;
|
||||||
|
} else {
|
||||||
cap = walk(s), *side = dict_;
|
cap = walk(s), *side = dict_;
|
||||||
if(c == '(')
|
if(c == '(')
|
||||||
dict_ = copy(s + 1, dict_, cap - s - 2);
|
dict_ = copy(s + 1, dict_, cap - s - 2);
|
||||||
|
@ -267,7 +271,7 @@ rewrite(void)
|
||||||
while(*s == ' ') s++;
|
while(*s == ' ') s++;
|
||||||
cap = walk(s), r = find_rule(s, cap);
|
cap = walk(s), r = find_rule(s, cap);
|
||||||
if(r != NULL) {
|
if(r != NULL) {
|
||||||
if(!quiet) fprintf(stderr, ">< (%s) (%s)\n", r->a, r->b);
|
if(!quiet) fprintf(stderr, ">< (%s) (%s)\n", r->a ? r->a : "", r->b ? r->b : "");
|
||||||
r->a = 0;
|
r->a = 0;
|
||||||
}
|
}
|
||||||
while(*cap == ' ') cap++;
|
while(*cap == ' ') cap++;
|
||||||
|
@ -278,7 +282,7 @@ rewrite(void)
|
||||||
r = rules_, r->id = rules_ - rules;
|
r = rules_, r->id = rules_ - rules;
|
||||||
s = parse_frag(&r->b, parse_frag(&r->a, s + 2));
|
s = parse_frag(&r->b, parse_frag(&r->a, s + 2));
|
||||||
if(r->a != NULL) {
|
if(r->a != NULL) {
|
||||||
if(!quiet) fprintf(stderr, "<> (%s) (%s)\n", r->a, r->b);
|
if(!quiet) fprintf(stderr, "<> (%s) (%s)\n", r->a ? r->a : "", r->b ? r->b : "");
|
||||||
rules_++;
|
rules_++;
|
||||||
}
|
}
|
||||||
while(*s == ' ') s++;
|
while(*s == ' ') s++;
|
||||||
|
|
Loading…
Reference in New Issue