diff --git a/src/modal.c b/src/modal.c index 5dcd970..558fb2a 100644 --- a/src/modal.c +++ b/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; } diff --git a/src/repl.modal b/src/repl.modal index d3875a8..c331b4e 100644 --- a/src/repl.modal +++ b/src/repl.modal @@ -11,7 +11,7 @@ \n ) -<> (quit listen!) (?(?: ?:) (\n\tSee you soon.\n\n)) -<> listen?~ (?~ listen!) +<> (quit ...) (?(?: ?:) (\n\tSee you soon.\n\n)) +<> ..?~ (?~ ...) -listen! \ No newline at end of file +... \ No newline at end of file