Continuous evaluation

This commit is contained in:
Devine Lu Linvega 2024-04-04 15:10:25 -07:00
parent 81a995090f
commit 41f7807cd6
1 changed files with 9 additions and 9 deletions

View File

@ -55,16 +55,15 @@ static void
save(void)
{
int i, end = outp_ - outp;
for(i = 0; i < end; i++) prog[i] = outp[i];
prog[i] = 0;
prog_ = prog;
outp_ = outp;
for(i = 0; i <= end; i++) prog[i] = outp[i];
prog_ = prog, outp_ = outp;
printf(".. %s\n", prog);
}
static int
rewrite(void)
{
int success = 0;
char c, *p = prog;
while((c = *p)) {
int i, found = 0;
@ -78,7 +77,7 @@ rewrite(void)
writereg(*b++);
else
*outp_++ = cc;
found = 1;
found = success = 1;
p = res;
}
}
@ -88,8 +87,9 @@ rewrite(void)
}
}
*outp_++ = 0;
if(success)
save();
return 1;
return success;
}
static void
@ -165,7 +165,7 @@ main(int argc, char **argv)
parse(argv[1]);
print_rules();
printf(".. %s\n", prog);
rewrite();
rewrite();
while(rewrite())
;
return 0;
}