]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - contrib/byacc/test/yacc/err_syntax18.tab.c
- Copy stable/10@285827 to releng/10.2 in preparation for 10.2-RC1
[FreeBSD/releng/10.2.git] / contrib / byacc / test / yacc / err_syntax18.tab.c
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_syntax18_parse
19 #endif /* yyparse */
20
21 #ifndef yylex
22 #define yylex      err_syntax18_lex
23 #endif /* yylex */
24
25 #ifndef yyerror
26 #define yyerror    err_syntax18_error
27 #endif /* yyerror */
28
29 #ifndef yychar
30 #define yychar     err_syntax18_char
31 #endif /* yychar */
32
33 #ifndef yyval
34 #define yyval      err_syntax18_val
35 #endif /* yyval */
36
37 #ifndef yylval
38 #define yylval     err_syntax18_lval
39 #endif /* yylval */
40
41 #ifndef yydebug
42 #define yydebug    err_syntax18_debug
43 #endif /* yydebug */
44
45 #ifndef yynerrs
46 #define yynerrs    err_syntax18_nerrs
47 #endif /* yynerrs */
48
49 #ifndef yyerrflag
50 #define yyerrflag  err_syntax18_errflag
51 #endif /* yyerrflag */
52
53 #ifndef yylhs
54 #define yylhs      err_syntax18_lhs
55 #endif /* yylhs */
56
57 #ifndef yylen
58 #define yylen      err_syntax18_len
59 #endif /* yylen */
60
61 #ifndef yydefred
62 #define yydefred   err_syntax18_defred
63 #endif /* yydefred */
64
65 #ifndef yydgoto
66 #define yydgoto    err_syntax18_dgoto
67 #endif /* yydgoto */
68
69 #ifndef yysindex
70 #define yysindex   err_syntax18_sindex
71 #endif /* yysindex */
72
73 #ifndef yyrindex
74 #define yyrindex   err_syntax18_rindex
75 #endif /* yyrindex */
76
77 #ifndef yygindex
78 #define yygindex   err_syntax18_gindex
79 #endif /* yygindex */
80
81 #ifndef yytable
82 #define yytable    err_syntax18_table
83 #endif /* yytable */
84
85 #ifndef yycheck
86 #define yycheck    err_syntax18_check
87 #endif /* yycheck */
88
89 #ifndef yyname
90 #define yyname     err_syntax18_name
91 #endif /* yyname */
92
93 #ifndef yyrule
94 #define yyrule     err_syntax18_rule
95 #endif /* yyrule */
96 #define YYPREFIX "err_syntax18_"
97
98 #define YYPURE 0
99
100 #line 2 "err_syntax18.y"
101 int yylex(void);
102 static void yyerror(const char *);
103 #line 104 "err_syntax18.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 err_syntax18_lhs[] = {                -1,
145     0,
146 };
147 static const YYINT err_syntax18_len[] = {                 2,
148     3,
149 };
150 static const YYINT err_syntax18_defred[] = {              0,
151     0,    0,    0,    1,
152 };
153 static const YYINT err_syntax18_dgoto[] = {               2,
154 };
155 static const YYINT err_syntax18_sindex[] = {            -40,
156   -40,    0,  -39,    0,
157 };
158 static const YYINT err_syntax18_rindex[] = {              0,
159     0,    0,    0,    0,
160 };
161 static const YYINT err_syntax18_gindex[] = {              2,
162 };
163 #define YYTABLESIZE 3
164 static const YYINT err_syntax18_table[] = {               1,
165     0,    4,    3,
166 };
167 static const YYINT err_syntax18_check[] = {              40,
168    -1,   41,    1,
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 err_syntax18_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,
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,"illegal-symbol",
187 };
188 static const char *const err_syntax18_rule[] = {
189 "$accept : expr",
190 "expr : '(' expr ')'",
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 13 "err_syntax18.y"
229
230 #include <stdio.h>
231
232 int
233 main(void)
234 {
235     printf("yyparse() = %d\n", yyparse());
236     return 0;
237 }
238
239 int
240 yylex(void)
241 {
242     return -1;
243 }
244
245 static void
246 yyerror(const char* s)
247 {
248     printf("%s\n", s);
249 }
250 #line 251 "err_syntax18.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 */
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)
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
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 case 1:
453 #line 9 "err_syntax18.y"
454         {  yyval = yystack.l_mark[1]; }
455 break;
456 #line 457 "err_syntax18.tab.c"
457     }
458     yystack.s_mark -= yym;
459     yystate = *yystack.s_mark;
460     yystack.l_mark -= yym;
461     yym = yylhs[yyn];
462     if (yystate == 0 && yym == 0)
463     {
464 #if YYDEBUG
465         if (yydebug)
466             printf("%sdebug: after reduction, shifting from state 0 to\
467  state %d\n", YYPREFIX, YYFINAL);
468 #endif
469         yystate = YYFINAL;
470         *++yystack.s_mark = YYFINAL;
471         *++yystack.l_mark = yyval;
472         if (yychar < 0)
473         {
474             if ((yychar = YYLEX) < 0) yychar = YYEOF;
475 #if YYDEBUG
476             if (yydebug)
477             {
478                 yys = yyname[YYTRANSLATE(yychar)];
479                 printf("%sdebug: state %d, reading %d (%s)\n",
480                         YYPREFIX, YYFINAL, yychar, yys);
481             }
482 #endif
483         }
484         if (yychar == YYEOF) goto yyaccept;
485         goto yyloop;
486     }
487     if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
488             yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
489         yystate = yytable[yyn];
490     else
491         yystate = yydgoto[yym];
492 #if YYDEBUG
493     if (yydebug)
494         printf("%sdebug: after reduction, shifting from state %d \
495 to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
496 #endif
497     if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
498     {
499         goto yyoverflow;
500     }
501     *++yystack.s_mark = (YYINT) yystate;
502     *++yystack.l_mark = yyval;
503     goto yyloop;
504
505 yyoverflow:
506     YYERROR_CALL("yacc stack overflow");
507
508 yyabort:
509     yyfreestack(&yystack);
510     return (1);
511
512 yyaccept:
513     yyfreestack(&yystack);
514     return (0);
515 }