Print result after the rewrite is entirely done
This commit is contained in:
parent
155857c120
commit
9f8d78c9ec
12
src/modal.c
12
src/modal.c
|
@ -176,7 +176,7 @@ write_reg(char r, char *reg)
|
|||
}
|
||||
|
||||
static int
|
||||
write_tail(char *s)
|
||||
write_tail(char *s, Rule *r)
|
||||
{
|
||||
while((*dst_++ = *s++))
|
||||
;
|
||||
|
@ -185,6 +185,7 @@ write_tail(char *s)
|
|||
src_ = bank_b, dst_ = bank_a;
|
||||
else
|
||||
src_ = bank_a, dst_ = bank_b;
|
||||
if(r && !quiet) fprintf(stderr, "%02d %s\n", r->id, src_), ++r->refs;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -222,8 +223,7 @@ apply_rule(Rule *r, char *s)
|
|||
while(*s == ' ') s++;
|
||||
if(*s == ')' && *(dst_ - 1) == ' ') dst_--;
|
||||
}
|
||||
if(!quiet) fprintf(stderr, "%02d %s\n", r->id, src_), ++r->refs;
|
||||
return write_tail(s);
|
||||
return write_tail(s, r);
|
||||
}
|
||||
|
||||
static char *
|
||||
|
@ -295,7 +295,7 @@ rewrite(void)
|
|||
remove_rule(r);
|
||||
}
|
||||
while(*cap == ' ') cap++;
|
||||
return write_tail(cap);
|
||||
return write_tail(cap, NULL);
|
||||
}
|
||||
/* phase: define */
|
||||
if(c == '<' && s[1] == '>') {
|
||||
|
@ -306,7 +306,7 @@ rewrite(void)
|
|||
rules_++;
|
||||
}
|
||||
while(*s == ' ') s++;
|
||||
return write_tail(s);
|
||||
return write_tail(s, NULL);
|
||||
}
|
||||
/* phase: lambda */
|
||||
if(c == '?' && s[1] == '(') {
|
||||
|
@ -316,7 +316,7 @@ rewrite(void)
|
|||
parse_frag(&r->b, parse_frag(&r->a, s + 2));
|
||||
s = cap;
|
||||
while(*s == ' ') s++;
|
||||
if(!(*r->a) || !apply_rule(r, s)) write_tail(s);
|
||||
if(!(*r->a) || !apply_rule(r, s)) write_tail(s, NULL);
|
||||
dict_ = d;
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
\n
|
||||
)
|
||||
|
||||
<> (quit listen!) (?(?: ?:) (\n\tSee you soon.\n\n))
|
||||
<> listen?~ (?~ listen!)
|
||||
<> (quit ...) (?(?: ?:) (\n\tSee you soon.\n\n))
|
||||
<> ..?~ (?~ ...)
|
||||
|
||||
listen!
|
||||
...
|
Loading…
Reference in New Issue