Fixed issue with delayed output

This commit is contained in:
Devine Lu Linvega 2024-04-28 20:49:27 -07:00
parent e84ef37c5d
commit c644597eac
1 changed files with 6 additions and 6 deletions

View File

@ -132,7 +132,7 @@ write_reg(char r, char *reg)
}
static int
write_tail(char *s)
write_tail(char *s, Rule *r)
{
while((*dst_++ = *s++))
;
@ -141,6 +141,7 @@ write_tail(char *s)
src_ = bank_b, dst_ = bank_a;
else
src_ = bank_a, dst_ = bank_b;
if(!quiet && r) fprintf(stderr, "%02d %s\n", r->id, src_), ++r->refs;
return 1;
}
@ -190,8 +191,7 @@ apply_rule(Rule *r, char *s)
while(*s == ' ') s++;
if(*s == ')' && *(dst_ - 1) == ' ') dst_--;
}
if(!quiet && r) fprintf(stderr, "%02d %s\n", r->id, src_), ++r->refs;
return write_tail(s);
return write_tail(s, r);
}
static char *
@ -244,7 +244,7 @@ rewrite(void)
r->a = 0;
}
while(*cap == ' ') cap++;
return write_tail(cap);
return write_tail(cap, NULL);
}
/* phase: define */
if(c == '<' && s[1] == '>') {
@ -255,7 +255,7 @@ rewrite(void)
rules_++;
}
while(*s == ' ') s++;
return write_tail(s);
return write_tail(s, NULL);
}
/* phase: lambda */
if(c == '?' && s[1] == '(') {
@ -264,7 +264,7 @@ rewrite(void)
parse_frag(&r->b, parse_frag(&r->a, s + 2));
s = cap;
while(*s == ' ') s++;
if(!apply_rule(&lambda, s)) write_tail(s);
if(!apply_rule(&lambda, s)) write_tail(s, r);
return 1;
}
/* phase: match */