Annotation of 3BSD/cmd/mip/cgram.c, revision 1.1.1.1

1.1       root        1: # define NAME 2
                      2: # define STRING 3
                      3: # define ICON 4
                      4: # define FCON 5
                      5: # define PLUS 6
                      6: # define MINUS 8
                      7: # define MUL 11
                      8: # define AND 14
                      9: # define OR 17
                     10: # define ER 19
                     11: # define QUEST 21
                     12: # define COLON 22
                     13: # define ANDAND 23
                     14: # define OROR 24
                     15: # define ASOP 25
                     16: # define RELOP 26
                     17: # define EQUOP 27
                     18: # define DIVOP 28
                     19: # define SHIFTOP 29
                     20: # define INCOP 30
                     21: # define UNOP 31
                     22: # define STROP 32
                     23: # define TYPE 33
                     24: # define CLASS 34
                     25: # define STRUCT 35
                     26: # define RETURN 36
                     27: # define GOTO 37
                     28: # define IF 38
                     29: # define ELSE 39
                     30: # define SWITCH 40
                     31: # define BREAK 41
                     32: # define CONTINUE 42
                     33: # define WHILE 43
                     34: # define DO 44
                     35: # define FOR 45
                     36: # define DEFAULT 46
                     37: # define CASE 47
                     38: # define SIZEOF 48
                     39: # define ENUM 49
                     40: # define LP 50
                     41: # define RP 51
                     42: # define LC 52
                     43: # define RC 53
                     44: # define LB 54
                     45: # define RB 55
                     46: # define CM 56
                     47: # define SM 57
                     48: # define ASSIGN 58
                     49: 
                     50: # line 108 "../mip/cgram.y"
                     51: # include "mfile1"
                     52: #define yyclearin yychar = -1
                     53: #define yyerrok yyerrflag = 0
                     54: extern int yychar;
                     55: extern short yyerrflag;
                     56: #ifndef YYMAXDEPTH
                     57: #define YYMAXDEPTH 150
                     58: #endif
                     59: YYSTYPE yylval, yyval;
                     60: 
                     61: # line 127 "../mip/cgram.y"
                     62:        static int fake = 0;
                     63:        static char fakename[NCHNAM+1];
                     64: # define YYERRCODE 256
                     65: 
                     66: # line 814 "../mip/cgram.y"
                     67: 
                     68: 
                     69: NODE *
                     70: mkty( t, d, s ) unsigned t; {
                     71:        return( block( TYPE, NIL, NIL, t, d, s ) );
                     72:        }
                     73: 
                     74: NODE *
                     75: bdty( op, p, v ) NODE *p; {
                     76:        register NODE *q;
                     77: 
                     78:        q = block( op, p, NIL, INT, 0, INT );
                     79: 
                     80:        switch( op ){
                     81: 
                     82:        case UNARY MUL:
                     83:        case UNARY CALL:
                     84:                break;
                     85: 
                     86:        case LB:
                     87:                q->right = bcon(v);
                     88:                break;
                     89: 
                     90:        case NAME:
                     91:                q->rval = v;
                     92:                break;
                     93: 
                     94:        default:
                     95:                cerror( "bad bdty" );
                     96:                }
                     97: 
                     98:        return( q );
                     99:        }
                    100: 
                    101: dstash( n ){ /* put n into the dimension table */
                    102:        if( curdim >= DIMTABSZ-1 ){
                    103:                cerror( "dimension table overflow");
                    104:                }
                    105:        dimtab[ curdim++ ] = n;
                    106:        }
                    107: 
                    108: savebc() {
                    109:        if( psavbc > & asavbc[BCSZ-4 ] ){
                    110:                cerror( "whiles, fors, etc. too deeply nested");
                    111:                }
                    112:        *psavbc++ = brklab;
                    113:        *psavbc++ = contlab;
                    114:        *psavbc++ = flostat;
                    115:        *psavbc++ = swx;
                    116:        flostat = 0;
                    117:        }
                    118: 
                    119: resetbc(mask){
                    120: 
                    121:        swx = *--psavbc;
                    122:        flostat = *--psavbc | (flostat&mask);
                    123:        contlab = *--psavbc;
                    124:        brklab = *--psavbc;
                    125: 
                    126:        }
                    127: 
                    128: addcase(p) NODE *p; { /* add case to switch */
                    129: 
                    130:        p = optim( p );  /* change enum to ints */
                    131:        if( p->op != ICON ){
                    132:                uerror( "non-constant case expression");
                    133:                return;
                    134:                }
                    135:        if( swp == swtab ){
                    136:                uerror( "case not in switch");
                    137:                return;
                    138:                }
                    139:        if( swp >= &swtab[SWITSZ] ){
                    140:                cerror( "switch table overflow");
                    141:                }
                    142:        swp->sval = p->lval;
                    143:        deflab( swp->slab = getlab() );
                    144:        ++swp;
                    145:        tfree(p);
                    146:        }
                    147: 
                    148: adddef(){ /* add default case to switch */
                    149:        if( swtab[swx].slab >= 0 ){
                    150:                uerror( "duplicate default in switch");
                    151:                return;
                    152:                }
                    153:        if( swp == swtab ){
                    154:                uerror( "default not inside switch");
                    155:                return;
                    156:                }
                    157:        deflab( swtab[swx].slab = getlab() );
                    158:        }
                    159: 
                    160: swstart(){
                    161:        /* begin a switch block */
                    162:        if( swp >= &swtab[SWITSZ] ){
                    163:                cerror( "switch table overflow");
                    164:                }
                    165:        swx = swp - swtab;
                    166:        swp->slab = -1;
                    167:        ++swp;
                    168:        }
                    169: 
                    170: swend(){ /* end a switch block */
                    171: 
                    172:        register struct sw *swbeg, *p, *q, *r, *r1;
                    173:        CONSZ temp;
                    174:        int tempi;
                    175: 
                    176:        swbeg = &swtab[swx+1];
                    177: 
                    178:        /* sort */
                    179: 
                    180:        r1 = swbeg;
                    181:        r = swp-1;
                    182: 
                    183:        while( swbeg < r ){
                    184:                /* bubble largest to end */
                    185:                for( q=swbeg; q<r; ++q ){
                    186:                        if( q->sval > (q+1)->sval ){
                    187:                                /* swap */
                    188:                                r1 = q+1;
                    189:                                temp = q->sval;
                    190:                                q->sval = r1->sval;
                    191:                                r1->sval = temp;
                    192:                                tempi = q->slab;
                    193:                                q->slab = r1->slab;
                    194:                                r1->slab = tempi;
                    195:                                }
                    196:                        }
                    197:                r = r1;
                    198:                r1 = swbeg;
                    199:                }
                    200: 
                    201:        /* it is now sorted */
                    202: 
                    203:        for( p = swbeg+1; p<swp; ++p ){
                    204:                if( p->sval == (p-1)->sval ){
                    205:                        uerror( "duplicate case in switch, %d", tempi=p->sval );
                    206:                        return;
                    207:                        }
                    208:                }
                    209: 
                    210:        genswitch( swbeg-1, swp-swbeg );
                    211:        swp = swbeg-1;
                    212:        }
                    213: extern short  yyexca[];
                    214: # define YYNPROD 184
                    215: # define YYLAST 1232
                    216: extern short  yyact[];
                    217: extern short  yypact[];
                    218: extern short  yypgo[];
                    219: extern short  yyr1[];
                    220: extern short  yyr2[];
                    221: extern short  yychk[];
                    222: extern short  yydef[];
                    223: #
                    224: # define YYFLAG -1000
                    225: # define YYERROR goto yyerrlab
                    226: # define YYACCEPT return(0)
                    227: # define YYABORT return(1)
                    228: 
                    229: /*     parser for yacc output  */
                    230: 
                    231: #ifdef YYDEBUG
                    232: int yydebug = 0; /* 1 for debugging */
                    233: #endif
                    234: YYSTYPE yyv[YYMAXDEPTH]; /* where the values are stored */
                    235: int yychar = -1; /* current input token number */
                    236: int yynerrs = 0;  /* number of errors */
                    237: short yyerrflag = 0;  /* error recovery flag */
                    238: 
                    239: yyparse() {
                    240: 
                    241:        short yys[YYMAXDEPTH];
                    242:        short yyj, yym;
                    243:        register YYSTYPE *yypvt;
                    244:        register short yystate, *yyps, yyn;
                    245:        register YYSTYPE *yypv;
                    246:        register short *yyxi;
                    247: 
                    248:        yystate = 0;
                    249:        yychar = -1;
                    250:        yynerrs = 0;
                    251:        yyerrflag = 0;
                    252:        yyps= &yys[-1];
                    253:        yypv= &yyv[-1];
                    254: 
                    255:  yystack:    /* put a state and value onto the stack */
                    256: 
                    257: #ifdef YYDEBUG
                    258:        if( yydebug  ) printf( "state %d, char 0%o\n", yystate, yychar );
                    259: #endif
                    260:                if( ++yyps> &yys[YYMAXDEPTH] ) { yyerror( "yacc stack overflow" ); return(1); }
                    261:                *yyps = yystate;
                    262:                ++yypv;
                    263:                *yypv = yyval;
                    264: 
                    265:  yynewstate:
                    266: 
                    267:        yyn = yypact[yystate];
                    268: 
                    269:        if( yyn<= YYFLAG ) goto yydefault; /* simple state */
                    270: 
                    271:        if( yychar<0 ) if( (yychar=yylex())<0 ) yychar=0;
                    272:        if( (yyn += yychar)<0 || yyn >= YYLAST ) goto yydefault;
                    273: 
                    274:        if( yychk[ yyn=yyact[ yyn ] ] == yychar ){ /* valid shift */
                    275:                yychar = -1;
                    276:                yyval = yylval;
                    277:                yystate = yyn;
                    278:                if( yyerrflag > 0 ) --yyerrflag;
                    279:                goto yystack;
                    280:                }
                    281: 
                    282:  yydefault:
                    283:        /* default state action */
                    284: 
                    285:        if( (yyn=yydef[yystate]) == -2 ) {
                    286:                if( yychar<0 ) if( (yychar=yylex())<0 ) yychar = 0;
                    287:                /* look through exception table */
                    288: 
                    289:                for( yyxi=yyexca; (*yyxi!= (-1)) || (yyxi[1]!=yystate) ; yyxi += 2 ) ; /* VOID */
                    290: 
                    291:                while( *(yyxi+=2) >= 0 ){
                    292:                        if( *yyxi == yychar ) break;
                    293:                        }
                    294:                if( (yyn = yyxi[1]) < 0 ) return(0);   /* accept */
                    295:                }
                    296: 
                    297:        if( yyn == 0 ){ /* error */
                    298:                /* error ... attempt to resume parsing */
                    299: 
                    300:                switch( yyerrflag ){
                    301: 
                    302:                case 0:   /* brand new error */
                    303: 
                    304:                        yyerror( "syntax error" );
                    305:                yyerrlab:
                    306:                        ++yynerrs;
                    307: 
                    308:                case 1:
                    309:                case 2: /* incompletely recovered error ... try again */
                    310: 
                    311:                        yyerrflag = 3;
                    312: 
                    313:                        /* find a state where "error" is a legal shift action */
                    314: 
                    315:                        while ( yyps >= yys ) {
                    316:                           yyn = yypact[*yyps] + YYERRCODE;
                    317:                           if( yyn>= 0 && yyn < YYLAST && yychk[yyact[yyn]] == YYERRCODE ){
                    318:                              yystate = yyact[yyn];  /* simulate a shift of "error" */
                    319:                              goto yystack;
                    320:                              }
                    321:                           yyn = yypact[*yyps];
                    322: 
                    323:                           /* the current yyps has no shift onn "error", pop stack */
                    324: 
                    325: #ifdef YYDEBUG
                    326:                           if( yydebug ) printf( "error recovery pops state %d, uncovers %d\n", *yyps, yyps[-1] );
                    327: #endif
                    328:                           --yyps;
                    329:                           --yypv;
                    330:                           }
                    331: 
                    332:                        /* there is no state on the stack with an error shift ... abort */
                    333: 
                    334:        yyabort:
                    335:                        return(1);
                    336: 
                    337: 
                    338:                case 3:  /* no shift yet; clobber input char */
                    339: 
                    340: #ifdef YYDEBUG
                    341:                        if( yydebug ) printf( "error recovery discards char %d\n", yychar );
                    342: #endif
                    343: 
                    344:                        if( yychar == 0 ) goto yyabort; /* don't discard EOF, quit */
                    345:                        yychar = -1;
                    346:                        goto yynewstate;   /* try again in the same state */
                    347: 
                    348:                        }
                    349: 
                    350:                }
                    351: 
                    352:        /* reduction by production yyn */
                    353: 
                    354: #ifdef YYDEBUG
                    355:                if( yydebug ) printf("reduce %d\n",yyn);
                    356: #endif
                    357:                yyps -= yyr2[yyn];
                    358:                yypvt = yypv;
                    359:                yypv -= yyr2[yyn];
                    360:                yyval = yypv[1];
                    361:                yym=yyn;
                    362:                        /* consult goto table to find next state */
                    363:                yyn = yyr1[yyn];
                    364:                yyj = yypgo[yyn] + *yyps + 1;
                    365:                if( yyj>=YYLAST || yychk[ yystate = yyact[yyj] ] != -yyn ) yystate = yyact[yypgo[yyn]];
                    366:                switch(yym){
                    367:                        
                    368: case 2:
                    369: # line 133 "../mip/cgram.y"
                    370: ftnend(); break;
                    371: case 3:
                    372: # line 136 "../mip/cgram.y"
                    373: { curclass = SNULL;  blevel = 0; } break;
                    374: case 4:
                    375: # line 138 "../mip/cgram.y"
                    376: { curclass = SNULL;  blevel = 0; } break;
                    377: case 5:
                    378: # line 142 "../mip/cgram.y"
                    379: {  yypvt[-1].nodep->op = FREE; } break;
                    380: case 6:
                    381: # line 144 "../mip/cgram.y"
                    382: {  yypvt[-2].nodep->op = FREE; } break;
                    383: case 7:
                    384: # line 145 "../mip/cgram.y"
                    385: {
                    386:                                defid( tymerge(yypvt[-1].nodep,yypvt[-0].nodep), curclass==STATIC?STATIC:EXTDEF );
                    387: #ifndef LINT
                    388:                                pfstab(stab[yypvt[-0].nodep->rval].sname);
                    389: #endif
                    390:                                } break;
                    391: case 8:
                    392: # line 151 "../mip/cgram.y"
                    393: {  
                    394:                            if( blevel ) cerror( "function level error" );
                    395:                            if( reached ) retstat |= NRETVAL; 
                    396:                            yypvt[-3].nodep->op = FREE;
                    397:                            ftnend();
                    398:                            } break;
                    399: case 11:
                    400: # line 162 "../mip/cgram.y"
                    401: {  blevel = 1; } break;
                    402: case 13:
                    403: # line 167 "../mip/cgram.y"
                    404: {  bccode();
                    405:                            locctr(PROG);
                    406:                            } break;
                    407: case 14:
                    408: # line 173 "../mip/cgram.y"
                    409: {  yypvt[-1].nodep->op = FREE; 
                    410: #ifndef LINT
                    411:                            plcstab(blevel);
                    412: #endif
                    413:                            } break;
                    414: case 15:
                    415: # line 179 "../mip/cgram.y"
                    416: {  yypvt[-2].nodep->op = FREE; 
                    417: #ifndef LINT
                    418:                            plcstab(blevel);
                    419: #endif
                    420:                            } break;
                    421: case 16:
                    422: # line 187 "../mip/cgram.y"
                    423: {  yypvt[-1].nodep->op = FREE; } break;
                    424: case 17:
                    425: # line 189 "../mip/cgram.y"
                    426: {  yypvt[-2].nodep->op = FREE; } break;
                    427: case 19:
                    428: # line 193 "../mip/cgram.y"
                    429: { curclass = SNULL;  yypvt[-2].nodep->op = FREE; } break;
                    430: case 20:
                    431: # line 195 "../mip/cgram.y"
                    432: { curclass = SNULL;  yypvt[-1].nodep->op = FREE; } break;
                    433: case 21:
                    434: # line 197 "../mip/cgram.y"
                    435: {  curclass = SNULL; } break;
                    436: case 23:
                    437: # line 201 "../mip/cgram.y"
                    438: {  yyval.nodep = mkty(INT,0,INT);  curclass = SNULL; } break;
                    439: case 24:
                    440: # line 204 "../mip/cgram.y"
                    441: {  yyval.nodep = yypvt[-0].nodep; } break;
                    442: case 26:
                    443: # line 207 "../mip/cgram.y"
                    444: {  yyval.nodep = mkty(INT,0,INT); } break;
                    445: case 27:
                    446: # line 209 "../mip/cgram.y"
                    447: { curclass = SNULL ; } break;
                    448: case 28:
                    449: # line 214 "../mip/cgram.y"
                    450: {  curclass = yypvt[-0].intval; } break;
                    451: case 30:
                    452: # line 219 "../mip/cgram.y"
                    453: {  yypvt[-1].nodep->type = types( yypvt[-1].nodep->type, yypvt[-0].nodep->type, UNDEF );
                    454:                            yypvt[-0].nodep->op = FREE;
                    455:                            } break;
                    456: case 31:
                    457: # line 223 "../mip/cgram.y"
                    458: {  yypvt[-2].nodep->type = types( yypvt[-2].nodep->type, yypvt[-1].nodep->type, yypvt[-0].nodep->type );
                    459:                            yypvt[-1].nodep->op = yypvt[-0].nodep->op = FREE;
                    460:                            } break;
                    461: case 34:
                    462: # line 231 "../mip/cgram.y"
                    463: { yyval.nodep = dclstruct(yypvt[-4].intval); } break;
                    464: case 35:
                    465: # line 233 "../mip/cgram.y"
                    466: {  yyval.nodep = rstruct(yypvt[-0].intval,0);  stwart = instruct; } break;
                    467: case 36:
                    468: # line 237 "../mip/cgram.y"
                    469: {  yyval.intval = bstruct(-1,0); } break;
                    470: case 37:
                    471: # line 239 "../mip/cgram.y"
                    472: {  yyval.intval = bstruct(yypvt[-0].intval,0); } break;
                    473: case 40:
                    474: # line 247 "../mip/cgram.y"
                    475: {  moedef( yypvt[-0].intval ); } break;
                    476: case 41:
                    477: # line 249 "../mip/cgram.y"
                    478: {  strucoff = yypvt[-0].intval;  moedef( yypvt[-2].intval ); } break;
                    479: case 42:
                    480: # line 253 "../mip/cgram.y"
                    481: { yyval.nodep = dclstruct(yypvt[-4].intval);  } break;
                    482: case 43:
                    483: # line 255 "../mip/cgram.y"
                    484: {  yyval.nodep = rstruct(yypvt[-0].intval,yypvt[-1].intval); } break;
                    485: case 44:
                    486: # line 259 "../mip/cgram.y"
                    487: {  yyval.intval = bstruct(-1,yypvt[-0].intval);  stwart=0; } break;
                    488: case 45:
                    489: # line 261 "../mip/cgram.y"
                    490: {  yyval.intval = bstruct(yypvt[-0].intval,yypvt[-1].intval);  stwart=0;  } break;
                    491: case 48:
                    492: # line 269 "../mip/cgram.y"
                    493: { curclass = SNULL;  stwart=0; yypvt[-1].nodep->op = FREE; } break;
                    494: case 49:
                    495: # line 271 "../mip/cgram.y"
                    496: {  if( curclass != MOU ){
                    497:                                curclass = SNULL;
                    498:                                }
                    499:                            else {
                    500:                                sprintf( fakename, "$%dFAKE", fake++ );
                    501:                                defid( tymerge(yypvt[-0].nodep, bdty(NAME,NIL,lookup( fakename, SMOS ))), curclass );
                    502:                                }
                    503:                            stwart = 0;
                    504:                            yypvt[-0].nodep->op = FREE;
                    505:                            } break;
                    506: case 50:
                    507: # line 285 "../mip/cgram.y"
                    508: { defid( tymerge(yypvt[-1].nodep,yypvt[-0].nodep), curclass);  stwart = instruct; } break;
                    509: case 51:
                    510: # line 286 "../mip/cgram.y"
                    511: {yyval.nodep=yypvt[-2].nodep;} break;
                    512: case 52:
                    513: # line 287 "../mip/cgram.y"
                    514: { defid( tymerge(yypvt[-4].nodep,yypvt[-0].nodep), curclass);  stwart = instruct; } break;
                    515: case 55:
                    516: # line 293 "../mip/cgram.y"
                    517: {  if( !(instruct&INSTRUCT) ) uerror( "field outside of structure" );
                    518:                            if( yypvt[-0].intval<0 || yypvt[-0].intval >= FIELD ){
                    519:                                uerror( "illegal field size" );
                    520:                                yypvt[-0].intval = 1;
                    521:                                }
                    522:                            defid( tymerge(yypvt[-3].nodep,yypvt[-2].nodep), FIELD|yypvt[-0].intval );
                    523:                            yyval.nodep = NIL;
                    524:                            } break;
                    525: case 56:
                    526: # line 303 "../mip/cgram.y"
                    527: {  if( !(instruct&INSTRUCT) ) uerror( "field outside of structure" );
                    528:                            falloc( stab, yypvt[-0].intval, -1, yypvt[-2].nodep );  /* alignment or hole */
                    529:                            yyval.nodep = NIL;
                    530:                            } break;
                    531: case 57:
                    532: # line 308 "../mip/cgram.y"
                    533: {  yyval.nodep = NIL; } break;
                    534: case 58:
                    535: # line 313 "../mip/cgram.y"
                    536: {  umul:
                    537:                                yyval.nodep = bdty( UNARY MUL, yypvt[-0].nodep, 0 ); } break;
                    538: case 59:
                    539: # line 316 "../mip/cgram.y"
                    540: {  uftn:
                    541:                                yyval.nodep = bdty( UNARY CALL, yypvt[-2].nodep, 0 );  } break;
                    542: case 60:
                    543: # line 319 "../mip/cgram.y"
                    544: {  uary:
                    545:                                yyval.nodep = bdty( LB, yypvt[-2].nodep, 0 );  } break;
                    546: case 61:
                    547: # line 322 "../mip/cgram.y"
                    548: {  bary:
                    549:                                if( (int)yypvt[-1].intval <= 0 ) werror( "zero or negative subscript" );
                    550:                                yyval.nodep = bdty( LB, yypvt[-3].nodep, yypvt[-1].intval );  } break;
                    551: case 62:
                    552: # line 326 "../mip/cgram.y"
                    553: {  yyval.nodep = bdty( NAME, NIL, yypvt[-0].intval );  } break;
                    554: case 63:
                    555: # line 328 "../mip/cgram.y"
                    556: { yyval.nodep=yypvt[-1].nodep; } break;
                    557: case 64:
                    558: # line 331 "../mip/cgram.y"
                    559: {  goto umul; } break;
                    560: case 65:
                    561: # line 333 "../mip/cgram.y"
                    562: {  goto uftn; } break;
                    563: case 66:
                    564: # line 335 "../mip/cgram.y"
                    565: {  goto uary; } break;
                    566: case 67:
                    567: # line 337 "../mip/cgram.y"
                    568: {  goto bary; } break;
                    569: case 68:
                    570: # line 339 "../mip/cgram.y"
                    571: { yyval.nodep = yypvt[-1].nodep; } break;
                    572: case 69:
                    573: # line 341 "../mip/cgram.y"
                    574: {
                    575:                                if( blevel!=0 ) uerror("function declaration in bad context");
                    576:                                yyval.nodep = bdty( UNARY CALL, bdty(NAME,NIL,yypvt[-2].intval), 0 );
                    577:                                stwart = 0;
                    578:                                } break;
                    579: case 70:
                    580: # line 347 "../mip/cgram.y"
                    581: {
                    582:                                yyval.nodep = bdty( UNARY CALL, bdty(NAME,NIL,yypvt[-1].intval), 0 );
                    583:                                stwart = 0;
                    584:                                } break;
                    585: case 71:
                    586: # line 354 "../mip/cgram.y"
                    587: {
                    588:                                /* turn off typedefs for argument names */
                    589:                                stwart = SEENAME;
                    590:                                } break;
                    591: case 72:
                    592: # line 361 "../mip/cgram.y"
                    593: { ftnarg( yypvt[-0].intval );  stwart = SEENAME; } break;
                    594: case 73:
                    595: # line 363 "../mip/cgram.y"
                    596: { ftnarg( yypvt[-0].intval );  stwart = SEENAME; } break;
                    597: case 75:
                    598: # line 368 "../mip/cgram.y"
                    599: {yyval.nodep=yypvt[-2].nodep;} break;
                    600: case 77:
                    601: # line 372 "../mip/cgram.y"
                    602: {  defid( yypvt[-0].nodep = tymerge(yypvt[-1].nodep,yypvt[-0].nodep), curclass);
                    603:                            beginit(yypvt[-0].nodep->rval);
                    604:                            } break;
                    605: case 79:
                    606: # line 379 "../mip/cgram.y"
                    607: {  nidcl( tymerge(yypvt[-1].nodep,yypvt[-0].nodep) ); } break;
                    608: case 80:
                    609: # line 381 "../mip/cgram.y"
                    610: {  defid( tymerge(yypvt[-1].nodep,yypvt[-0].nodep), uclass(curclass) );
                    611:                        } break;
                    612: case 81:
                    613: # line 385 "../mip/cgram.y"
                    614: {  doinit( yypvt[-0].nodep );
                    615:                            endinit(); } break;
                    616: case 82:
                    617: # line 388 "../mip/cgram.y"
                    618: {  endinit(); } break;
                    619: case 85:
                    620: # line 397 "../mip/cgram.y"
                    621: {  doinit( yypvt[-0].nodep ); } break;
                    622: case 86:
                    623: # line 399 "../mip/cgram.y"
                    624: {  irbrace(); } break;
                    625: case 91:
                    626: # line 411 "../mip/cgram.y"
                    627: {  werror( "old-fashioned initialization: use =" ); } break;
                    628: case 93:
                    629: # line 416 "../mip/cgram.y"
                    630: {  ilbrace(); } break;
                    631: case 96:
                    632: # line 426 "../mip/cgram.y"
                    633: {  
                    634: #ifndef LINT
                    635:                            prcstab(blevel);
                    636: #endif
                    637:                            --blevel;
                    638:                            if( blevel == 1 ) blevel = 0;
                    639:                            clearst( blevel );
                    640:                            checkst( blevel );
                    641:                            autooff = *--psavbc;
                    642:                            regvar = *--psavbc;
                    643:                            } break;
                    644: case 97:
                    645: # line 440 "../mip/cgram.y"
                    646: {  --blevel;
                    647:                            if( blevel == 1 ) blevel = 0;
                    648:                            clearst( blevel );
                    649:                            checkst( blevel );
                    650:                            autooff = *--psavbc;
                    651:                            regvar = *--psavbc;
                    652:                            } break;
                    653: case 98:
                    654: # line 450 "../mip/cgram.y"
                    655: {  if( blevel == 1 ) dclargs();
                    656:                            ++blevel;
                    657:                            if( psavbc > &asavbc[BCSZ-2] ) cerror( "nesting too deep" );
                    658:                            *psavbc++ = regvar;
                    659:                            *psavbc++ = autooff;
                    660:                            } break;
                    661: case 99:
                    662: # line 459 "../mip/cgram.y"
                    663: { ecomp( yypvt[-1].nodep ); } break;
                    664: case 101:
                    665: # line 462 "../mip/cgram.y"
                    666: { deflab(yypvt[-1].intval);
                    667:                           reached = 1;
                    668:                           } break;
                    669: case 102:
                    670: # line 466 "../mip/cgram.y"
                    671: {  if( yypvt[-1].intval != NOLAB ){
                    672:                                deflab( yypvt[-1].intval );
                    673:                                reached = 1;
                    674:                                }
                    675:                            } break;
                    676: case 103:
                    677: # line 472 "../mip/cgram.y"
                    678: {  branch(  contlab );
                    679:                            deflab( brklab );
                    680:                            if( (flostat&FBRK) || !(flostat&FLOOP)) reached = 1;
                    681:                            else reached = 0;
                    682:                            resetbc(0);
                    683:                            } break;
                    684: case 104:
                    685: # line 479 "../mip/cgram.y"
                    686: {  deflab( contlab );
                    687:                            if( flostat & FCONT ) reached = 1;
                    688:                            ecomp( buildtree( CBRANCH, buildtree( NOT, yypvt[-2].nodep, NIL ), bcon( yypvt[-6].intval ) ) );
                    689:                            deflab( brklab );
                    690:                            reached = 1;
                    691:                            resetbc(0);
                    692:                            } break;
                    693: case 105:
                    694: # line 487 "../mip/cgram.y"
                    695: {  deflab( contlab );
                    696:                            if( flostat&FCONT ) reached = 1;
                    697:                            if( yypvt[-2].nodep ) ecomp( yypvt[-2].nodep );
                    698:                            branch( yypvt[-3].intval );
                    699:                            deflab( brklab );
                    700:                            if( (flostat&FBRK) || !(flostat&FLOOP) ) reached = 1;
                    701:                            else reached = 0;
                    702:                            resetbc(0);
                    703:                            } break;
                    704: case 106:
                    705: # line 497 "../mip/cgram.y"
                    706: {  if( reached ) branch( brklab );
                    707:                            deflab( yypvt[-1].intval );
                    708:                           swend();
                    709:                            deflab(brklab);
                    710:                            if( (flostat&FBRK) || !(flostat&FDEF) ) reached = 1;
                    711:                            resetbc(FCONT);
                    712:                            } break;
                    713: case 107:
                    714: # line 505 "../mip/cgram.y"
                    715: {  if( brklab == NOLAB ) uerror( "illegal break");
                    716:                            else if(reached) branch( brklab );
                    717:                            flostat |= FBRK;
                    718:                            if( brkflag ) goto rch;
                    719:                            reached = 0;
                    720:                            } break;
                    721: case 108:
                    722: # line 512 "../mip/cgram.y"
                    723: {  if( contlab == NOLAB ) uerror( "illegal continue");
                    724:                            else branch( contlab );
                    725:                            flostat |= FCONT;
                    726:                            goto rch;
                    727:                            } break;
                    728: case 109:
                    729: # line 518 "../mip/cgram.y"
                    730: {  retstat |= NRETVAL;
                    731:                            branch( retlab );
                    732:                        rch:
                    733:                            if( !reached ) werror( "statement not reached");
                    734:                            reached = 0;
                    735:                            } break;
                    736: case 110:
                    737: # line 525 "../mip/cgram.y"
                    738: {  register NODE *temp;
                    739:                            idname = curftn;
                    740:                            temp = buildtree( NAME, NIL, NIL );
                    741:                            temp->type = DECREF( temp->type );
                    742:                            temp = buildtree( RETURN, temp, yypvt[-1].nodep );
                    743:                            /* now, we have the type of the RHS correct */
                    744:                            temp->left->op = FREE;
                    745:                            temp->op = FREE;
                    746:                            ecomp( buildtree( FORCE, temp->right, NIL ) );
                    747:                            retstat |= RETVAL;
                    748:                            branch( retlab );
                    749:                            reached = 0;
                    750:                            } break;
                    751: case 111:
                    752: # line 539 "../mip/cgram.y"
                    753: {  register NODE *q;
                    754:                            q = block( FREE, NIL, NIL, INT|ARY, 0, INT );
                    755:                            q->rval = idname = yypvt[-1].intval;
                    756:                            defid( q, ULABEL );
                    757:                            stab[idname].suse = -lineno;
                    758:                            branch( stab[idname].offset );
                    759:                            goto rch;
                    760:                            } break;
                    761: case 116:
                    762: # line 553 "../mip/cgram.y"
                    763: {  register NODE *q;
                    764:                            q = block( FREE, NIL, NIL, INT|ARY, 0, LABEL );
                    765:                            q->rval = yypvt[-1].intval;
                    766:                            defid( q, LABEL );
                    767:                            reached = 1;
                    768:                            } break;
                    769: case 117:
                    770: # line 560 "../mip/cgram.y"
                    771: {  addcase(yypvt[-1].nodep);
                    772:                            reached = 1;
                    773:                            } break;
                    774: case 118:
                    775: # line 564 "../mip/cgram.y"
                    776: {  reached = 1;
                    777:                            adddef();
                    778:                            flostat |= FDEF;
                    779:                            } break;
                    780: case 119:
                    781: # line 570 "../mip/cgram.y"
                    782: {  savebc();
                    783:                            if( !reached ) werror( "loop not entered at top");
                    784:                            brklab = getlab();
                    785:                            contlab = getlab();
                    786:                            deflab( yyval.intval = getlab() );
                    787:                            reached = 1;
                    788:                            } break;
                    789: case 120:
                    790: # line 579 "../mip/cgram.y"
                    791: {  ecomp( buildtree( CBRANCH, yypvt[-1].nodep, bcon( yyval.intval=getlab()) ) ) ;
                    792:                            reached = 1;
                    793:                            } break;
                    794: case 121:
                    795: # line 584 "../mip/cgram.y"
                    796: {  if( reached ) branch( yyval.intval = getlab() );
                    797:                            else yyval.intval = NOLAB;
                    798:                            deflab( yypvt[-2].intval );
                    799:                            reached = 1;
                    800:                            } break;
                    801: case 122:
                    802: # line 592 "../mip/cgram.y"
                    803: {  savebc();
                    804:                            if( !reached ) werror( "loop not entered at top");
                    805:                            if( yypvt[-1].nodep->op == ICON && yypvt[-1].nodep->lval != 0 ) flostat = FLOOP;
                    806:                            deflab( contlab = getlab() );
                    807:                            reached = 1;
                    808:                            brklab = getlab();
                    809:                            if( flostat == FLOOP ) tfree( yypvt[-1].nodep );
                    810:                            else ecomp( buildtree( CBRANCH, yypvt[-1].nodep, bcon( brklab) ) );
                    811:                            } break;
                    812: case 123:
                    813: # line 603 "../mip/cgram.y"
                    814: {  if( yypvt[-3].nodep ) ecomp( yypvt[-3].nodep );
                    815:                            else if( !reached ) werror( "loop not entered at top");
                    816:                            savebc();
                    817:                            contlab = getlab();
                    818:                            brklab = getlab();
                    819:                            deflab( yyval.intval = getlab() );
                    820:                            reached = 1;
                    821:                            if( yypvt[-1].nodep ) ecomp( buildtree( CBRANCH, yypvt[-1].nodep, bcon( brklab) ) );
                    822:                            else flostat |= FLOOP;
                    823:                            } break;
                    824: case 124:
                    825: # line 615 "../mip/cgram.y"
                    826: {  savebc();
                    827:                            brklab = getlab();
                    828:                            ecomp( buildtree( FORCE, yypvt[-1].nodep, NIL ) );
                    829:                            branch( yyval.intval = getlab() );
                    830:                            swstart();
                    831:                            reached = 0;
                    832:                            } break;
                    833: case 125:
                    834: # line 624 "../mip/cgram.y"
                    835: { yyval.intval=instruct; stwart=instruct=0; } break;
                    836: case 126:
                    837: # line 626 "../mip/cgram.y"
                    838: {  yyval.intval = icons( yypvt[-0].nodep );  instruct=yypvt[-1].intval; } break;
                    839: case 128:
                    840: # line 630 "../mip/cgram.y"
                    841: { yyval.nodep=0; } break;
                    842: case 130:
                    843: # line 635 "../mip/cgram.y"
                    844: {  goto bop; } break;
                    845: case 131:
                    846: # line 639 "../mip/cgram.y"
                    847: {
                    848:                        preconf:
                    849:                            if( yychar==RELOP||yychar==EQUOP||yychar==AND||yychar==OR||yychar==ER ){
                    850:                            precplaint:
                    851:                                if( hflag ) werror( "precedence confusion possible: parenthesize!" );
                    852:                                }
                    853:                        bop:
                    854:                            yyval.nodep = buildtree( yypvt[-1].intval, yypvt[-2].nodep, yypvt[-0].nodep );
                    855:                            } break;
                    856: case 132:
                    857: # line 649 "../mip/cgram.y"
                    858: {  yypvt[-1].intval = COMOP;
                    859:                            goto bop;
                    860:                            } break;
                    861: case 133:
                    862: # line 653 "../mip/cgram.y"
                    863: {  goto bop; } break;
                    864: case 134:
                    865: # line 655 "../mip/cgram.y"
                    866: {  if(yychar==SHIFTOP) goto precplaint; else goto bop; } break;
                    867: case 135:
                    868: # line 657 "../mip/cgram.y"
                    869: {  if(yychar==SHIFTOP ) goto precplaint; else goto bop; } break;
                    870: case 136:
                    871: # line 659 "../mip/cgram.y"
                    872: {  if(yychar==PLUS||yychar==MINUS) goto precplaint; else goto bop; } break;
                    873: case 137:
                    874: # line 661 "../mip/cgram.y"
                    875: {  goto bop; } break;
                    876: case 138:
                    877: # line 663 "../mip/cgram.y"
                    878: {  goto preconf; } break;
                    879: case 139:
                    880: # line 665 "../mip/cgram.y"
                    881: {  if( yychar==RELOP||yychar==EQUOP ) goto preconf;  else goto bop; } break;
                    882: case 140:
                    883: # line 667 "../mip/cgram.y"
                    884: {  if(yychar==RELOP||yychar==EQUOP) goto preconf; else goto bop; } break;
                    885: case 141:
                    886: # line 669 "../mip/cgram.y"
                    887: {  if(yychar==RELOP||yychar==EQUOP) goto preconf; else goto bop; } break;
                    888: case 142:
                    889: # line 671 "../mip/cgram.y"
                    890: {  goto bop; } break;
                    891: case 143:
                    892: # line 673 "../mip/cgram.y"
                    893: {  goto bop; } break;
                    894: case 144:
                    895: # line 675 "../mip/cgram.y"
                    896: {  abop:
                    897:                                yyval.nodep = buildtree( ASG yypvt[-2].intval, yypvt[-3].nodep, yypvt[-0].nodep );
                    898:                                } break;
                    899: case 145:
                    900: # line 679 "../mip/cgram.y"
                    901: {  goto abop; } break;
                    902: case 146:
                    903: # line 681 "../mip/cgram.y"
                    904: {  goto abop; } break;
                    905: case 147:
                    906: # line 683 "../mip/cgram.y"
                    907: {  goto abop; } break;
                    908: case 148:
                    909: # line 685 "../mip/cgram.y"
                    910: {  goto abop; } break;
                    911: case 149:
                    912: # line 687 "../mip/cgram.y"
                    913: {  goto abop; } break;
                    914: case 150:
                    915: # line 689 "../mip/cgram.y"
                    916: {  goto abop; } break;
                    917: case 151:
                    918: # line 691 "../mip/cgram.y"
                    919: {  goto abop; } break;
                    920: case 152:
                    921: # line 693 "../mip/cgram.y"
                    922: {  yyval.nodep=buildtree(QUEST, yypvt[-4].nodep, buildtree( COLON, yypvt[-2].nodep, yypvt[-0].nodep ) );
                    923:                            } break;
                    924: case 153:
                    925: # line 696 "../mip/cgram.y"
                    926: {  werror( "old-fashioned assignment operator" );  goto bop; } break;
                    927: case 154:
                    928: # line 698 "../mip/cgram.y"
                    929: {  goto bop; } break;
                    930: case 156:
                    931: # line 702 "../mip/cgram.y"
                    932: {  yyval.nodep = buildtree( yypvt[-0].intval, yypvt[-1].nodep, bcon(1) ); } break;
                    933: case 157:
                    934: # line 704 "../mip/cgram.y"
                    935: { ubop:
                    936:                            yyval.nodep = buildtree( UNARY yypvt[-1].intval, yypvt[-0].nodep, NIL );
                    937:                            } break;
                    938: case 158:
                    939: # line 708 "../mip/cgram.y"
                    940: {  if( ISFTN(yypvt[-0].nodep->type) || ISARY(yypvt[-0].nodep->type) ){
                    941:                                werror( "& before array or function: ignored" );
                    942:                                yyval.nodep = yypvt[-0].nodep;
                    943:                                }
                    944:                            else goto ubop;
                    945:                            } break;
                    946: case 159:
                    947: # line 715 "../mip/cgram.y"
                    948: {  goto ubop; } break;
                    949: case 160:
                    950: # line 717 "../mip/cgram.y"
                    951: {
                    952:                            yyval.nodep = buildtree( yypvt[-1].intval, yypvt[-0].nodep, NIL );
                    953:                            } break;
                    954: case 161:
                    955: # line 721 "../mip/cgram.y"
                    956: {  yyval.nodep = buildtree( yypvt[-1].intval==INCR ? ASG PLUS : ASG MINUS,
                    957:                                                yypvt[-0].nodep,
                    958:                                                bcon(1)  );
                    959:                            } break;
                    960: case 162:
                    961: # line 726 "../mip/cgram.y"
                    962: {  yyval.nodep = doszof( yypvt[-0].nodep ); } break;
                    963: case 163:
                    964: # line 728 "../mip/cgram.y"
                    965: {  yyval.nodep = buildtree( CAST, yypvt[-2].nodep, yypvt[-0].nodep );
                    966:                            yyval.nodep->left->op = FREE;
                    967:                            yyval.nodep->op = FREE;
                    968:                            yyval.nodep = yyval.nodep->right;
                    969:                            } break;
                    970: case 164:
                    971: # line 734 "../mip/cgram.y"
                    972: {  yyval.nodep = doszof( yypvt[-1].nodep ); } break;
                    973: case 165:
                    974: # line 736 "../mip/cgram.y"
                    975: {  yyval.nodep = buildtree( UNARY MUL, buildtree( PLUS, yypvt[-3].nodep, yypvt[-1].nodep ), NIL ); } break;
                    976: case 166:
                    977: # line 738 "../mip/cgram.y"
                    978: {  yyval.nodep=buildtree(UNARY CALL,yypvt[-1].nodep,NIL); } break;
                    979: case 167:
                    980: # line 740 "../mip/cgram.y"
                    981: {  yyval.nodep=buildtree(CALL,yypvt[-2].nodep,yypvt[-1].nodep); } break;
                    982: case 168:
                    983: # line 742 "../mip/cgram.y"
                    984: {  if( yypvt[-1].intval == DOT ){
                    985:                                yypvt[-2].nodep = buildtree( UNARY AND, yypvt[-2].nodep, NIL );
                    986:                                }
                    987:                            idname = yypvt[-0].intval;
                    988:                            yyval.nodep = buildtree( STREF, yypvt[-2].nodep, buildtree( NAME, NIL, NIL ) );
                    989:                            } break;
                    990: case 169:
                    991: # line 749 "../mip/cgram.y"
                    992: {  idname = yypvt[-0].intval;
                    993:                            /* recognize identifiers in initializations */
                    994:                            if( blevel==0 && stab[idname].stype == UNDEF ) {
                    995:                                register NODE *q;
                    996:                                werror( "undeclared initializer name %.8s", stab[idname].sname );
                    997:                                q = block( FREE, NIL, NIL, INT, 0, INT );
                    998:                                q->rval = idname;
                    999:                                defid( q, EXTERN );
                   1000:                                }
                   1001:                            yyval.nodep=buildtree(NAME,NIL,NIL);
                   1002:                            stab[yypvt[-0].intval].suse = -lineno;
                   1003:                        } break;
                   1004: case 170:
                   1005: # line 762 "../mip/cgram.y"
                   1006: {  yyval.nodep=bcon(0);
                   1007:                            yyval.nodep->lval = lastcon;
                   1008:                            yyval.nodep->rval = NONAME;
                   1009:                            if( yypvt[-0].intval ) yyval.nodep->csiz = yyval.nodep->type = ctype(LONG);
                   1010:                            } break;
                   1011: case 171:
                   1012: # line 768 "../mip/cgram.y"
                   1013: {  yyval.nodep=buildtree(FCON,NIL,NIL);
                   1014:                            yyval.nodep->dval = dcon;
                   1015:                            } break;
                   1016: case 172:
                   1017: # line 772 "../mip/cgram.y"
                   1018: {  yyval.nodep = getstr(); /* get string contents */ } break;
                   1019: case 173:
                   1020: # line 774 "../mip/cgram.y"
                   1021: { yyval.nodep=yypvt[-1].nodep; } break;
                   1022: case 174:
                   1023: # line 778 "../mip/cgram.y"
                   1024: {
                   1025:                        yyval.nodep = tymerge( yypvt[-1].nodep, yypvt[-0].nodep );
                   1026:                        yyval.nodep->op = NAME;
                   1027:                        yypvt[-1].nodep->op = FREE;
                   1028:                        } break;
                   1029: case 175:
                   1030: # line 786 "../mip/cgram.y"
                   1031: { yyval.nodep = bdty( NAME, NIL, -1 ); } break;
                   1032: case 176:
                   1033: # line 788 "../mip/cgram.y"
                   1034: { yyval.nodep = bdty( UNARY CALL, bdty(NAME,NIL,-1),0); } break;
                   1035: case 177:
                   1036: # line 790 "../mip/cgram.y"
                   1037: {  yyval.nodep = bdty( UNARY CALL, yypvt[-3].nodep, 0 ); } break;
                   1038: case 178:
                   1039: # line 792 "../mip/cgram.y"
                   1040: {  goto umul; } break;
                   1041: case 179:
                   1042: # line 794 "../mip/cgram.y"
                   1043: {  goto uary; } break;
                   1044: case 180:
                   1045: # line 796 "../mip/cgram.y"
                   1046: {  goto bary;  } break;
                   1047: case 181:
                   1048: # line 798 "../mip/cgram.y"
                   1049: { yyval.nodep = yypvt[-1].nodep; } break;
                   1050: case 182:
                   1051: # line 802 "../mip/cgram.y"
                   1052: {  if( stab[yypvt[-1].intval].stype == UNDEF ){
                   1053:                                register NODE *q;
                   1054:                                q = block( FREE, NIL, NIL, FTN|INT, 0, INT );
                   1055:                                q->rval = yypvt[-1].intval;
                   1056:                                defid( q, EXTERN );
                   1057:                                }
                   1058:                            idname = yypvt[-1].intval;
                   1059:                            yyval.nodep=buildtree(NAME,NIL,NIL);
                   1060:                            stab[idname].suse = -lineno;
                   1061:                        } break;
                   1062:                }
                   1063:                goto yystack;  /* stack new state and value */
                   1064: 
                   1065:        }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.