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