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