|
|
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: /* config.l 1.14 83/05/18 */ ! 29: ! 30: #include <ctype.h> ! 31: #include "y.tab.h" ! 32: #include "config.h" ! 33: ! 34: #define tprintf if (do_trace) printf ! 35: ! 36: /* ! 37: * Key word table ! 38: */ ! 39: ! 40: struct kt { ! 41: char *kt_name; ! 42: int kt_val; ! 43: } key_words[] = { ! 44: { "and", AND }, ! 45: { "args", ARGS }, ! 46: { "at", AT }, ! 47: { "config", CONFIG }, ! 48: { "controller", CONTROLLER }, ! 49: { "cpu", CPU }, ! 50: { "csr", CSR }, ! 51: { "device", DEVICE }, ! 52: { "disk", DISK }, ! 53: { "drive", DRIVE }, ! 54: { "dst", DST }, ! 55: { "dumps", DUMPS }, ! 56: { "flags", FLAGS }, ! 57: { "hz", HZ }, ! 58: { "ident", IDENT }, ! 59: { "machine", MACHINE }, ! 60: { "major", MAJOR }, ! 61: { "master", MASTER }, ! 62: { "maxusers", MAXUSERS }, ! 63: { "mba", MBA }, ! 64: { "minor", MINOR }, ! 65: { "nexus", NEXUS }, ! 66: { "on", ON }, ! 67: { "options", OPTIONS }, ! 68: { "priority", PRIORITY }, ! 69: { "pseudo-device",PSEUDO_DEVICE }, ! 70: { "root", ROOT }, ! 71: { "size", SIZE }, ! 72: { "slave", SLAVE }, ! 73: { "swap", SWAP }, ! 74: { "tape", DEVICE }, ! 75: { "timezone", TIMEZONE }, ! 76: { "trace", TRACE }, ! 77: { "uba", UBA }, ! 78: { "vba", VBA }, ! 79: { "vector", VECTOR }, ! 80: { 0, 0 }, ! 81: }; ! 82: # define YYNEWLINE 10 ! 83: yylex(){ ! 84: int nstr; extern int yyprevious; ! 85: while((nstr = yylook()) >= 0) ! 86: yyfussy: switch(nstr){ ! 87: case 0: ! 88: if(yywrap()) return(0); break; ! 89: case 1: ! 90: { ! 91: int i; ! 92: ! 93: if ((i = kw_lookup(yytext)) == -1) ! 94: { ! 95: yylval.str = yytext; ! 96: tprintf("id(%s) ", yytext); ! 97: return ID; ! 98: } ! 99: tprintf("(%s) ", yytext); ! 100: return i; ! 101: } ! 102: break; ! 103: case 2: ! 104: { ! 105: yytext[strlen(yytext)-1] = '\0'; ! 106: yylval.str = yytext + 1; ! 107: return ID; ! 108: } ! 109: break; ! 110: case 3: ! 111: { ! 112: yylval.val = octal(yytext); ! 113: tprintf("#O:%o ", yylval.val); ! 114: return NUMBER; ! 115: } ! 116: break; ! 117: case 4: ! 118: { ! 119: yylval.val = hex(yytext); ! 120: tprintf("#X:%x ", yylval.val); ! 121: return NUMBER; ! 122: } ! 123: break; ! 124: case 5: ! 125: { ! 126: yylval.val = atoi(yytext); ! 127: tprintf("#D:%d ", yylval.val); ! 128: return NUMBER; ! 129: } ! 130: break; ! 131: case 6: ! 132: { ! 133: double atof(); ! 134: yylval.val = (int) (60 * atof(yytext) + 0.5); ! 135: return FPNUMBER; ! 136: } ! 137: break; ! 138: case 7: ! 139: { ! 140: return MINUS; ! 141: } ! 142: break; ! 143: case 8: ! 144: { ! 145: yylval.val = -1; ! 146: tprintf("? "); ! 147: return NUMBER; ! 148: } ! 149: break; ! 150: case 9: ! 151: { ! 152: yyline++; ! 153: tprintf("\n... "); ! 154: } ! 155: break; ! 156: case 10: ! 157: { ! 158: yyline++; ! 159: tprintf("\n"); ! 160: return SEMICOLON; ! 161: } ! 162: break; ! 163: case 11: ! 164: { /* Ignored (comment) */; } ! 165: break; ! 166: case 12: ! 167: { /* Ignored (white space) */; } ! 168: break; ! 169: case 13: ! 170: { return SEMICOLON; } ! 171: break; ! 172: case 14: ! 173: { return COMMA; } ! 174: break; ! 175: case 15: ! 176: { return EQUALS; } ! 177: break; ! 178: case 16: ! 179: { return AT; } ! 180: break; ! 181: case 17: ! 182: { return yytext[0]; } ! 183: break; ! 184: case -1: ! 185: break; ! 186: default: ! 187: fprintf(yyout,"bad switch yylook %d",nstr); ! 188: } return(0); } ! 189: /* end of yylex */ ! 190: /* ! 191: * kw_lookup ! 192: * Look up a string in the keyword table. Returns a -1 if the ! 193: * string is not a keyword otherwise it returns the keyword number ! 194: */ ! 195: ! 196: kw_lookup(word) ! 197: register char *word; ! 198: { ! 199: register struct kt *kp; ! 200: ! 201: for (kp = key_words; kp->kt_name != 0; kp++) ! 202: if (eq(word, kp->kt_name)) ! 203: return kp->kt_val; ! 204: return -1; ! 205: } ! 206: ! 207: /* ! 208: * Number conversion routines ! 209: */ ! 210: ! 211: octal(str) ! 212: char *str; ! 213: { ! 214: int num; ! 215: ! 216: (void) sscanf(str, "%o", &num); ! 217: return num; ! 218: } ! 219: ! 220: hex(str) ! 221: char *str; ! 222: { ! 223: int num; ! 224: ! 225: (void) sscanf(str+2, "%x", &num); ! 226: return num; ! 227: } ! 228: int yyvstop[] ={ ! 229: 0, ! 230: ! 231: 12, ! 232: 0, ! 233: ! 234: 12, ! 235: 0, ! 236: ! 237: 17, ! 238: 0, ! 239: ! 240: 12, ! 241: 17, ! 242: 0, ! 243: ! 244: 10, ! 245: -9, ! 246: 0, ! 247: ! 248: 17, ! 249: 0, ! 250: ! 251: 11, ! 252: 17, ! 253: 0, ! 254: ! 255: 14, ! 256: 17, ! 257: 0, ! 258: ! 259: 7, ! 260: 17, ! 261: 0, ! 262: ! 263: 3, ! 264: 17, ! 265: 0, ! 266: ! 267: 5, ! 268: 17, ! 269: 0, ! 270: ! 271: 13, ! 272: 17, ! 273: 0, ! 274: ! 275: 15, ! 276: 17, ! 277: 0, ! 278: ! 279: 8, ! 280: 17, ! 281: 0, ! 282: ! 283: 16, ! 284: 17, ! 285: 0, ! 286: ! 287: 1, ! 288: 17, ! 289: 0, ! 290: ! 291: 12, ! 292: 0, ! 293: ! 294: 9, ! 295: 0, ! 296: ! 297: 11, ! 298: 0, ! 299: ! 300: 6, ! 301: 0, ! 302: ! 303: 3, ! 304: 0, ! 305: ! 306: 5, ! 307: 0, ! 308: ! 309: 1, ! 310: 0, ! 311: ! 312: 2, ! 313: 0, ! 314: ! 315: 4, ! 316: 0, ! 317: 0}; ! 318: # define YYTYPE char ! 319: struct yywork { YYTYPE verify, advance; } yycrank[] ={ ! 320: 0,0, 0,0, 1,3, 1,3, ! 321: 6,19, 6,19, 0,0, 0,0, ! 322: 19,19, 20,20, 1,4, 1,5, ! 323: 6,19, 6,19, 2,3, 4,17, ! 324: 5,18, 20,0, 0,0, 0,0, ! 325: 0,0, 0,0, 0,0, 0,0, ! 326: 0,0, 0,0, 0,0, 0,0, ! 327: 0,0, 0,0, 0,0, 0,0, ! 328: 0,0, 0,0, 0,0, 1,6, ! 329: 1,7, 6,0, 4,17, 5,18, ! 330: 19,26, 0,0, 0,0, 0,0, ! 331: 0,0, 1,8, 1,9, 2,7, ! 332: 6,19, 1,10, 1,11, 6,19, ! 333: 6,19, 0,0, 0,0, 0,0, ! 334: 2,8, 1,11, 0,0, 6,19, ! 335: 1,12, 0,0, 1,13, 0,0, ! 336: 1,14, 1,15, 1,16, 0,0, ! 337: 6,19, 7,20, 7,20, 2,12, ! 338: 1,16, 2,13, 6,19, 2,14, ! 339: 2,15, 7,20, 7,0, 10,21, ! 340: 0,0, 10,22, 10,22, 10,22, ! 341: 10,22, 10,22, 10,22, 10,22, ! 342: 10,22, 11,21, 0,0, 11,24, ! 343: 11,24, 11,24, 11,24, 11,24, ! 344: 11,24, 11,24, 11,24, 11,24, ! 345: 11,24, 0,0, 7,20, 21,21, ! 346: 21,21, 21,21, 21,21, 21,21, ! 347: 21,21, 21,21, 21,21, 21,21, ! 348: 21,21, 7,20, 0,0, 0,0, ! 349: 7,20, 7,20, 0,0, 0,0, ! 350: 0,0, 0,0, 0,0, 0,0, ! 351: 7,20, 22,22, 22,22, 22,22, ! 352: 22,22, 22,22, 22,22, 22,22, ! 353: 22,22, 7,20, 16,25, 0,0, ! 354: 0,0, 0,0, 0,0, 7,20, ! 355: 24,24, 24,24, 24,24, 24,24, ! 356: 24,24, 24,24, 24,24, 24,24, ! 357: 24,24, 24,24, 0,0, 0,0, ! 358: 0,0, 10,23, 16,25, 16,25, ! 359: 16,25, 16,25, 16,25, 16,25, ! 360: 16,25, 16,25, 16,25, 16,25, ! 361: 16,25, 16,25, 16,25, 16,25, ! 362: 16,25, 16,25, 16,25, 16,25, ! 363: 16,25, 16,25, 16,25, 16,25, ! 364: 16,25, 16,25, 16,25, 16,25, ! 365: 0,0, 0,0, 0,0, 0,0, ! 366: 16,25, 0,0, 16,25, 16,25, ! 367: 16,25, 16,25, 16,25, 16,25, ! 368: 16,25, 16,25, 16,25, 16,25, ! 369: 16,25, 16,25, 16,25, 16,25, ! 370: 16,25, 16,25, 16,25, 16,25, ! 371: 16,25, 16,25, 16,25, 16,25, ! 372: 16,25, 16,25, 16,25, 16,25, ! 373: 23,27, 23,27, 23,27, 23,27, ! 374: 23,27, 23,27, 23,27, 23,27, ! 375: 23,27, 23,27, 0,0, 0,0, ! 376: 0,0, 0,0, 0,0, 0,0, ! 377: 0,0, 23,27, 23,27, 23,27, ! 378: 23,27, 23,27, 23,27, 0,0, ! 379: 0,0, 0,0, 0,0, 0,0, ! 380: 0,0, 0,0, 0,0, 0,0, ! 381: 0,0, 0,0, 0,0, 0,0, ! 382: 0,0, 0,0, 0,0, 0,0, ! 383: 0,0, 0,0, 0,0, 0,0, ! 384: 0,0, 0,0, 0,0, 0,0, ! 385: 0,0, 23,27, 23,27, 23,27, ! 386: 23,27, 23,27, 23,27, 0,0, ! 387: 0,0}; ! 388: struct yysvf yysvec[] ={ ! 389: 0, 0, 0, ! 390: yycrank+-1, 0, yyvstop+1, ! 391: yycrank+-12, yysvec+1, yyvstop+3, ! 392: yycrank+0, 0, yyvstop+5, ! 393: yycrank+6, 0, yyvstop+7, ! 394: yycrank+7, 0, yyvstop+10, ! 395: yycrank+-3, 0, yyvstop+13, ! 396: yycrank+-68, 0, yyvstop+15, ! 397: yycrank+0, 0, yyvstop+18, ! 398: yycrank+0, 0, yyvstop+21, ! 399: yycrank+33, 0, yyvstop+24, ! 400: yycrank+43, 0, yyvstop+27, ! 401: yycrank+0, 0, yyvstop+30, ! 402: yycrank+0, 0, yyvstop+33, ! 403: yycrank+0, 0, yyvstop+36, ! 404: yycrank+0, 0, yyvstop+39, ! 405: yycrank+89, 0, yyvstop+42, ! 406: yycrank+0, yysvec+4, yyvstop+45, ! 407: yycrank+0, 0, yyvstop+47, ! 408: yycrank+-6, yysvec+6, 0, ! 409: yycrank+-7, yysvec+7, yyvstop+49, ! 410: yycrank+55, 0, yyvstop+51, ! 411: yycrank+77, 0, yyvstop+53, ! 412: yycrank+164, 0, 0, ! 413: yycrank+92, 0, yyvstop+55, ! 414: yycrank+0, yysvec+16, yyvstop+57, ! 415: yycrank+0, 0, yyvstop+59, ! 416: yycrank+0, yysvec+23, yyvstop+61, ! 417: 0, 0, 0}; ! 418: struct yywork *yytop = yycrank+266; ! 419: struct yysvf *yybgin = yysvec+1; ! 420: char yymatch[] ={ ! 421: 00 ,01 ,00 ,01 ,01 ,01 ,01 ,01 , ! 422: 01 ,011 ,012 ,01 ,01 ,01 ,01 ,01 , ! 423: 01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 , ! 424: 01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 , ! 425: 011 ,01 ,'"' ,01 ,01 ,01 ,01 ,01 , ! 426: 01 ,01 ,01 ,01 ,01 ,'-' ,01 ,01 , ! 427: '0' ,'1' ,'1' ,'1' ,'1' ,'1' ,'1' ,'1' , ! 428: '8' ,'8' ,01 ,01 ,01 ,01 ,01 ,01 , ! 429: 01 ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'G' , ! 430: 'G' ,'G' ,'G' ,'G' ,'G' ,'G' ,'G' ,'G' , ! 431: 'G' ,'G' ,'G' ,'G' ,'G' ,'G' ,'G' ,'G' , ! 432: 'G' ,'G' ,'G' ,01 ,01 ,01 ,01 ,'G' , ! 433: 01 ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'G' , ! 434: 'G' ,'G' ,'G' ,'G' ,'G' ,'G' ,'G' ,'G' , ! 435: 'G' ,'G' ,'G' ,'G' ,'G' ,'G' ,'G' ,'G' , ! 436: 'G' ,'G' ,'G' ,01 ,01 ,01 ,01 ,01 , ! 437: 0}; ! 438: char yyextra[] ={ ! 439: 0,0,0,0,0,0,0,0, ! 440: 0,1,0,0,0,0,0,0, ! 441: 0,0,0,0,0,0,0,0, ! 442: 0}; ! 443: int yylineno =1; ! 444: # define YYU(x) x ! 445: # define NLSTATE yyprevious=YYNEWLINE ! 446: char yytext[YYLMAX]; ! 447: struct yysvf *yylstate [YYLMAX], **yylsp, **yyolsp; ! 448: char yysbuf[YYLMAX]; ! 449: char *yysptr = yysbuf; ! 450: int *yyfnd; ! 451: extern struct yysvf *yyestate; ! 452: int yyprevious = YYNEWLINE; ! 453: yylook(){ ! 454: register struct yysvf *yystate, **lsp; ! 455: register struct yywork *yyt; ! 456: struct yysvf *yyz; ! 457: int yych; ! 458: struct yywork *yyr; ! 459: # ifdef LEXDEBUG ! 460: int debug; ! 461: # endif ! 462: char *yylastch; ! 463: /* start off machines */ ! 464: # ifdef LEXDEBUG ! 465: debug = 0; ! 466: # endif ! 467: if (!yymorfg) ! 468: yylastch = yytext; ! 469: else { ! 470: yymorfg=0; ! 471: yylastch = yytext+yyleng; ! 472: } ! 473: for(;;){ ! 474: lsp = yylstate; ! 475: yyestate = yystate = yybgin; ! 476: if (yyprevious==YYNEWLINE) yystate++; ! 477: for (;;){ ! 478: # ifdef LEXDEBUG ! 479: if(debug)fprintf(yyout,"state %d\n",yystate-yysvec-1); ! 480: # endif ! 481: yyt = yystate->yystoff; ! 482: if(yyt == yycrank){ /* may not be any transitions */ ! 483: yyz = yystate->yyother; ! 484: if(yyz == 0)break; ! 485: if(yyz->yystoff == yycrank)break; ! 486: } ! 487: *yylastch++ = yych = input(); ! 488: tryagain: ! 489: # ifdef LEXDEBUG ! 490: if(debug){ ! 491: fprintf(yyout,"char "); ! 492: allprint(yych); ! 493: putchar('\n'); ! 494: } ! 495: # endif ! 496: yyr = yyt; ! 497: if ( (int)yyt > (int)yycrank){ ! 498: yyt = yyr + yych; ! 499: if (yyt <= yytop && yyt->verify+yysvec == yystate){ ! 500: if(yyt->advance+yysvec == YYLERR) /* error transitions */ ! 501: {unput(*--yylastch);break;} ! 502: *lsp++ = yystate = yyt->advance+yysvec; ! 503: goto contin; ! 504: } ! 505: } ! 506: # ifdef YYOPTIM ! 507: else if((int)yyt < (int)yycrank) { /* r < yycrank */ ! 508: yyt = yyr = yycrank+(yycrank-yyt); ! 509: # ifdef LEXDEBUG ! 510: if(debug)fprintf(yyout,"compressed state\n"); ! 511: # endif ! 512: yyt = yyt + yych; ! 513: if(yyt <= yytop && yyt->verify+yysvec == yystate){ ! 514: if(yyt->advance+yysvec == YYLERR) /* error transitions */ ! 515: {unput(*--yylastch);break;} ! 516: *lsp++ = yystate = yyt->advance+yysvec; ! 517: goto contin; ! 518: } ! 519: yyt = yyr + YYU(yymatch[yych]); ! 520: # ifdef LEXDEBUG ! 521: if(debug){ ! 522: fprintf(yyout,"try fall back character "); ! 523: allprint(YYU(yymatch[yych])); ! 524: putchar('\n'); ! 525: } ! 526: # endif ! 527: if(yyt <= yytop && yyt->verify+yysvec == yystate){ ! 528: if(yyt->advance+yysvec == YYLERR) /* error transition */ ! 529: {unput(*--yylastch);break;} ! 530: *lsp++ = yystate = yyt->advance+yysvec; ! 531: goto contin; ! 532: } ! 533: } ! 534: if ((yystate = yystate->yyother) && (yyt= yystate->yystoff) != yycrank){ ! 535: # ifdef LEXDEBUG ! 536: if(debug)fprintf(yyout,"fall back to state %d\n",yystate-yysvec-1); ! 537: # endif ! 538: goto tryagain; ! 539: } ! 540: # endif ! 541: else ! 542: {unput(*--yylastch);break;} ! 543: contin: ! 544: # ifdef LEXDEBUG ! 545: if(debug){ ! 546: fprintf(yyout,"state %d char ",yystate-yysvec-1); ! 547: allprint(yych); ! 548: putchar('\n'); ! 549: } ! 550: # endif ! 551: ; ! 552: } ! 553: # ifdef LEXDEBUG ! 554: if(debug){ ! 555: fprintf(yyout,"stopped at %d with ",*(lsp-1)-yysvec-1); ! 556: allprint(yych); ! 557: putchar('\n'); ! 558: } ! 559: # endif ! 560: while (lsp-- > yylstate){ ! 561: *yylastch-- = 0; ! 562: if (*lsp != 0 && (yyfnd= (*lsp)->yystops) && *yyfnd > 0){ ! 563: yyolsp = lsp; ! 564: if(yyextra[*yyfnd]){ /* must backup */ ! 565: while(yyback((*lsp)->yystops,-*yyfnd) != 1 && lsp > yylstate){ ! 566: lsp--; ! 567: unput(*yylastch--); ! 568: } ! 569: } ! 570: yyprevious = YYU(*yylastch); ! 571: yylsp = lsp; ! 572: yyleng = yylastch-yytext+1; ! 573: yytext[yyleng] = 0; ! 574: # ifdef LEXDEBUG ! 575: if(debug){ ! 576: fprintf(yyout,"\nmatch "); ! 577: sprint(yytext); ! 578: fprintf(yyout," action %d\n",*yyfnd); ! 579: } ! 580: # endif ! 581: return(*yyfnd++); ! 582: } ! 583: unput(*yylastch); ! 584: } ! 585: if (yytext[0] == 0 /* && feof(yyin) */) ! 586: { ! 587: yysptr=yysbuf; ! 588: return(0); ! 589: } ! 590: yyprevious = yytext[0] = input(); ! 591: if (yyprevious>0) ! 592: output(yyprevious); ! 593: yylastch=yytext; ! 594: # ifdef LEXDEBUG ! 595: if(debug)putchar('\n'); ! 596: # endif ! 597: } ! 598: } ! 599: yyback(p, m) ! 600: int *p; ! 601: { ! 602: if (p==0) return(0); ! 603: while (*p) ! 604: { ! 605: if (*p++ == m) ! 606: return(1); ! 607: } ! 608: return(0); ! 609: } ! 610: /* the following are only used in the lex library */ ! 611: yyinput(){ ! 612: return(input()); ! 613: } ! 614: yyoutput(c) ! 615: int c; { ! 616: output(c); ! 617: } ! 618: yyunput(c) ! 619: int c; { ! 620: unput(c); ! 621: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.