xref: /minix/external/bsd/byacc/dist/test/yacc/error.tab.c (revision 0a6a1f1d)
1 /*	$NetBSD: error.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    error_parse
21 #endif /* yyparse */
22 
23 #ifndef yylex
24 #define yylex      error_lex
25 #endif /* yylex */
26 
27 #ifndef yyerror
28 #define yyerror    error_error
29 #endif /* yyerror */
30 
31 #ifndef yychar
32 #define yychar     error_char
33 #endif /* yychar */
34 
35 #ifndef yyval
36 #define yyval      error_val
37 #endif /* yyval */
38 
39 #ifndef yylval
40 #define yylval     error_lval
41 #endif /* yylval */
42 
43 #ifndef yydebug
44 #define yydebug    error_debug
45 #endif /* yydebug */
46 
47 #ifndef yynerrs
48 #define yynerrs    error_nerrs
49 #endif /* yynerrs */
50 
51 #ifndef yyerrflag
52 #define yyerrflag  error_errflag
53 #endif /* yyerrflag */
54 
55 #ifndef yylhs
56 #define yylhs      error_lhs
57 #endif /* yylhs */
58 
59 #ifndef yylen
60 #define yylen      error_len
61 #endif /* yylen */
62 
63 #ifndef yydefred
64 #define yydefred   error_defred
65 #endif /* yydefred */
66 
67 #ifndef yydgoto
68 #define yydgoto    error_dgoto
69 #endif /* yydgoto */
70 
71 #ifndef yysindex
72 #define yysindex   error_sindex
73 #endif /* yysindex */
74 
75 #ifndef yyrindex
76 #define yyrindex   error_rindex
77 #endif /* yyrindex */
78 
79 #ifndef yygindex
80 #define yygindex   error_gindex
81 #endif /* yygindex */
82 
83 #ifndef yytable
84 #define yytable    error_table
85 #endif /* yytable */
86 
87 #ifndef yycheck
88 #define yycheck    error_check
89 #endif /* yycheck */
90 
91 #ifndef yyname
92 #define yyname     error_name
93 #endif /* yyname */
94 
95 #ifndef yyrule
96 #define yyrule     error_rule
97 #endif /* yyrule */
98 #define YYPREFIX "error_"
99 
100 #define YYPURE 0
101 
102 #line 2 "error.y"
103 int yylex(void);
104 static void yyerror(const char *);
105 #line 104 "error.tab.c"
106 
107 #if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED)
108 /* Default: YYSTYPE is the semantic value type. */
109 typedef int YYSTYPE;
110 # define YYSTYPE_IS_DECLARED 1
111 #endif
112 
113 /* compatibility with bison */
114 #ifdef YYPARSE_PARAM
115 /* compatibility with FreeBSD */
116 # ifdef YYPARSE_PARAM_TYPE
117 #  define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
118 # else
119 #  define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
120 # endif
121 #else
122 # define YYPARSE_DECL() yyparse(void)
123 #endif
124 
125 /* Parameters sent to lex. */
126 #ifdef YYLEX_PARAM
127 # define YYLEX_DECL() yylex(void *YYLEX_PARAM)
128 # define YYLEX yylex(YYLEX_PARAM)
129 #else
130 # define YYLEX_DECL() yylex(void)
131 # define YYLEX yylex()
132 #endif
133 
134 /* Parameters sent to yyerror. */
135 #ifndef YYERROR_DECL
136 #define YYERROR_DECL() yyerror(const char *s)
137 #endif
138 #ifndef YYERROR_CALL
139 #define YYERROR_CALL(msg) yyerror(msg)
140 #endif
141 
142 extern int YYPARSE_DECL();
143 
144 #define YYERRCODE 256
145 typedef short YYINT;
146 static const YYINT error_lhs[] = {                       -1,
147     0,
148 };
149 static const YYINT error_len[] = {                        2,
150     1,
151 };
152 static const YYINT error_defred[] = {                     0,
153     1,    0,
154 };
155 static const YYINT error_dgoto[] = {                      2,
156 };
157 static const YYINT error_sindex[] = {                  -256,
158     0,    0,
159 };
160 static const YYINT error_rindex[] = {                     0,
161     0,    0,
162 };
163 static const YYINT error_gindex[] = {                     0,
164 };
165 #define YYTABLESIZE 0
166 static const YYINT error_table[] = {                      1,
167 };
168 static const YYINT error_check[] = {                    256,
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 error_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,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,"illegal-symbol",
187 };
188 static const char *const error_rule[] = {
189 "$accept : S",
190 "S : error",
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 8 "error.y"
229 
230 #include <stdio.h>
231 
232 int
main(void)233 main(void)
234 {
235     printf("yyparse() = %d\n", yyparse());
236     return 0;
237 }
238 
239 int
yylex(void)240 yylex(void)
241 {
242     return -1;
243 }
244 
245 static void
yyerror(const char * s)246 yyerror(const char* s)
247 {
248     printf("%s\n", s);
249 }
250 #line 249 "error.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 */
yygrowstack(YYSTACKDATA * data)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)
yyfreestack(YYSTACKDATA * data)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
YYPARSE_DECL()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     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         if ((yychar = YYLEX) < 0) yychar = YYEOF;
345 #if YYDEBUG
346         if (yydebug)
347         {
348             yys = yyname[YYTRANSLATE(yychar)];
349             printf("%sdebug: state %d, reading %d (%s)\n",
350                     YYPREFIX, yystate, yychar, yys);
351         }
352 #endif
353     }
354     if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
355             yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
356     {
357 #if YYDEBUG
358         if (yydebug)
359             printf("%sdebug: state %d, shifting to state %d\n",
360                     YYPREFIX, yystate, yytable[yyn]);
361 #endif
362         if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
363         {
364             goto yyoverflow;
365         }
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]) && (yyn += yychar) >= 0 &&
374             yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
375     {
376         yyn = yytable[yyn];
377         goto yyreduce;
378     }
379     if (yyerrflag) goto yyinrecovery;
380 
381     YYERROR_CALL("syntax error");
382 
383     goto yyerrlab;
384 
385 yyerrlab:
386     ++yynerrs;
387 
388 yyinrecovery:
389     if (yyerrflag < 3)
390     {
391         yyerrflag = 3;
392         for (;;)
393         {
394             if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
395                     yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
396             {
397 #if YYDEBUG
398                 if (yydebug)
399                     printf("%sdebug: state %d, error recovery shifting\
400  to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
401 #endif
402                 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
403                 {
404                     goto yyoverflow;
405                 }
406                 yystate = yytable[yyn];
407                 *++yystack.s_mark = yytable[yyn];
408                 *++yystack.l_mark = yylval;
409                 goto yyloop;
410             }
411             else
412             {
413 #if YYDEBUG
414                 if (yydebug)
415                     printf("%sdebug: error recovery discarding state %d\n",
416                             YYPREFIX, *yystack.s_mark);
417 #endif
418                 if (yystack.s_mark <= yystack.s_base) goto yyabort;
419                 --yystack.s_mark;
420                 --yystack.l_mark;
421             }
422         }
423     }
424     else
425     {
426         if (yychar == YYEOF) goto yyabort;
427 #if YYDEBUG
428         if (yydebug)
429         {
430             yys = yyname[YYTRANSLATE(yychar)];
431             printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
432                     YYPREFIX, yystate, yychar, yys);
433         }
434 #endif
435         yychar = YYEMPTY;
436         goto yyloop;
437     }
438 
439 yyreduce:
440 #if YYDEBUG
441     if (yydebug)
442         printf("%sdebug: state %d, reducing by rule %d (%s)\n",
443                 YYPREFIX, yystate, yyn, yyrule[yyn]);
444 #endif
445     yym = yylen[yyn];
446     if (yym)
447         yyval = yystack.l_mark[1-yym];
448     else
449         memset(&yyval, 0, sizeof yyval);
450     switch (yyn)
451     {
452     }
453     yystack.s_mark -= yym;
454     yystate = *yystack.s_mark;
455     yystack.l_mark -= yym;
456     yym = yylhs[yyn];
457     if (yystate == 0 && yym == 0)
458     {
459 #if YYDEBUG
460         if (yydebug)
461             printf("%sdebug: after reduction, shifting from state 0 to\
462  state %d\n", YYPREFIX, YYFINAL);
463 #endif
464         yystate = YYFINAL;
465         *++yystack.s_mark = YYFINAL;
466         *++yystack.l_mark = yyval;
467         if (yychar < 0)
468         {
469             if ((yychar = YYLEX) < 0) yychar = YYEOF;
470 #if YYDEBUG
471             if (yydebug)
472             {
473                 yys = yyname[YYTRANSLATE(yychar)];
474                 printf("%sdebug: state %d, reading %d (%s)\n",
475                         YYPREFIX, YYFINAL, yychar, yys);
476             }
477 #endif
478         }
479         if (yychar == YYEOF) goto yyaccept;
480         goto yyloop;
481     }
482     if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
483             yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
484         yystate = yytable[yyn];
485     else
486         yystate = yydgoto[yym];
487 #if YYDEBUG
488     if (yydebug)
489         printf("%sdebug: after reduction, shifting from state %d \
490 to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
491 #endif
492     if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
493     {
494         goto yyoverflow;
495     }
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