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