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