xref: /csrg-svn/usr.bin/yacc/test/error.tab.c (revision 40084)
140077Sbostic #ifndef lint
2*40084Sbostic char yysccsid[] = "@(#)yaccpar	1.3 (Berkeley) 01/21/90";
340077Sbostic #endif
440077Sbostic #define YYERRCODE 256
5*40084Sbostic short yylhs[] = {                                        -1,
640077Sbostic     0,
740077Sbostic };
8*40084Sbostic short yylen[] = {                                         2,
940077Sbostic     1,
1040077Sbostic };
11*40084Sbostic short yydefred[] = {                                      0,
1240077Sbostic     1,    0,
1340077Sbostic };
14*40084Sbostic short yydgoto[] = {                                       2,
1540077Sbostic };
16*40084Sbostic short yysindex[] = {                                   -256,
1740077Sbostic     0,    0,
1840077Sbostic };
19*40084Sbostic short yyrindex[] = {                                      0,
2040077Sbostic     0,    0,
2140077Sbostic };
22*40084Sbostic short yygindex[] = {                                      0,
2340077Sbostic };
24*40084Sbostic #define YYTABLESIZE 0
25*40084Sbostic short yytable[] = {                                       1,
2640077Sbostic };
27*40084Sbostic short yycheck[] = {                                     256,
2840077Sbostic };
2940077Sbostic #define YYFINAL 2
3040077Sbostic #ifndef YYDEBUG
3140077Sbostic #define YYDEBUG 0
3240077Sbostic #endif
3340077Sbostic #define YYMAXTOKEN 0
3440077Sbostic #if YYDEBUG
35*40084Sbostic char *yyname[] = {
3640077Sbostic "end-of-file",
3740077Sbostic };
38*40084Sbostic char *yyrule[] = {
3940077Sbostic "$accept : S",
4040077Sbostic "S : error",
4140077Sbostic };
4240077Sbostic #endif
4340077Sbostic #ifndef YYSTYPE
4440077Sbostic typedef int YYSTYPE;
4540077Sbostic #endif
4640077Sbostic #define yyclearin (yychar=(-1))
4740077Sbostic #define yyerrok (yyerrflag=0)
4840077Sbostic #ifndef YYSTACKSIZE
4940077Sbostic #ifdef YYMAXDEPTH
5040077Sbostic #define YYSTACKSIZE YYMAXDEPTH
5140077Sbostic #else
5240077Sbostic #define YYSTACKSIZE 300
5340077Sbostic #endif
5440077Sbostic #endif
5540077Sbostic int yydebug;
5640077Sbostic int yynerrs;
5740077Sbostic int yyerrflag;
5840077Sbostic int yychar;
5940077Sbostic short *yyssp;
6040077Sbostic YYSTYPE *yyvsp;
6140077Sbostic YYSTYPE yyval;
6240077Sbostic YYSTYPE yylval;
6340077Sbostic #define yystacksize YYSTACKSIZE
6440077Sbostic short yyss[YYSTACKSIZE];
6540077Sbostic YYSTYPE yyvs[YYSTACKSIZE];
66*40084Sbostic #line 4 "error.y"
67*40084Sbostic main(){printf("yyparse() = %d\n",yyparse());}
68*40084Sbostic yylex(){return-1;}
69*40084Sbostic yyerror(s)char*s;{printf("%s\n",s);}
70*40084Sbostic #line 70 "error.tab.c"
71*40084Sbostic #define YYABORT goto yyabort
7240077Sbostic #define YYACCEPT goto yyaccept
7340077Sbostic #define YYERROR goto yyerrlab
7440077Sbostic int
7540077Sbostic yyparse()
7640077Sbostic {
7740077Sbostic     register int yym, yyn, yystate;
7840077Sbostic #if YYDEBUG
7940077Sbostic     register char *yys;
8040077Sbostic     extern char *getenv();
8140077Sbostic 
8240077Sbostic     if (yys = getenv("YYDEBUG"))
8340077Sbostic     {
8440077Sbostic         yyn = *yys;
8540077Sbostic         if (yyn == '0')
8640077Sbostic             yydebug = 0;
8740077Sbostic         else if (yyn >= '1' && yyn <= '9')
8840077Sbostic             yydebug = yyn - '0';
8940077Sbostic     }
9040077Sbostic #endif
9140077Sbostic 
9240077Sbostic     yynerrs = 0;
9340077Sbostic     yyerrflag = 0;
9440077Sbostic     yychar = (-1);
9540077Sbostic 
9640077Sbostic     yyssp = yyss;
9740077Sbostic     yyvsp = yyvs;
9840077Sbostic     *yyssp = yystate = 0;
9940077Sbostic 
10040077Sbostic yyloop:
10140077Sbostic     if (yyn = yydefred[yystate]) goto yyreduce;
10240077Sbostic     if (yychar < 0)
10340077Sbostic     {
10440077Sbostic         if ((yychar = yylex()) < 0) yychar = 0;
10540077Sbostic #if YYDEBUG
10640077Sbostic         if (yydebug)
10740077Sbostic         {
10840077Sbostic             yys = 0;
10940077Sbostic             if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
11040077Sbostic             if (!yys) yys = "illegal-symbol";
11140077Sbostic             printf("yydebug: state %d, reading %d (%s)\n", yystate,
11240077Sbostic                     yychar, yys);
11340077Sbostic         }
11440077Sbostic #endif
11540077Sbostic     }
11640077Sbostic     if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
11740077Sbostic             yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
11840077Sbostic     {
11940077Sbostic #if YYDEBUG
12040077Sbostic         if (yydebug)
12140077Sbostic             printf("yydebug: state %d, shifting to state %d\n",
12240077Sbostic                     yystate, yytable[yyn]);
12340077Sbostic #endif
12440077Sbostic         if (yyssp >= yyss + yystacksize - 1)
12540077Sbostic         {
12640077Sbostic             goto yyoverflow;
12740077Sbostic         }
12840077Sbostic         *++yyssp = yystate = yytable[yyn];
12940077Sbostic         *++yyvsp = yylval;
13040077Sbostic         yychar = (-1);
13140077Sbostic         if (yyerrflag > 0)  --yyerrflag;
13240077Sbostic         goto yyloop;
13340077Sbostic     }
13440077Sbostic     if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
13540077Sbostic             yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
13640077Sbostic     {
13740077Sbostic         yyn = yytable[yyn];
13840077Sbostic         goto yyreduce;
13940077Sbostic     }
14040077Sbostic     if (yyerrflag) goto yyinrecovery;
141*40084Sbostic #ifdef lint
142*40084Sbostic     goto yynewerror;
143*40084Sbostic #endif
14440077Sbostic yynewerror:
14540077Sbostic     yyerror("syntax error");
146*40084Sbostic #ifdef lint
147*40084Sbostic     goto yyerrlab;
148*40084Sbostic #endif
14940077Sbostic yyerrlab:
15040077Sbostic     ++yynerrs;
15140077Sbostic yyinrecovery:
15240077Sbostic     if (yyerrflag < 3)
15340077Sbostic     {
15440077Sbostic         yyerrflag = 3;
15540077Sbostic         for (;;)
15640077Sbostic         {
15740077Sbostic             if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 &&
15840077Sbostic                     yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
15940077Sbostic             {
16040077Sbostic #if YYDEBUG
16140077Sbostic                 if (yydebug)
16240077Sbostic                     printf("yydebug: state %d, error recovery shifting\
16340077Sbostic  to state %d\n", *yyssp, yytable[yyn]);
16440077Sbostic #endif
16540077Sbostic                 if (yyssp >= yyss + yystacksize - 1)
16640077Sbostic                 {
16740077Sbostic                     goto yyoverflow;
16840077Sbostic                 }
16940077Sbostic                 *++yyssp = yystate = yytable[yyn];
17040077Sbostic                 *++yyvsp = yylval;
17140077Sbostic                 goto yyloop;
17240077Sbostic             }
17340077Sbostic             else
17440077Sbostic             {
17540077Sbostic #if YYDEBUG
17640077Sbostic                 if (yydebug)
17740077Sbostic                     printf("yydebug: error recovery discarding state %d\n",
17840077Sbostic                             *yyssp);
17940077Sbostic #endif
18040077Sbostic                 if (yyssp <= yyss) goto yyabort;
18140077Sbostic                 --yyssp;
18240077Sbostic                 --yyvsp;
18340077Sbostic             }
18440077Sbostic         }
18540077Sbostic     }
18640077Sbostic     else
18740077Sbostic     {
18840077Sbostic         if (yychar == 0) goto yyabort;
18940077Sbostic #if YYDEBUG
19040077Sbostic         if (yydebug)
19140077Sbostic         {
19240077Sbostic             yys = 0;
19340077Sbostic             if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
19440077Sbostic             if (!yys) yys = "illegal-symbol";
19540077Sbostic             printf("yydebug: state %d, error recovery discards token %d (%s)\n",
19640077Sbostic                     yystate, yychar, yys);
19740077Sbostic         }
19840077Sbostic #endif
19940077Sbostic         yychar = (-1);
20040077Sbostic         goto yyloop;
20140077Sbostic     }
20240077Sbostic yyreduce:
20340077Sbostic #if YYDEBUG
20440077Sbostic     if (yydebug)
20540077Sbostic         printf("yydebug: state %d, reducing by rule %d (%s)\n",
20640077Sbostic                 yystate, yyn, yyrule[yyn]);
20740077Sbostic #endif
20840077Sbostic     yym = yylen[yyn];
20940077Sbostic     yyval = yyvsp[1-yym];
21040077Sbostic     switch (yyn)
21140077Sbostic     {
21240077Sbostic     }
21340077Sbostic     yyssp -= yym;
21440077Sbostic     yystate = *yyssp;
21540077Sbostic     yyvsp -= yym;
21640077Sbostic     yym = yylhs[yyn];
21740077Sbostic     if (yystate == 0 && yym == 0)
21840077Sbostic     {
21940077Sbostic #ifdef YYDEBUG
22040077Sbostic         if (yydebug)
22140077Sbostic             printf("yydebug: after reduction, shifting from state 0 to\
22240077Sbostic  state %d\n", YYFINAL);
22340077Sbostic #endif
22440077Sbostic         yystate = YYFINAL;
22540077Sbostic         *++yyssp = YYFINAL;
22640077Sbostic         *++yyvsp = yyval;
22740077Sbostic         if (yychar < 0)
22840077Sbostic         {
22940077Sbostic             if ((yychar = yylex()) < 0) yychar = 0;
23040077Sbostic #if YYDEBUG
23140077Sbostic             if (yydebug)
23240077Sbostic             {
23340077Sbostic                 yys = 0;
23440077Sbostic                 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
23540077Sbostic                 if (!yys) yys = "illegal-symbol";
23640077Sbostic                 printf("yydebug: state %d, reading %d (%s)\n",
23740077Sbostic                         YYFINAL, yychar, yys);
23840077Sbostic             }
23940077Sbostic #endif
24040077Sbostic         }
24140077Sbostic         if (yychar == 0) goto yyaccept;
24240077Sbostic         goto yyloop;
24340077Sbostic     }
24440077Sbostic     if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
24540077Sbostic             yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
24640077Sbostic         yystate = yytable[yyn];
24740077Sbostic     else
24840077Sbostic         yystate = yydgoto[yym];
24940077Sbostic #ifdef YYDEBUG
25040077Sbostic     if (yydebug)
25140077Sbostic         printf("yydebug: after reduction, shifting from state %d \
25240077Sbostic to state %d\n", *yyssp, yystate);
25340077Sbostic #endif
25440077Sbostic     if (yyssp >= yyss + yystacksize - 1)
25540077Sbostic     {
25640077Sbostic         goto yyoverflow;
25740077Sbostic     }
25840077Sbostic     *++yyssp = yystate;
25940077Sbostic     *++yyvsp = yyval;
26040077Sbostic     goto yyloop;
26140077Sbostic yyoverflow:
26240077Sbostic     yyerror("yacc stack overflow");
26340077Sbostic yyabort:
26440077Sbostic     return (1);
26540077Sbostic yyaccept:
26640077Sbostic     return (0);
26740077Sbostic }
268