xref: /freebsd/contrib/byacc/test/yacc/err_syntax20.tab.c (revision 2e3507c25e42292b45a5482e116d278f5515d04d)
1 /* original parser id follows */
2 /* yysccsid[] = "@(#)yaccpar	1.9 (Berkeley) 02/21/93" */
3 /* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */
4 
5 #define YYBYACC 1
6 #define YYMAJOR 2
7 #define YYMINOR 0
8 #define YYCHECK "yyyymmdd"
9 
10 #define YYEMPTY        (-1)
11 #define yyclearin      (yychar = YYEMPTY)
12 #define yyerrok        (yyerrflag = 0)
13 #define YYRECOVERING() (yyerrflag != 0)
14 #define YYENOMEM       (-2)
15 #define YYEOF          0
16 
17 #ifndef yyparse
18 #define yyparse    err_syntax20_parse
19 #endif /* yyparse */
20 
21 #ifndef yylex
22 #define yylex      err_syntax20_lex
23 #endif /* yylex */
24 
25 #ifndef yyerror
26 #define yyerror    err_syntax20_error
27 #endif /* yyerror */
28 
29 #ifndef yychar
30 #define yychar     err_syntax20_char
31 #endif /* yychar */
32 
33 #ifndef yyval
34 #define yyval      err_syntax20_val
35 #endif /* yyval */
36 
37 #ifndef yylval
38 #define yylval     err_syntax20_lval
39 #endif /* yylval */
40 
41 #ifndef yydebug
42 #define yydebug    err_syntax20_debug
43 #endif /* yydebug */
44 
45 #ifndef yynerrs
46 #define yynerrs    err_syntax20_nerrs
47 #endif /* yynerrs */
48 
49 #ifndef yyerrflag
50 #define yyerrflag  err_syntax20_errflag
51 #endif /* yyerrflag */
52 
53 #ifndef yylhs
54 #define yylhs      err_syntax20_lhs
55 #endif /* yylhs */
56 
57 #ifndef yylen
58 #define yylen      err_syntax20_len
59 #endif /* yylen */
60 
61 #ifndef yydefred
62 #define yydefred   err_syntax20_defred
63 #endif /* yydefred */
64 
65 #ifndef yydgoto
66 #define yydgoto    err_syntax20_dgoto
67 #endif /* yydgoto */
68 
69 #ifndef yysindex
70 #define yysindex   err_syntax20_sindex
71 #endif /* yysindex */
72 
73 #ifndef yyrindex
74 #define yyrindex   err_syntax20_rindex
75 #endif /* yyrindex */
76 
77 #ifndef yygindex
78 #define yygindex   err_syntax20_gindex
79 #endif /* yygindex */
80 
81 #ifndef yytable
82 #define yytable    err_syntax20_table
83 #endif /* yytable */
84 
85 #ifndef yycheck
86 #define yycheck    err_syntax20_check
87 #endif /* yycheck */
88 
89 #ifndef yyname
90 #define yyname     err_syntax20_name
91 #endif /* yyname */
92 
93 #ifndef yyrule
94 #define yyrule     err_syntax20_rule
95 #endif /* yyrule */
96 #define YYPREFIX "err_syntax20_"
97 
98 #define YYPURE 0
99 
100 #line 2 "err_syntax20.y"
101 int yylex(void);
102 static void yyerror(const char *);
103 #line 104 "err_syntax20.tab.c"
104 
105 /* compatibility with bison */
106 #ifdef YYPARSE_PARAM
107 /* compatibility with FreeBSD */
108 # ifdef YYPARSE_PARAM_TYPE
109 #  define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
110 # else
111 #  define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
112 # endif
113 #else
114 # define YYPARSE_DECL() yyparse(void)
115 #endif
116 
117 /* Parameters sent to lex. */
118 #ifdef YYLEX_PARAM
119 # define YYLEX_DECL() yylex(void *YYLEX_PARAM)
120 # define YYLEX yylex(YYLEX_PARAM)
121 #else
122 # define YYLEX_DECL() yylex(void)
123 # define YYLEX yylex()
124 #endif
125 
126 /* Parameters sent to yyerror. */
127 #ifndef YYERROR_DECL
128 #define YYERROR_DECL() yyerror(const char *s)
129 #endif
130 #ifndef YYERROR_CALL
131 #define YYERROR_CALL(msg) yyerror(msg)
132 #endif
133 
134 extern int YYPARSE_DECL();
135 
136 #define recur 257
137 #define YYERRCODE 256
138 typedef int YYINT;
139 static const YYINT err_syntax20_lhs[] = {                -1,
140     0,
141 };
142 static const YYINT err_syntax20_len[] = {                 2,
143     3,
144 };
145 static const YYINT err_syntax20_defred[] = {              0,
146     0,    0,    0,    1,
147 };
148 static const YYINT err_syntax20_dgoto[] = {               2,
149 };
150 static const YYINT err_syntax20_sindex[] = {            -40,
151  -256,    0,  -39,    0,
152 };
153 static const YYINT err_syntax20_rindex[] = {              0,
154     0,    0,    0,    0,
155 };
156 static const YYINT err_syntax20_gindex[] = {              0,
157 };
158 #define YYTABLESIZE 2
159 static const YYINT err_syntax20_table[] = {               1,
160     3,    4,
161 };
162 static const YYINT err_syntax20_check[] = {              40,
163   257,   41,
164 };
165 #define YYFINAL 2
166 #ifndef YYDEBUG
167 #define YYDEBUG 0
168 #endif
169 #define YYMAXTOKEN 257
170 #define YYUNDFTOKEN 260
171 #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
172 #if YYDEBUG
173 static const char *const err_syntax20_name[] = {
174 
175 "end-of-file",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,
176 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,
177 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,
178 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,
179 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,
180 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,
181 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,"recur",0,0,
182 "illegal-symbol",
183 };
184 static const char *const err_syntax20_rule[] = {
185 "$accept : expr",
186 "expr : '(' recur ')'",
187 
188 };
189 #endif
190 
191 #if YYDEBUG
192 int      yydebug;
193 #endif
194 
195 int      yyerrflag;
196 int      yychar;
197 YYSTYPE  yyval;
198 YYSTYPE  yylval;
199 int      yynerrs;
200 
201 /* define the initial stack-sizes */
202 #ifdef YYSTACKSIZE
203 #undef YYMAXDEPTH
204 #define YYMAXDEPTH  YYSTACKSIZE
205 #else
206 #ifdef YYMAXDEPTH
207 #define YYSTACKSIZE YYMAXDEPTH
208 #else
209 #define YYSTACKSIZE 10000
210 #define YYMAXDEPTH  10000
211 #endif
212 #endif
213 
214 #define YYINITSTACKSIZE 200
215 
216 typedef struct {
217     unsigned stacksize;
218     YYINT    *s_base;
219     YYINT    *s_mark;
220     YYINT    *s_last;
221     YYSTYPE  *l_base;
222     YYSTYPE  *l_mark;
223 } YYSTACKDATA;
224 /* variables for the parser stack */
225 static YYSTACKDATA yystack;
226 #line 16 "err_syntax20.y"
227 
228 #include <stdio.h>
229 
230 int
231 main(void)
232 {
233     printf("yyparse() = %d\n", yyparse());
234     return 0;
235 }
236 
237 int
238 yylex(void)
239 {
240     return -1;
241 }
242 
243 static void
244 yyerror(const char* s)
245 {
246     printf("%s\n", s);
247 }
248 #line 249 "err_syntax20.tab.c"
249 
250 #if YYDEBUG
251 #include <stdio.h>	/* needed for printf */
252 #endif
253 
254 #include <stdlib.h>	/* needed for malloc, etc */
255 #include <string.h>	/* needed for memset */
256 
257 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
258 static int yygrowstack(YYSTACKDATA *data)
259 {
260     int i;
261     unsigned newsize;
262     YYINT *newss;
263     YYSTYPE *newvs;
264 
265     if ((newsize = data->stacksize) == 0)
266         newsize = YYINITSTACKSIZE;
267     else if (newsize >= YYMAXDEPTH)
268         return YYENOMEM;
269     else if ((newsize *= 2) > YYMAXDEPTH)
270         newsize = YYMAXDEPTH;
271 
272     i = (int) (data->s_mark - data->s_base);
273     newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
274     if (newss == NULL)
275         return YYENOMEM;
276 
277     data->s_base = newss;
278     data->s_mark = newss + i;
279 
280     newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
281     if (newvs == NULL)
282         return YYENOMEM;
283 
284     data->l_base = newvs;
285     data->l_mark = newvs + i;
286 
287     data->stacksize = newsize;
288     data->s_last = data->s_base + newsize - 1;
289     return 0;
290 }
291 
292 #if YYPURE || defined(YY_NO_LEAKS)
293 static void yyfreestack(YYSTACKDATA *data)
294 {
295     free(data->s_base);
296     free(data->l_base);
297     memset(data, 0, sizeof(*data));
298 }
299 #else
300 #define yyfreestack(data) /* nothing */
301 #endif
302 
303 #define YYABORT  goto yyabort
304 #define YYREJECT goto yyabort
305 #define YYACCEPT goto yyaccept
306 #define YYERROR  goto yyerrlab
307 
308 int
309 YYPARSE_DECL()
310 {
311     int yym, yyn, yystate;
312 #if YYDEBUG
313     const char *yys;
314 
315     if ((yys = getenv("YYDEBUG")) != NULL)
316     {
317         yyn = *yys;
318         if (yyn >= '0' && yyn <= '9')
319             yydebug = yyn - '0';
320     }
321 #endif
322 
323     /* yym is set below */
324     /* yyn is set below */
325     yynerrs = 0;
326     yyerrflag = 0;
327     yychar = YYEMPTY;
328     yystate = 0;
329 
330 #if YYPURE
331     memset(&yystack, 0, sizeof(yystack));
332 #endif
333 
334     if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
335     yystack.s_mark = yystack.s_base;
336     yystack.l_mark = yystack.l_base;
337     yystate = 0;
338     *yystack.s_mark = 0;
339 
340 yyloop:
341     if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
342     if (yychar < 0)
343     {
344         yychar = YYLEX;
345         if (yychar < 0) yychar = YYEOF;
346 #if YYDEBUG
347         if (yydebug)
348         {
349             if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
350             printf("%sdebug: state %d, reading %d (%s)\n",
351                     YYPREFIX, yystate, yychar, yys);
352         }
353 #endif
354     }
355     if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
356             yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
357     {
358 #if YYDEBUG
359         if (yydebug)
360             printf("%sdebug: state %d, shifting to state %d\n",
361                     YYPREFIX, yystate, yytable[yyn]);
362 #endif
363         if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
364         yystate = yytable[yyn];
365         *++yystack.s_mark = yytable[yyn];
366         *++yystack.l_mark = yylval;
367         yychar = YYEMPTY;
368         if (yyerrflag > 0)  --yyerrflag;
369         goto yyloop;
370     }
371     if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
372             yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
373     {
374         yyn = yytable[yyn];
375         goto yyreduce;
376     }
377     if (yyerrflag != 0) goto yyinrecovery;
378 
379     YYERROR_CALL("syntax error");
380 
381     goto yyerrlab; /* redundant goto avoids 'unused label' warning */
382 yyerrlab:
383     ++yynerrs;
384 
385 yyinrecovery:
386     if (yyerrflag < 3)
387     {
388         yyerrflag = 3;
389         for (;;)
390         {
391             if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
392                     yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
393             {
394 #if YYDEBUG
395                 if (yydebug)
396                     printf("%sdebug: state %d, error recovery shifting\
397  to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
398 #endif
399                 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
400                 yystate = yytable[yyn];
401                 *++yystack.s_mark = yytable[yyn];
402                 *++yystack.l_mark = yylval;
403                 goto yyloop;
404             }
405             else
406             {
407 #if YYDEBUG
408                 if (yydebug)
409                     printf("%sdebug: error recovery discarding state %d\n",
410                             YYPREFIX, *yystack.s_mark);
411 #endif
412                 if (yystack.s_mark <= yystack.s_base) goto yyabort;
413                 --yystack.s_mark;
414                 --yystack.l_mark;
415             }
416         }
417     }
418     else
419     {
420         if (yychar == YYEOF) goto yyabort;
421 #if YYDEBUG
422         if (yydebug)
423         {
424             if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
425             printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
426                     YYPREFIX, yystate, yychar, yys);
427         }
428 #endif
429         yychar = YYEMPTY;
430         goto yyloop;
431     }
432 
433 yyreduce:
434 #if YYDEBUG
435     if (yydebug)
436         printf("%sdebug: state %d, reducing by rule %d (%s)\n",
437                 YYPREFIX, yystate, yyn, yyrule[yyn]);
438 #endif
439     yym = yylen[yyn];
440     if (yym > 0)
441         yyval = yystack.l_mark[1-yym];
442     else
443         memset(&yyval, 0, sizeof yyval);
444 
445     switch (yyn)
446     {
447 case 1:
448 #line 12 "err_syntax20.y"
449 	{ yystack.l_mark[-1].rechk = 3; }
450 #line 451 "err_syntax20.tab.c"
451 break;
452 #line 453 "err_syntax20.tab.c"
453     }
454     yystack.s_mark -= yym;
455     yystate = *yystack.s_mark;
456     yystack.l_mark -= yym;
457     yym = yylhs[yyn];
458     if (yystate == 0 && yym == 0)
459     {
460 #if YYDEBUG
461         if (yydebug)
462             printf("%sdebug: after reduction, shifting from state 0 to\
463  state %d\n", YYPREFIX, YYFINAL);
464 #endif
465         yystate = YYFINAL;
466         *++yystack.s_mark = YYFINAL;
467         *++yystack.l_mark = yyval;
468         if (yychar < 0)
469         {
470             yychar = YYLEX;
471             if (yychar < 0) yychar = YYEOF;
472 #if YYDEBUG
473             if (yydebug)
474             {
475                 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
476                 printf("%sdebug: state %d, reading %d (%s)\n",
477                         YYPREFIX, YYFINAL, yychar, yys);
478             }
479 #endif
480         }
481         if (yychar == YYEOF) goto yyaccept;
482         goto yyloop;
483     }
484     if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
485             yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
486         yystate = yytable[yyn];
487     else
488         yystate = yydgoto[yym];
489 #if YYDEBUG
490     if (yydebug)
491         printf("%sdebug: after reduction, shifting from state %d \
492 to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
493 #endif
494     if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
495     *++yystack.s_mark = (YYINT) yystate;
496     *++yystack.l_mark = yyval;
497     goto yyloop;
498 
499 yyoverflow:
500     YYERROR_CALL("yacc stack overflow");
501 
502 yyabort:
503     yyfreestack(&yystack);
504     return (1);
505 
506 yyaccept:
507     yyfreestack(&yystack);
508     return (0);
509 }
510