Print rule ran
This commit is contained in:
parent
373137a054
commit
84efce7fa6
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue