diff --git a/src/other/b.b b/src/other/b.b index 84bbb66..764f5ea 100644 --- a/src/other/b.b +++ b/src/other/b.b @@ -268,8 +268,8 @@ case21: *csym = 6; /* extrn */ } else { *csym = 2; /* internal */ - isn = isn+1; csym[1] = isn; + isn = isn+1; } } if (*csym==5) /* auto */ @@ -280,7 +280,8 @@ case21: write('.'); name(csym+2); } else { /* internal */ - write('l'); + write('1f'); + write('+'); number(csym[1]); } write('*n'); @@ -587,14 +588,14 @@ next: if (cval==12) { /* if */ pexpr(); - isn = isn+1; o1 = isn; + isn = isn+1; jumpc(o1); stmt(); o = symbol(); if (o==19 & cval==14) { /* else */ - isn = isn+1; o2 = isn; + isn = isn+1; jump(o2); label(o1); stmt(); @@ -607,12 +608,12 @@ next: } if (cval==13) { /* while */ - isn = isn+1; o1 = isn; + isn = isn+1; label(o1); pexpr(); - isn = isn+1; o2 = isn; + isn = isn+1; jumpc(o2); stmt(); jump(o1); @@ -628,8 +629,8 @@ next: peekc = 0; if (!*csym) { *csym = 2; /* param */ - isn = isn+1; csym[1] = isn; + isn = isn+1; } else if (*csym != 2) { error('rd'); goto next; @@ -653,17 +654,20 @@ syntax: } blkend() { - extrn isn, nisn; + extrn isn; + auto i; - while (nisn < isn) { - nisn = nisn+1; + if (!isn) + return; + write('1:'); + i = 0; + while (i < isn) { write('l'); - number(nisn); - write(':'); - write('ll'); - number(nisn); + number(i); write('*n'); + i = i+1; } + isn = 0; } gen(o,n) { @@ -675,22 +679,25 @@ gen(o,n) { jumpc(n) { write('f '); /* ifop */ - write('l'); + write('1f'); + write('+'); number(n); write('*n'); } jump(n) { - write('t '); /* traop */ - write('ll'); + write('x '); + write('1f'); + write('+'); number(n); - write('*n'); + gen('*nn',6); /* goto */ } label(n) { - write('ll'); + write('l'); number(n); - write(':'); + write('=.'); + write('*n'); } printn(n) { @@ -778,6 +785,5 @@ csym; ns; cval; isn; -nisn; nerror; nauto; diff --git a/tools/b.c b/tools/b.c index f1f4109..12aeda3 100644 --- a/tools/b.c +++ b/tools/b.c @@ -53,19 +53,19 @@ xflush() { #define flush xflush main(int argc, char **argv) { - extern symtab[], eof, *ns; + extern symtab[], eof, *ns, nerror; extern fin, fout; if (argc > 1) { if (argc > 2) { if ((fout = creat(argv[2], 0777))<0) { error('fo'); - return 1; + return(1); } } if ((fin = open(argv[1],0))<0) { error('fi'); - return 1; + return(1); } } @@ -74,7 +74,7 @@ main(int argc, char **argv) { extdef(); blkend(); } - return 0; + return(nerror!=0); } int *lookup() { @@ -316,8 +316,8 @@ case21: *csym = 6; /* extrn */ } else { *csym = 2; /* internal */ - isn = isn+1; csym[1] = isn; + isn = isn+1; } } if (*csym==5) /* auto */ @@ -328,7 +328,8 @@ case21: write('.'); name(csym+2); } else { /* internal */ - write('l'); + write('1f'); + write('+'); number(csym[1]); } write('\n'); @@ -635,14 +636,14 @@ next: if (cval==12) { /* if */ pexpr(); - isn = isn+1; o1 = isn; + isn = isn+1; jumpc(o1); stmt(); o = symbol(); if (o==19 & cval==14) { /* else */ - isn = isn+1; o2 = isn; + isn = isn+1; jump(o2); label(o1); stmt(); @@ -655,12 +656,12 @@ next: } if (cval==13) { /* while */ - isn = isn+1; o1 = isn; + isn = isn+1; label(o1); pexpr(); - isn = isn+1; o2 = isn; + isn = isn+1; jumpc(o2); stmt(); jump(o1); @@ -676,8 +677,8 @@ next: peekc = 0; if (!*csym) { *csym = 2; /* param */ - isn = isn+1; csym[1] = isn; + isn = isn+1; } else if (*csym != 2) { error('rd'); goto next; @@ -701,17 +702,20 @@ syntax: } blkend() { - extern isn, nisn; + extern isn; + auto i; - while (nisn < isn) { - nisn = nisn+1; + if (!isn) + return; + write('1:'); + i = 0; + while (i < isn) { write('l'); - number(nisn); - write(':'); - write('ll'); - number(nisn); + number(i); write('\n'); + i = i+1; } + isn = 0; } gen(o,n) { @@ -723,22 +727,25 @@ gen(o,n) { jumpc(n) { write('f '); /* ifop */ - write('l'); + write('1f'); + write('+'); number(n); write('\n'); } jump(n) { - write('t '); /* traop */ - write('ll'); + write('x '); + write('1f'); + write('+'); number(n); - write('\n'); + gen('\nn',6); /* goto */ } label(n) { - write('ll'); + write('l'); number(n); - write(':'); + write('=.'); + write('\n'); } printn(n) { @@ -826,6 +833,5 @@ int *csym; int *ns; int cval; int isn; -int nisn; int nerror; int nauto;