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