xref: /freebsd/contrib/byacc/test/yacc/err_syntax18.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_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 int      yydebug;
196 int      yynerrs;
197 
198 int      yyerrflag;
199 int      yychar;
200 YYSTYPE  yyval;
201 YYSTYPE  yylval;
202 
203 /* define the initial stack-sizes */
204 #ifdef YYSTACKSIZE
205 #undef YYMAXDEPTH
206 #define YYMAXDEPTH  YYSTACKSIZE
207 #else
208 #ifdef YYMAXDEPTH
209 #define YYSTACKSIZE YYMAXDEPTH
210 #else
211 #define YYSTACKSIZE 10000
212 #define YYMAXDEPTH  10000
213 #endif
214 #endif
215 
216 #define YYINITSTACKSIZE 200
217 
218 typedef struct {
219     unsigned stacksize;
220     YYINT    *s_base;
221     YYINT    *s_mark;
222     YYINT    *s_last;
223     YYSTYPE  *l_base;
224     YYSTYPE  *l_mark;
225 } YYSTACKDATA;
226 /* variables for the parser stack */
227 static YYSTACKDATA yystack;
228 #line 13 "err_syntax18.y"
229 
230 #include <stdio.h>
231 
232 int
233 main(void)
234 {
235     printf("yyparse() = %d\n", yyparse());
236     return 0;
237 }
238 
239 int
240 yylex(void)
241 {
242     return -1;
243 }
244 
245 static void
246 yyerror(const char* s)
247 {
248     printf("%s\n", s);
249 }
250 #line 251 "err_syntax18.tab.c"
251 
252 #if YYDEBUG
253 #include <stdio.h>	/* needed for printf */
254 #endif
255 
256 #include <stdlib.h>	/* needed for malloc, etc */
257 #include <string.h>	/* needed for memset */
258 
259 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
260 static int yygrowstack(YYSTACKDATA *data)
261 {
262     int i;
263     unsigned newsize;
264     YYINT *newss;
265     YYSTYPE *newvs;
266 
267     if ((newsize = data->stacksize) == 0)
268         newsize = YYINITSTACKSIZE;
269     else if (newsize >= YYMAXDEPTH)
270         return YYENOMEM;
271     else if ((newsize *= 2) > YYMAXDEPTH)
272         newsize = YYMAXDEPTH;
273 
274     i = (int) (data->s_mark - data->s_base);
275     newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
276     if (newss == 0)
277         return YYENOMEM;
278 
279     data->s_base = newss;
280     data->s_mark = newss + i;
281 
282     newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
283     if (newvs == 0)
284         return YYENOMEM;
285 
286     data->l_base = newvs;
287     data->l_mark = newvs + i;
288 
289     data->stacksize = newsize;
290     data->s_last = data->s_base + newsize - 1;
291     return 0;
292 }
293 
294 #if YYPURE || defined(YY_NO_LEAKS)
295 static void yyfreestack(YYSTACKDATA *data)
296 {
297     free(data->s_base);
298     free(data->l_base);
299     memset(data, 0, sizeof(*data));
300 }
301 #else
302 #define yyfreestack(data) /* nothing */
303 #endif
304 
305 #define YYABORT  goto yyabort
306 #define YYREJECT goto yyabort
307 #define YYACCEPT goto yyaccept
308 #define YYERROR  goto yyerrlab
309 
310 int
311 YYPARSE_DECL()
312 {
313     int yym, yyn, yystate;
314 #if YYDEBUG
315     const char *yys;
316 
317     if ((yys = getenv("YYDEBUG")) != 0)
318     {
319         yyn = *yys;
320         if (yyn >= '0' && yyn <= '9')
321             yydebug = yyn - '0';
322     }
323 #endif
324 
325     yym = 0;
326     yyn = 0;
327     yynerrs = 0;
328     yyerrflag = 0;
329     yychar = YYEMPTY;
330     yystate = 0;
331 
332 #if YYPURE
333     memset(&yystack, 0, sizeof(yystack));
334 #endif
335 
336     if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
337     yystack.s_mark = yystack.s_base;
338     yystack.l_mark = yystack.l_base;
339     yystate = 0;
340     *yystack.s_mark = 0;
341 
342 yyloop:
343     if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
344     if (yychar < 0)
345     {
346         yychar = YYLEX;
347         if (yychar < 0) yychar = YYEOF;
348 #if YYDEBUG
349         if (yydebug)
350         {
351             if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
352             printf("%sdebug: state %d, reading %d (%s)\n",
353                     YYPREFIX, yystate, yychar, yys);
354         }
355 #endif
356     }
357     if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
358             yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
359     {
360 #if YYDEBUG
361         if (yydebug)
362             printf("%sdebug: state %d, shifting to state %d\n",
363                     YYPREFIX, yystate, yytable[yyn]);
364 #endif
365         if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
366         yystate = yytable[yyn];
367         *++yystack.s_mark = yytable[yyn];
368         *++yystack.l_mark = yylval;
369         yychar = YYEMPTY;
370         if (yyerrflag > 0)  --yyerrflag;
371         goto yyloop;
372     }
373     if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
374             yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
375     {
376         yyn = yytable[yyn];
377         goto yyreduce;
378     }
379     if (yyerrflag != 0) goto yyinrecovery;
380 
381     YYERROR_CALL("syntax error");
382 
383     goto yyerrlab; /* redundant goto avoids 'unused label' warning */
384 yyerrlab:
385     ++yynerrs;
386 
387 yyinrecovery:
388     if (yyerrflag < 3)
389     {
390         yyerrflag = 3;
391         for (;;)
392         {
393             if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
394                     yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
395             {
396 #if YYDEBUG
397                 if (yydebug)
398                     printf("%sdebug: state %d, error recovery shifting\
399  to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
400 #endif
401                 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
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             if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
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 > 0)
443         yyval = yystack.l_mark[1-yym];
444     else
445         memset(&yyval, 0, sizeof yyval);
446 
447     switch (yyn)
448     {
449 case 1:
450 #line 9 "err_syntax18.y"
451 	{  yyval = yystack.l_mark[1]; }
452 break;
453 #line 454 "err_syntax18.tab.c"
454     }
455     yystack.s_mark -= yym;
456     yystate = *yystack.s_mark;
457     yystack.l_mark -= yym;
458     yym = yylhs[yyn];
459     if (yystate == 0 && yym == 0)
460     {
461 #if YYDEBUG
462         if (yydebug)
463             printf("%sdebug: after reduction, shifting from state 0 to\
464  state %d\n", YYPREFIX, YYFINAL);
465 #endif
466         yystate = YYFINAL;
467         *++yystack.s_mark = YYFINAL;
468         *++yystack.l_mark = yyval;
469         if (yychar < 0)
470         {
471             yychar = YYLEX;
472             if (yychar < 0) yychar = YYEOF;
473 #if YYDEBUG
474             if (yydebug)
475             {
476                 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
477                 printf("%sdebug: state %d, reading %d (%s)\n",
478                         YYPREFIX, YYFINAL, yychar, yys);
479             }
480 #endif
481         }
482         if (yychar == YYEOF) goto yyaccept;
483         goto yyloop;
484     }
485     if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
486             yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
487         yystate = yytable[yyn];
488     else
489         yystate = yydgoto[yym];
490 #if YYDEBUG
491     if (yydebug)
492         printf("%sdebug: after reduction, shifting from state %d \
493 to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
494 #endif
495     if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
496     *++yystack.s_mark = (YYINT) yystate;
497     *++yystack.l_mark = yyval;
498     goto yyloop;
499 
500 yyoverflow:
501     YYERROR_CALL("yacc stack overflow");
502 
503 yyabort:
504     yyfreestack(&yystack);
505     return (1);
506 
507 yyaccept:
508     yyfreestack(&yystack);
509     return (0);
510 }
511