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