Annotation of 42BSD/etc/htable/scan.c, revision 1.1

1.1     ! root        1: # include "stdio.h"
        !             2: # define U(x) x
        !             3: # define NLSTATE yyprevious=YYNEWLINE
        !             4: # define BEGIN yybgin = yysvec + 1 +
        !             5: # define INITIAL 0
        !             6: # define YYLERR yysvec
        !             7: # define YYSTATE (yyestate-yysvec-1)
        !             8: # define YYOPTIM 1
        !             9: # define YYLMAX 200
        !            10: # define output(c) putc(c,yyout)
        !            11: # define input() (((yytchar=yysptr>yysbuf?U(*--yysptr):getc(yyin))==10?(yylineno++,yytchar):yytchar)==EOF?0:yytchar)
        !            12: # define unput(c) {yytchar= (c);if(yytchar=='\n')yylineno--;*yysptr++=yytchar;}
        !            13: # define yymore() (yymorfg=1)
        !            14: # define ECHO fprintf(yyout, "%s",yytext)
        !            15: # define REJECT { nstr = yyreject(); goto yyfussy;}
        !            16: int yyleng; extern char yytext[];
        !            17: int yymorfg;
        !            18: extern char *yysptr, yysbuf[];
        !            19: int yytchar;
        !            20: FILE *yyin ={stdin}, *yyout ={stdout};
        !            21: extern int yylineno;
        !            22: struct yysvf { 
        !            23:        struct yywork *yystoff;
        !            24:        struct yysvf *yyother;
        !            25:        int *yystops;};
        !            26: struct yysvf *yyestate;
        !            27: extern struct yysvf yysvec[], *yybgin;
        !            28: #ifndef lint
        !            29: static char sccsid[] = "@(#)scan.l     4.1 (Berkeley) 10/20/82";
        !            30: #endif
        !            31: 
        !            32: #include "y.tab.h"
        !            33: #include "htable.h"
        !            34: # define YYNEWLINE 10
        !            35: yylex(){
        !            36: int nstr; extern int yyprevious;
        !            37: while((nstr = yylook()) >= 0)
        !            38: yyfussy: switch(nstr){
        !            39: case 0:
        !            40: if(yywrap()) return(0); break;
        !            41: case 1:
        !            42:        {
        !            43:                        yylval.number = KW_NET;
        !            44:                        return (KEYWORD);
        !            45:                }
        !            46: break;
        !            47: case 2:
        !            48: {
        !            49:                        yylval.number = KW_GATEWAY;
        !            50:                        return (KEYWORD);
        !            51:                }
        !            52: break;
        !            53: case 3:
        !            54:        {
        !            55:                        yylval.number = KW_HOST;
        !            56:                        return (KEYWORD);
        !            57:                }
        !            58: break;
        !            59: case 4:
        !            60: {
        !            61:                        yylval.namelist = newname(yytext);
        !            62:                        return (NAME);
        !            63:                }
        !            64: break;
        !            65: case 5:
        !            66:        return (NAME);
        !            67: break;
        !            68: case 6:
        !            69: {
        !            70:                        yylval.number = atoi(yytext);
        !            71:                        return (NUMBER);
        !            72:                }
        !            73: break;
        !            74: case 7:
        !            75:        return ('.');
        !            76: break;
        !            77: case 8:
        !            78:        return (':');
        !            79: break;
        !            80: case 9:
        !            81:        return (',');
        !            82: break;
        !            83: case 10:
        !            84:        return ('/');
        !            85: break;
        !            86: case 11:
        !            87:        ;
        !            88: break;
        !            89: case 12:
        !            90: ;
        !            91: break;
        !            92: case 13:
        !            93: ;
        !            94: break;
        !            95: case 14:
        !            96:        return (END);
        !            97: break;
        !            98: case 15:
        !            99:        fprintf(stderr, "Illegal char: '%s'\n", yytext);
        !           100: break;
        !           101: case -1:
        !           102: break;
        !           103: default:
        !           104: fprintf(yyout,"bad switch yylook %d",nstr);
        !           105: } return(0); }
        !           106: /* end of yylex */
        !           107: 
        !           108: yywrap()
        !           109: {
        !           110:        return (1);
        !           111: }
        !           112: int yyvstop[] ={
        !           113: 0,
        !           114: 
        !           115: 15,
        !           116: 0,
        !           117: 
        !           118: 13,
        !           119: 15,
        !           120: 0,
        !           121: 
        !           122: 14,
        !           123: 0,
        !           124: 
        !           125: 9,
        !           126: 15,
        !           127: 0,
        !           128: 
        !           129: 7,
        !           130: 15,
        !           131: 0,
        !           132: 
        !           133: 10,
        !           134: 15,
        !           135: 0,
        !           136: 
        !           137: 6,
        !           138: 15,
        !           139: 0,
        !           140: 
        !           141: 8,
        !           142: 15,
        !           143: 0,
        !           144: 
        !           145: 11,
        !           146: 15,
        !           147: 0,
        !           148: 
        !           149: 5,
        !           150: 15,
        !           151: 0,
        !           152: 
        !           153: 5,
        !           154: 15,
        !           155: 0,
        !           156: 
        !           157: 5,
        !           158: 15,
        !           159: 0,
        !           160: 
        !           161: 5,
        !           162: 15,
        !           163: 0,
        !           164: 
        !           165: 13,
        !           166: 0,
        !           167: 
        !           168: 12,
        !           169: 0,
        !           170: 
        !           171: 6,
        !           172: 0,
        !           173: 
        !           174: 11,
        !           175: 0,
        !           176: 
        !           177: 4,
        !           178: 0,
        !           179: 
        !           180: 4,
        !           181: 0,
        !           182: 
        !           183: 4,
        !           184: 0,
        !           185: 
        !           186: 4,
        !           187: 0,
        !           188: 
        !           189: 4,
        !           190: 0,
        !           191: 
        !           192: 4,
        !           193: 0,
        !           194: 
        !           195: 1,
        !           196: 4,
        !           197: 0,
        !           198: 
        !           199: 4,
        !           200: 0,
        !           201: 
        !           202: 3,
        !           203: 4,
        !           204: 0,
        !           205: 
        !           206: 4,
        !           207: 0,
        !           208: 
        !           209: 4,
        !           210: 0,
        !           211: 
        !           212: 2,
        !           213: 4,
        !           214: 0,
        !           215: 0};
        !           216: # define YYTYPE char
        !           217: struct yywork { YYTYPE verify, advance; } yycrank[] ={
        !           218: 0,0,   0,0,    1,3,    0,0,    
        !           219: 0,0,   0,0,    0,0,    11,19,  
        !           220: 0,0,   0,0,    1,4,    1,5,    
        !           221: 4,16,  5,17,   0,0,    11,19,  
        !           222: 11,0,  0,0,    0,0,    0,0,    
        !           223: 0,0,   0,0,    0,0,    0,0,    
        !           224: 19,0,  0,0,    0,0,    0,0,    
        !           225: 0,0,   0,0,    0,0,    0,0,    
        !           226: 0,0,   0,0,    0,0,    4,16,   
        !           227: 5,17,  0,0,    0,0,    0,0,    
        !           228: 0,0,   0,0,    0,0,    0,0,    
        !           229: 0,0,   1,6,    1,3,    1,7,    
        !           230: 1,8,   1,9,    2,6,    11,19,  
        !           231: 2,7,   2,8,    11,19,  0,0,    
        !           232: 0,0,   0,0,    0,0,    1,10,   
        !           233: 1,11,  0,0,    0,0,    0,0,    
        !           234: 2,10,  2,11,   1,12,   0,0,    
        !           235: 0,0,   0,0,    0,0,    11,19,  
        !           236: 1,13,  1,14,   0,0,    0,0,    
        !           237: 0,0,   2,13,   2,14,   1,15,   
        !           238: 13,22, 30,31,  0,0,    15,24,  
        !           239: 2,15,  9,18,   9,18,   9,18,   
        !           240: 9,18,  9,18,   9,18,   9,18,   
        !           241: 9,18,  9,18,   9,18,   12,20,  
        !           242: 12,20, 12,20,  12,21,  12,21,  
        !           243: 12,21, 12,21,  12,21,  12,21,  
        !           244: 12,21, 12,21,  12,21,  12,21,  
        !           245: 14,23, 22,25,  23,26,  24,27,  
        !           246: 25,28, 26,29,  28,30,  12,21,  
        !           247: 12,21, 12,21,  12,21,  12,21,  
        !           248: 12,21, 12,21,  12,21,  12,21,  
        !           249: 12,21, 12,21,  12,21,  12,21,  
        !           250: 12,21, 12,21,  12,21,  12,21,  
        !           251: 12,21, 12,21,  12,21,  12,21,  
        !           252: 12,21, 12,21,  12,21,  12,21,  
        !           253: 12,21, 31,32,  0,0,    0,0,    
        !           254: 0,0};
        !           255: struct yysvf yysvec[] ={
        !           256: 0,     0,      0,
        !           257: yycrank+-1,    0,              0,      
        !           258: yycrank+-6,    yysvec+1,       0,      
        !           259: yycrank+0,     0,              yyvstop+1,
        !           260: yycrank+3,     0,              yyvstop+3,
        !           261: yycrank+4,     0,              yyvstop+6,
        !           262: yycrank+0,     0,              yyvstop+8,
        !           263: yycrank+0,     0,              yyvstop+11,
        !           264: yycrank+0,     0,              yyvstop+14,
        !           265: yycrank+37,    0,              yyvstop+17,
        !           266: yycrank+0,     0,              yyvstop+20,
        !           267: yycrank+-6,    0,              yyvstop+23,
        !           268: yycrank+50,    0,              yyvstop+26,
        !           269: yycrank+15,    yysvec+12,      yyvstop+29,
        !           270: yycrank+29,    yysvec+12,      yyvstop+32,
        !           271: yycrank+14,    yysvec+12,      yyvstop+35,
        !           272: yycrank+0,     yysvec+4,       yyvstop+38,
        !           273: yycrank+0,     yysvec+5,       yyvstop+40,
        !           274: yycrank+0,     yysvec+9,       yyvstop+42,
        !           275: yycrank+-14,   yysvec+11,      yyvstop+44,
        !           276: yycrank+0,     yysvec+12,      0,      
        !           277: yycrank+0,     yysvec+12,      yyvstop+46,
        !           278: yycrank+25,    yysvec+12,      yyvstop+48,
        !           279: yycrank+27,    yysvec+12,      yyvstop+50,
        !           280: yycrank+27,    yysvec+12,      yyvstop+52,
        !           281: yycrank+43,    yysvec+12,      yyvstop+54,
        !           282: yycrank+29,    yysvec+12,      yyvstop+56,
        !           283: yycrank+0,     yysvec+12,      yyvstop+58,
        !           284: yycrank+27,    yysvec+12,      yyvstop+61,
        !           285: yycrank+0,     yysvec+12,      yyvstop+63,
        !           286: yycrank+16,    yysvec+12,      yyvstop+66,
        !           287: yycrank+52,    yysvec+12,      yyvstop+68,
        !           288: yycrank+0,     yysvec+12,      yyvstop+70,
        !           289: 0,     0,      0};
        !           290: struct yywork *yytop = yycrank+141;
        !           291: struct yysvf *yybgin = yysvec+1;
        !           292: char yymatch[] ={
        !           293: 00  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
        !           294: 01  ,011 ,012 ,01  ,01  ,01  ,01  ,01  ,
        !           295: 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
        !           296: 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
        !           297: 011 ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
        !           298: 01  ,01  ,01  ,01  ,01  ,'-' ,'-' ,'-' ,
        !           299: '0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,
        !           300: '0' ,'0' ,01  ,01  ,01  ,01  ,01  ,01  ,
        !           301: 01  ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,
        !           302: 'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,
        !           303: 'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,
        !           304: 'A' ,'A' ,'A' ,01  ,01  ,01  ,01  ,01  ,
        !           305: 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
        !           306: 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
        !           307: 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
        !           308: 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
        !           309: 0};
        !           310: char yyextra[] ={
        !           311: 0,0,0,0,0,0,0,0,
        !           312: 0,0,0,0,0,0,0,0,
        !           313: 0};
        !           314: /*     ncform  4.1     83/08/11        */
        !           315: 
        !           316: int yylineno =1;
        !           317: # define YYU(x) x
        !           318: # define NLSTATE yyprevious=YYNEWLINE
        !           319: char yytext[YYLMAX];
        !           320: struct yysvf *yylstate [YYLMAX], **yylsp, **yyolsp;
        !           321: char yysbuf[YYLMAX];
        !           322: char *yysptr = yysbuf;
        !           323: int *yyfnd;
        !           324: extern struct yysvf *yyestate;
        !           325: int yyprevious = YYNEWLINE;
        !           326: yylook(){
        !           327:        register struct yysvf *yystate, **lsp;
        !           328:        register struct yywork *yyt;
        !           329:        struct yysvf *yyz;
        !           330:        int yych;
        !           331:        struct yywork *yyr;
        !           332: # ifdef LEXDEBUG
        !           333:        int debug;
        !           334: # endif
        !           335:        char *yylastch;
        !           336:        /* start off machines */
        !           337: # ifdef LEXDEBUG
        !           338:        debug = 0;
        !           339: # endif
        !           340:        if (!yymorfg)
        !           341:                yylastch = yytext;
        !           342:        else {
        !           343:                yymorfg=0;
        !           344:                yylastch = yytext+yyleng;
        !           345:                }
        !           346:        for(;;){
        !           347:                lsp = yylstate;
        !           348:                yyestate = yystate = yybgin;
        !           349:                if (yyprevious==YYNEWLINE) yystate++;
        !           350:                for (;;){
        !           351: # ifdef LEXDEBUG
        !           352:                        if(debug)fprintf(yyout,"state %d\n",yystate-yysvec-1);
        !           353: # endif
        !           354:                        yyt = yystate->yystoff;
        !           355:                        if(yyt == yycrank){             /* may not be any transitions */
        !           356:                                yyz = yystate->yyother;
        !           357:                                if(yyz == 0)break;
        !           358:                                if(yyz->yystoff == yycrank)break;
        !           359:                                }
        !           360:                        *yylastch++ = yych = input();
        !           361:                tryagain:
        !           362: # ifdef LEXDEBUG
        !           363:                        if(debug){
        !           364:                                fprintf(yyout,"char ");
        !           365:                                allprint(yych);
        !           366:                                putchar('\n');
        !           367:                                }
        !           368: # endif
        !           369:                        yyr = yyt;
        !           370:                        if ( (int)yyt > (int)yycrank){
        !           371:                                yyt = yyr + yych;
        !           372:                                if (yyt <= yytop && yyt->verify+yysvec == yystate){
        !           373:                                        if(yyt->advance+yysvec == YYLERR)       /* error transitions */
        !           374:                                                {unput(*--yylastch);break;}
        !           375:                                        *lsp++ = yystate = yyt->advance+yysvec;
        !           376:                                        goto contin;
        !           377:                                        }
        !           378:                                }
        !           379: # ifdef YYOPTIM
        !           380:                        else if((int)yyt < (int)yycrank) {              /* r < yycrank */
        !           381:                                yyt = yyr = yycrank+(yycrank-yyt);
        !           382: # ifdef LEXDEBUG
        !           383:                                if(debug)fprintf(yyout,"compressed state\n");
        !           384: # endif
        !           385:                                yyt = yyt + yych;
        !           386:                                if(yyt <= yytop && yyt->verify+yysvec == yystate){
        !           387:                                        if(yyt->advance+yysvec == YYLERR)       /* error transitions */
        !           388:                                                {unput(*--yylastch);break;}
        !           389:                                        *lsp++ = yystate = yyt->advance+yysvec;
        !           390:                                        goto contin;
        !           391:                                        }
        !           392:                                yyt = yyr + YYU(yymatch[yych]);
        !           393: # ifdef LEXDEBUG
        !           394:                                if(debug){
        !           395:                                        fprintf(yyout,"try fall back character ");
        !           396:                                        allprint(YYU(yymatch[yych]));
        !           397:                                        putchar('\n');
        !           398:                                        }
        !           399: # endif
        !           400:                                if(yyt <= yytop && yyt->verify+yysvec == yystate){
        !           401:                                        if(yyt->advance+yysvec == YYLERR)       /* error transition */
        !           402:                                                {unput(*--yylastch);break;}
        !           403:                                        *lsp++ = yystate = yyt->advance+yysvec;
        !           404:                                        goto contin;
        !           405:                                        }
        !           406:                                }
        !           407:                        if ((yystate = yystate->yyother) && (yyt= yystate->yystoff) != yycrank){
        !           408: # ifdef LEXDEBUG
        !           409:                                if(debug)fprintf(yyout,"fall back to state %d\n",yystate-yysvec-1);
        !           410: # endif
        !           411:                                goto tryagain;
        !           412:                                }
        !           413: # endif
        !           414:                        else
        !           415:                                {unput(*--yylastch);break;}
        !           416:                contin:
        !           417: # ifdef LEXDEBUG
        !           418:                        if(debug){
        !           419:                                fprintf(yyout,"state %d char ",yystate-yysvec-1);
        !           420:                                allprint(yych);
        !           421:                                putchar('\n');
        !           422:                                }
        !           423: # endif
        !           424:                        ;
        !           425:                        }
        !           426: # ifdef LEXDEBUG
        !           427:                if(debug){
        !           428:                        fprintf(yyout,"stopped at %d with ",*(lsp-1)-yysvec-1);
        !           429:                        allprint(yych);
        !           430:                        putchar('\n');
        !           431:                        }
        !           432: # endif
        !           433:                while (lsp-- > yylstate){
        !           434:                        *yylastch-- = 0;
        !           435:                        if (*lsp != 0 && (yyfnd= (*lsp)->yystops) && *yyfnd > 0){
        !           436:                                yyolsp = lsp;
        !           437:                                if(yyextra[*yyfnd]){            /* must backup */
        !           438:                                        while(yyback((*lsp)->yystops,-*yyfnd) != 1 && lsp > yylstate){
        !           439:                                                lsp--;
        !           440:                                                unput(*yylastch--);
        !           441:                                                }
        !           442:                                        }
        !           443:                                yyprevious = YYU(*yylastch);
        !           444:                                yylsp = lsp;
        !           445:                                yyleng = yylastch-yytext+1;
        !           446:                                yytext[yyleng] = 0;
        !           447: # ifdef LEXDEBUG
        !           448:                                if(debug){
        !           449:                                        fprintf(yyout,"\nmatch ");
        !           450:                                        sprint(yytext);
        !           451:                                        fprintf(yyout," action %d\n",*yyfnd);
        !           452:                                        }
        !           453: # endif
        !           454:                                return(*yyfnd++);
        !           455:                                }
        !           456:                        unput(*yylastch);
        !           457:                        }
        !           458:                if (yytext[0] == 0  /* && feof(yyin) */)
        !           459:                        {
        !           460:                        yysptr=yysbuf;
        !           461:                        return(0);
        !           462:                        }
        !           463:                yyprevious = yytext[0] = input();
        !           464:                if (yyprevious>0)
        !           465:                        output(yyprevious);
        !           466:                yylastch=yytext;
        !           467: # ifdef LEXDEBUG
        !           468:                if(debug)putchar('\n');
        !           469: # endif
        !           470:                }
        !           471:        }
        !           472: yyback(p, m)
        !           473:        int *p;
        !           474: {
        !           475: if (p==0) return(0);
        !           476: while (*p)
        !           477:        {
        !           478:        if (*p++ == m)
        !           479:                return(1);
        !           480:        }
        !           481: return(0);
        !           482: }
        !           483:        /* the following are only used in the lex library */
        !           484: yyinput(){
        !           485:        return(input());
        !           486:        }
        !           487: yyoutput(c)
        !           488:   int c; {
        !           489:        output(c);
        !           490:        }
        !           491: yyunput(c)
        !           492:    int c; {
        !           493:        unput(c);
        !           494:        }

unix.superglobalmegacorp.com

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