xref: /csrg-svn/usr.bin/yacc/test/error.tab.c (revision 40077)
1*40077Sbostic #ifndef lint
2*40077Sbostic char yysccsid[] = "@(#)yaccpar	1.1 (Berkeley) 12/10/89";
3*40077Sbostic #endif
4*40077Sbostic #define YYERRCODE 256
5*40077Sbostic #ifndef YYCONST
6*40077Sbostic #define YYCONST /* const */
7*40077Sbostic #endif
8*40077Sbostic YYCONST short yylhs[] = {                                -1,
9*40077Sbostic     0,
10*40077Sbostic };
11*40077Sbostic YYCONST short yylen[] = {                                 2,
12*40077Sbostic     1,
13*40077Sbostic };
14*40077Sbostic YYCONST short yydefred[] = {                              0,
15*40077Sbostic     1,    0,
16*40077Sbostic };
17*40077Sbostic YYCONST short yydgoto[] = {                               2,
18*40077Sbostic };
19*40077Sbostic YYCONST short yysindex[] = {                           -256,
20*40077Sbostic     0,    0,
21*40077Sbostic };
22*40077Sbostic YYCONST short yyrindex[] = {                              0,
23*40077Sbostic     0,    0,
24*40077Sbostic };
25*40077Sbostic YYCONST short yygindex[] = {                              0,
26*40077Sbostic };
27*40077Sbostic #define	YYTABLESIZE		0
28*40077Sbostic YYCONST short yytable[] = {                               1,
29*40077Sbostic };
30*40077Sbostic YYCONST short yycheck[] = {                             256,
31*40077Sbostic };
32*40077Sbostic #define YYFINAL 2
33*40077Sbostic #ifndef YYDEBUG
34*40077Sbostic #define YYDEBUG 0
35*40077Sbostic #endif
36*40077Sbostic #define YYMAXTOKEN 0
37*40077Sbostic #if YYDEBUG
38*40077Sbostic YYCONST char *yyname[] = {
39*40077Sbostic "end-of-file",
40*40077Sbostic };
41*40077Sbostic YYCONST char *yyrule[] = {
42*40077Sbostic "$accept : S",
43*40077Sbostic "S : error",
44*40077Sbostic };
45*40077Sbostic #endif
46*40077Sbostic #ifndef YYSTYPE
47*40077Sbostic typedef int YYSTYPE;
48*40077Sbostic #endif
49*40077Sbostic #define yyclearin (yychar=(-1))
50*40077Sbostic #define yyerrok (yyerrflag=0)
51*40077Sbostic #ifndef YYSTACKSIZE
52*40077Sbostic #ifdef YYMAXDEPTH
53*40077Sbostic #define YYSTACKSIZE YYMAXDEPTH
54*40077Sbostic #else
55*40077Sbostic #define YYSTACKSIZE 300
56*40077Sbostic #endif
57*40077Sbostic #endif
58*40077Sbostic int yydebug;
59*40077Sbostic int yynerrs;
60*40077Sbostic int yyerrflag;
61*40077Sbostic int yychar;
62*40077Sbostic short *yyssp;
63*40077Sbostic YYSTYPE *yyvsp;
64*40077Sbostic YYSTYPE yyval;
65*40077Sbostic YYSTYPE yylval;
66*40077Sbostic #define yystacksize YYSTACKSIZE
67*40077Sbostic short yyss[YYSTACKSIZE];
68*40077Sbostic YYSTYPE yyvs[YYSTACKSIZE];
69*40077Sbostic #define YYACCEPT goto yyaccept
70*40077Sbostic #define YYERROR goto yyerrlab
71*40077Sbostic int
72*40077Sbostic yyparse()
73*40077Sbostic {
74*40077Sbostic     register int yym, yyn, yystate;
75*40077Sbostic #if YYDEBUG
76*40077Sbostic     register char *yys;
77*40077Sbostic     extern char *getenv();
78*40077Sbostic 
79*40077Sbostic     if (yys = getenv("YYDEBUG"))
80*40077Sbostic     {
81*40077Sbostic         yyn = *yys;
82*40077Sbostic         if (yyn == '0')
83*40077Sbostic             yydebug = 0;
84*40077Sbostic         else if (yyn >= '1' && yyn <= '9')
85*40077Sbostic             yydebug = yyn - '0';
86*40077Sbostic     }
87*40077Sbostic #endif
88*40077Sbostic 
89*40077Sbostic     yynerrs = 0;
90*40077Sbostic     yyerrflag = 0;
91*40077Sbostic     yychar = (-1);
92*40077Sbostic 
93*40077Sbostic     yyssp = yyss;
94*40077Sbostic     yyvsp = yyvs;
95*40077Sbostic     *yyssp = yystate = 0;
96*40077Sbostic 
97*40077Sbostic yyloop:
98*40077Sbostic     if (yyn = yydefred[yystate]) goto yyreduce;
99*40077Sbostic     if (yychar < 0)
100*40077Sbostic     {
101*40077Sbostic         if ((yychar = yylex()) < 0) yychar = 0;
102*40077Sbostic #if YYDEBUG
103*40077Sbostic         if (yydebug)
104*40077Sbostic         {
105*40077Sbostic             yys = 0;
106*40077Sbostic             if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
107*40077Sbostic             if (!yys) yys = "illegal-symbol";
108*40077Sbostic             printf("yydebug: state %d, reading %d (%s)\n", yystate,
109*40077Sbostic                     yychar, yys);
110*40077Sbostic         }
111*40077Sbostic #endif
112*40077Sbostic     }
113*40077Sbostic     if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
114*40077Sbostic             yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
115*40077Sbostic     {
116*40077Sbostic #if YYDEBUG
117*40077Sbostic         if (yydebug)
118*40077Sbostic             printf("yydebug: state %d, shifting to state %d\n",
119*40077Sbostic                     yystate, yytable[yyn]);
120*40077Sbostic #endif
121*40077Sbostic         if (yyssp >= yyss + yystacksize - 1)
122*40077Sbostic         {
123*40077Sbostic             goto yyoverflow;
124*40077Sbostic         }
125*40077Sbostic         *++yyssp = yystate = yytable[yyn];
126*40077Sbostic         *++yyvsp = yylval;
127*40077Sbostic         yychar = (-1);
128*40077Sbostic         if (yyerrflag > 0)  --yyerrflag;
129*40077Sbostic         goto yyloop;
130*40077Sbostic     }
131*40077Sbostic     if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
132*40077Sbostic             yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
133*40077Sbostic     {
134*40077Sbostic         yyn = yytable[yyn];
135*40077Sbostic         goto yyreduce;
136*40077Sbostic     }
137*40077Sbostic     if (yyerrflag) goto yyinrecovery;
138*40077Sbostic yynewerror:
139*40077Sbostic     yyerror("syntax error");
140*40077Sbostic yyerrlab:
141*40077Sbostic     ++yynerrs;
142*40077Sbostic yyinrecovery:
143*40077Sbostic     if (yyerrflag < 3)
144*40077Sbostic     {
145*40077Sbostic         yyerrflag = 3;
146*40077Sbostic         for (;;)
147*40077Sbostic         {
148*40077Sbostic             if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 &&
149*40077Sbostic                     yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
150*40077Sbostic             {
151*40077Sbostic #if YYDEBUG
152*40077Sbostic                 if (yydebug)
153*40077Sbostic                     printf("yydebug: state %d, error recovery shifting\
154*40077Sbostic  to state %d\n", *yyssp, yytable[yyn]);
155*40077Sbostic #endif
156*40077Sbostic                 if (yyssp >= yyss + yystacksize - 1)
157*40077Sbostic                 {
158*40077Sbostic                     goto yyoverflow;
159*40077Sbostic                 }
160*40077Sbostic                 *++yyssp = yystate = yytable[yyn];
161*40077Sbostic                 *++yyvsp = yylval;
162*40077Sbostic                 goto yyloop;
163*40077Sbostic             }
164*40077Sbostic             else
165*40077Sbostic             {
166*40077Sbostic #if YYDEBUG
167*40077Sbostic                 if (yydebug)
168*40077Sbostic                     printf("yydebug: error recovery discarding state %d\n",
169*40077Sbostic                             *yyssp);
170*40077Sbostic #endif
171*40077Sbostic                 if (yyssp <= yyss) goto yyabort;
172*40077Sbostic                 --yyssp;
173*40077Sbostic                 --yyvsp;
174*40077Sbostic             }
175*40077Sbostic         }
176*40077Sbostic     }
177*40077Sbostic     else
178*40077Sbostic     {
179*40077Sbostic         if (yychar == 0) goto yyabort;
180*40077Sbostic #if YYDEBUG
181*40077Sbostic         if (yydebug)
182*40077Sbostic         {
183*40077Sbostic             yys = 0;
184*40077Sbostic             if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
185*40077Sbostic             if (!yys) yys = "illegal-symbol";
186*40077Sbostic             printf("yydebug: state %d, error recovery discards token %d (%s)\n",
187*40077Sbostic                     yystate, yychar, yys);
188*40077Sbostic         }
189*40077Sbostic #endif
190*40077Sbostic         yychar = (-1);
191*40077Sbostic         goto yyloop;
192*40077Sbostic     }
193*40077Sbostic yyreduce:
194*40077Sbostic #if YYDEBUG
195*40077Sbostic     if (yydebug)
196*40077Sbostic         printf("yydebug: state %d, reducing by rule %d (%s)\n",
197*40077Sbostic                 yystate, yyn, yyrule[yyn]);
198*40077Sbostic #endif
199*40077Sbostic     yym = yylen[yyn];
200*40077Sbostic     yyval = yyvsp[1-yym];
201*40077Sbostic     switch (yyn)
202*40077Sbostic     {
203*40077Sbostic     }
204*40077Sbostic     yyssp -= yym;
205*40077Sbostic     yystate = *yyssp;
206*40077Sbostic     yyvsp -= yym;
207*40077Sbostic     yym = yylhs[yyn];
208*40077Sbostic     if (yystate == 0 && yym == 0)
209*40077Sbostic     {
210*40077Sbostic #ifdef YYDEBUG
211*40077Sbostic         if (yydebug)
212*40077Sbostic             printf("yydebug: after reduction, shifting from state 0 to\
213*40077Sbostic  state %d\n", YYFINAL);
214*40077Sbostic #endif
215*40077Sbostic         yystate = YYFINAL;
216*40077Sbostic         *++yyssp = YYFINAL;
217*40077Sbostic         *++yyvsp = yyval;
218*40077Sbostic         if (yychar < 0)
219*40077Sbostic         {
220*40077Sbostic             if ((yychar = yylex()) < 0) yychar = 0;
221*40077Sbostic #if YYDEBUG
222*40077Sbostic             if (yydebug)
223*40077Sbostic             {
224*40077Sbostic                 yys = 0;
225*40077Sbostic                 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
226*40077Sbostic                 if (!yys) yys = "illegal-symbol";
227*40077Sbostic                 printf("yydebug: state %d, reading %d (%s)\n",
228*40077Sbostic                         YYFINAL, yychar, yys);
229*40077Sbostic             }
230*40077Sbostic #endif
231*40077Sbostic         }
232*40077Sbostic         if (yychar == 0) goto yyaccept;
233*40077Sbostic         goto yyloop;
234*40077Sbostic     }
235*40077Sbostic     if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
236*40077Sbostic             yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
237*40077Sbostic         yystate = yytable[yyn];
238*40077Sbostic     else
239*40077Sbostic         yystate = yydgoto[yym];
240*40077Sbostic #ifdef YYDEBUG
241*40077Sbostic     if (yydebug)
242*40077Sbostic         printf("yydebug: after reduction, shifting from state %d \
243*40077Sbostic to state %d\n", *yyssp, yystate);
244*40077Sbostic #endif
245*40077Sbostic     if (yyssp >= yyss + yystacksize - 1)
246*40077Sbostic     {
247*40077Sbostic         goto yyoverflow;
248*40077Sbostic     }
249*40077Sbostic     *++yyssp = yystate;
250*40077Sbostic     *++yyvsp = yyval;
251*40077Sbostic     goto yyloop;
252*40077Sbostic yyoverflow:
253*40077Sbostic     yyerror("yacc stack overflow");
254*40077Sbostic yyabort:
255*40077Sbostic     return (1);
256*40077Sbostic yyaccept:
257*40077Sbostic     return (0);
258*40077Sbostic }
259