Annotation of xinu/con/y.tab.c, revision 1.1.1.2

1.1       root        1: # define DEFBRK 257
                      2: # define COLON 258
                      3: # define OCTAL 259
                      4: # define INTEGER 260
                      5: # define IDENT 261
                      6: # define CSR 262
                      7: # define IVEC 263
                      8: # define OVEC 264
                      9: # define IINT 265
                     10: # define OINT 266
                     11: # define INIT 267
                     12: # define OPEN 268
                     13: # define CLOSE 269
                     14: # define READ 270
                     15: # define WRITE 271
                     16: # define SEEK 272
                     17: # define CNTL 273
                     18: # define IS 274
                     19: # define ON 275
                     20: # define GETC 276
                     21: # define PUTC 277
                     22: 
                     23: # line 4 "config.y"
                     24: #include <stdio.h>
                     25: 
                     26: #define        NIL     (dvptr)0
                     27: 
                     28: #define        CONFIGC         "../sys/conf.c"         /* name of .c output    */
                     29: #define        CONFIGH         "../h/conf.h"           /* name of .h output    */
                     30: #define        CONFIGIN        "Configuration"         /* name of input file   */
                     31: 
                     32: FILE   *confc;
                     33: FILE   *confh;
                     34: 
                     35: char   *dbstr;
                     36: extern char *malloc();
                     37: int    ndevs = 0;
                     38: int    currname = -1;
                     39: int    currtname = -1;
                     40: int    currdname = -1;
                     41: int    brkcount = 0;
                     42: 
                     43: struct syment  {                       /* symbol table                 */
                     44:        char    *symname;
                     45:        int     symoccurs;
                     46:        } symtab[250];
                     47: 
                     48: int    nsym = 0;
                     49: int    lookup();
                     50: int    linectr = 1;
                     51: char   *doing = "device type declaration";
                     52: char   *s;
                     53: struct dvtype {
                     54:        char            *dvname;        /* device name (not used in types)*/
                     55:        char            *dvtname;       /* type name                    */
                     56:        int             dvtnum;         /* symbol table index of type   */
                     57:        char            *dvdevice;      /* device name                  */
                     58:        int             dvcsr;          /* Control Status Register addr */
                     59:        int             dvivec;         /* input interrupt vector       */
                     60:        int             dvovec;         /* Output interrupt vector      */
                     61:        char            dviint[20];     /* input interrupt routine      */
                     62:        char            dvoint[20];     /* output interrupt routine     */
                     63:        char            dvinit[20];     /* init routine name            */
                     64:        char            dvopen[20];     /* open routine name            */
                     65:        char            dvclose[20];    /* close routine name           */
                     66:        char            dvread[20];     /* read routine name            */
                     67:        char            dvwrite[20];    /* write routine name           */
                     68:        char            dvcntl[20];     /* control routine name         */
                     69:        char            dvseek[20];     /* seek routine name            */
                     70:        char            dvgetc[20];     /* getc routine name            */
                     71:        char            dvputc[20];     /* putc routine name            */
                     72:        int             dvminor;        /* device number 0,1,...        */
                     73:        struct dvtype   *dvnext;        /* next node on the list        */
                     74:        };
                     75: typedef        struct  dvtype  *dvptr;
                     76:        dvptr   ftypes = NIL;           /* linked list of device types  */
                     77:        dvptr   devs = NIL;             /* linked list of device decls. */
                     78:        dvptr   lastdv = NIL;
                     79:        dvptr   currtype = NIL;
                     80: 
                     81: char   *ftout[] = 
1.1.1.2 ! root       82:               {"struct\tdevsw\t{\t\t\t/* device table entry */\n",
1.1       root       83:                "\tint\tdvnum;\n",
                     84:                "\tint\t(*dvinit)();\n",
                     85:                "\tint\t(*dvopen)();\n",
                     86:                "\tint\t(*dvclose)();\n",
                     87:                "\tint\t(*dvread)();\n",
                     88:                "\tint\t(*dvwrite)();\n",
                     89:                "\tint\t(*dvseek)();\n",
                     90:                "\tint\t(*dvgetc)();\n",
                     91:                "\tint\t(*dvputc)();\n",
                     92:                "\tint\t(*dvcntl)();\n",
                     93:                "\tint\tdvcsr;\n",
                     94:                "\tint\tdvivec;\n",
                     95:                "\tint\tdvovec;\n",
                     96:                "\tint\t(*dviint)();\n",
                     97:                "\tint\t(*dvoint)();\n",
                     98:                "\tchar\t*dvioblk;\n",
                     99:                "\tint\tdvminor;\n",
                    100:                "\t};\n\n",
                    101:                "extern\tstruct\tdevsw devtab[];",
1.1.1.2 ! root      102:                "\t\t/* one entry per device */\n\n",
1.1       root      103:                NULL};
                    104: #define yyclearin yychar = -1
                    105: #define yyerrok yyerrflag = 0
                    106: extern int yychar;
                    107: extern short yyerrflag;
                    108: #ifndef YYMAXDEPTH
                    109: #define YYMAXDEPTH 150
                    110: #endif
                    111: #ifndef YYSTYPE
                    112: #define YYSTYPE int
                    113: #endif
                    114: YYSTYPE yylval, yyval;
                    115: # define YYERRCODE 256
                    116: 
1.1.1.2 ! root      117: # line 168 "config.y"
1.1       root      118: 
                    119: #include "lex.yy.c"
                    120: main(argc, argv)
                    121:        int     argc;
                    122:        char    *argv[];
                    123: {
                    124:        int     n, i, j, l, fcount;
                    125:        dvptr   s;
                    126:        int     verbose = 0;
                    127:        char    *p;
                    128:        char    c;
                    129: 
                    130:        if (argc>1 && (strcmp("-v",argv[1])==0)) {
                    131:                argc--;
                    132:                argv++;
                    133:                verbose++;
                    134:        }
                    135:        if (argc>2) {
                    136:                fprintf(stderr,"use: config [-v] [file]\n");
                    137:                exit(1);
                    138:        }
                    139:        if (verbose)
                    140:                printf("Opening input file...\n");
                    141:        if (argc == 2) {
                    142:                if (freopen(argv[1], "r", stdin) == NULL) {
                    143:                        fprintf(stderr,"Can't open %s\n",argv[1]);
                    144:                        exit(1);
                    145:                }
                    146:        } else {        /* try to open Configuration file */
                    147:                if (freopen(CONFIGIN, "r", stdin) == NULL) {
                    148:                        fprintf(stderr,"Can't open %s\n", CONFIGIN);
                    149:                        exit(1);
                    150:                }
                    151:        }
                    152: 
                    153:        /* Parse the Configuration file */
                    154: 
                    155:        if (verbose)
                    156:                printf("Parsing configuration specs...\n");
                    157:        if ((n=yyparse()) != 0)
                    158:                exit(n);
                    159: 
                    160:        /* write config.h and config.c */
                    161: 
                    162:        if (verbose)
                    163:                printf("Opening output files...\n");
                    164:        if ( (confc=fopen(CONFIGC,"w") ) == NULL) {
                    165:                fprintf(stderr, "Can't write on %s\n", CONFIGC);
                    166:                exit(1);
                    167:        }
                    168: 
                    169:        if ( (confh=fopen(CONFIGH,"w") ) == NULL) {
                    170:                fprintf(stderr, "Can't write on %s\n", CONFIGH);
                    171:                exit(1);
                    172:        }
                    173:        fprintf(confh,
                    174:                "/* conf.h (GENERATED FILE; DO NOT EDIT) */\n");
                    175:        fprintf(confc,
                    176:                "/* conf.c (GENERATED FILE; DO NOT EDIT) */\n");
1.1.1.2 ! root      177:        fprintf(confc, "\n#include \"%s\"\n", CONFIGH);
1.1       root      178:        fprintf(confh, "\n#define\tNULLPTR\t(char *)0\n");
                    179: 
                    180: 
                    181:        if (verbose)
                    182:                printf("Writing output...\n");
                    183:        fprintf(confh,"\n/* Device table declarations */\n");
                    184:        for (i=0 ; (p=ftout[i])!=NULL ; i++)
                    185:                fprintf(confh, "%s", p);
1.1.1.2 ! root      186: 
1.1       root      187:        /* write device declarations and definitions; count type refs. */
                    188: 
                    189:        fprintf(confh, "\n/* Device name definitions */\n\n");
                    190:        for (i=0,s=devs; s!=NIL ; s=s->dvnext,i++) {
                    191:                fprintf(confh, "#define\t%-12s%d\t\t\t/* type %-8s */\n",
                    192:                        s->dvname, i, s->dvtname);
                    193:                s->dvminor = symtab[s->dvtnum].symoccurs++;
                    194:        }
                    195: 
                    196:        /* write count of device types */
                    197: 
                    198:        fprintf(confh,"\n/* Control block sizes */\n\n");
                    199:        for (i=0 ; i<nsym ; i++)
                    200:                if (symtab[i].symoccurs > 0) {
                    201:                        fprintf(confh, "#define\tN%s\t%d\n",
                    202:                                symtab[i].symname, symtab[i].symoccurs);
                    203:                }
                    204:        if (ndevs > 0)
                    205:                fprintf(confh, "\n#define\tNDEVS\t%d\n\n", ndevs);
                    206: 
                    207:        /* empty symbol table, collect, and write names of all I/O routines */
                    208: 
                    209:        nsym = 0;
                    210:        for (s=devs; s!=NIL ; s=s->dvnext) {
                    211:                lookup(s->dvinit,strlen(s->dvinit));
                    212:                lookup(s->dvopen,strlen(s->dvopen));
                    213:                lookup(s->dvclose,strlen(s->dvclose));
                    214:                lookup(s->dvread,strlen(s->dvread));
                    215:                lookup(s->dvwrite,strlen(s->dvwrite));
                    216:                lookup(s->dvseek,strlen(s->dvseek));
                    217:                lookup(s->dvcntl,strlen(s->dvcntl));
                    218:                lookup(s->dvgetc,strlen(s->dvgetc));
                    219:                lookup(s->dvputc,strlen(s->dvputc));
                    220:                lookup(s->dviint,strlen(s->dviint));
                    221:                lookup(s->dvoint,strlen(s->dvoint));
                    222:                
                    223:        }
                    224:        fprintf(confh,
                    225:                "/* Declarations of I/O routines referenced */\n\n");
                    226:        for (i=0 ; i<nsym ; i++)
                    227:                fprintf(confh, "extern\tint\t%s();\n", symtab[i].symname);
                    228: 
                    229: 
                    230:        /* produce devtab (giant I/O switch table) */
                    231: 
                    232:        fprintf(confc, "\n/* device independent I/O switch */\n\n");
1.1.1.2 ! root      233:        if (ndevs > 0)
1.1       root      234:                fprintf(confc, "struct\tdevsw\tdevtab[NDEVS] = {\n");
                    235:        for (fcount=0,s=devs ; s!=NIL ; s=s->dvnext,fcount++) {
1.1.1.2 ! root      236:                fprintf(confc, "\n/*  %s */\n", s->dvname, s->dvtname);
        !           237:                fprintf(confc, "%d,\n", fcount);
1.1       root      238:                fprintf(confc, "%s, %s, %s,\n",
                    239:                        s->dvinit, s->dvopen, s->dvclose);
                    240:                fprintf(confc, "%s, %s, %s,\n",
                    241:                        s->dvread, s->dvwrite, s->dvseek);
                    242:                fprintf(confc, "%s, %s, %s,\n",
                    243:                        s->dvgetc, s->dvputc, s->dvcntl);
                    244:                fprintf(confc, "0%06o, 0%03o, 0%03o,\n",
                    245:                        s->dvcsr, s->dvivec, s->dvovec);
                    246:                fprintf(confc, "%s, %s, NULLPTR, %d",
                    247:                        s->dviint, s->dvoint, s->dvminor);
                    248:                if ( s->dvnext != NIL )
                    249:                        fprintf(confc, ",\n");
                    250:                else
                    251:                        fprintf(confc, "\n\t};");
                    252:        }
                    253: 
                    254:        /* Copy definitions to output */
                    255: 
                    256:        if (brkcount == 2 && verbose)
                    257:                printf("Copying definitions to %s...\n", CONFIGH);
                    258:        if (brkcount == 2 )
                    259:                while ( (c=input()) != 0)       /* lex input routine */
                    260:                        putc(c, confh);
                    261: 
                    262:        /* guarantee conf.c written later than conf.c for make */
                    263: 
                    264:        fclose(confh);
                    265:        fprintf(confc, "\n");
                    266:        fclose(confc);
                    267: 
                    268:        /* finish up and write report for user if requested */
                    269: 
                    270:        if (verbose) {
                    271:            printf("\nConfiguration complete. Number of devs=%d:\n\n",ndevs);
                    272:            for (s=devs; s!=NIL ; s=s->dvnext)
                    273:              printf(
                    274:                "Device %s (on %s) csr=0%-7o, ivec=0%-3o, ovec=0%-3o, minor=%d\n",
                    275:                s->dvname, s->dvdevice, s->dvcsr, s->dvivec, s->dvovec,
                    276:                s->dvminor);
                    277:        }
                    278:        
                    279: 
                    280: }
                    281: 
                    282: 
                    283: yyerror(s)
                    284:        char *s;
                    285: {
                    286:        fprintf(stderr,"Syntax error in %s on line %d\n",
                    287:                doing,linectr);
                    288: }
                    289: 
                    290: 
                    291: /*  lookup  --  lookup a name in the symbol table; return position */
                    292: 
                    293: lookup(str,len)
                    294:        char    *str;
                    295:        int     len;
                    296: {
                    297:        int     i;
                    298:        char    *s;
                    299: 
                    300:        if (len >= 20) {
                    301:                len = 19;
                    302:                fprintf(stderr,"warning: name %s truncated\n",str);
                    303:                }
                    304:        s = malloc(len+1);
                    305:        strncpy(s,str,len);
                    306:        s[len] = '\000';
                    307:        for (i=0 ; i<nsym ; i++)
                    308:                if (strcmp(s,symtab[i].symname) == 0){
                    309:                        return(i);
                    310:                }
                    311:        symtab[nsym].symname = s;
                    312:        symtab[nsym].symoccurs = 0;
                    313:        return(nsym++);
                    314: }
                    315: 
                    316: atoi(str,len)
                    317:        char *str;
                    318:        int len;
                    319: {
                    320:        int i;
                    321:        char c;
                    322: 
                    323:        for (i=0; len > 0 ; len--) {
                    324:                c = *str++;
                    325:                i = 10*i + (c - '0');
                    326:                }
                    327: }
                    328: otoi(str,len)
                    329:        char *str;
                    330:        int len;
                    331: {
                    332:        int i;
                    333:        char c;
                    334: 
                    335:        for (i=0; len > 0 ; len--) {
                    336:                c = *str++;
                    337:                if (c > '7')
                    338:                        fprintf(stderr,"invalid octal digit on line %d\n",
                    339:                                linectr);
                    340:                else
                    341:                        i = 8*i + (c - '0');
                    342:                }
                    343: }
                    344: 
                    345: /* newattr -- add a new attribute spec to current type/device description      */
                    346: 
                    347: newattr(tok,val)
                    348:        int     tok;                    /* token type (attribute type)  */
                    349:        int     val;                    /* symbol number of value       */
                    350: {
                    351:        char    *c;
                    352:        dvptr   s;
                    353: 
                    354:        if (devs == NIL)                /* doing types                  */
                    355:                s = currtype;
                    356:        else
                    357:                s = lastdv;
                    358:        if (val>=0 && val<nsym) {
                    359:                c = symtab[val].symname;
                    360:                if (strlen(c) > 20 ) {
                    361:                        fprintf(stderr,"Internal overflow\n");
                    362:                        exit(1);
                    363:                }
                    364:        } else
                    365:                c = NULL;
                    366: 
                    367:        switch (tok) {
                    368: 
                    369:        case CSR:       s->dvcsr = val;
                    370:                        break;
                    371:        case IVEC:      s->dvivec = val;
                    372:                        break;
                    373:        case OVEC:      s->dvovec = val;
                    374:                        break;
                    375:        case IINT:      strcpy(s->dviint,c);
                    376:                        break;
                    377:        case OINT:      strcpy(s->dvoint,c);
                    378:                        break;
                    379:        case READ:      strcpy(s->dvread,c);
                    380:                        break;
                    381:        case WRITE:     strcpy(s->dvwrite,c);
                    382:                        break;
                    383:        case GETC:      strcpy(s->dvgetc,c);
                    384:                        break;
                    385:        case PUTC:      strcpy(s->dvputc,c);
                    386:                        break;
                    387:        case OPEN:      strcpy(s->dvopen,c);
                    388:                        break;
                    389:        case CLOSE:     strcpy(s->dvclose,c);
                    390:                        break;
                    391:        case INIT:      strcpy(s->dvinit,c);
                    392:                        break;
                    393:        case SEEK:      strcpy(s->dvseek,c);
                    394:                        break;
                    395:        case CNTL:      strcpy(s->dvcntl,c);
                    396:                        break;
                    397:        default:        fprintf(stderr, "Internal error 1\n");
                    398:        }
                    399: }
                    400: 
                    401: /* cktname  --  check type name for duplicates */
                    402: 
                    403: cktname(symid)
                    404:        int symid;
                    405: {
                    406:        dvptr   s;
                    407: extern dvptr   ftypes;
                    408:        char    *name;
                    409: 
                    410:        name = symtab[symid].symname;
                    411:        for (s=ftypes; s!=NIL ; s=s->dvnext) {
                    412:                if (s->dvtname == name) {
                    413:                        fprintf(stderr,"Duplicate type name %s on line %d\n",
                    414:                                name,linectr);
                    415:                        exit(1);
                    416:                        }
                    417:                }
                    418:        return(symid);
                    419: }
                    420: 
                    421: /* mktype  --  make a node in the type list and initialize to defaults */
                    422: 
                    423: mktype(deviceid)
                    424:        int deviceid;
                    425: {
                    426:        dvptr   s,p;
                    427:        char    *tn,*dn;
                    428: 
                    429:        p = NIL;
                    430:        tn = symtab[currtname].symname;
                    431:        dn = symtab[deviceid].symname;
                    432:        for (s = ftypes; s!=NIL ; s=s->dvnext) {
                    433:                if (s->dvtname == tn && s->dvdevice==dn) {
                    434:                   fprintf(stderr,
                    435:                     "Duplicate device %s for type %s on line %d\n",
                    436:                     dn, tn, linectr);
                    437:                   exit(1);
                    438:                }
                    439:                p = s;
                    440:        }
                    441:        currtype = s = (dvptr) malloc( sizeof(struct dvtype));
                    442:        if (ftypes != NIL) {
                    443:                p->dvnext = s;
                    444:        }
                    445:        else {
                    446:                ftypes = s;
                    447:        }
                    448:        initattr(s, currtname, deviceid);
                    449: }
                    450: 
                    451: /* initialize attributes in a type declaration node to typename...     */
                    452: 
                    453: initattr(fstr, tnum, deviceid)
                    454:        dvptr   fstr;
                    455:        int     tnum;
                    456:        int     deviceid;
                    457: {
                    458:        char    *typnam;
                    459: 
                    460:        typnam = symtab[tnum].symname;
                    461:        fstr->dvname = NULL;
                    462:        fstr->dvtname = typnam;
                    463:        fstr->dvtnum = tnum;
                    464:        fstr->dvdevice = symtab[deviceid].symname;
                    465:        fstr->dvcsr = 0;
                    466:        fstr->dvivec = 0;
                    467:        fstr->dvovec = 0;
                    468:        strcpy(fstr->dviint,typnam);
                    469:        strcat(fstr->dviint,"iin");
                    470:        strcpy(fstr->dvoint,typnam);
                    471:        strcat(fstr->dvoint,"oin");
                    472:        strcpy(fstr->dvinit,typnam);
                    473:        strcat(fstr->dvinit,"init");
                    474:        strcpy(fstr->dvopen,typnam);
                    475:        strcat(fstr->dvopen,"open");
                    476:        strcpy(fstr->dvclose,typnam);
                    477:        strcat(fstr->dvclose,"close");
                    478:        strcpy(fstr->dvread,typnam);
                    479:        strcat(fstr->dvread,"read");
                    480:        strcpy(fstr->dvwrite,typnam);
                    481:        strcat(fstr->dvwrite,"write");
                    482:        strcpy(fstr->dvcntl,typnam);
                    483:        strcat(fstr->dvcntl,"control");
                    484:        strcpy(fstr->dvseek,typnam);
                    485:        strcat(fstr->dvseek,"seek");
                    486:        strcpy(fstr->dvgetc,typnam);
                    487:        strcat(fstr->dvgetc,"getc");
                    488:        strcpy(fstr->dvputc,typnam);
                    489:        strcat(fstr->dvputc,"putc");
                    490:        fstr->dvminor = 0;
                    491: }
                    492: 
                    493: /* mkdev  --  make a node on the device list */
                    494: 
                    495: mkdev(nameid, typid, deviceid)
                    496:        int     nameid, typid, deviceid;
                    497: {
                    498:        dvptr   s;
                    499:        char    *devn,*tn,*dn;
                    500:        int     found;
                    501: 
                    502:        s = (dvptr) malloc(sizeof(struct dvtype));
                    503:        s->dvnext = NIL;
                    504:        if (devs == NIL) {
                    505:                devs = s;
                    506:                lastdv = s;
                    507:        } else {
                    508:                lastdv->dvnext = s;
                    509:                lastdv = s;
                    510:        }
                    511:        ndevs++;
                    512:        tn = symtab[typid].symname;
                    513:        devn = symtab[nameid].symname;
                    514:        if (deviceid >= 0)
                    515:                dn = symtab[deviceid].symname;
                    516:        else
                    517:                dn = NULL;
                    518:        found = 0;
                    519:        for (s=ftypes ; s != NULL ; s=s->dvnext)
                    520:                if (s->dvtname == tn && (dn==NULL || s->dvdevice==dn)) {
                    521:                        strdup(lastdv,s,sizeof(struct dvtype));
                    522:                        found=1;
                    523:                        break;
                    524:                }
                    525:        if (found==0) {
                    526:                fprintf(stderr,
                    527:                  "Bad type or device name in declaration of %s on line %d\n",
                    528:                  devn, linectr);
                    529:                exit(1);
                    530:        }
                    531:        lastdv->dvnext = NIL;
                    532:        lastdv->dvname = devn;
                    533: }
                    534: 
                    535: 
                    536: /* chdname  -- check for duplicate device name */
                    537: 
                    538: ckdname(devid)
                    539:        int devid;
                    540: {
                    541:        dvptr   s;
                    542: extern dvptr   devs;
                    543:        char    *name;
                    544: 
                    545:        name = symtab[devid].symname;
                    546:        for (s=devs; s!=NIL ; s=s->dvnext) {
                    547:                if (s->dvname == name) {
                    548:                        fprintf(stderr,"Duplicate device name %s on line %d\n",
                    549:                                name,linectr);
                    550:                        exit(1);
                    551:                        }
                    552:                }
                    553:        return(devid);
                    554: }
                    555: 
                    556: strdup(tostr,fromstr,len)
                    557:        char    *tostr, *fromstr;
                    558:        int     len;
                    559: {
                    560:        for( ; len > 0 ; len--)
                    561:                *tostr++ = *fromstr++;
                    562: }
                    563: short yyexca[] ={
                    564: -1, 1,
                    565:        0, -1,
                    566:        -2, 0,
                    567:        };
                    568: # define YYNPROD 36
                    569: # define YYLAST 79
                    570: short yyact[]={
                    571: 
                    572:   24,  25,  26,  27,  28,  31,  29,  30,  34,  35,
                    573:   36,  37,  57,  19,  32,  33,  16,   5,   9,  17,
                    574:    8,   9,  42,  41,  15,  13,  18,  56,  12,  11,
                    575:   10,  23,  14,  40,   7,   6,   3,  22,   4,  20,
                    576:   38,   2,  21,   1,   0,   0,   0,  39,  45,  46,
                    577:   47,  48,  49,  50,  51,  52,  53,  54,  55,  43,
                    578:   44,   0,   0,   0,   0,   0,   0,   0,   0,   0,
                    579:    0,   0,   0,   0,   0,   0,   0,   0,  58 };
                    580: short yypact[]={
                    581: 
                    582: -1000,-1000,-1000,-240,-243,-1000,-1000,-259,-239,-1000,
                    583: -1000,-1000,-261,-1000,-259,-1000,-243,-1000,-262,-243,
                    584: -1000,-262,-1000,-1000,-237,-237,-237,-243,-243,-243,
                    585: -243,-243,-243,-243,-243,-243,-243,-243,-263,-262,
                    586: -1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,
                    587: -1000,-1000,-1000,-1000,-1000,-1000,-1000,-243,-1000 };
                    588: short yypgo[]={
                    589: 
                    590:    0,  43,  41,  38,  36,  35,  34,  32,  24,  26,
                    591:   20,  31,  33,  30,  29,  28,  27 };
                    592: short yyr1[]={
                    593: 
                    594:    0,   1,   2,   4,   4,   5,   7,   7,   8,   6,
                    595:   10,   9,   9,  11,  11,  11,  11,  11,  11,  11,
                    596:   11,  11,  11,  11,  11,  11,  11,  12,  12,   3,
                    597:    3,  13,  14,  15,  16,  16 };
                    598: short yyr2[]={
                    599: 
                    600:    0,   2,   2,   0,   2,   2,   2,   3,   2,   2,
                    601:    1,   0,   2,   2,   2,   2,   2,   2,   2,   2,
                    602:    2,   2,   2,   2,   2,   2,   2,   1,   1,   0,
                    603:    2,   2,   4,   1,   0,   2 };
                    604: short yychk[]={
                    605: 
                    606: -1000,  -1,  -2,  -4,  -3, 257,  -5,  -6, -10, 261,
                    607:  -13, -14, -15, -10,  -7,  -8, 275, 258,  -9, 274,
                    608:   -8,  -9, -10, -11, 262, 263, 264, 265, 266, 268,
                    609:  269, 267, 276, 277, 270, 271, 272, 273, -10,  -9,
                    610:  -12, 260, 259, -12, -12, -10, -10, -10, -10, -10,
                    611:  -10, -10, -10, -10, -10, -10, -16, 275, -10 };
                    612: short yydef[]={
                    613: 
                    614:    3,  -2,  29,   0,   1,   2,   4,   0,   0,  10,
                    615:   30,  11,   0,  33,   5,  11,   0,   9,  31,   0,
                    616:   11,   6,   8,  12,   0,   0,   0,   0,   0,   0,
                    617:    0,   0,   0,   0,   0,   0,   0,   0,  34,   7,
                    618:   13,  27,  28,  14,  15,  16,  17,  18,  19,  20,
                    619:   21,  22,  23,  24,  25,  26,  32,   0,  35 };
                    620: #ifndef lint
1.1.1.2 ! root      621: static char yaccpar_sccsid[] = "@(#)yaccpar 1.2 86/07/18 SMI"; /* from UCB 4.1 83/02/11 */
        !           622: #endif
1.1       root      623: 
                    624: #
                    625: # define YYFLAG -1000
                    626: # define YYERROR goto yyerrlab
                    627: # define YYACCEPT return(0)
                    628: # define YYABORT return(1)
                    629: 
                    630: /*     parser for yacc output  */
                    631: 
                    632: #ifdef YYDEBUG
                    633: int yydebug = 0; /* 1 for debugging */
                    634: #endif
                    635: YYSTYPE yyv[YYMAXDEPTH]; /* where the values are stored */
                    636: int yychar = -1; /* current input token number */
                    637: int yynerrs = 0;  /* number of errors */
                    638: short yyerrflag = 0;  /* error recovery flag */
                    639: 
                    640: yyparse() {
                    641: 
                    642:        short yys[YYMAXDEPTH];
                    643:        short yyj, yym;
                    644:        register YYSTYPE *yypvt;
                    645:        register short yystate, *yyps, yyn;
                    646:        register YYSTYPE *yypv;
                    647:        register short *yyxi;
                    648: 
                    649:        yystate = 0;
                    650:        yychar = -1;
                    651:        yynerrs = 0;
                    652:        yyerrflag = 0;
                    653:        yyps= &yys[-1];
                    654:        yypv= &yyv[-1];
                    655: 
                    656:  yystack:    /* put a state and value onto the stack */
                    657: 
                    658: #ifdef YYDEBUG
                    659:        if( yydebug  ) printf( "state %d, char 0%o\n", yystate, yychar );
                    660: #endif
1.1.1.2 ! root      661:                if( ++yyps>= &yys[YYMAXDEPTH] ) { yyerror( "yacc stack overflow" ); return(1); }
1.1       root      662:                *yyps = yystate;
                    663:                ++yypv;
                    664:                *yypv = yyval;
                    665: 
                    666:  yynewstate:
                    667: 
                    668:        yyn = yypact[yystate];
                    669: 
                    670:        if( yyn<= YYFLAG ) goto yydefault; /* simple state */
                    671: 
                    672:        if( yychar<0 ) if( (yychar=yylex())<0 ) yychar=0;
                    673:        if( (yyn += yychar)<0 || yyn >= YYLAST ) goto yydefault;
                    674: 
                    675:        if( yychk[ yyn=yyact[ yyn ] ] == yychar ){ /* valid shift */
                    676:                yychar = -1;
                    677:                yyval = yylval;
                    678:                yystate = yyn;
                    679:                if( yyerrflag > 0 ) --yyerrflag;
                    680:                goto yystack;
                    681:                }
                    682: 
                    683:  yydefault:
                    684:        /* default state action */
                    685: 
                    686:        if( (yyn=yydef[yystate]) == -2 ) {
                    687:                if( yychar<0 ) if( (yychar=yylex())<0 ) yychar = 0;
                    688:                /* look through exception table */
                    689: 
                    690:                for( yyxi=yyexca; (*yyxi!= (-1)) || (yyxi[1]!=yystate) ; yyxi += 2 ) ; /* VOID */
                    691: 
                    692:                while( *(yyxi+=2) >= 0 ){
                    693:                        if( *yyxi == yychar ) break;
                    694:                        }
                    695:                if( (yyn = yyxi[1]) < 0 ) return(0);   /* accept */
                    696:                }
                    697: 
                    698:        if( yyn == 0 ){ /* error */
                    699:                /* error ... attempt to resume parsing */
                    700: 
                    701:                switch( yyerrflag ){
                    702: 
                    703:                case 0:   /* brand new error */
                    704: 
                    705:                        yyerror( "syntax error" );
                    706:                yyerrlab:
                    707:                        ++yynerrs;
                    708: 
                    709:                case 1:
                    710:                case 2: /* incompletely recovered error ... try again */
                    711: 
                    712:                        yyerrflag = 3;
                    713: 
                    714:                        /* find a state where "error" is a legal shift action */
                    715: 
                    716:                        while ( yyps >= yys ) {
                    717:                           yyn = yypact[*yyps] + YYERRCODE;
                    718:                           if( yyn>= 0 && yyn < YYLAST && yychk[yyact[yyn]] == YYERRCODE ){
                    719:                              yystate = yyact[yyn];  /* simulate a shift of "error" */
                    720:                              goto yystack;
                    721:                              }
                    722:                           yyn = yypact[*yyps];
                    723: 
                    724:                           /* the current yyps has no shift onn "error", pop stack */
                    725: 
                    726: #ifdef YYDEBUG
                    727:                           if( yydebug ) printf( "error recovery pops state %d, uncovers %d\n", *yyps, yyps[-1] );
                    728: #endif
                    729:                           --yyps;
                    730:                           --yypv;
                    731:                           }
                    732: 
                    733:                        /* there is no state on the stack with an error shift ... abort */
                    734: 
                    735:        yyabort:
                    736:                        return(1);
                    737: 
                    738: 
                    739:                case 3:  /* no shift yet; clobber input char */
                    740: 
                    741: #ifdef YYDEBUG
                    742:                        if( yydebug ) printf( "error recovery discards char %d\n", yychar );
                    743: #endif
                    744: 
                    745:                        if( yychar == 0 ) goto yyabort; /* don't discard EOF, quit */
                    746:                        yychar = -1;
                    747:                        goto yynewstate;   /* try again in the same state */
                    748: 
                    749:                        }
                    750: 
                    751:                }
                    752: 
                    753:        /* reduction by production yyn */
                    754: 
                    755: #ifdef YYDEBUG
                    756:                if( yydebug ) printf("reduce %d\n",yyn);
                    757: #endif
                    758:                yyps -= yyr2[yyn];
                    759:                yypvt = yypv;
                    760:                yypv -= yyr2[yyn];
                    761:                yyval = yypv[1];
                    762:                yym=yyn;
                    763:                        /* consult goto table to find next state */
                    764:                yyn = yyr1[yyn];
                    765:                yyj = yypgo[yyn] + *yyps + 1;
                    766:                if( yyj>=YYLAST || yychk[ yystate = yyact[yyj] ] != -yyn ) yystate = yyact[yypgo[yyn]];
                    767:                switch(yym){
                    768:                        
                    769: case 2:
1.1.1.2 ! root      770: # line 89 "config.y"
1.1       root      771: {doing = "device definitions";} break;
                    772: case 8:
1.1.1.2 ! root      773: # line 100 "config.y"
1.1       root      774: {mktype(yypvt[-0]);} break;
                    775: case 9:
1.1.1.2 ! root      776: # line 103 "config.y"
1.1       root      777: {yyval = currtname = cktname(yypvt[-1]);} break;
                    778: case 10:
1.1.1.2 ! root      779: # line 106 "config.y"
1.1       root      780: {yyval = currname =
                    781:                                         lookup(yytext,yyleng);
                    782:                                        } break;
                    783: case 13:
1.1.1.2 ! root      784: # line 114 "config.y"
1.1       root      785: {newattr(CSR,yypvt[-0]);} break;
                    786: case 14:
1.1.1.2 ! root      787: # line 116 "config.y"
1.1       root      788: {newattr(IVEC,yypvt[-0]);} break;
                    789: case 15:
1.1.1.2 ! root      790: # line 118 "config.y"
1.1       root      791: {newattr(OVEC,yypvt[-0]);} break;
                    792: case 16:
1.1.1.2 ! root      793: # line 120 "config.y"
1.1       root      794: {newattr(IINT,yypvt[-0]);} break;
                    795: case 17:
1.1.1.2 ! root      796: # line 122 "config.y"
1.1       root      797: {newattr(OINT,yypvt[-0]);} break;
                    798: case 18:
1.1.1.2 ! root      799: # line 124 "config.y"
1.1       root      800: {newattr(OPEN,yypvt[-0]);} break;
                    801: case 19:
1.1.1.2 ! root      802: # line 126 "config.y"
1.1       root      803: {newattr(CLOSE,yypvt[-0]);} break;
                    804: case 20:
1.1.1.2 ! root      805: # line 128 "config.y"
1.1       root      806: {newattr(INIT,yypvt[-0]);} break;
                    807: case 21:
1.1.1.2 ! root      808: # line 130 "config.y"
1.1       root      809: {newattr(GETC,yypvt[-0]);} break;
                    810: case 22:
1.1.1.2 ! root      811: # line 132 "config.y"
1.1       root      812: {newattr(PUTC,yypvt[-0]);} break;
                    813: case 23:
1.1.1.2 ! root      814: # line 134 "config.y"
1.1       root      815: {newattr(READ,yypvt[-0]);} break;
                    816: case 24:
1.1.1.2 ! root      817: # line 136 "config.y"
1.1       root      818: {newattr(WRITE,yypvt[-0]);} break;
                    819: case 25:
1.1.1.2 ! root      820: # line 138 "config.y"
1.1       root      821: {newattr(SEEK,yypvt[-0]);} break;
                    822: case 26:
1.1.1.2 ! root      823: # line 140 "config.y"
1.1       root      824: {newattr(CNTL,yypvt[-0]);} break;
                    825: case 27:
1.1.1.2 ! root      826: # line 148 "config.y"
1.1       root      827: {yyval = otoi(yytext,yyleng);} break;
                    828: case 28:
1.1.1.2 ! root      829: # line 150 "config.y"
1.1       root      830: {yyval = otoi(yytext,yyleng);} break;
                    831: case 32:
1.1.1.2 ! root      832: # line 158 "config.y"
1.1       root      833: {mkdev(yypvt[-3],yypvt[-1],yypvt[-0]);} break;
                    834: case 33:
1.1.1.2 ! root      835: # line 161 "config.y"
1.1       root      836: {yyval = currdname = ckdname(yypvt[-0]);} break;
                    837: case 34:
1.1.1.2 ! root      838: # line 164 "config.y"
1.1       root      839: {yyval = 0;} break;
                    840: case 35:
1.1.1.2 ! root      841: # line 166 "config.y"
1.1       root      842: {yyval = yypvt[-0];} break;
                    843:                }
                    844:                goto yystack;  /* stack new state and value */
                    845: 
                    846:        }

unix.superglobalmegacorp.com

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