Annotation of researchv10no/ipc/internet/htable/parse.c, revision 1.1.1.1

1.1       root        1: 
                      2: # line 2 "parse.y"
                      3: 
                      4: /*
                      5:  * Copyright (c) 1983 Regents of the University of California.
                      6:  * All rights reserved.
                      7:  *
                      8:  * Redistribution and use in source and binary forms are permitted
                      9:  * provided that the above copyright notice and this paragraph are
                     10:  * duplicated in all such forms and that any documentation,
                     11:  * advertising materials, and other materials related to such
                     12:  * distribution and use acknowledge that the software was developed
                     13:  * by the University of California, Berkeley.  The name of the
                     14:  * University may not be used to endorse or promote products derived
                     15:  * from this software without specific prior written permission.
                     16:  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
                     17:  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
                     18:  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
                     19:  */
                     20: 
                     21: #ifndef lint
                     22: static char sccsid[] = "@(#)parse.y    5.4 (Berkeley) 6/18/88";
                     23: #endif /* not lint */
                     24: #include "htable.h"
                     25: 
                     26: #include "y.tab.h"
                     27: 
                     28: # line 28 "parse.y"
                     29: typedef union  {
                     30:        int     number;
                     31:        struct  addr *addrlist;
                     32:        struct  name *namelist;
                     33: } YYSTYPE;
                     34: # define END 257
                     35: # define NUMBER 258
                     36: # define KEYWORD 259
                     37: # define NAME 260
                     38: #define yyclearin yychar = -1
                     39: #define yyerrok yyerrflag = 0
                     40: extern int yychar;
                     41: extern short yyerrflag;
                     42: #ifndef YYMAXDEPTH
                     43: #define YYMAXDEPTH 150
                     44: #endif
                     45: YYSTYPE yylval, yyval;
                     46: # define YYERRCODE 256
                     47: 
                     48: # line 139 "parse.y"
                     49: 
                     50: 
                     51: #include <stdio.h>
                     52: 
                     53: extern int yylineno;
                     54: 
                     55: yyerror(msg)
                     56:        char *msg;
                     57: {
                     58:        fprintf(stderr, "\"%s\", line %d: %s\n", infile, yylineno, msg);
                     59: }
                     60: short yyexca[] ={
                     61: -1, 1,
                     62:        0, -1,
                     63:        -2, 0,
                     64:        };
                     65: # define YYNPROD 22
                     66: # define YYLAST 203
                     67: short yyact[]={
                     68: 
                     69:   35,  29,  22,  38,  31,  24,   4,   5,  16,   3,
                     70:   32,  26,  18,  11,  42,  39,   8,  40,  33,  27,
                     71:   19,  12,   7,  28,  21,  14,  41,  20,  13,  36,
                     72:   15,   9,   2,  10,   6,  37,  30,  23,   1,   0,
                     73:    0,   0,   0,   0,   0,  17,   0,   0,   0,   0,
                     74:    0,  25,   0,   0,   0,   0,   0,   0,   0,   0,
                     75:    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
                     76:    0,  43,   0,   0,   0,   0,   0,   0,   0,   0,
                     77:    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
                     78:    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
                     79:    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
                     80:    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
                     81:    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
                     82:    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
                     83:    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
                     84:    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
                     85:    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
                     86:    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
                     87:    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
                     88:    0,   0,   0,   0,   0,   0,   0,   0,   0,  34,
                     89:    0,   0,  38 };
                     90: short yypact[]={
                     91: 
                     92: -250,-250,-1000, -36,-241,-1000,-1000,-245,-1000, -37,
                     93:  -16, -21,-252,-245,-246, -38, -17,-1000, -22,-255,
                     94: -252,-247,-1000, -39,-1000,-1000, -23,-256,-248,-1000,
                     95:  -40,-1000,-1000, -58,-1000,-242, -41, -18,-1000,-1000,
                     96: -243,-257,-1000,-1000 };
                     97: short yypgo[]={
                     98: 
                     99:    0,  38,  30,  37,  36,  29,  35,  31,  33,  32 };
                    100: short yyr1[]={
                    101: 
                    102:    0,   1,   1,   9,   9,   9,   9,   9,   9,   9,
                    103:    7,   7,   8,   2,   2,   3,   3,   4,   4,   5,
                    104:    5,   6 };
                    105: short yyr2[]={
                    106: 
                    107:    0,   1,   2,   7,   9,  11,  12,  13,   2,   1,
                    108:    1,   3,   7,   1,   3,   0,   1,   0,   1,   1,
                    109:    3,   1 };
                    110: short yychk[]={
                    111: 
                    112: -1000,  -1,  -9, 259, 256, 257,  -9,  58, 257,  -7,
                    113:   -8, 258,  58,  44,  46,  -2, 260,  -7, 258,  58,
                    114:   44,  46, 257,  -3, 260,  -2, 258,  58,  46, 257,
                    115:   -4, 260, 258,  58, 257,  58,  -5,  -6, 260, 257,
                    116:   58,  44, 257,  -5 };
                    117: short yydef[]={
                    118: 
                    119:    0,  -2,   1,   0,   0,   9,   2,   0,   8,   0,
                    120:   10,   0,   0,   0,   0,   0,  13,  11,   0,  15,
                    121:    0,   0,   3,   0,  16,  14,   0,  17,   0,   4,
                    122:    0,  18,  12,   0,   5,   0,   0,  19,  21,   6,
                    123:    0,   0,   7,  20 };
                    124: # ifdef YYDEBUG
                    125: # include "y.debug"
                    126: # endif
                    127: 
                    128: # define YYFLAG -1000
                    129: # define YYERROR goto yyerrlab
                    130: # define YYACCEPT return(0)
                    131: # define YYABORT return(1)
                    132: 
                    133: /*     parser for yacc output  */
                    134: 
                    135: #ifdef YYDEBUG
                    136: int yydebug = 0; /* 1 for debugging */
                    137: #endif
                    138: YYSTYPE yyv[YYMAXDEPTH]; /* where the values are stored */
                    139: int yychar = -1; /* current input token number */
                    140: int yynerrs = 0;  /* number of errors */
                    141: short yyerrflag = 0;  /* error recovery flag */
                    142: 
                    143: yyparse()
                    144: {      short yys[YYMAXDEPTH];
                    145:        int yyj, yym;
                    146:        register YYSTYPE *yypvt;
                    147:        register int yystate, yyn;
                    148:        register short *yyps;
                    149:        register YYSTYPE *yypv;
                    150:        register short *yyxi;
                    151: 
                    152:        yystate = 0;
                    153:        yychar = -1;
                    154:        yynerrs = 0;
                    155:        yyerrflag = 0;
                    156:        yyps= &yys[-1];
                    157:        yypv= &yyv[-1];
                    158: 
                    159: yystack:    /* put a state and value onto the stack */
                    160: #ifdef YYDEBUG
                    161:        if(yydebug >= 3)
                    162:                if(yychar < 0 || yytoknames[yychar] == 0)
                    163:                        printf("char %d in %s", yychar, yystates[yystate]);
                    164:                else
                    165:                        printf("%s in %s", yytoknames[yychar], yystates[yystate]);
                    166: #endif
                    167:        if( ++yyps >= &yys[YYMAXDEPTH] ) { 
                    168:                yyerror( "yacc stack overflow" ); 
                    169:                return(1); 
                    170:        }
                    171:        *yyps = yystate;
                    172:        ++yypv;
                    173:        *yypv = yyval;
                    174: yynewstate:
                    175:        yyn = yypact[yystate];
                    176:        if(yyn <= YYFLAG) goto yydefault; /* simple state */
                    177:        if(yychar<0) {
                    178:                yychar = yylex();
                    179: #ifdef YYDEBUG
                    180:                if(yydebug >= 2) {
                    181:                        if(yychar <= 0)
                    182:                                printf("lex EOF\n");
                    183:                        else if(yytoknames[yychar])
                    184:                                printf("lex %s\n", yytoknames[yychar]);
                    185:                        else
                    186:                                printf("lex (%c)\n", yychar);
                    187:                }
                    188: #endif
                    189:                if(yychar < 0)
                    190:                        yychar = 0;
                    191:        }
                    192:        if((yyn += yychar) < 0 || yyn >= YYLAST)
                    193:                goto yydefault;
                    194:        if( yychk[ yyn=yyact[ yyn ] ] == yychar ){ /* valid shift */
                    195:                yychar = -1;
                    196:                yyval = yylval;
                    197:                yystate = yyn;
                    198:                if( yyerrflag > 0 ) --yyerrflag;
                    199:                goto yystack;
                    200:        }
                    201: yydefault:
                    202:        /* default state action */
                    203:        if( (yyn=yydef[yystate]) == -2 ) {
                    204:                if(yychar < 0) {
                    205:                        yychar = yylex();
                    206: #ifdef YYDEBUG
                    207:                        if(yydebug >= 2)
                    208:                                if(yychar < 0)
                    209:                                        printf("lex EOF\n");
                    210:                                else
                    211:                                        printf("lex %s\n", yytoknames[yychar]);
                    212: #endif
                    213:                        if(yychar < 0)
                    214:                                yychar = 0;
                    215:                }
                    216:                /* look through exception table */
                    217:                for(yyxi=yyexca; (*yyxi!= (-1)) || (yyxi[1]!=yystate);
                    218:                        yyxi += 2 ) ; /* VOID */
                    219:                while( *(yyxi+=2) >= 0 ){
                    220:                        if( *yyxi == yychar ) break;
                    221:                }
                    222:                if( (yyn = yyxi[1]) < 0 ) return(0);   /* accept */
                    223:        }
                    224:        if( yyn == 0 ){ /* error */
                    225:                /* error ... attempt to resume parsing */
                    226:                switch( yyerrflag ){
                    227:                case 0:   /* brand new error */
                    228: #ifdef YYDEBUG
                    229:                        yyerror("syntax error\n%s", yystates[yystate]);
                    230:                        if(yytoknames[yychar])
                    231:                                yyerror("saw %s\n", yytoknames[yychar]);
                    232:                        else if(yychar >= ' ' && yychar < '\177')
                    233:                                yyerror("saw `%c'\n", yychar);
                    234:                        else if(yychar == 0)
                    235:                                yyerror("saw EOF\n");
                    236:                        else
                    237:                                yyerror("saw char 0%o\n", yychar);
                    238: #else
                    239:                        yyerror( "syntax error" );
                    240: #endif
                    241: yyerrlab:
                    242:                        ++yynerrs;
                    243:                case 1:
                    244:                case 2: /* incompletely recovered error ... try again */
                    245:                        yyerrflag = 3;
                    246:                        /* find a state where "error" is a legal shift action */
                    247:                        while ( yyps >= yys ) {
                    248:                                yyn = yypact[*yyps] + YYERRCODE;
                    249:                                if( yyn>= 0 && yyn < YYLAST && yychk[yyact[yyn]] == YYERRCODE ){
                    250:                                        yystate = yyact[yyn];  /* simulate a shift of "error" */
                    251:                                        goto yystack;
                    252:                                }
                    253:                                yyn = yypact[*yyps];
                    254:                                /* the current yyps has no shift onn "error", pop stack */
                    255: #ifdef YYDEBUG
                    256:                                if( yydebug ) printf( "error recovery pops state %d, uncovers %d\n", *yyps, yyps[-1] );
                    257: #endif
                    258:                                --yyps;
                    259:                                --yypv;
                    260:                        }
                    261:                        /* there is no state on the stack with an error shift ... abort */
                    262: yyabort:
                    263:                        return(1);
                    264:                case 3:  /* no shift yet; clobber input char */
                    265: #ifdef YYDEBUG
                    266:                        if( yydebug ) {
                    267:                                printf("error recovery discards ");
                    268:                                if(yytoknames[yychar])
                    269:                                        printf("%s\n", yytoknames[yychar]);
                    270:                                else if(yychar >= ' ' && yychar < '\177')
                    271:                                        printf("`%c'\n", yychar);
                    272:                                else if(yychar == 0)
                    273:                                        printf("EOF\n");
                    274:                                else
                    275:                                        printf("char 0%o\n", yychar);
                    276:                        }
                    277: #endif
                    278:                        if( yychar == 0 ) goto yyabort; /* don't discard EOF, quit */
                    279:                        yychar = -1;
                    280:                        goto yynewstate;   /* try again in the same state */
                    281:                }
                    282:        }
                    283:        /* reduction by production yyn */
                    284: #ifdef YYDEBUG
                    285:        if(yydebug) {   char *s;
                    286:                printf("reduce %d in:\n\t", yyn);
                    287:                for(s = yystates[yystate]; *s; s++) {
                    288:                        putchar(*s);
                    289:                        if(*s == '\n' && *(s+1))
                    290:                                putchar('\t');
                    291:                }
                    292:        }
                    293: #endif
                    294:        yyps -= yyr2[yyn];
                    295:        yypvt = yypv;
                    296:        yypv -= yyr2[yyn];
                    297:        yyval = yypv[1];
                    298:        yym=yyn;
                    299:        /* consult goto table to find next state */
                    300:        yyn = yyr1[yyn];
                    301:        yyj = yypgo[yyn] + *yyps + 1;
                    302:        if( yyj>=YYLAST || yychk[ yystate = yyact[yyj] ] != -yyn ) yystate = yyact[yypgo[yyn]];
                    303:        switch(yym){
                    304:                
                    305: case 3:
                    306: # line 47 "parse.y"
                    307:  {
                    308:                do_entry(yypvt[-6].number, yypvt[-4].addrlist, yypvt[-2].namelist, NONAME, NONAME, NONAME);
                    309:        } break;
                    310: case 4:
                    311: # line 51 "parse.y"
                    312:  {
                    313:                do_entry(yypvt[-8].number, yypvt[-6].addrlist, yypvt[-4].namelist, yypvt[-2].namelist, NONAME, NONAME);
                    314:        } break;
                    315: case 5:
                    316: # line 55 "parse.y"
                    317:  {
                    318:                do_entry(yypvt[-10].number, yypvt[-8].addrlist, yypvt[-6].namelist, yypvt[-4].namelist, yypvt[-2].namelist, NONAME);
                    319:        } break;
                    320: case 6:
                    321: # line 59 "parse.y"
                    322:  {
                    323:                do_entry(yypvt[-11].number, yypvt[-9].addrlist, yypvt[-7].namelist, yypvt[-5].namelist, yypvt[-3].namelist, NONAME);
                    324:        } break;
                    325: case 7:
                    326: # line 63 "parse.y"
                    327:  {
                    328:                do_entry(yypvt[-12].number, yypvt[-10].addrlist, yypvt[-8].namelist, yypvt[-6].namelist, yypvt[-4].namelist, yypvt[-2].namelist);
                    329:        } break;
                    330: case 10:
                    331: # line 71 "parse.y"
                    332:  {
                    333:                yyval.addrlist = yypvt[-0].addrlist;
                    334:        } break;
                    335: case 11:
                    336: # line 75 "parse.y"
                    337:  {
                    338:                yypvt[-2].addrlist->addr_link = yypvt[-0].addrlist;
                    339:                yyval.addrlist = yypvt[-2].addrlist;
                    340:        } break;
                    341: case 12:
                    342: # line 82 "parse.y"
                    343:  {
                    344:                char *a;
                    345: 
                    346:                yyval.addrlist = (struct addr *)malloc(sizeof (struct addr));
                    347:                a = (char *)&(yyval.addrlist->addr_val);
                    348:                a[0] = yypvt[-6].number; a[1] = yypvt[-4].number; a[2] = yypvt[-2].number; a[3] = yypvt[-0].number;
                    349:                yyval.addrlist->addr_link = NOADDR;
                    350:        } break;
                    351: case 13:
                    352: # line 93 "parse.y"
                    353:  {
                    354:                yyval.namelist = yypvt[-0].namelist;
                    355:        } break;
                    356: case 14:
                    357: # line 97 "parse.y"
                    358:  {
                    359:                yypvt[-2].namelist->name_link = yypvt[-0].namelist;
                    360:                yyval.namelist = yypvt[-2].namelist;
                    361:        } break;
                    362: case 15:
                    363: # line 104 "parse.y"
                    364:  {
                    365:                yyval.namelist = NONAME;
                    366:        } break;
                    367: case 16:
                    368: # line 108 "parse.y"
                    369:  {
                    370:                yyval.namelist = yypvt[-0].namelist;
                    371:        } break;
                    372: case 17:
                    373: # line 114 "parse.y"
                    374:  {
                    375:                yyval.namelist = NONAME;
                    376:        } break;
                    377: case 18:
                    378: # line 118 "parse.y"
                    379:  {
                    380:                yyval.namelist = yypvt[-0].namelist;
                    381:        } break;
                    382: case 19:
                    383: # line 124 "parse.y"
                    384:  {
                    385:                yyval.namelist = yypvt[-0].namelist;
                    386:        } break;
                    387: case 20:
                    388: # line 128 "parse.y"
                    389:  {
                    390:                yypvt[-2].namelist->name_link = yypvt[-0].namelist;
                    391:                yyval.namelist = yypvt[-2].namelist;
                    392:        } break;
                    393: case 21:
                    394: # line 135 "parse.y"
                    395:  {
                    396:                yyval.namelist = yypvt[-0].namelist;
                    397:        } break;
                    398:        }
                    399:        goto yystack;  /* stack new state and value */
                    400: }

unix.superglobalmegacorp.com

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