1: #include "r.h"
   2: 
   3: char    scrat[500];
   4: 
   5: int brkptr  -1;
   6: int brkstk[10];
   7: int forptr  0;
   8: int forstk[10];
   9: 
  10: repcode() {
  11:     outcont(0);
  12:     yyval = genlab();
  13:     outcont(yyval);
  14:     brkstk[++brkptr] = yyval+1;
  15:     genlab();
  16:     genlab();
  17: }
  18: 
  19: untils(p1) int p1; {
  20:     outnum(p1+1);
  21:     outcode("\tif(.not.");
  22:     balpar(scrat);
  23:     outcode(scrat);
  24:     outcode(")");
  25:     outgoto(p1);
  26:     outcont(p1+2);
  27:     brkptr--;
  28: }
  29: 
  30: ifcode(p1) int p1; {
  31:     outcode("\tif(.not.");
  32:     balpar(scrat);
  33:     outcode(scrat);
  34:     outcode(")");
  35:     outgoto(yyval=genlab()); genlab();
  36: }
  37: 
  38: whilecode(p1) int p1; {
  39:     outcont(0);
  40:     brkstk[++brkptr] = yyval = genlab(); genlab();
  41:     outnum(yyval);
  42:     outcode("\tif(.not.");
  43:     balpar(scrat);
  44:     outcode(scrat);
  45:     outcode(")");
  46:     outgoto(yyval+1);
  47: }
  48: 
  49: whilestat(p1) int p1; {
  50:     outgoto(p1);
  51:     outcont(p1+1);
  52:     brkptr--;
  53: }
  54: 
  55: balpar(bp) char *bp; {
  56:     int  i, c, lpar;
  57:     extern int peek;
  58:     while( (c=getc()) == ' ' || c == '\t' || c=='\n' );
  59:     peek = c;
  60:     if( c != '(' ){
  61:         error("missing left paren");
  62:         bp[0] = '\0';
  63:         return(bp);
  64:     }
  65:     for( lpar=i=0; (bp[i++]=c=getc())!='\0'; ){
  66:         if( c=='\'' || c=='"' )
  67:             while( (bp[i++]=getc()) != c );
  68:         if( i>=499 || c=='{' || c=='}' ){
  69:             error("missing right parenthesis at %.20s", bp);
  70:             break;
  71:         }
  72:         if( c=='(' )
  73:             lpar++;
  74:         else if( c==')' )
  75:             lpar--;
  76:         if( lpar == 0 )
  77:             break;
  78:     }
  79:     bp[i] = '\0';
  80:     return(bp);
  81: }
  82: 
  83: int labval  23000;
  84: 
  85: genlab(){
  86:     return(++labval);
  87: }
  88: 
  89: gokcode(p1) char *p1; {
  90:     outcode("\t");
  91:     outcode(p1);
  92:     eatup(p1,scrat);
  93:     outcode(scrat);
  94:     outcode(0);
  95: }
  96: 
  97: eatup(p1,bp) char *p1, *bp; {
  98:     extern int peek;
  99:     int i,c,lnb,lpar;
 100:     lnb = '\n';
 101:     while( c = *p1++ )
 102:         if( c!=' ' )
 103:             lnb = c;
 104:     i = lpar = 0;
 105:   more:
 106:     for( ; (bp[i++]=c=getc())!=';' && c!='{' && c!='\n' && c!='}'; ){
 107:         if( i>=499 ){
 108:             error("statement too long at %.20s", bp);
 109:             break;
 110:         }
 111:         if( c != ' ' && c != '\t' )
 112:             lnb = c;
 113:         if( c=='\'' || c=='"' )
 114:             while( (bp[i++]=getc()) != c );
 115:         if( c=='(' )
 116:             lpar++;
 117:         else if( c==')' ) {
 118:             lpar--;
 119:             if( lpar < 0 )
 120:                 error("missing left paren at %.20s",bp);
 121:         }
 122:     }
 123:     if( c == '\n' ){
 124:         if( lnb=='\n' || lnb=='+' || lnb=='-' || lnb=='*' || lnb=='('
 125:             || lnb=='/' || lnb==',' || lnb=='&'  || lnb=='|'
 126:             || lnb=='=' )
 127:                 goto more;
 128:         c = ';';
 129:     }
 130:     if( c!=';' )
 131:         peek = c;
 132:     bp[i-1] = '\0';
 133:     if( lpar > 0 )
 134:         error("missing right paren at %.20s",bp);
 135:     return(bp);
 136: }
 137: 
 138: forcode(){
 139:     extern int peek;
 140:     int i,j,c;
 141:     char *bp, *getvec();
 142:     outcont(0);
 143:     balpar(scrat);
 144:     yyval = genlab(); genlab(); genlab();
 145:     brkstk[++brkptr] = yyval+1;
 146:     if( scrat[0] == '\0' ){
 147:         forstk[forptr++] = bp = getvec(1);
 148:         *bp = '\0';
 149:         return;
 150:     }
 151:     scrat[0] = '\t';
 152:     for( i=1; (c=scrat[i++])!=';' && c!='\0' ; )
 153:         if( c=='\'' || c=='"' )
 154:             while( scrat[i++] != c );
 155:     scrat[i-1] = '\0';
 156:     if( nonblank(scrat) ){
 157:         outcode(scrat);
 158:         outcode(0);
 159:     }
 160:     for( j=i; (c=scrat[i++])!=';' && c!='\0' ; )
 161:         if( c=='\'' || c=='"' )
 162:             while( scrat[i++] != c );
 163:     scrat[i-1] = '\0';
 164:     if( nonblank(&scrat[j]) ){
 165:         outnum(yyval);
 166:         outcode("\tif(.not.(");
 167:         outcode(&scrat[j]);
 168:         outcode("))");
 169:         outgoto(yyval+2);
 170:     }
 171:     else
 172:         outcont(yyval);
 173:     for( j=0; scrat[i+1]!='\0'; )
 174:         scrat[j++] = scrat[i++];
 175:     scrat[j] = '\0';
 176:     forstk[forptr++] = bp = getvec(j+1);
 177:     for(i=0; *bp++ = scrat[i++]; );
 178: }
 179: 
 180: forstat(p1) int p1; {
 181:     char *bp, *q;
 182:     int i;
 183:     bp = forstk[--forptr];
 184:     outnum(p1+1);
 185:     if( nonblank(bp) ){
 186:         outcode("\t");
 187:         outcode(bp);
 188:         outcode(0);
 189:     }
 190:     outgoto(p1);
 191:     outcont(p1+2);
 192:     for( q=bp; *q++; );
 193:     relvec(bp, q-bp);
 194:     brkptr--;
 195: }
 196: 
 197: docode(new,p1) int new; char *p1; {
 198:     outcode("\t");
 199:     outcode(p1);
 200:     eatup(p1,scrat);
 201:     yyval = 0;
 202:     if(new){
 203:         yyval = genlab(); genlab();
 204:         brkstk[++brkptr] = yyval;
 205:         outnum(yyval);
 206:     }
 207:     outcode(scrat);
 208:     outcode(0);
 209: }
 210: 
 211: dostat(p1) int p1; {
 212:     if( p1==0 )
 213:         return;
 214:     outcont(p1);
 215:     outcont(p1+1);
 216:     brkptr--;
 217: }
 218: 
 219: breakcode(p1) int p1; {
 220:     if(brkptr<0){
 221:         error("illegal BREAK");
 222:         return;
 223:     }
 224:     outgoto(brkstk[brkptr]+1);
 225: }
 226: 
 227: nextcode(p1) int p1; {
 228:     if(brkptr<0){
 229:         error("illegal NEXT");
 230:         return;
 231:     }
 232:     outgoto(brkstk[brkptr]);
 233: }
 234: 
 235: nonblank(s) char *s; {
 236:     int c;
 237:     while( c = *s++ )
 238:         if( c!=' ' && c!='\t' && c!='\n' )
 239:             return(1);
 240:     return(0);
 241: }
 242: 
 243: error(s1, s2) char *s1, *s2; {
 244:     extern int linect[],ninclude,infile;
 245:     printf( 2, "error at line %d, file %d: ",linect[ninclude],infile);
 246:     printf( 2, s1,s2);
 247:     printf( 2, "\n");
 248:     errorflag = 1;
 249: }
 250: 
 251: errcode(p1) char *p1; {
 252:     int c;
 253:     extern int yychar;
 254:     extern int linect[],ninclude,infile;
 255:     printf( 2, "\nsyntax error, line %d, file %d\n", linect[ninclude],infile);
 256:     while( (c=getc()) != ';' && c != '}' && c != '\n' && c != '\0' );
 257:     yychar = -1;
 258:     errorflag = 1;
 259: }

Defined functions

balpar defined in line 55; used 4 times
breakcode defined in line 219; used 1 times
docode defined in line 197; used 2 times
dostat defined in line 211; used 1 times
eatup defined in line 97; used 2 times
errcode defined in line 251; used 1 times
error defined in line 243; used 12 times
forcode defined in line 138; used 1 times
forstat defined in line 180; used 1 times
genlab defined in line 85; used 12 times
gokcode defined in line 89; used 1 times
ifcode defined in line 30; used 1 times
nextcode defined in line 227; used 1 times
nonblank defined in line 235; used 3 times
repcode defined in line 10; used 1 times
untils defined in line 19; used 1 times
whilecode defined in line 38; used 1 times
whilestat defined in line 49; used 1 times

Defined variables

brkptr defined in line 5; used 12 times
brkstk defined in line 6; used 6 times
forptr defined in line 7; used 3 times
forstk defined in line 8; used 3 times
labval defined in line 83; used 1 times
  • in line 86
scrat defined in line 3; used 28 times
Last modified: 1975-05-14
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1231
Valid CSS Valid XHTML 1.0 Strict