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