xref: /freebsd/contrib/byacc/test/yacc/pure_error.tab.c (revision f699532fb5b2c7b2445404b62f87bcd436195e5a)
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 1
7 #define YYMINOR 9
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 int      yydebug;
206 int      yynerrs;
207 
208 /* define the initial stack-sizes */
209 #ifdef YYSTACKSIZE
210 #undef YYMAXDEPTH
211 #define YYMAXDEPTH  YYSTACKSIZE
212 #else
213 #ifdef YYMAXDEPTH
214 #define YYSTACKSIZE YYMAXDEPTH
215 #else
216 #define YYSTACKSIZE 10000
217 #define YYMAXDEPTH  10000
218 #endif
219 #endif
220 
221 #define YYINITSTACKSIZE 200
222 
223 typedef struct {
224     unsigned stacksize;
225     YYINT    *s_base;
226     YYINT    *s_mark;
227     YYINT    *s_last;
228     YYSTYPE  *l_base;
229     YYSTYPE  *l_mark;
230 } YYSTACKDATA;
231 #line 17 "pure_error.y"
232 
233 #include <stdio.h>
234 
235 #ifdef YYBYACC
236 extern int YYLEX_DECL();
237 #endif
238 
239 int
240 main(void)
241 {
242     printf("yyparse() = %d\n", yyparse());
243     return 0;
244 }
245 
246 int
247 yylex(YYSTYPE *value)
248 {
249     return value ? 0 : -1;
250 }
251 
252 static void
253 yyerror(const char* s)
254 {
255     printf("%s\n", s);
256 }
257 #line 258 "pure_error.tab.c"
258 
259 #if YYDEBUG
260 #include <stdio.h>	/* needed for printf */
261 #endif
262 
263 #include <stdlib.h>	/* needed for malloc, etc */
264 #include <string.h>	/* needed for memset */
265 
266 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
267 static int yygrowstack(YYSTACKDATA *data)
268 {
269     int i;
270     unsigned newsize;
271     YYINT *newss;
272     YYSTYPE *newvs;
273 
274     if ((newsize = data->stacksize) == 0)
275         newsize = YYINITSTACKSIZE;
276     else if (newsize >= YYMAXDEPTH)
277         return YYENOMEM;
278     else if ((newsize *= 2) > YYMAXDEPTH)
279         newsize = YYMAXDEPTH;
280 
281     i = (int) (data->s_mark - data->s_base);
282     newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
283     if (newss == 0)
284         return YYENOMEM;
285 
286     data->s_base = newss;
287     data->s_mark = newss + i;
288 
289     newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
290     if (newvs == 0)
291         return YYENOMEM;
292 
293     data->l_base = newvs;
294     data->l_mark = newvs + i;
295 
296     data->stacksize = newsize;
297     data->s_last = data->s_base + newsize - 1;
298     return 0;
299 }
300 
301 #if YYPURE || defined(YY_NO_LEAKS)
302 static void yyfreestack(YYSTACKDATA *data)
303 {
304     free(data->s_base);
305     free(data->l_base);
306     memset(data, 0, sizeof(*data));
307 }
308 #else
309 #define yyfreestack(data) /* nothing */
310 #endif
311 
312 #define YYABORT  goto yyabort
313 #define YYREJECT goto yyabort
314 #define YYACCEPT goto yyaccept
315 #define YYERROR  goto yyerrlab
316 
317 int
318 YYPARSE_DECL()
319 {
320     int      yyerrflag;
321     int      yychar;
322     YYSTYPE  yyval;
323     YYSTYPE  yylval;
324 
325     /* variables for the parser stack */
326     YYSTACKDATA yystack;
327     int yym, yyn, yystate;
328 #if YYDEBUG
329     const char *yys;
330 
331     if ((yys = getenv("YYDEBUG")) != 0)
332     {
333         yyn = *yys;
334         if (yyn >= '0' && yyn <= '9')
335             yydebug = yyn - '0';
336     }
337 #endif
338 
339     yym = 0;
340     yyn = 0;
341     yynerrs = 0;
342     yyerrflag = 0;
343     yychar = YYEMPTY;
344     yystate = 0;
345 
346 #if YYPURE
347     memset(&yystack, 0, sizeof(yystack));
348 #endif
349 
350     if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
351     yystack.s_mark = yystack.s_base;
352     yystack.l_mark = yystack.l_base;
353     yystate = 0;
354     *yystack.s_mark = 0;
355 
356 yyloop:
357     if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
358     if (yychar < 0)
359     {
360         yychar = YYLEX;
361         if (yychar < 0) yychar = YYEOF;
362 #if YYDEBUG
363         if (yydebug)
364         {
365             if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
366             printf("%sdebug: state %d, reading %d (%s)\n",
367                     YYPREFIX, yystate, yychar, yys);
368         }
369 #endif
370     }
371     if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
372             yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
373     {
374 #if YYDEBUG
375         if (yydebug)
376             printf("%sdebug: state %d, shifting to state %d\n",
377                     YYPREFIX, yystate, yytable[yyn]);
378 #endif
379         if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
380         yystate = yytable[yyn];
381         *++yystack.s_mark = yytable[yyn];
382         *++yystack.l_mark = yylval;
383         yychar = YYEMPTY;
384         if (yyerrflag > 0)  --yyerrflag;
385         goto yyloop;
386     }
387     if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
388             yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
389     {
390         yyn = yytable[yyn];
391         goto yyreduce;
392     }
393     if (yyerrflag != 0) goto yyinrecovery;
394 
395     YYERROR_CALL("syntax error");
396 
397     goto yyerrlab; /* redundant goto avoids 'unused label' warning */
398 yyerrlab:
399     ++yynerrs;
400 
401 yyinrecovery:
402     if (yyerrflag < 3)
403     {
404         yyerrflag = 3;
405         for (;;)
406         {
407             if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
408                     yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
409             {
410 #if YYDEBUG
411                 if (yydebug)
412                     printf("%sdebug: state %d, error recovery shifting\
413  to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
414 #endif
415                 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
416                 yystate = yytable[yyn];
417                 *++yystack.s_mark = yytable[yyn];
418                 *++yystack.l_mark = yylval;
419                 goto yyloop;
420             }
421             else
422             {
423 #if YYDEBUG
424                 if (yydebug)
425                     printf("%sdebug: error recovery discarding state %d\n",
426                             YYPREFIX, *yystack.s_mark);
427 #endif
428                 if (yystack.s_mark <= yystack.s_base) goto yyabort;
429                 --yystack.s_mark;
430                 --yystack.l_mark;
431             }
432         }
433     }
434     else
435     {
436         if (yychar == YYEOF) goto yyabort;
437 #if YYDEBUG
438         if (yydebug)
439         {
440             if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
441             printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
442                     YYPREFIX, yystate, yychar, yys);
443         }
444 #endif
445         yychar = YYEMPTY;
446         goto yyloop;
447     }
448 
449 yyreduce:
450 #if YYDEBUG
451     if (yydebug)
452         printf("%sdebug: state %d, reducing by rule %d (%s)\n",
453                 YYPREFIX, yystate, yyn, yyrule[yyn]);
454 #endif
455     yym = yylen[yyn];
456     if (yym > 0)
457         yyval = yystack.l_mark[1-yym];
458     else
459         memset(&yyval, 0, sizeof yyval);
460 
461     switch (yyn)
462     {
463     }
464     yystack.s_mark -= yym;
465     yystate = *yystack.s_mark;
466     yystack.l_mark -= yym;
467     yym = yylhs[yyn];
468     if (yystate == 0 && yym == 0)
469     {
470 #if YYDEBUG
471         if (yydebug)
472             printf("%sdebug: after reduction, shifting from state 0 to\
473  state %d\n", YYPREFIX, YYFINAL);
474 #endif
475         yystate = YYFINAL;
476         *++yystack.s_mark = YYFINAL;
477         *++yystack.l_mark = yyval;
478         if (yychar < 0)
479         {
480             yychar = YYLEX;
481             if (yychar < 0) yychar = YYEOF;
482 #if YYDEBUG
483             if (yydebug)
484             {
485                 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
486                 printf("%sdebug: state %d, reading %d (%s)\n",
487                         YYPREFIX, YYFINAL, yychar, yys);
488             }
489 #endif
490         }
491         if (yychar == YYEOF) goto yyaccept;
492         goto yyloop;
493     }
494     if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
495             yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
496         yystate = yytable[yyn];
497     else
498         yystate = yydgoto[yym];
499 #if YYDEBUG
500     if (yydebug)
501         printf("%sdebug: after reduction, shifting from state %d \
502 to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
503 #endif
504     if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
505     *++yystack.s_mark = (YYINT) yystate;
506     *++yystack.l_mark = yyval;
507     goto yyloop;
508 
509 yyoverflow:
510     YYERROR_CALL("yacc stack overflow");
511 
512 yyabort:
513     yyfreestack(&yystack);
514     return (1);
515 
516 yyaccept:
517     yyfreestack(&yystack);
518     return (0);
519 }
520