xref: /freebsd/contrib/byacc/test/yacc/err_syntax12.tab.c (revision 9268022b74279434ed6300244e3f977e56a8ceb5)
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_syntax12_parse
19 #endif /* yyparse */
20 
21 #ifndef yylex
22 #define yylex      err_syntax12_lex
23 #endif /* yylex */
24 
25 #ifndef yyerror
26 #define yyerror    err_syntax12_error
27 #endif /* yyerror */
28 
29 #ifndef yychar
30 #define yychar     err_syntax12_char
31 #endif /* yychar */
32 
33 #ifndef yyval
34 #define yyval      err_syntax12_val
35 #endif /* yyval */
36 
37 #ifndef yylval
38 #define yylval     err_syntax12_lval
39 #endif /* yylval */
40 
41 #ifndef yydebug
42 #define yydebug    err_syntax12_debug
43 #endif /* yydebug */
44 
45 #ifndef yynerrs
46 #define yynerrs    err_syntax12_nerrs
47 #endif /* yynerrs */
48 
49 #ifndef yyerrflag
50 #define yyerrflag  err_syntax12_errflag
51 #endif /* yyerrflag */
52 
53 #ifndef yylhs
54 #define yylhs      err_syntax12_lhs
55 #endif /* yylhs */
56 
57 #ifndef yylen
58 #define yylen      err_syntax12_len
59 #endif /* yylen */
60 
61 #ifndef yydefred
62 #define yydefred   err_syntax12_defred
63 #endif /* yydefred */
64 
65 #ifndef yydgoto
66 #define yydgoto    err_syntax12_dgoto
67 #endif /* yydgoto */
68 
69 #ifndef yysindex
70 #define yysindex   err_syntax12_sindex
71 #endif /* yysindex */
72 
73 #ifndef yyrindex
74 #define yyrindex   err_syntax12_rindex
75 #endif /* yyrindex */
76 
77 #ifndef yygindex
78 #define yygindex   err_syntax12_gindex
79 #endif /* yygindex */
80 
81 #ifndef yytable
82 #define yytable    err_syntax12_table
83 #endif /* yytable */
84 
85 #ifndef yycheck
86 #define yycheck    err_syntax12_check
87 #endif /* yycheck */
88 
89 #ifndef yyname
90 #define yyname     err_syntax12_name
91 #endif /* yyname */
92 
93 #ifndef yyrule
94 #define yyrule     err_syntax12_rule
95 #endif /* yyrule */
96 #define YYPREFIX "err_syntax12_"
97 
98 #define YYPURE 0
99 
100 #line 2 "err_syntax12.y"
101 int yylex(void);
102 static void yyerror(const char *);
103 #line 104 "err_syntax12.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 text 456
143 #define YYERRCODE 256
144 typedef int YYINT;
145 static const YYINT err_syntax12_lhs[] = {                -1,
146     0,
147 };
148 static const YYINT err_syntax12_len[] = {                 2,
149     1,
150 };
151 static const YYINT err_syntax12_defred[] = {              0,
152     1,    0,
153 };
154 static const YYINT err_syntax12_dgoto[] = {               2,
155 };
156 static const YYINT err_syntax12_sindex[] = {           -256,
157     0,    0,
158 };
159 static const YYINT err_syntax12_rindex[] = {              0,
160     0,    0,
161 };
162 static const YYINT err_syntax12_gindex[] = {              0,
163 };
164 #define YYTABLESIZE 0
165 static const YYINT err_syntax12_table[] = {               1,
166 };
167 static const YYINT err_syntax12_check[] = {             256,
168 };
169 #define YYFINAL 2
170 #ifndef YYDEBUG
171 #define YYDEBUG 0
172 #endif
173 #define YYMAXTOKEN 456
174 #define YYUNDFTOKEN 459
175 #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
176 #if YYDEBUG
177 static const char *const err_syntax12_name[] = {
178 
179 "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,
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,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,"text",0,0,"illegal-symbol",
191 };
192 static const char *const err_syntax12_rule[] = {
193 "$accept : S",
194 "S : error",
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 12 "err_syntax12.y"
233 
234 #include <stdio.h>
235 
236 int
237 main(void)
238 {
239     printf("yyparse() = %d\n", yyparse());
240     return 0;
241 }
242 
243 int
244 yylex(void)
245 {
246     return -1;
247 }
248 
249 static void
250 yyerror(const char* s)
251 {
252     printf("%s\n", s);
253 }
254 #line 255 "err_syntax12.tab.c"
255 
256 #if YYDEBUG
257 #include <stdio.h>		/* needed for printf */
258 #endif
259 
260 #include <stdlib.h>	/* needed for malloc, etc */
261 #include <string.h>	/* needed for memset */
262 
263 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
264 static int yygrowstack(YYSTACKDATA *data)
265 {
266     int i;
267     unsigned newsize;
268     YYINT *newss;
269     YYSTYPE *newvs;
270 
271     if ((newsize = data->stacksize) == 0)
272         newsize = YYINITSTACKSIZE;
273     else if (newsize >= YYMAXDEPTH)
274         return YYENOMEM;
275     else if ((newsize *= 2) > YYMAXDEPTH)
276         newsize = YYMAXDEPTH;
277 
278     i = (int) (data->s_mark - data->s_base);
279     newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
280     if (newss == 0)
281         return YYENOMEM;
282 
283     data->s_base = newss;
284     data->s_mark = newss + i;
285 
286     newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
287     if (newvs == 0)
288         return YYENOMEM;
289 
290     data->l_base = newvs;
291     data->l_mark = newvs + i;
292 
293     data->stacksize = newsize;
294     data->s_last = data->s_base + newsize - 1;
295     return 0;
296 }
297 
298 #if YYPURE || defined(YY_NO_LEAKS)
299 static void yyfreestack(YYSTACKDATA *data)
300 {
301     free(data->s_base);
302     free(data->l_base);
303     memset(data, 0, sizeof(*data));
304 }
305 #else
306 #define yyfreestack(data) /* nothing */
307 #endif
308 
309 #define YYABORT  goto yyabort
310 #define YYREJECT goto yyabort
311 #define YYACCEPT goto yyaccept
312 #define YYERROR  goto yyerrlab
313 
314 int
315 YYPARSE_DECL()
316 {
317     int yym, yyn, yystate;
318 #if YYDEBUG
319     const char *yys;
320 
321     if ((yys = getenv("YYDEBUG")) != 0)
322     {
323         yyn = *yys;
324         if (yyn >= '0' && yyn <= '9')
325             yydebug = yyn - '0';
326     }
327 #endif
328 
329     yynerrs = 0;
330     yyerrflag = 0;
331     yychar = YYEMPTY;
332     yystate = 0;
333 
334 #if YYPURE
335     memset(&yystack, 0, sizeof(yystack));
336 #endif
337 
338     if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
339     yystack.s_mark = yystack.s_base;
340     yystack.l_mark = yystack.l_base;
341     yystate = 0;
342     *yystack.s_mark = 0;
343 
344 yyloop:
345     if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
346     if (yychar < 0)
347     {
348         if ((yychar = YYLEX) < 0) yychar = YYEOF;
349 #if YYDEBUG
350         if (yydebug)
351         {
352             yys = yyname[YYTRANSLATE(yychar)];
353             printf("%sdebug: state %d, reading %d (%s)\n",
354                     YYPREFIX, yystate, yychar, yys);
355         }
356 #endif
357     }
358     if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
359             yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
360     {
361 #if YYDEBUG
362         if (yydebug)
363             printf("%sdebug: state %d, shifting to state %d\n",
364                     YYPREFIX, yystate, yytable[yyn]);
365 #endif
366         if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
367         {
368             goto yyoverflow;
369         }
370         yystate = yytable[yyn];
371         *++yystack.s_mark = yytable[yyn];
372         *++yystack.l_mark = yylval;
373         yychar = YYEMPTY;
374         if (yyerrflag > 0)  --yyerrflag;
375         goto yyloop;
376     }
377     if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
378             yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
379     {
380         yyn = yytable[yyn];
381         goto yyreduce;
382     }
383     if (yyerrflag) goto yyinrecovery;
384 
385     YYERROR_CALL("syntax error");
386 
387     goto yyerrlab;
388 
389 yyerrlab:
390     ++yynerrs;
391 
392 yyinrecovery:
393     if (yyerrflag < 3)
394     {
395         yyerrflag = 3;
396         for (;;)
397         {
398             if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
399                     yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
400             {
401 #if YYDEBUG
402                 if (yydebug)
403                     printf("%sdebug: state %d, error recovery shifting\
404  to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
405 #endif
406                 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
407                 {
408                     goto yyoverflow;
409                 }
410                 yystate = yytable[yyn];
411                 *++yystack.s_mark = yytable[yyn];
412                 *++yystack.l_mark = yylval;
413                 goto yyloop;
414             }
415             else
416             {
417 #if YYDEBUG
418                 if (yydebug)
419                     printf("%sdebug: error recovery discarding state %d\n",
420                             YYPREFIX, *yystack.s_mark);
421 #endif
422                 if (yystack.s_mark <= yystack.s_base) goto yyabort;
423                 --yystack.s_mark;
424                 --yystack.l_mark;
425             }
426         }
427     }
428     else
429     {
430         if (yychar == YYEOF) goto yyabort;
431 #if YYDEBUG
432         if (yydebug)
433         {
434             yys = yyname[YYTRANSLATE(yychar)];
435             printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
436                     YYPREFIX, yystate, yychar, yys);
437         }
438 #endif
439         yychar = YYEMPTY;
440         goto yyloop;
441     }
442 
443 yyreduce:
444 #if YYDEBUG
445     if (yydebug)
446         printf("%sdebug: state %d, reducing by rule %d (%s)\n",
447                 YYPREFIX, yystate, yyn, yyrule[yyn]);
448 #endif
449     yym = yylen[yyn];
450     if (yym)
451         yyval = yystack.l_mark[1-yym];
452     else
453         memset(&yyval, 0, sizeof yyval);
454     switch (yyn)
455     {
456     }
457     yystack.s_mark -= yym;
458     yystate = *yystack.s_mark;
459     yystack.l_mark -= yym;
460     yym = yylhs[yyn];
461     if (yystate == 0 && yym == 0)
462     {
463 #if YYDEBUG
464         if (yydebug)
465             printf("%sdebug: after reduction, shifting from state 0 to\
466  state %d\n", YYPREFIX, YYFINAL);
467 #endif
468         yystate = YYFINAL;
469         *++yystack.s_mark = YYFINAL;
470         *++yystack.l_mark = yyval;
471         if (yychar < 0)
472         {
473             if ((yychar = YYLEX) < 0) yychar = YYEOF;
474 #if YYDEBUG
475             if (yydebug)
476             {
477                 yys = yyname[YYTRANSLATE(yychar)];
478                 printf("%sdebug: state %d, reading %d (%s)\n",
479                         YYPREFIX, YYFINAL, yychar, yys);
480             }
481 #endif
482         }
483         if (yychar == YYEOF) goto yyaccept;
484         goto yyloop;
485     }
486     if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
487             yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
488         yystate = yytable[yyn];
489     else
490         yystate = yydgoto[yym];
491 #if YYDEBUG
492     if (yydebug)
493         printf("%sdebug: after reduction, shifting from state %d \
494 to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
495 #endif
496     if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
497     {
498         goto yyoverflow;
499     }
500     *++yystack.s_mark = (YYINT) yystate;
501     *++yystack.l_mark = yyval;
502     goto yyloop;
503 
504 yyoverflow:
505     YYERROR_CALL("yacc stack overflow");
506 
507 yyabort:
508     yyfreestack(&yystack);
509     return (1);
510 
511 yyaccept:
512     yyfreestack(&yystack);
513     return (0);
514 }
515