xref: /original-bsd/usr.bin/yacc/test/error.tab.c (revision ec356984)
138a7878eSbostic #ifndef lint
2*ec356984Sbostic static char yysccsid[] = "@(#)yaccpar	1.9 (Berkeley) 02/21/93";
338a7878eSbostic #endif
4*ec356984Sbostic #define YYBYACC 1
5*ec356984Sbostic #define YYMAJOR 1
6*ec356984Sbostic #define YYMINOR 9
7*ec356984Sbostic #define yyclearin (yychar=(-1))
8*ec356984Sbostic #define yyerrok (yyerrflag=0)
9*ec356984Sbostic #define YYRECOVERING (yyerrflag!=0)
10*ec356984Sbostic #define YYPREFIX "yy"
1138a7878eSbostic #define YYERRCODE 256
12a0fca5a1Sbostic short yylhs[] = {                                        -1,
1338a7878eSbostic     0,
1438a7878eSbostic };
15a0fca5a1Sbostic short yylen[] = {                                         2,
1638a7878eSbostic     1,
1738a7878eSbostic };
18a0fca5a1Sbostic short yydefred[] = {                                      0,
1938a7878eSbostic     1,    0,
2038a7878eSbostic };
21a0fca5a1Sbostic short yydgoto[] = {                                       2,
2238a7878eSbostic };
23a0fca5a1Sbostic short yysindex[] = {                                   -256,
2438a7878eSbostic     0,    0,
2538a7878eSbostic };
26a0fca5a1Sbostic short yyrindex[] = {                                      0,
2738a7878eSbostic     0,    0,
2838a7878eSbostic };
29a0fca5a1Sbostic short yygindex[] = {                                      0,
3038a7878eSbostic };
3138a7878eSbostic #define YYTABLESIZE 0
32a0fca5a1Sbostic short yytable[] = {                                       1,
3338a7878eSbostic };
34a0fca5a1Sbostic short yycheck[] = {                                     256,
3538a7878eSbostic };
3638a7878eSbostic #define YYFINAL 2
3738a7878eSbostic #ifndef YYDEBUG
3838a7878eSbostic #define YYDEBUG 0
3938a7878eSbostic #endif
4038a7878eSbostic #define YYMAXTOKEN 0
4138a7878eSbostic #if YYDEBUG
42a0fca5a1Sbostic char *yyname[] = {
4338a7878eSbostic "end-of-file",
4438a7878eSbostic };
45a0fca5a1Sbostic char *yyrule[] = {
4638a7878eSbostic "$accept : S",
4738a7878eSbostic "S : error",
4838a7878eSbostic };
4938a7878eSbostic #endif
5038a7878eSbostic #ifndef YYSTYPE
5138a7878eSbostic typedef int YYSTYPE;
5238a7878eSbostic #endif
53*ec356984Sbostic #ifdef YYSTACKSIZE
54*ec356984Sbostic #undef YYMAXDEPTH
55*ec356984Sbostic #define YYMAXDEPTH YYSTACKSIZE
56*ec356984Sbostic #else
5738a7878eSbostic #ifdef YYMAXDEPTH
5838a7878eSbostic #define YYSTACKSIZE YYMAXDEPTH
5938a7878eSbostic #else
60*ec356984Sbostic #define YYSTACKSIZE 500
61*ec356984Sbostic #define YYMAXDEPTH 500
6238a7878eSbostic #endif
6338a7878eSbostic #endif
6438a7878eSbostic int yydebug;
6538a7878eSbostic int yynerrs;
6638a7878eSbostic int yyerrflag;
6738a7878eSbostic int yychar;
6838a7878eSbostic short *yyssp;
6938a7878eSbostic YYSTYPE *yyvsp;
7038a7878eSbostic YYSTYPE yyval;
7138a7878eSbostic YYSTYPE yylval;
7238a7878eSbostic short yyss[YYSTACKSIZE];
7338a7878eSbostic YYSTYPE yyvs[YYSTACKSIZE];
74*ec356984Sbostic #define yystacksize YYSTACKSIZE
75a0fca5a1Sbostic #line 4 "error.y"
main()76a0fca5a1Sbostic main(){printf("yyparse() = %d\n",yyparse());}
yylex()77a0fca5a1Sbostic yylex(){return-1;}
yyerror(s)78a0fca5a1Sbostic yyerror(s)char*s;{printf("%s\n",s);}
79*ec356984Sbostic #line 80 "error.tab.c"
80a0fca5a1Sbostic #define YYABORT goto yyabort
81*ec356984Sbostic #define YYREJECT goto yyabort
8238a7878eSbostic #define YYACCEPT goto yyaccept
8338a7878eSbostic #define YYERROR goto yyerrlab
8438a7878eSbostic int
yyparse()8538a7878eSbostic yyparse()
8638a7878eSbostic {
8738a7878eSbostic     register int yym, yyn, yystate;
8838a7878eSbostic #if YYDEBUG
8938a7878eSbostic     register char *yys;
9038a7878eSbostic     extern char *getenv();
9138a7878eSbostic 
9238a7878eSbostic     if (yys = getenv("YYDEBUG"))
9338a7878eSbostic     {
9438a7878eSbostic         yyn = *yys;
95*ec356984Sbostic         if (yyn >= '0' && yyn <= '9')
9638a7878eSbostic             yydebug = yyn - '0';
9738a7878eSbostic     }
9838a7878eSbostic #endif
9938a7878eSbostic 
10038a7878eSbostic     yynerrs = 0;
10138a7878eSbostic     yyerrflag = 0;
10238a7878eSbostic     yychar = (-1);
10338a7878eSbostic 
10438a7878eSbostic     yyssp = yyss;
10538a7878eSbostic     yyvsp = yyvs;
10638a7878eSbostic     *yyssp = yystate = 0;
10738a7878eSbostic 
10838a7878eSbostic yyloop:
10938a7878eSbostic     if (yyn = yydefred[yystate]) goto yyreduce;
11038a7878eSbostic     if (yychar < 0)
11138a7878eSbostic     {
11238a7878eSbostic         if ((yychar = yylex()) < 0) yychar = 0;
11338a7878eSbostic #if YYDEBUG
11438a7878eSbostic         if (yydebug)
11538a7878eSbostic         {
11638a7878eSbostic             yys = 0;
11738a7878eSbostic             if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
11838a7878eSbostic             if (!yys) yys = "illegal-symbol";
119*ec356984Sbostic             printf("%sdebug: state %d, reading %d (%s)\n",
120*ec356984Sbostic                     YYPREFIX, yystate, yychar, yys);
12138a7878eSbostic         }
12238a7878eSbostic #endif
12338a7878eSbostic     }
12438a7878eSbostic     if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
12538a7878eSbostic             yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
12638a7878eSbostic     {
12738a7878eSbostic #if YYDEBUG
12838a7878eSbostic         if (yydebug)
129*ec356984Sbostic             printf("%sdebug: state %d, shifting to state %d\n",
130*ec356984Sbostic                     YYPREFIX, yystate, yytable[yyn]);
13138a7878eSbostic #endif
13238a7878eSbostic         if (yyssp >= yyss + yystacksize - 1)
13338a7878eSbostic         {
13438a7878eSbostic             goto yyoverflow;
13538a7878eSbostic         }
13638a7878eSbostic         *++yyssp = yystate = yytable[yyn];
13738a7878eSbostic         *++yyvsp = yylval;
13838a7878eSbostic         yychar = (-1);
13938a7878eSbostic         if (yyerrflag > 0)  --yyerrflag;
14038a7878eSbostic         goto yyloop;
14138a7878eSbostic     }
14238a7878eSbostic     if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
14338a7878eSbostic             yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
14438a7878eSbostic     {
14538a7878eSbostic         yyn = yytable[yyn];
14638a7878eSbostic         goto yyreduce;
14738a7878eSbostic     }
14838a7878eSbostic     if (yyerrflag) goto yyinrecovery;
149a0fca5a1Sbostic #ifdef lint
150a0fca5a1Sbostic     goto yynewerror;
151a0fca5a1Sbostic #endif
15238a7878eSbostic yynewerror:
15338a7878eSbostic     yyerror("syntax error");
154a0fca5a1Sbostic #ifdef lint
155a0fca5a1Sbostic     goto yyerrlab;
156a0fca5a1Sbostic #endif
15738a7878eSbostic yyerrlab:
15838a7878eSbostic     ++yynerrs;
15938a7878eSbostic yyinrecovery:
16038a7878eSbostic     if (yyerrflag < 3)
16138a7878eSbostic     {
16238a7878eSbostic         yyerrflag = 3;
16338a7878eSbostic         for (;;)
16438a7878eSbostic         {
16538a7878eSbostic             if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 &&
16638a7878eSbostic                     yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
16738a7878eSbostic             {
16838a7878eSbostic #if YYDEBUG
16938a7878eSbostic                 if (yydebug)
170*ec356984Sbostic                     printf("%sdebug: state %d, error recovery shifting\
171*ec356984Sbostic  to state %d\n", YYPREFIX, *yyssp, yytable[yyn]);
17238a7878eSbostic #endif
17338a7878eSbostic                 if (yyssp >= yyss + yystacksize - 1)
17438a7878eSbostic                 {
17538a7878eSbostic                     goto yyoverflow;
17638a7878eSbostic                 }
17738a7878eSbostic                 *++yyssp = yystate = yytable[yyn];
17838a7878eSbostic                 *++yyvsp = yylval;
17938a7878eSbostic                 goto yyloop;
18038a7878eSbostic             }
18138a7878eSbostic             else
18238a7878eSbostic             {
18338a7878eSbostic #if YYDEBUG
18438a7878eSbostic                 if (yydebug)
185*ec356984Sbostic                     printf("%sdebug: error recovery discarding state %d\n",
186*ec356984Sbostic                             YYPREFIX, *yyssp);
18738a7878eSbostic #endif
18838a7878eSbostic                 if (yyssp <= yyss) goto yyabort;
18938a7878eSbostic                 --yyssp;
19038a7878eSbostic                 --yyvsp;
19138a7878eSbostic             }
19238a7878eSbostic         }
19338a7878eSbostic     }
19438a7878eSbostic     else
19538a7878eSbostic     {
19638a7878eSbostic         if (yychar == 0) goto yyabort;
19738a7878eSbostic #if YYDEBUG
19838a7878eSbostic         if (yydebug)
19938a7878eSbostic         {
20038a7878eSbostic             yys = 0;
20138a7878eSbostic             if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
20238a7878eSbostic             if (!yys) yys = "illegal-symbol";
203*ec356984Sbostic             printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
204*ec356984Sbostic                     YYPREFIX, yystate, yychar, yys);
20538a7878eSbostic         }
20638a7878eSbostic #endif
20738a7878eSbostic         yychar = (-1);
20838a7878eSbostic         goto yyloop;
20938a7878eSbostic     }
21038a7878eSbostic yyreduce:
21138a7878eSbostic #if YYDEBUG
21238a7878eSbostic     if (yydebug)
213*ec356984Sbostic         printf("%sdebug: state %d, reducing by rule %d (%s)\n",
214*ec356984Sbostic                 YYPREFIX, yystate, yyn, yyrule[yyn]);
21538a7878eSbostic #endif
21638a7878eSbostic     yym = yylen[yyn];
21738a7878eSbostic     yyval = yyvsp[1-yym];
21838a7878eSbostic     switch (yyn)
21938a7878eSbostic     {
22038a7878eSbostic     }
22138a7878eSbostic     yyssp -= yym;
22238a7878eSbostic     yystate = *yyssp;
22338a7878eSbostic     yyvsp -= yym;
22438a7878eSbostic     yym = yylhs[yyn];
22538a7878eSbostic     if (yystate == 0 && yym == 0)
22638a7878eSbostic     {
227*ec356984Sbostic #if YYDEBUG
22838a7878eSbostic         if (yydebug)
229*ec356984Sbostic             printf("%sdebug: after reduction, shifting from state 0 to\
230*ec356984Sbostic  state %d\n", YYPREFIX, YYFINAL);
23138a7878eSbostic #endif
23238a7878eSbostic         yystate = YYFINAL;
23338a7878eSbostic         *++yyssp = YYFINAL;
23438a7878eSbostic         *++yyvsp = yyval;
23538a7878eSbostic         if (yychar < 0)
23638a7878eSbostic         {
23738a7878eSbostic             if ((yychar = yylex()) < 0) yychar = 0;
23838a7878eSbostic #if YYDEBUG
23938a7878eSbostic             if (yydebug)
24038a7878eSbostic             {
24138a7878eSbostic                 yys = 0;
24238a7878eSbostic                 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
24338a7878eSbostic                 if (!yys) yys = "illegal-symbol";
244*ec356984Sbostic                 printf("%sdebug: state %d, reading %d (%s)\n",
245*ec356984Sbostic                         YYPREFIX, YYFINAL, yychar, yys);
24638a7878eSbostic             }
24738a7878eSbostic #endif
24838a7878eSbostic         }
24938a7878eSbostic         if (yychar == 0) goto yyaccept;
25038a7878eSbostic         goto yyloop;
25138a7878eSbostic     }
25238a7878eSbostic     if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
25338a7878eSbostic             yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
25438a7878eSbostic         yystate = yytable[yyn];
25538a7878eSbostic     else
25638a7878eSbostic         yystate = yydgoto[yym];
257*ec356984Sbostic #if YYDEBUG
25838a7878eSbostic     if (yydebug)
259*ec356984Sbostic         printf("%sdebug: after reduction, shifting from state %d \
260*ec356984Sbostic to state %d\n", YYPREFIX, *yyssp, yystate);
26138a7878eSbostic #endif
26238a7878eSbostic     if (yyssp >= yyss + yystacksize - 1)
26338a7878eSbostic     {
26438a7878eSbostic         goto yyoverflow;
26538a7878eSbostic     }
26638a7878eSbostic     *++yyssp = yystate;
26738a7878eSbostic     *++yyvsp = yyval;
26838a7878eSbostic     goto yyloop;
26938a7878eSbostic yyoverflow:
27038a7878eSbostic     yyerror("yacc stack overflow");
27138a7878eSbostic yyabort:
27238a7878eSbostic     return (1);
27338a7878eSbostic yyaccept:
27438a7878eSbostic     return (0);
27538a7878eSbostic }
276