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