Minor code cleanup
This commit is contained in:
rswier
2016-03-21 22:13:32 -04:00
parent 5f4e420e63
commit 9f69fc62da
2 changed files with 70 additions and 72 deletions
+24 -25
View File
@@ -79,7 +79,6 @@ symbol() {
} else { } else {
if (eof) if (eof)
return(0); return(0);
else
c = read(); c = read();
} }
loop: loop:
@@ -97,18 +96,18 @@ loop:
goto loop; goto loop;
} }
if (c=='=') { if (c=='=')
return(subseq('=',80,60)); return(subseq('=',80,60));
}
if (c=='<') { if (c=='<')
return(subseq('=',63,62)); return(subseq('=',63,62));
}
if (c=='>') { if (c=='>')
return(subseq('=',65,64)); return(subseq('=',65,64));
}
if (c=='!') { if (c=='!')
return(subseq('=',34,61)); return(subseq('=',34,61));
}
if (c=='$') { if (c=='$') {
if (subseq('(',0,1)) if (subseq('(',0,1))
return(2); return(2);
@@ -155,9 +154,12 @@ com1:
} }
if (ct==123) { /* letter */ if (ct==123) { /* letter */
sp = symbuf; sp = symbuf;
while(ctab[c]==123 | ctab[c]==124) { while(ct==123 | ct==124) {
if (sp<symbuf+9) { *sp = c; sp = sp+1; } if (sp<symbuf+9) {
c = read(); *sp = c;
sp = sp+1;
}
ct = ctab[c = read()];
} }
*sp = 0; *sp = 0;
peekc = c; peekc = c;
@@ -192,11 +194,13 @@ getcc() {
auto c; auto c;
cval = 0; cval = 0;
if ((c = mapch('*'')) < 0) return; if ((c = mapch('*'')) < 0)
return;
cval = c; cval = c;
if ((c = mapch('*'')) < 0) return; if ((c = mapch('*'')) < 0)
return;
cval = cval * 512 + c; cval = cval * 512 + c;
if ((c = mapch('*'')) >= 0) if (mapch('*'') >= 0)
error('cc'); error('cc');
} }
@@ -394,13 +398,10 @@ loop:
peeksym = o; peeksym = o;
} }
pexpr() pexpr() {
{ if (symbol()==6) { /* ( */
auto o, t;
if ((o=symbol())==6) { /* ( */
expr(15); expr(15);
if ((o=symbol())==7) /* ) */ if (symbol()==7) /* ) */
return; return;
} }
error('()'); error('()');
@@ -556,8 +557,7 @@ stmt() {
next: next:
o = symbol(); o = symbol();
if (o==0) /* eof */ if (o==0) { /* eof */
{
error('fe'); /* Unexpected eof */ error('fe'); /* Unexpected eof */
return; return;
} }
@@ -716,8 +716,7 @@ name(s) {
} }
} }
error(code) error(code) {
{
extrn line, eof, csym, nerror, fout; extrn line, eof, csym, nerror, fout;
auto f; auto f;
+24 -25
View File
@@ -126,7 +126,6 @@ symbol() {
} else { } else {
if (eof) if (eof)
return(0); return(0);
else
c = read(); c = read();
} }
loop: loop:
@@ -144,18 +143,18 @@ loop:
goto loop; goto loop;
} }
if (c=='=') { if (c=='=')
return(subseq('=',80,60)); return(subseq('=',80,60));
}
if (c=='<') { if (c=='<')
return(subseq('=',63,62)); return(subseq('=',63,62));
}
if (c=='>') { if (c=='>')
return(subseq('=',65,64)); return(subseq('=',65,64));
}
if (c=='!') { if (c=='!')
return(subseq('=',34,61)); return(subseq('=',34,61));
}
if (c=='$') { if (c=='$') {
if (subseq('(',0,1)) if (subseq('(',0,1))
return(2); return(2);
@@ -202,9 +201,12 @@ com1:
} }
if (ct==123) { /* letter */ if (ct==123) { /* letter */
sp = symbuf; sp = symbuf;
while(ctab[c]==123 | ctab[c]==124) { while(ct==123 | ct==124) {
if (sp<symbuf+9) { *sp = c; sp = sp+1; } if (sp<symbuf+9) {
c = read(); *sp = c;
sp = sp+1;
}
ct = ctab[c = read()];
} }
*sp = 0; *sp = 0;
peekc = c; peekc = c;
@@ -239,11 +241,13 @@ getcc() {
auto c; auto c;
cval = 0; cval = 0;
if ((c = mapch('\'')) < 0) return; if ((c = mapch('\'')) < 0)
return;
cval = c; cval = c;
if ((c = mapch('\'')) < 0) return; if ((c = mapch('\'')) < 0)
return;
cval = cval * 512 + c; cval = cval * 512 + c;
if ((c = mapch('\'')) >= 0) if (mapch('\'') >= 0)
error('cc'); error('cc');
} }
@@ -441,13 +445,10 @@ loop:
peeksym = o; peeksym = o;
} }
pexpr() pexpr() {
{ if (symbol()==6) { /* ( */
auto o, t;
if ((o=symbol())==6) { /* ( */
expr(15); expr(15);
if ((o=symbol())==7) /* ) */ if (symbol()==7) /* ) */
return; return;
} }
error('()'); error('()');
@@ -603,8 +604,7 @@ stmt() {
next: next:
o = symbol(); o = symbol();
if (o==0) /* eof */ if (o==0) { /* eof */
{
error('fe'); /* Unexpected eof */ error('fe'); /* Unexpected eof */
return; return;
} }
@@ -763,8 +763,7 @@ name(int *s) {
} }
} }
error(code) error(code) {
{
extern line, eof, *csym, nerror, fout; extern line, eof, *csym, nerror, fout;
auto f; auto f;