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