Send debug to stderr

This commit is contained in:
Devine Lu Linvega 2024-04-06 15:11:38 -07:00
parent 1713409a40
commit afe94cf84b
2 changed files with 9 additions and 10 deletions

View File

@ -8,7 +8,7 @@ all: dest bin/modal
dest:
@ mkdir -p bin
run: all
@ bin/modal examples/test.modal
@ bin/modal examples/test.modal 2> /dev/null
test: all
@ bin/modal -v
@ bin/modal examples/test.modal

View File

@ -7,8 +7,8 @@ typedef struct {
static int rules_len, direction = 0;
static Rule rules[0x100];
static char dict[0x8000], *dict_ = dict;
static char bank_a[0x1000], *prog_ = bank_a;
static char bank_b[0x1000], *outp_ = bank_b;
static char bank_a[0x4000], *prog_ = bank_a;
static char bank_b[0x4000], *outp_ = bank_b;
static char *regs[0x100];
#define spacer(c) (c < 0x21 || c == '(' || c == ')')
@ -47,8 +47,7 @@ call(char *s)
{
char *ss = walk(s);
if(*s == '(') s++, --ss;
while(s < ss)
putc(*(s++), stdout);
while(s < ss) putc(*(s++), stdout);
}
static char *
@ -82,7 +81,7 @@ bind(char r)
{
int depth = 0;
char c, *s = regs[(int)r];
if(!s) return !printf("?%c Empty\n", r);
if(!s) return !fprintf(stderr, "?%c Empty\n", r);
if(s[0] == '(') {
while((c = *s++)) {
if(c == '(') depth++;
@ -106,7 +105,7 @@ save(int rule)
if(rule >= 0) {
char *program = direction ? bank_b : bank_a;
while(program[1] && program[0] < 0x21) program++;
printf("%02d %s\n", rule, program);
fprintf(stderr, "%02d %s\n", rule, program);
}
}
@ -191,10 +190,10 @@ static void
print_rules(void)
{
int i;
printf("\n");
fprintf(stderr, "\n");
for(i = 0; i < rules_len; i++)
printf("<> (%s) (%s)\n", rules[i].a, rules[i].b);
printf("\n");
fprintf(stderr, "<> (%s) (%s)\n", rules[i].a, rules[i].b);
fprintf(stderr, "\n");
}
int