Continuous evaluation
This commit is contained in:
parent
81a995090f
commit
41f7807cd6
18
src/modal.c
18
src/modal.c
|
@ -55,16 +55,15 @@ static void
|
||||||
save(void)
|
save(void)
|
||||||
{
|
{
|
||||||
int i, end = outp_ - outp;
|
int i, end = outp_ - outp;
|
||||||
for(i = 0; i < end; i++) prog[i] = outp[i];
|
for(i = 0; i <= end; i++) prog[i] = outp[i];
|
||||||
prog[i] = 0;
|
prog_ = prog, outp_ = outp;
|
||||||
prog_ = prog;
|
|
||||||
outp_ = outp;
|
|
||||||
printf(".. %s\n", prog);
|
printf(".. %s\n", prog);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
rewrite(void)
|
rewrite(void)
|
||||||
{
|
{
|
||||||
|
int success = 0;
|
||||||
char c, *p = prog;
|
char c, *p = prog;
|
||||||
while((c = *p)) {
|
while((c = *p)) {
|
||||||
int i, found = 0;
|
int i, found = 0;
|
||||||
|
@ -78,7 +77,7 @@ rewrite(void)
|
||||||
writereg(*b++);
|
writereg(*b++);
|
||||||
else
|
else
|
||||||
*outp_++ = cc;
|
*outp_++ = cc;
|
||||||
found = 1;
|
found = success = 1;
|
||||||
p = res;
|
p = res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -88,8 +87,9 @@ rewrite(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*outp_++ = 0;
|
*outp_++ = 0;
|
||||||
save();
|
if(success)
|
||||||
return 1;
|
save();
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -165,7 +165,7 @@ main(int argc, char **argv)
|
||||||
parse(argv[1]);
|
parse(argv[1]);
|
||||||
print_rules();
|
print_rules();
|
||||||
printf(".. %s\n", prog);
|
printf(".. %s\n", prog);
|
||||||
rewrite();
|
while(rewrite())
|
||||||
rewrite();
|
;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
Loading…
Reference in New Issue