Print rule ran

This commit is contained in:
Devine Lu Linvega 2024-04-05 09:20:18 -07:00
parent 373137a054
commit 84efce7fa6
2 changed files with 6 additions and 5 deletions

View File

@ -1,4 +1,5 @@
<> (?x dup) (?x ?x)
<> (?x ?y swap) (?y ?x)
<> (?x pop) ()
A B dup
(1 2 3) (4 5 6) swap pop

View File

@ -62,13 +62,13 @@ writereg(char r)
}
static void
save(void)
save(int rule)
{
int i, end = outp_ - outp;
/* todo: change pointer instead of copying memory */
for(i = 0; i <= end; i++) prog[i] = outp[i];
prog_ = prog, outp_ = outp;
printf(".. %s\n", prog);
printf("..%02d %s\n", rule, prog);
}
static int
@ -91,7 +91,7 @@ rewrite(void)
while((*outp_++ = *res++))
;
*outp_++ = 0;
save();
save(i);
return 1;
}
}
@ -183,7 +183,7 @@ main(int argc, char **argv)
return !printf("Modal - Modal Interpreter, 3 Apr 2024.\n");
parse(argv[1]);
print_rules();
printf(".. %s\n", prog);
printf(".... %s\n", prog);
while(rewrite())
;
return 0;