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