Quake-III-Arena

Quake III Arena GPL Source Release
Log | Files | Refs

gram.c (18378B)


      1 #if defined(__STDC__) || defined(__cplusplus)
      2 #define YYCONST const
      3 #define YYPARAMS(x) x
      4 #define YYDEFUN(name, arglist, args) name(args)
      5 #define YYAND ,
      6 #define YYPTR void *
      7 #else
      8 #define YYCONST
      9 #define YYPARAMS(x) ()
     10 #define YYDEFUN(name, arglist, args) name arglist args;
     11 #define YYAND ;
     12 #define YYPTR char *
     13 #endif
     14 #ifndef lint
     15 YYCONST static char yysccsid[] = "@(#)yaccpar	1.8 (Berkeley +Cygnus.28) 01/20/91";
     16 #endif
     17 #define YYBYACC 1
     18 #ifndef YYDONT_INCLUDE_STDIO
     19 #include <stdio.h>
     20 #endif
     21 #ifdef __cplusplus
     22 #include <stdlib.h> /* for malloc/realloc/free */
     23 #endif
     24 #line 2 "lburg/gram.y"
     25 #include <stdio.h>
     26 #include "lburg.h"
     27 /*lint -e616 -e527 -e652 -esym(552,yynerrs) -esym(563,yynewstate,yyerrlab) */
     28 static int yylineno = 0;
     29 #line 8 "lburg/gram.y"
     30 typedef union {
     31 	int n;
     32 	char *string;
     33 	Tree tree;
     34 } YYSTYPE;
     35 #line 37 "y.tab.c"
     36 #define TERMINAL 257
     37 #define START 258
     38 #define PPERCENT 259
     39 #define ID 260
     40 #define TEMPLATE 261
     41 #define CODE 262
     42 #define INT 263
     43 #define YYERRCODE 256
     44 static YYCONST short yylhs[] = {                                        -1,
     45     0,    0,    4,    4,    6,    6,    6,    6,    7,    7,
     46     5,    5,    5,    5,    1,    3,    3,    3,    2,
     47 };
     48 static YYCONST short yylen[] = {                                         2,
     49     3,    1,    0,    2,    3,    3,    1,    2,    0,    4,
     50     0,    7,    2,    3,    1,    1,    4,    6,    1,
     51 };
     52 static YYCONST short yydefred[] = {                                      3,
     53     0,    0,    0,    9,    0,   11,    7,    4,    8,    0,
     54    15,    0,    0,    0,    5,    6,    0,   13,    0,    0,
     55    14,    0,   10,    0,    0,    0,    0,    0,   19,    0,
     56    17,    0,   12,    0,   18,
     57 };
     58 static YYCONST short yydgoto[] = {                                       1,
     59    12,   30,   25,    2,   13,    8,   10,
     60 };
     61 static YYCONST short yysindex[] = {                                      0,
     62     0,   -4,   -2,    0, -250,    0,    0,    0,    0,   -9,
     63     0,    1,  -10,  -49,    0,    0,    3,    0,  -44, -248,
     64     0, -244,    0,  -22, -242, -244, -245,  -37,    0,   10,
     65     0, -244,    0,  -20,    0,
     66 };
     67 static YYCONST short yyrindex[] = {                                      0,
     68     0,   22,    0,    0,    0,    0,    0,    0,    0,    0,
     69     0,    0,   23,    0,    0,    0,    0,    0,    0,    0,
     70     0,    0,    0,  -39,    0,    0,    0,    0,    0,    0,
     71     0,    0,    0,    0,    0,
     72 };
     73 static YYCONST short yygindex[] = {                                      0,
     74    11,    0,  -23,    0,    0,    0,    0,
     75 };
     76 #define YYTABLESIZE 255
     77 static YYCONST short yytable[] = {                                      18,
     78    15,   16,   28,   31,   16,    7,   32,    9,   34,   11,
     79    16,   20,   21,   22,   23,   24,   29,   26,   27,   33,
     80    35,    2,    1,   19,    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,    0,
     89     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
     90     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
     91     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
     92     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
     93     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
     94     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
     95     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
     96     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
     97     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
     98     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
     99     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    100     0,   16,    0,    0,    0,    0,    0,    0,    0,    0,
    101     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    102     0,    0,    0,    0,    0,   17,    0,    0,    0,   11,
    103    14,    3,    4,    5,    6,
    104 };
    105 static YYCONST short yycheck[] = {                                      10,
    106    10,   41,   26,   41,   44,   10,   44,   10,   32,  260,
    107    10,   61,   10,   58,  263,  260,  262,   40,  261,   10,
    108    41,    0,    0,   13,   -1,   -1,   -1,   -1,   -1,   -1,
    109    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
    110    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
    111    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
    112    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
    113    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
    114    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
    115    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
    116    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
    117    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
    118    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
    119    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
    120    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
    121    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
    122    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
    123    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
    124    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
    125    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
    126    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
    127    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
    128    -1,  261,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
    129    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
    130    -1,   -1,   -1,   -1,   -1,  256,   -1,   -1,   -1,  260,
    131   260,  256,  257,  258,  259,
    132 };
    133 #define YYFINAL 1
    134 #ifndef YYDEBUG
    135 #define YYDEBUG 0
    136 #endif
    137 #define YYMAXTOKEN 263
    138 #if YYDEBUG
    139 static YYCONST char *YYCONST yyname[] = {
    140 "end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
    141 0,0,0,0,0,0,0,0,0,"'('","')'",0,0,"','",0,0,0,0,0,0,0,0,0,0,0,0,0,"':'",0,0,
    142 "'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
    143 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
    144 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
    145 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
    146 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
    147 "TERMINAL","START","PPERCENT","ID","TEMPLATE","CODE","INT",
    148 };
    149 static YYCONST char *YYCONST yyrule[] = {
    150 "$accept : spec",
    151 "spec : decls PPERCENT rules",
    152 "spec : decls",
    153 "decls :",
    154 "decls : decls decl",
    155 "decl : TERMINAL blist '\\n'",
    156 "decl : START nonterm '\\n'",
    157 "decl : '\\n'",
    158 "decl : error '\\n'",
    159 "blist :",
    160 "blist : blist ID '=' INT",
    161 "rules :",
    162 "rules : rules nonterm ':' tree TEMPLATE cost '\\n'",
    163 "rules : rules '\\n'",
    164 "rules : rules error '\\n'",
    165 "nonterm : ID",
    166 "tree : ID",
    167 "tree : ID '(' tree ')'",
    168 "tree : ID '(' tree ',' tree ')'",
    169 "cost : CODE",
    170 };
    171 #endif
    172 #define YYLEX yylex()
    173 #define YYEMPTY -1
    174 #define yyclearin (yychar=(YYEMPTY))
    175 #define yyerrok (yyerrflag=0)
    176 #ifndef YYINITDEPTH
    177 #define YYINITDEPTH 200
    178 #endif
    179 #ifdef YYSTACKSIZE
    180 #ifndef YYMAXDEPTH
    181 #define YYMAXDEPTH YYSTACKSIZE
    182 #endif
    183 #else
    184 #ifdef YYMAXDEPTH
    185 #define YYSTACKSIZE YYMAXDEPTH
    186 #else
    187 #define YYSTACKSIZE 500
    188 #define YYMAXDEPTH 500
    189 #endif
    190 #endif
    191 #ifndef YYMAXSTACKSIZE
    192 #define YYMAXSTACKSIZE 10000
    193 #endif
    194 int yydebug;
    195 int yynerrs;
    196 int yyerrflag;
    197 int yychar;
    198 YYSTYPE yyval;
    199 YYSTYPE yylval;
    200 static short *yyss;
    201 static YYSTYPE *yyvs;
    202 static int yystacksize;
    203 #define yyfree(x) free(x)
    204 extern int yylex();
    205 
    206 static YYPTR
    207 YYDEFUN (yymalloc, (bytes), unsigned bytes)
    208 {
    209     YYPTR ptr = (YYPTR) malloc (bytes);
    210     if (ptr != 0) return (ptr);
    211     yyerror ("yyparse: memory exhausted");
    212     return (0);
    213 }
    214 
    215 static YYPTR
    216 YYDEFUN (yyrealloc, (old, bytes), YYPTR old YYAND unsigned bytes)
    217 {
    218     YYPTR ptr = (YYPTR) realloc (old, bytes);
    219     if (ptr != 0) return (ptr);
    220     yyerror ("yyparse: memory exhausted");
    221     return (0);
    222 }
    223 
    224 static int
    225 #ifdef __GNUC__
    226 inline
    227 #endif
    228 yygrow ()
    229 {
    230     int old_stacksize = yystacksize;
    231     short *new_yyss;
    232     YYSTYPE *new_yyvs;
    233 
    234     if (yystacksize == YYMAXSTACKSIZE)
    235         return (1);
    236     yystacksize += (yystacksize + 1 ) / 2;
    237     if (yystacksize > YYMAXSTACKSIZE)
    238         yystacksize = YYMAXSTACKSIZE;
    239 #if YYDEBUG
    240     if (yydebug)
    241         printf("yydebug: growing stack size from %d to %d\n",
    242                old_stacksize, yystacksize);
    243 #endif
    244     new_yyss = (short *) yyrealloc ((char *)yyss, yystacksize * sizeof (short));
    245     if (new_yyss == 0)
    246         return (1);
    247     new_yyvs = (YYSTYPE *) yyrealloc ((char *)yyvs, yystacksize * sizeof (YYSTYPE));
    248     if (new_yyvs == 0)
    249     {
    250         yyfree (new_yyss);
    251         return (1);
    252     }
    253     yyss = new_yyss;
    254     yyvs = new_yyvs;
    255     return (0);
    256 }
    257 #line 60 "lburg/gram.y"
    258 #include <assert.h>
    259 #include <stdarg.h>
    260 #include <ctype.h>
    261 #include <string.h>
    262 #include <limits.h>
    263 
    264 int errcnt = 0;
    265 FILE *infp = NULL;
    266 FILE *outfp = NULL;
    267 static char buf[BUFSIZ], *bp = buf;
    268 static int ppercent = 0;
    269 static int code = 0;
    270 
    271 static int get(void) {
    272 	if (*bp == 0) {
    273 		bp = buf;
    274 		*bp = 0;
    275 		if (fgets(buf, sizeof buf, infp) == NULL)
    276 			return EOF;
    277 		yylineno++;
    278 		while (buf[0] == '%' && buf[1] == '{' && buf[2] == '\n') {
    279 			for (;;) {
    280 				if (fgets(buf, sizeof buf, infp) == NULL) {
    281 					yywarn("unterminated %{...%}\n");
    282 					return EOF;
    283 				}
    284 				yylineno++;
    285 				if (strcmp(buf, "%}\n") == 0)
    286 					break;
    287 				fputs(buf, outfp);
    288 			}
    289 			if (fgets(buf, sizeof buf, infp) == NULL)
    290 				return EOF;
    291 			yylineno++;
    292 		}
    293 	}
    294 	return *bp++;
    295 }
    296 
    297 void yyerror(char *fmt, ...) {
    298 	va_list ap;
    299 
    300 	va_start(ap, fmt);
    301 	if (yylineno > 0)
    302 		fprintf(stderr, "line %d: ", yylineno);
    303 	vfprintf(stderr, fmt, ap);
    304 	if (fmt[strlen(fmt)-1] != '\n')
    305 		 fprintf(stderr, "\n");
    306 	errcnt++;
    307 	va_end(ap);
    308 }
    309 
    310 int yylex(void) {
    311 	int c;
    312 
    313 	if (code) {
    314 		char *p;
    315 		bp += strspn(bp, " \t\f");
    316 		p = strchr(bp, '\n');
    317 		if (p == NULL)
    318 			p = strchr(bp, '\n');
    319 		while (p > bp && isspace(p[-1]))
    320 			p--;
    321 		yylval.string = alloc(p - bp + 1);
    322 		strncpy(yylval.string, bp, p - bp);
    323 		yylval.string[p - bp] = 0;
    324 		bp = p;
    325 		code--;
    326 		return CODE;
    327 	}
    328 	while ((c = get()) != EOF) {
    329 		switch (c) {
    330 		case ' ': case '\f': case '\t':
    331 			continue;
    332 		case '\n':
    333 		case '(': case ')': case ',':
    334 		case ':': case '=':
    335 			return c;
    336 		}
    337 		if (c == '%' && *bp == '%') {
    338 			bp++;
    339 			return ppercent++ ? 0 : PPERCENT;
    340 		} else if (c == '%' && strncmp(bp, "term", 4) == 0
    341 		&& isspace(bp[4])) {
    342 			bp += 4;
    343 			return TERMINAL;
    344 		} else if (c == '%' && strncmp(bp, "start", 5) == 0
    345 		&& isspace(bp[5])) {
    346 			bp += 5;
    347 			return START;
    348 		} else if (c == '"') {
    349 			char *p = strchr(bp, '"');
    350 			if (p == NULL) {
    351 				yyerror("missing \" in assembler template\n");
    352 				p = strchr(bp, '\n');
    353 				if (p == NULL)
    354 					p = strchr(bp, '\0');
    355 			}
    356 			assert(p);
    357 			yylval.string = alloc(p - bp + 1);
    358 			strncpy(yylval.string, bp, p - bp);
    359 			yylval.string[p - bp] = 0;
    360 			bp = *p == '"' ? p + 1 : p;
    361 			code++;
    362 			return TEMPLATE;
    363 		} else if (isdigit(c)) {
    364 			int n = 0;
    365 			do {
    366 				int d = c - '0';
    367 				if (n > (INT_MAX - d)/10)
    368 					yyerror("integer greater than %d\n", INT_MAX);
    369 				else
    370 					n = 10*n + d;
    371 				c = get();
    372 			} while (c != EOF && isdigit(c));
    373 			bp--;
    374 			yylval.n = n;
    375 			return INT;
    376 		} else if (isalpha(c)) {
    377 			char *p = bp - 1;
    378 			while (isalpha(*bp) || isdigit(*bp) || *bp == '_')
    379 				bp++;
    380 			yylval.string = alloc(bp - p + 1);
    381 			strncpy(yylval.string, p, bp - p);
    382 			yylval.string[bp - p] = 0;
    383 			return ID;
    384 		} else if (isprint(c))
    385 			yyerror("invalid character `%c'\n", c);
    386 		else
    387 			yyerror("invalid character `\\%03o'\n", (unsigned char)c);
    388 	}
    389 	return 0;
    390 }
    391 
    392 void yywarn(char *fmt, ...) {
    393 	va_list ap;
    394 
    395 	va_start(ap, fmt);
    396 	if (yylineno > 0)
    397 		fprintf(stderr, "line %d: ", yylineno);
    398 	fprintf(stderr, "warning: ");
    399 	vfprintf(stderr, fmt, ap);
    400 }
    401 #line 403 "y.tab.c"
    402 #define YYABORT goto yyabort
    403 #define YYACCEPT goto yyaccept
    404 #define YYERROR goto yyerrlab
    405 
    406 #if YYDEBUG
    407 #ifdef __cplusplus
    408 extern "C" char *getenv();
    409 #else
    410 extern char *getenv();
    411 #endif
    412 #endif
    413 
    414 int
    415 yyparse()
    416 {
    417     register int yym, yyn, yystate;
    418     register YYSTYPE *yyvsp;
    419     register short *yyssp;
    420     short *yysse;
    421 #if YYDEBUG
    422     register YYCONST char *yys;
    423 
    424     if (yys = getenv("YYDEBUG"))
    425     {
    426         yyn = *yys;
    427         if (yyn >= '0' && yyn <= '9')
    428             yydebug = yyn - '0';
    429     }
    430 #endif
    431 
    432     yynerrs = 0;
    433     yyerrflag = 0;
    434     yychar = (-1);
    435 
    436     if (yyss == 0)
    437     {
    438         yyss = (short *) yymalloc (YYSTACKSIZE * sizeof (short));
    439         if (yyss == 0)
    440           goto yyabort;
    441         yyvs = (YYSTYPE *) yymalloc (YYSTACKSIZE * sizeof (YYSTYPE));
    442         if (yyvs == 0)
    443         {
    444             yyfree (yyss);
    445             goto yyabort;
    446         }
    447         yystacksize = YYSTACKSIZE;
    448     }
    449     yysse = yyss + yystacksize - 1;
    450     yyssp = yyss;
    451     yyvsp = yyvs;
    452     *yyssp = yystate = 0;
    453     goto yyloop;
    454 
    455 yypush_lex:
    456     yyval = yylval;
    457     yystate = yytable[yyn];
    458 yypush:
    459     if (yyssp >= yysse)
    460     {
    461         int depth = yyssp - yyss;
    462         if (yygrow() != 0)
    463              goto yyoverflow;
    464         yysse = yyss + yystacksize -1;
    465         yyssp = depth + yyss;
    466         yyvsp = depth + yyvs;
    467     }
    468     *++yyssp = yystate;
    469     *++yyvsp = yyval;
    470 
    471 yyloop:
    472     if (yyn = yydefred[yystate]) goto yyreduce;
    473     yyn = yysindex[yystate];
    474     if (yychar < 0)
    475     {
    476         if ((yychar = yylex()) < 0) yychar = 0;
    477 #if YYDEBUG
    478         if (yydebug)
    479         {
    480             yys = 0;
    481             if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
    482             if (!yys) yys = "illegal-symbol";
    483             printf("yydebug: state %d, reading %d (%s)\n", yystate,
    484                     yychar, yys);
    485         }
    486 #endif
    487     }
    488     if (yyn != 0
    489         && ((yyn += yychar), ((unsigned)yyn <= (unsigned)YYTABLESIZE))
    490         && yycheck[yyn] == yychar)
    491     {
    492 #if YYDEBUG
    493         if (yydebug)
    494             printf("yydebug: state %d, shifting to state %d\n",
    495                     yystate, yytable[yyn]);
    496 #endif
    497         if (yyerrflag > 0)  --yyerrflag;
    498         yychar = (-1);
    499         goto yypush_lex;
    500     }
    501     yyn = yyrindex[yystate];
    502     if (yyn != 0
    503         && ((yyn += yychar), ((unsigned)yyn <= (unsigned)YYTABLESIZE))
    504         && yycheck[yyn] == yychar)
    505     {
    506         yyn = yytable[yyn];
    507         goto yyreduce;
    508     }
    509     if (yyerrflag) goto yyinrecovery;
    510 #ifdef lint
    511     goto yynewerror;
    512 #endif
    513 yynewerror:
    514     yyerror("syntax error");
    515 #ifdef lint
    516     goto yyerrlab;
    517 #endif
    518 yyerrlab:
    519     ++yynerrs;
    520 yyinrecovery:
    521     if (yyerrflag < 3)
    522     {
    523         yyerrflag = 3;
    524         for (;;)
    525         {
    526             yyn = yysindex[*yyssp];
    527             if (yyn != 0
    528                 && ((yyn += YYERRCODE), ((unsigned)yyn <= (unsigned)YYTABLESIZE))
    529                 && yycheck[yyn] == YYERRCODE)
    530             {
    531 #if YYDEBUG
    532                 if (yydebug)
    533                     printf("yydebug: state %d, error recovery shifting\
    534  to state %d\n", *yyssp, yytable[yyn]);
    535 #endif
    536                 goto yypush_lex;
    537             }
    538             else
    539             {
    540 #if YYDEBUG
    541                 if (yydebug)
    542                     printf("yydebug: error recovery discarding state %d\n",
    543                             *yyssp);
    544 #endif
    545                 if (yyssp <= yyss) goto yyabort;
    546                 --yyssp;
    547                 --yyvsp;
    548             }
    549         }
    550     }
    551     else
    552     {
    553         if (yychar == 0) goto yyabort;
    554 #if YYDEBUG
    555         if (yydebug)
    556         {
    557             yys = 0;
    558             if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
    559             if (!yys) yys = "illegal-symbol";
    560             printf("yydebug: state %d, error recovery discards token %d (%s)\n",
    561                     yystate, yychar, yys);
    562         }
    563 #endif
    564         yychar = (-1);
    565         goto yyloop;
    566     }
    567 yyreduce:
    568 #if YYDEBUG
    569     if (yydebug)
    570         printf("yydebug: state %d, reducing by rule %d (%s)\n",
    571                 yystate, yyn, yyrule[yyn]);
    572 #endif
    573     yym = yylen[yyn];
    574     yyval = yyvsp[1-yym];
    575     switch (yyn)
    576     {
    577 case 1:
    578 #line 22 "lburg/gram.y"
    579 { yylineno = 0; }
    580 break;
    581 case 2:
    582 #line 23 "lburg/gram.y"
    583 { yylineno = 0; }
    584 break;
    585 case 6:
    586 #line 31 "lburg/gram.y"
    587 {
    588 		if (nonterm(yyvsp[-1].string)->number != 1)
    589 			yyerror("redeclaration of the start symbol\n");
    590 		}
    591 break;
    592 case 8:
    593 #line 36 "lburg/gram.y"
    594 { yyerrok; }
    595 break;
    596 case 10:
    597 #line 40 "lburg/gram.y"
    598 { term(yyvsp[-2].string, yyvsp[0].n); }
    599 break;
    600 case 12:
    601 #line 44 "lburg/gram.y"
    602 { rule(yyvsp[-5].string, yyvsp[-3].tree, yyvsp[-2].string, yyvsp[-1].string); }
    603 break;
    604 case 14:
    605 #line 46 "lburg/gram.y"
    606 { yyerrok; }
    607 break;
    608 case 15:
    609 #line 49 "lburg/gram.y"
    610 { nonterm(yyval.string = yyvsp[0].string); }
    611 break;
    612 case 16:
    613 #line 52 "lburg/gram.y"
    614 { yyval.tree = tree(yyvsp[0].string,  0,  0); }
    615 break;
    616 case 17:
    617 #line 53 "lburg/gram.y"
    618 { yyval.tree = tree(yyvsp[-3].string, yyvsp[-1].tree,  0); }
    619 break;
    620 case 18:
    621 #line 54 "lburg/gram.y"
    622 { yyval.tree = tree(yyvsp[-5].string, yyvsp[-3].tree, yyvsp[-1].tree); }
    623 break;
    624 case 19:
    625 #line 57 "lburg/gram.y"
    626 { if (*yyvsp[0].string == 0) yyval.string = "0"; }
    627 break;
    628 #line 630 "y.tab.c"
    629     }
    630     yyssp -= yym;
    631     yyvsp -= yym;
    632     yym = yylhs[yyn];
    633     yystate = *yyssp;
    634     if (yystate == 0 && yym == 0)
    635     {
    636 #if YYDEBUG
    637         if (yydebug)
    638             printf("yydebug: after reduction, shifting from state 0 to\
    639  state %d\n", YYFINAL);
    640 #endif
    641         yystate = YYFINAL;
    642         *++yyssp = YYFINAL;
    643         *++yyvsp = yyval;
    644         if (yychar < 0)
    645         {
    646             if ((yychar = yylex()) < 0) yychar = 0;
    647 #if YYDEBUG
    648             if (yydebug)
    649             {
    650                 yys = 0;
    651                 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
    652                 if (!yys) yys = "illegal-symbol";
    653                 printf("yydebug: state %d, reading %d (%s)\n",
    654                         YYFINAL, yychar, yys);
    655             }
    656 #endif
    657         }
    658         if (yychar == 0) goto yyaccept;
    659         goto yyloop;
    660     }
    661     yyn = yygindex[yym];
    662 	 if (yyn != 0
    663         && ((yyn += yystate), ((unsigned)yyn <= (unsigned)YYTABLESIZE))
    664         && yycheck[yyn] == yystate)
    665         yystate = yytable[yyn];
    666     else
    667         yystate = yydgoto[yym];
    668 #if YYDEBUG
    669     if (yydebug)
    670         printf("yydebug: after reduction, shifting from state %d \
    671 to state %d\n", *yyssp, yystate);
    672 #endif
    673     goto yypush;
    674 yyoverflow:
    675     yyerror("yacc stack overflow");
    676 yyabort:
    677     return (1);
    678 yyaccept:
    679     return (0);
    680 }