Continuous evaluation
This commit is contained in:
parent
81a995090f
commit
41f7807cd6
16
src/modal.c
16
src/modal.c
|
@ -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;
|
||||
}
|
Loading…
Reference in New Issue