xref: /freebsd/contrib/byacc/test/yacc/err_syntax18.tab.c (revision 7fdf597e96a02165cfe22ff357b857d5fa15ed8a)
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 2
7 #define YYMINOR 0
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_syntax18_parse
19 #endif /* yyparse */
20 
21 #ifndef yylex
22 #define yylex      err_syntax18_lex
23 #endif /* yylex */
24 
25 #ifndef yyerror
26 #define yyerror    err_syntax18_error
27 #endif /* yyerror */
28 
29 #ifndef yychar
30 #define yychar     err_syntax18_char
31 #endif /* yychar */
32 
33 #ifndef yyval
34 #define yyval      err_syntax18_val
35 #endif /* yyval */
36 
37 #ifndef yylval
38 #define yylval     err_syntax18_lval
39 #endif /* yylval */
40 
41 #ifndef yydebug
42 #define yydebug    err_syntax18_debug
43 #endif /* yydebug */
44 
45 #ifndef yynerrs
46 #define yynerrs    err_syntax18_nerrs
47 #endif /* yynerrs */
48 
49 #ifndef yyerrflag
50 #define yyerrflag  err_syntax18_errflag
51 #endif /* yyerrflag */
52 
53 #ifndef yylhs
54 #define yylhs      err_syntax18_lhs
55 #endif /* yylhs */
56 
57 #ifndef yylen
58 #define yylen      err_syntax18_len
59 #endif /* yylen */
60 
61 #ifndef yydefred
62 #define yydefred   err_syntax18_defred
63 #endif /* yydefred */
64 
65 #ifndef yydgoto
66 #define yydgoto    err_syntax18_dgoto
67 #endif /* yydgoto */
68 
69 #ifndef yysindex
70 #define yysindex   err_syntax18_sindex
71 #endif /* yysindex */
72 
73 #ifndef yyrindex
74 #define yyrindex   err_syntax18_rindex
75 #endif /* yyrindex */
76 
77 #ifndef yygindex
78 #define yygindex   err_syntax18_gindex
79 #endif /* yygindex */
80 
81 #ifndef yytable
82 #define yytable    err_syntax18_table
83 #endif /* yytable */
84 
85 #ifndef yycheck
86 #define yycheck    err_syntax18_check
87 #endif /* yycheck */
88 
89 #ifndef yyname
90 #define yyname     err_syntax18_name
91 #endif /* yyname */
92 
93 #ifndef yyrule
94 #define yyrule     err_syntax18_rule
95 #endif /* yyrule */
96 #define YYPREFIX "err_syntax18_"
97 
98 #define YYPURE 0
99 
100 #line 2 "err_syntax18.y"
101 int yylex(void);
102 static void yyerror(const char *);
103 #line 104 "err_syntax18.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 YYERRCODE 256
143 typedef int YYINT;
144 static const YYINT err_syntax18_lhs[] = {                -1,
145     0,
146 };
147 static const YYINT err_syntax18_len[] = {                 2,
148     3,
149 };
150 static const YYINT err_syntax18_defred[] = {              0,
151     0,    0,    0,    1,
152 };
153 static const YYINT err_syntax18_dgoto[] = {               2,
154 };
155 static const YYINT err_syntax18_sindex[] = {            -40,
156   -40,    0,  -39,    0,
157 };
158 static const YYINT err_syntax18_rindex[] = {              0,
159     0,    0,    0,    0,
160 };
161 static const YYINT err_syntax18_gindex[] = {              2,
162 };
163 #define YYTABLESIZE 3
164 static const YYINT err_syntax18_table[] = {               1,
165     0,    4,    3,
166 };
167 static const YYINT err_syntax18_check[] = {              40,
168    -1,   41,    1,
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_syntax18_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,
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,"illegal-symbol",
187 };
188 static const char *const err_syntax18_rule[] = {
189 "$accept : expr",
190 "expr : '(' expr ')'",
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 13 "err_syntax18.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 253 "err_syntax18.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 == NULL)
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 == NULL)
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")) != NULL)
320     {
321         yyn = *yys;
322         if (yyn >= '0' && yyn <= '9')
323             yydebug = yyn - '0';
324     }
325 #endif
326 
327     /* yym is set below */
328     /* yyn is set below */
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 case 1:
452 #line 9 "err_syntax18.y"
453 	{  yyval = yystack.l_mark[1]; }
454 #line 455 "err_syntax18.tab.c"
455 break;
456 #line 457 "err_syntax18.tab.c"
457     }
458     yystack.s_mark -= yym;
459     yystate = *yystack.s_mark;
460     yystack.l_mark -= yym;
461     yym = yylhs[yyn];
462     if (yystate == 0 && yym == 0)
463     {
464 #if YYDEBUG
465         if (yydebug)
466             printf("%sdebug: after reduction, shifting from state 0 to\
467  state %d\n", YYPREFIX, YYFINAL);
468 #endif
469         yystate = YYFINAL;
470         *++yystack.s_mark = YYFINAL;
471         *++yystack.l_mark = yyval;
472         if (yychar < 0)
473         {
474             yychar = YYLEX;
475             if (yychar < 0) yychar = YYEOF;
476 #if YYDEBUG
477             if (yydebug)
478             {
479                 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
480                 printf("%sdebug: state %d, reading %d (%s)\n",
481                         YYPREFIX, YYFINAL, yychar, yys);
482             }
483 #endif
484         }
485         if (yychar == YYEOF) goto yyaccept;
486         goto yyloop;
487     }
488     if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
489             yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
490         yystate = yytable[yyn];
491     else
492         yystate = yydgoto[yym];
493 #if YYDEBUG
494     if (yydebug)
495         printf("%sdebug: after reduction, shifting from state %d \
496 to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
497 #endif
498     if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
499     *++yystack.s_mark = (YYINT) yystate;
500     *++yystack.l_mark = yyval;
501     goto yyloop;
502 
503 yyoverflow:
504     YYERROR_CALL("yacc stack overflow");
505 
506 yyabort:
507     yyfreestack(&yystack);
508     return (1);
509 
510 yyaccept:
511     yyfreestack(&yystack);
512     return (0);
513 }
514