Moved print out of write_tail
This commit is contained in:
parent
c440725559
commit
e1f4641f69
17
src/modal.c
17
src/modal.c
|
@ -135,7 +135,7 @@ write_reg(char r, char *reg)
|
|||
}
|
||||
|
||||
static int
|
||||
write_tail(char *s, Rule *r)
|
||||
write_tail(char *s)
|
||||
{
|
||||
while((*dst_++ = *s++))
|
||||
;
|
||||
|
@ -144,7 +144,6 @@ write_tail(char *s, Rule *r)
|
|||
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;
|
||||
}
|
||||
|
||||
|
@ -194,7 +193,8 @@ apply_rule(Rule *r, char *s)
|
|||
while(*s == ' ') s++;
|
||||
if(*s == ')' && *(dst_ - 1) == ' ') dst_--;
|
||||
}
|
||||
return write_tail(s, r);
|
||||
if(!quiet) fprintf(stderr, "%02d %s\n", r->id, src_), ++r->refs;
|
||||
return write_tail(s);
|
||||
}
|
||||
|
||||
static char *
|
||||
|
@ -247,7 +247,7 @@ rewrite(void)
|
|||
r->a = 0;
|
||||
}
|
||||
while(*cap == ' ') cap++;
|
||||
return write_tail(cap, NULL);
|
||||
return write_tail(cap);
|
||||
}
|
||||
/* phase: define */
|
||||
if(c == '<' && s[1] == '>') {
|
||||
|
@ -258,7 +258,7 @@ rewrite(void)
|
|||
rules_++;
|
||||
}
|
||||
while(*s == ' ') s++;
|
||||
return write_tail(s, NULL);
|
||||
return write_tail(s);
|
||||
}
|
||||
/* phase: lambda */
|
||||
if(c == '?' && s[1] == '(') {
|
||||
|
@ -267,7 +267,10 @@ 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, r);
|
||||
if(!apply_rule(&lambda, s)) {
|
||||
if(!quiet) fprintf(stderr, "%02d %s\n", r->id, src_), ++r->refs;
|
||||
write_tail(s);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
/* phase: match */
|
||||
|
@ -291,7 +294,7 @@ main(int argc, char **argv)
|
|||
return !printf("usage: modal [-vqn] source.modal\n");
|
||||
for(i = 1; i < argc && *argv[i] == '-'; i++) {
|
||||
switch(argv[i][1]) {
|
||||
case 'v': /* version */ return !printf("Modal Interpreter, 29 Apr 2024.\n");
|
||||
case 'v': /* version */ return !printf("Modal Interpreter, 2 May 2024.\n");
|
||||
case 'q': /* quiet */ quiet = 1; break;
|
||||
case 'p': /* debug */ debug = 1; break;
|
||||
case 'n': /* infinite */ cycles = 0xffffffff; break;
|
||||
|
|
Loading…
Reference in New Issue