Send everything to stdout
This commit is contained in:
parent
e83ac9ce02
commit
392e05d19e
21
src/modal.c
21
src/modal.c
|
@ -139,7 +139,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;
|
if(!quiet && r) printf("%02d %s\n", r->id, src_), ++r->refs;
|
||||||
return write_tail(s);
|
return write_tail(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,7 +216,7 @@ rewrite(void)
|
||||||
if(c == '<' && s[1] == '>') {
|
if(c == '<' && s[1] == '>') {
|
||||||
r = rules_++;
|
r = rules_++;
|
||||||
s = compile_rule(r, rules_ - rules - 1, s + 2);
|
s = compile_rule(r, rules_ - rules - 1, s + 2);
|
||||||
if(!quiet && r->a) fprintf(stderr, "<> (%s) (%s)\n", r->a, r->b);
|
if(!quiet && r->a) printf("<> (%s) (%s)\n", r->a, r->b);
|
||||||
while(*s == ' ') s++;
|
while(*s == ' ') s++;
|
||||||
return write_tail(s);
|
return write_tail(s);
|
||||||
}
|
}
|
||||||
|
@ -225,7 +225,7 @@ rewrite(void)
|
||||||
s += 2;
|
s += 2;
|
||||||
while(*s == ' ') s++;
|
while(*s == ' ') s++;
|
||||||
cap = walk(s), r = find_rule(s, cap), r->a = 0;
|
cap = walk(s), r = find_rule(s, cap), r->a = 0;
|
||||||
if(!quiet && r->a) fprintf(stderr, ">< (%s)\n", r->a);
|
if(!quiet && r->a) printf(">< (%s)\n", r->a);
|
||||||
while(*cap == ' ') cap++;
|
while(*cap == ' ') cap++;
|
||||||
return write_tail(cap);
|
return write_tail(cap);
|
||||||
}
|
}
|
||||||
|
@ -263,7 +263,7 @@ main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!(f = fopen(argv[i], "r")))
|
if(!(f = fopen(argv[i], "r")))
|
||||||
return !fprintf(stdout, "Modal file invalid: %s.\n", argv[i]);
|
return !printf("Modal file invalid: %s.\n", argv[i]);
|
||||||
while(fread(&c, 1, 1, f)) {
|
while(fread(&c, 1, 1, f)) {
|
||||||
c = c <= 0x20 ? 0x20 : c;
|
c = c <= 0x20 ? 0x20 : c;
|
||||||
if(c == ' ' && last == '(') continue;
|
if(c == ' ' && last == '(') continue;
|
||||||
|
@ -278,11 +278,14 @@ main(int argc, char **argv)
|
||||||
while(*(--w) <= ' ') *w = 0;
|
while(*(--w) <= ' ') *w = 0;
|
||||||
fclose(f);
|
fclose(f);
|
||||||
if(pr != pl)
|
if(pr != pl)
|
||||||
return !fprintf(stdout, "Modal program imbalanced.\n");
|
return !printf("Modal program imbalanced.\n");
|
||||||
while(rewrite() && ++rw)
|
while(rewrite() && ++rw)
|
||||||
if(!cycles--) return !fprintf(stdout, "Modal rewrites exceeded.\n");
|
if(!cycles--) return !printf("Modal rewrites exceeded.\n");
|
||||||
while(rules_-- > rules && !quiet)
|
if(!quiet) {
|
||||||
if(!rules_->refs && rules_->a) printf("-- Unused rule: %d <> (%s) (%s)\n", rules_->refs, rules_->a, rules_->b);
|
while(rules_-- > rules)
|
||||||
if(!quiet) printf(".. %s\nCompleted in %d rewrites.\n", src_, rw);
|
if(!rules_->refs && rules_->a)
|
||||||
|
printf("-- Unused rule: %d <> (%s) (%s)\n", rules_->refs, rules_->a, rules_->b);
|
||||||
|
printf(".. %s\nCompleted in %d rewrites.\n", src_, rw);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
Loading…
Reference in New Issue