Fixed issue with delayed output
This commit is contained in:
parent
e84ef37c5d
commit
c644597eac
12
src/modal.c
12
src/modal.c
|
@ -132,7 +132,7 @@ write_reg(char r, char *reg)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
write_tail(char *s)
|
write_tail(char *s, Rule *r)
|
||||||
{
|
{
|
||||||
while((*dst_++ = *s++))
|
while((*dst_++ = *s++))
|
||||||
;
|
;
|
||||||
|
@ -141,6 +141,7 @@ write_tail(char *s)
|
||||||
src_ = bank_b, dst_ = bank_a;
|
src_ = bank_b, dst_ = bank_a;
|
||||||
else
|
else
|
||||||
src_ = bank_a, dst_ = bank_b;
|
src_ = bank_a, dst_ = bank_b;
|
||||||
|
if(!quiet && r) fprintf(stderr, "%02d %s\n", r->id, src_), ++r->refs;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,8 +191,7 @@ apply_rule(Rule *r, char *s)
|
||||||
while(*s == ' ') s++;
|
while(*s == ' ') s++;
|
||||||
if(*s == ')' && *(dst_ - 1) == ' ') dst_--;
|
if(*s == ')' && *(dst_ - 1) == ' ') dst_--;
|
||||||
}
|
}
|
||||||
if(!quiet && r) fprintf(stderr, "%02d %s\n", r->id, src_), ++r->refs;
|
return write_tail(s, r);
|
||||||
return write_tail(s);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
|
@ -244,7 +244,7 @@ rewrite(void)
|
||||||
r->a = 0;
|
r->a = 0;
|
||||||
}
|
}
|
||||||
while(*cap == ' ') cap++;
|
while(*cap == ' ') cap++;
|
||||||
return write_tail(cap);
|
return write_tail(cap, NULL);
|
||||||
}
|
}
|
||||||
/* phase: define */
|
/* phase: define */
|
||||||
if(c == '<' && s[1] == '>') {
|
if(c == '<' && s[1] == '>') {
|
||||||
|
@ -255,7 +255,7 @@ rewrite(void)
|
||||||
rules_++;
|
rules_++;
|
||||||
}
|
}
|
||||||
while(*s == ' ') s++;
|
while(*s == ' ') s++;
|
||||||
return write_tail(s);
|
return write_tail(s, NULL);
|
||||||
}
|
}
|
||||||
/* phase: lambda */
|
/* phase: lambda */
|
||||||
if(c == '?' && s[1] == '(') {
|
if(c == '?' && s[1] == '(') {
|
||||||
|
@ -264,7 +264,7 @@ rewrite(void)
|
||||||
parse_frag(&r->b, parse_frag(&r->a, s + 2));
|
parse_frag(&r->b, parse_frag(&r->a, s + 2));
|
||||||
s = cap;
|
s = cap;
|
||||||
while(*s == ' ') s++;
|
while(*s == ' ') s++;
|
||||||
if(!apply_rule(&lambda, s)) write_tail(s);
|
if(!apply_rule(&lambda, s)) write_tail(s, r);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
/* phase: match */
|
/* phase: match */
|
||||||
|
|
Loading…
Reference in New Issue