Quake-III-Arena

Quake III Arena GPL Source Release
Log | Files | Refs

yacc.c (13491B)


      1 # define ID 257
      2 # define CON 258
      3 # define UNARYMINUS 259
      4 #define yyclearin yychar = -1
      5 #define yyerrok yyerrflag = 0
      6 extern int yychar;
      7 extern short yyerrflag;
      8 #ifndef YYMAXDEPTH
      9 #define YYMAXDEPTH 150
     10 #endif
     11 #ifndef YYSTYPE
     12 #define YYSTYPE int
     13 #endif
     14 YYSTYPE yylval, yyval;
     15 # define YYERRCODE 256
     16 
     17 
     18 
     19 #include <stdio.h>
     20 
     21 # define U(x) x
     22 # define NLSTATE yyprevious=YYNEWLINE
     23 # define BEGIN yybgin = yysvec + 1 +
     24 # define INITIAL 0
     25 # define YYLERR yysvec
     26 # define YYSTATE (yyestate-yysvec-1)
     27 # define YYOPTIM 1
     28 # define YYLMAX 200
     29 # define output(c) (void)putc(c,yyout)
     30 # define input() (((yytchar=yysptr>yysbuf?U(*--yysptr):getc(yyin))==10?(yylineno++,yytchar):yytchar)==EOF?0:yytchar)
     31 # define unput(c) {yytchar= (c);if(yytchar=='\n')yylineno--;*yysptr++=yytchar;}
     32 # define yymore() (yymorfg=1)
     33 # define ECHO fprintf(yyout, "%s",yytext)
     34 # define REJECT { nstr = yyreject(); goto yyfussy;}
     35 int yyleng; extern char yytext[];
     36 int yymorfg;
     37 extern char *yysptr, yysbuf[];
     38 int yytchar;
     39 FILE *yyin ={stdin}, *yyout ={stdout};
     40 extern int yylineno;
     41 struct yysvf { 
     42 	struct yywork *yystoff;
     43 	struct yysvf *yyother;
     44 	int *yystops;};
     45 struct yysvf *yyestate;
     46 extern struct yysvf yysvec[], *yybgin;
     47 # define YYNEWLINE 10
     48 yylex(){
     49 int nstr; extern int yyprevious;
     50 while((nstr = yylook()) >= 0)
     51 yyfussy: switch(nstr){
     52 case 0:
     53 if(yywrap()) return(0); break;
     54 case 1:
     55  return ID;
     56 break;
     57 case 2:
     58                  return CON;
     59 break;
     60 case 3:
     61                   ;
     62 break;
     63 case 4:
     64                    return yytext[0];
     65 break;
     66 case -1:
     67 break;
     68 default:
     69 fprintf(yyout,"bad switch yylook %d",nstr);
     70 } return(0); }
     71 /* end of yylex */
     72 int yyvstop[] ={
     73 0,
     74 
     75 4,
     76 0,
     77 
     78 3,
     79 4,
     80 0,
     81 
     82 2,
     83 4,
     84 0,
     85 
     86 1,
     87 4,
     88 0,
     89 
     90 2,
     91 0,
     92 
     93 1,
     94 0,
     95 0};
     96 # define YYTYPE char
     97 struct yywork { YYTYPE verify, advance; } yycrank[] ={
     98 0,0,	0,0,	1,3,	0,0,	
     99 0,0,	0,0,	0,0,	0,0,	
    100 0,0,	0,0,	1,4,	1,3,	
    101 0,0,	0,0,	0,0,	0,0,	
    102 0,0,	0,0,	0,0,	0,0,	
    103 0,0,	0,0,	0,0,	0,0,	
    104 0,0,	0,0,	0,0,	0,0,	
    105 0,0,	0,0,	0,0,	0,0,	
    106 0,0,	0,0,	0,0,	0,0,	
    107 0,0,	0,0,	0,0,	0,0,	
    108 0,0,	0,0,	0,0,	0,0,	
    109 0,0,	0,0,	0,0,	0,0,	
    110 0,0,	1,5,	5,7,	5,7,	
    111 5,7,	5,7,	5,7,	5,7,	
    112 5,7,	5,7,	5,7,	5,7,	
    113 0,0,	0,0,	0,0,	0,0,	
    114 0,0,	0,0,	1,6,	6,8,	
    115 6,8,	6,8,	6,8,	6,8,	
    116 6,8,	6,8,	6,8,	6,8,	
    117 6,8,	0,0,	0,0,	0,0,	
    118 0,0,	0,0,	0,0,	0,0,	
    119 6,8,	6,8,	6,8,	6,8,	
    120 6,8,	6,8,	6,8,	6,8,	
    121 6,8,	6,8,	6,8,	6,8,	
    122 6,8,	6,8,	6,8,	6,8,	
    123 6,8,	6,8,	6,8,	6,8,	
    124 6,8,	6,8,	6,8,	6,8,	
    125 6,8,	6,8,	0,0,	0,0,	
    126 0,0,	0,0,	6,8,	0,0,	
    127 6,8,	6,8,	6,8,	6,8,	
    128 6,8,	6,8,	6,8,	6,8,	
    129 6,8,	6,8,	6,8,	6,8,	
    130 6,8,	6,8,	6,8,	6,8,	
    131 6,8,	6,8,	6,8,	6,8,	
    132 6,8,	6,8,	6,8,	6,8,	
    133 6,8,	6,8,	0,0,	0,0,	
    134 0,0};
    135 struct yysvf yysvec[] ={
    136 0,	0,	0,
    137 yycrank+-1,	0,		0,	
    138 yycrank+0,	yysvec+1,	0,	
    139 yycrank+0,	0,		yyvstop+1,
    140 yycrank+0,	0,		yyvstop+3,
    141 yycrank+2,	0,		yyvstop+6,
    142 yycrank+19,	0,		yyvstop+9,
    143 yycrank+0,	yysvec+5,	yyvstop+12,
    144 yycrank+0,	yysvec+6,	yyvstop+14,
    145 0,	0,	0};
    146 struct yywork *yytop = yycrank+141;
    147 struct yysvf *yybgin = yysvec+1;
    148 char yymatch[] ={
    149 00  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
    150 01  ,011 ,012 ,01  ,01  ,01  ,01  ,01  ,
    151 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
    152 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
    153 011 ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
    154 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
    155 '0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,
    156 '0' ,'0' ,01  ,01  ,01  ,01  ,01  ,01  ,
    157 01  ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,
    158 'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,
    159 'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,
    160 'A' ,'A' ,'A' ,01  ,01  ,01  ,01  ,'A' ,
    161 01  ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,
    162 'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,
    163 'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,
    164 'A' ,'A' ,'A' ,01  ,01  ,01  ,01  ,01  ,
    165 0};
    166 char yyextra[] ={
    167 0,0,0,0,0,0,0,0,
    168 0};
    169 /*	ncform	4.1	83/08/11	*/
    170 
    171 int yylineno =1;
    172 # define YYU(x) x
    173 # define NLSTATE yyprevious=YYNEWLINE
    174 char yytext[YYLMAX];
    175 struct yysvf *yylstate [YYLMAX], **yylsp, **yyolsp;
    176 char yysbuf[YYLMAX];
    177 char *yysptr = yysbuf;
    178 int *yyfnd;
    179 extern struct yysvf *yyestate;
    180 int yyprevious = YYNEWLINE;
    181 yylook(){
    182 	register struct yysvf *yystate, **lsp;
    183 	register struct yywork *yyt;
    184 	struct yysvf *yyz;
    185 	int yych;
    186 	struct yywork *yyr;
    187 # ifdef LEXDEBUG
    188 	int debug;
    189 # endif
    190 	char *yylastch;
    191 	/* start off machines */
    192 # ifdef LEXDEBUG
    193 	debug = 0;
    194 # endif
    195 	if (!yymorfg)
    196 		yylastch = yytext;
    197 	else {
    198 		yymorfg=0;
    199 		yylastch = yytext+yyleng;
    200 		}
    201 	for(;;){
    202 		lsp = yylstate;
    203 		yyestate = yystate = yybgin;
    204 		if (yyprevious==YYNEWLINE) yystate++;
    205 		for (;;){
    206 # ifdef LEXDEBUG
    207 			if(debug)fprintf(yyout,"state %d\n",yystate-yysvec-1);
    208 # endif
    209 			yyt = yystate->yystoff;
    210 			if(yyt == yycrank){		/* may not be any transitions */
    211 				yyz = yystate->yyother;
    212 				if(yyz == 0)break;
    213 				if(yyz->yystoff == yycrank)break;
    214 				}
    215 			*yylastch++ = yych = input();
    216 		tryagain:
    217 # ifdef LEXDEBUG
    218 			if(debug){
    219 				fprintf(yyout,"char ");
    220 				allprint(yych);
    221 				putchar('\n');
    222 				}
    223 # endif
    224 			yyr = yyt;
    225 			if ( yyt > yycrank){
    226 				yyt = yyr + yych;
    227 				if (yyt <= yytop && yyt->verify+yysvec == yystate){
    228 					if(yyt->advance+yysvec == YYLERR)	/* error transitions */
    229 						{unput(*--yylastch);break;}
    230 					*lsp++ = yystate = yyt->advance+yysvec;
    231 					goto contin;
    232 					}
    233 				}
    234 # ifdef YYOPTIM
    235 			else if(yyt < yycrank) {		/* r < yycrank */
    236 				yyt = yyr = yycrank+(yycrank-yyt);
    237 # ifdef LEXDEBUG
    238 				if(debug)fprintf(yyout,"compressed state\n");
    239 # endif
    240 				yyt = yyt + yych;
    241 				if(yyt <= yytop && yyt->verify+yysvec == yystate){
    242 					if(yyt->advance+yysvec == YYLERR)	/* error transitions */
    243 						{unput(*--yylastch);break;}
    244 					*lsp++ = yystate = yyt->advance+yysvec;
    245 					goto contin;
    246 					}
    247 				yyt = yyr + YYU(yymatch[yych]);
    248 # ifdef LEXDEBUG
    249 				if(debug){
    250 					fprintf(yyout,"try fall back character ");
    251 					allprint(YYU(yymatch[yych]));
    252 					putchar('\n');
    253 					}
    254 # endif
    255 				if(yyt <= yytop && yyt->verify+yysvec == yystate){
    256 					if(yyt->advance+yysvec == YYLERR)	/* error transition */
    257 						{unput(*--yylastch);break;}
    258 					*lsp++ = yystate = yyt->advance+yysvec;
    259 					goto contin;
    260 					}
    261 				}
    262 			if ((yystate = yystate->yyother) && (yyt= yystate->yystoff) != yycrank){
    263 # ifdef LEXDEBUG
    264 				if(debug)fprintf(yyout,"fall back to state %d\n",yystate-yysvec-1);
    265 # endif
    266 				goto tryagain;
    267 				}
    268 # endif
    269 			else
    270 				{unput(*--yylastch);break;}
    271 		contin:
    272 # ifdef LEXDEBUG
    273 			if(debug){
    274 				fprintf(yyout,"state %d char ",yystate-yysvec-1);
    275 				allprint(yych);
    276 				putchar('\n');
    277 				}
    278 # endif
    279 			;
    280 			}
    281 # ifdef LEXDEBUG
    282 		if(debug){
    283 			fprintf(yyout,"stopped at %d with ",*(lsp-1)-yysvec-1);
    284 			allprint(yych);
    285 			putchar('\n');
    286 			}
    287 # endif
    288 		while (lsp-- > yylstate){
    289 			*yylastch-- = 0;
    290 			if (*lsp != 0 && (yyfnd= (*lsp)->yystops) && *yyfnd > 0){
    291 				yyolsp = lsp;
    292 				if(yyextra[*yyfnd]){		/* must backup */
    293 					while(yyback((*lsp)->yystops,-*yyfnd) != 1 && lsp > yylstate){
    294 						lsp--;
    295 						unput(*yylastch--);
    296 						}
    297 					}
    298 				yyprevious = YYU(*yylastch);
    299 				yylsp = lsp;
    300 				yyleng = yylastch-yytext+1;
    301 				yytext[yyleng] = 0;
    302 # ifdef LEXDEBUG
    303 				if(debug){
    304 					fprintf(yyout,"\nmatch ");
    305 					sprint(yytext);
    306 					fprintf(yyout," action %d\n",*yyfnd);
    307 					}
    308 # endif
    309 				return(*yyfnd++);
    310 				}
    311 			unput(*yylastch);
    312 			}
    313 		if (yytext[0] == 0  /* && feof(yyin) */)
    314 			{
    315 			yysptr=yysbuf;
    316 			return(0);
    317 			}
    318 		yyprevious = yytext[0] = input();
    319 		if (yyprevious>0)
    320 			output(yyprevious);
    321 		yylastch=yytext;
    322 # ifdef LEXDEBUG
    323 		if(debug)putchar('\n');
    324 # endif
    325 		}
    326 	}
    327 yyback(p, m)
    328 	int *p;
    329 {
    330 if (p==0) return(0);
    331 while (*p)
    332 	{
    333 	if (*p++ == m)
    334 		return(1);
    335 	}
    336 return(0);
    337 }
    338 	/* the following are only used in the lex library */
    339 yyinput(){
    340 	return(input());
    341 	}
    342 yyoutput(c)
    343   int c; {
    344 	output(c);
    345 	}
    346 yyunput(c)
    347    int c; {
    348 	unput(c);
    349 	}
    350 
    351 main() {
    352         yyparse();
    353 	return 0;
    354 }
    355 
    356 /* yyerror - issue error message */
    357 yyerror(s) char *s; {
    358         printf("%s\n", s);
    359 }
    360 short yyexca[] ={
    361 -1, 1,
    362 	0, -1,
    363 	-2, 0,
    364 	};
    365 # define YYNPROD 15
    366 # define YYLAST 249
    367 short yyact[]={
    368 
    369   12,   2,   9,   8,  17,  11,  25,  17,  15,  18,
    370   16,  10,  18,  17,  15,   7,  16,  13,  18,   5,
    371    3,   1,   0,  19,  20,   0,   0,  21,  22,  23,
    372   24,   0,   0,   0,   0,   0,   0,   0,   0,   0,
    373    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
    374    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
    375    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
    376    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
    377    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
    378    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
    379    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
    380    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
    381    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
    382    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
    383    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
    384    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
    385    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
    386    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
    387    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
    388    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
    389    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
    390    0,   0,   0,   0,   0,   0,   0,   6,  14,   0,
    391    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
    392    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
    393    0,   0,   0,   0,   0,   0,   0,   4,   6 };
    394 short yypact[]={
    395 
    396 -1000,  -9,-1000,   5,  -7, -59,-1000,-1000,-1000, -40,
    397  -29, -40, -40,-1000,-1000, -40, -40, -40, -40, -38,
    398  -35, -38, -38,-1000,-1000,-1000 };
    399 short yypgo[]={
    400 
    401    0,  21,  20,  17,  11 };
    402 short yyr1[]={
    403 
    404    0,   1,   1,   1,   1,   2,   4,   4,   4,   4,
    405    4,   4,   4,   4,   3 };
    406 short yyr2[]={
    407 
    408    0,   0,   2,   3,   3,   3,   3,   3,   3,   3,
    409    2,   3,   1,   1,   1 };
    410 short yychk[]={
    411 
    412 -1000,  -1,  10,  -2, 256,  -3, 257,  10,  10,  61,
    413   -4,  45,  40,  -3, 258,  43,  45,  42,  47,  -4,
    414   -4,  -4,  -4,  -4,  -4,  41 };
    415 short yydef[]={
    416 
    417    1,  -2,   2,   0,   0,   0,  14,   3,   4,   0,
    418    5,   0,   0,  12,  13,   0,   0,   0,   0,  10,
    419    0,   6,   7,   8,   9,  11 };
    420 #ifndef lint
    421 #endif
    422 
    423 # define YYFLAG -1000
    424 # define YYERROR goto yyerrlab
    425 # define YYACCEPT return(0)
    426 # define YYABORT return(1)
    427 
    428 /*	parser for yacc output	*/
    429 
    430 #ifdef YYDEBUG
    431 int yydebug = 0; /* 1 for debugging */
    432 #endif
    433 YYSTYPE yyv[YYMAXDEPTH]; /* where the values are stored */
    434 int yychar = -1; /* current input token number */
    435 int yynerrs = 0;  /* number of errors */
    436 short yyerrflag = 0;  /* error recovery flag */
    437 
    438 yyparse() {
    439 
    440 	short yys[YYMAXDEPTH];
    441 	short yyj, yym;
    442 	register YYSTYPE *yypvt;
    443 	register short yystate, *yyps, yyn;
    444 	register YYSTYPE *yypv;
    445 	register short *yyxi;
    446 
    447 	yystate = 0;
    448 	yychar = -1;
    449 	yynerrs = 0;
    450 	yyerrflag = 0;
    451 	yyps= &yys[-1];
    452 	yypv= &yyv[-1];
    453 
    454  yystack:    /* put a state and value onto the stack */
    455 
    456 #ifdef YYDEBUG
    457 	if( yydebug  ) printf( "state %d, char 0%o\n", yystate, yychar );
    458 #endif
    459 		if( ++yyps> &yys[YYMAXDEPTH] ) { yyerror( "yacc stack overflow" ); return(1); }
    460 		*yyps = yystate;
    461 		++yypv;
    462 		*yypv = yyval;
    463 
    464  yynewstate:
    465 
    466 	yyn = yypact[yystate];
    467 
    468 	if( yyn<= YYFLAG ) goto yydefault; /* simple state */
    469 
    470 	if( yychar<0 ) if( (yychar=yylex())<0 ) yychar=0;
    471 	if( (yyn += yychar)<0 || yyn >= YYLAST ) goto yydefault;
    472 
    473 	if( yychk[ yyn=yyact[ yyn ] ] == yychar ){ /* valid shift */
    474 		yychar = -1;
    475 		yyval = yylval;
    476 		yystate = yyn;
    477 		if( yyerrflag > 0 ) --yyerrflag;
    478 		goto yystack;
    479 		}
    480 
    481  yydefault:
    482 	/* default state action */
    483 
    484 	if( (yyn=yydef[yystate]) == -2 ) {
    485 		if( yychar<0 ) if( (yychar=yylex())<0 ) yychar = 0;
    486 		/* look through exception table */
    487 
    488 		for( yyxi=yyexca; (*yyxi!= (-1)) || (yyxi[1]!=yystate) ; yyxi += 2 ) ; /* VOID */
    489 
    490 		while( *(yyxi+=2) >= 0 ){
    491 			if( *yyxi == yychar ) break;
    492 			}
    493 		if( (yyn = yyxi[1]) < 0 ) return(0);   /* accept */
    494 		}
    495 
    496 	if( yyn == 0 ){ /* error */
    497 		/* error ... attempt to resume parsing */
    498 
    499 		switch( yyerrflag ){
    500 
    501 		case 0:   /* brand new error */
    502 
    503 			yyerror( "syntax error" );
    504 		yyerrlab:
    505 			++yynerrs;
    506 
    507 		case 1:
    508 		case 2: /* incompletely recovered error ... try again */
    509 
    510 			yyerrflag = 3;
    511 
    512 			/* find a state where "error" is a legal shift action */
    513 
    514 			while ( yyps >= yys ) {
    515 			   yyn = yypact[*yyps] + YYERRCODE;
    516 			   if( yyn>= 0 && yyn < YYLAST && yychk[yyact[yyn]] == YYERRCODE ){
    517 			      yystate = yyact[yyn];  /* simulate a shift of "error" */
    518 			      goto yystack;
    519 			      }
    520 			   yyn = yypact[*yyps];
    521 
    522 			   /* the current yyps has no shift onn "error", pop stack */
    523 
    524 #ifdef YYDEBUG
    525 			   if( yydebug ) printf( "error recovery pops state %d, uncovers %d\n", *yyps, yyps[-1] );
    526 #endif
    527 			   --yyps;
    528 			   --yypv;
    529 			   }
    530 
    531 			/* there is no state on the stack with an error shift ... abort */
    532 
    533 	yyabort:
    534 			return(1);
    535 
    536 
    537 		case 3:  /* no shift yet; clobber input char */
    538 
    539 #ifdef YYDEBUG
    540 			if( yydebug ) printf( "error recovery discards char %d\n", yychar );
    541 #endif
    542 
    543 			if( yychar == 0 ) goto yyabort; /* don't discard EOF, quit */
    544 			yychar = -1;
    545 			goto yynewstate;   /* try again in the same state */
    546 
    547 			}
    548 
    549 		}
    550 
    551 	/* reduction by production yyn */
    552 
    553 #ifdef YYDEBUG
    554 		if( yydebug ) printf("reduce %d\n",yyn);
    555 #endif
    556 		yyps -= yyr2[yyn];
    557 		yypvt = yypv;
    558 		yypv -= yyr2[yyn];
    559 		yyval = yypv[1];
    560 		yym=yyn;
    561 			/* consult goto table to find next state */
    562 		yyn = yyr1[yyn];
    563 		yyj = yypgo[yyn] + *yyps + 1;
    564 		if( yyj>=YYLAST || yychk[ yystate = yyact[yyj] ] != -yyn ) yystate = yyact[yypgo[yyn]];
    565 		switch(yym){
    566 			
    567 case 4:
    568 { yyerrok; } break;
    569 case 5:
    570 { printf("store\n"); } break;
    571 case 6:
    572 { printf("add\n"); } break;
    573 case 7:
    574 { printf("negate\nadd\n"); } break;
    575 case 8:
    576 { printf("multiply\n"); } break;
    577 case 9:
    578 { printf("divide\n"); } break;
    579 case 10:
    580 { printf("negate\n"); } break;
    581 case 12:
    582 { printf("load\n"); } break;
    583 case 13:
    584 { printf("push %s\n", yytext); } break;
    585 case 14:
    586 { printf("%s\n", yytext); } break;
    587 		}
    588 		goto yystack;  /* stack new state and value */
    589 
    590 	}
    591 int yywrap() { return 1; }