1 /* $NetBSD: err_syntax20.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 err_syntax20_parse
21 #endif /* yyparse */
22
23 #ifndef yylex
24 #define yylex err_syntax20_lex
25 #endif /* yylex */
26
27 #ifndef yyerror
28 #define yyerror err_syntax20_error
29 #endif /* yyerror */
30
31 #ifndef yychar
32 #define yychar err_syntax20_char
33 #endif /* yychar */
34
35 #ifndef yyval
36 #define yyval err_syntax20_val
37 #endif /* yyval */
38
39 #ifndef yylval
40 #define yylval err_syntax20_lval
41 #endif /* yylval */
42
43 #ifndef yydebug
44 #define yydebug err_syntax20_debug
45 #endif /* yydebug */
46
47 #ifndef yynerrs
48 #define yynerrs err_syntax20_nerrs
49 #endif /* yynerrs */
50
51 #ifndef yyerrflag
52 #define yyerrflag err_syntax20_errflag
53 #endif /* yyerrflag */
54
55 #ifndef yylhs
56 #define yylhs err_syntax20_lhs
57 #endif /* yylhs */
58
59 #ifndef yylen
60 #define yylen err_syntax20_len
61 #endif /* yylen */
62
63 #ifndef yydefred
64 #define yydefred err_syntax20_defred
65 #endif /* yydefred */
66
67 #ifndef yydgoto
68 #define yydgoto err_syntax20_dgoto
69 #endif /* yydgoto */
70
71 #ifndef yysindex
72 #define yysindex err_syntax20_sindex
73 #endif /* yysindex */
74
75 #ifndef yyrindex
76 #define yyrindex err_syntax20_rindex
77 #endif /* yyrindex */
78
79 #ifndef yygindex
80 #define yygindex err_syntax20_gindex
81 #endif /* yygindex */
82
83 #ifndef yytable
84 #define yytable err_syntax20_table
85 #endif /* yytable */
86
87 #ifndef yycheck
88 #define yycheck err_syntax20_check
89 #endif /* yycheck */
90
91 #ifndef yyname
92 #define yyname err_syntax20_name
93 #endif /* yyname */
94
95 #ifndef yyrule
96 #define yyrule err_syntax20_rule
97 #endif /* yyrule */
98 #define YYPREFIX "err_syntax20_"
99
100 #define YYPURE 0
101
102 #line 2 "err_syntax20.y"
103 int yylex(void);
104 static void yyerror(const char *);
105 #line 104 "err_syntax20.tab.c"
106
107 /* compatibility with bison */
108 #ifdef YYPARSE_PARAM
109 /* compatibility with FreeBSD */
110 # ifdef YYPARSE_PARAM_TYPE
111 # define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
112 # else
113 # define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
114 # endif
115 #else
116 # define YYPARSE_DECL() yyparse(void)
117 #endif
118
119 /* Parameters sent to lex. */
120 #ifdef YYLEX_PARAM
121 # define YYLEX_DECL() yylex(void *YYLEX_PARAM)
122 # define YYLEX yylex(YYLEX_PARAM)
123 #else
124 # define YYLEX_DECL() yylex(void)
125 # define YYLEX yylex()
126 #endif
127
128 /* Parameters sent to yyerror. */
129 #ifndef YYERROR_DECL
130 #define YYERROR_DECL() yyerror(const char *s)
131 #endif
132 #ifndef YYERROR_CALL
133 #define YYERROR_CALL(msg) yyerror(msg)
134 #endif
135
136 extern int YYPARSE_DECL();
137
138 #define recur 257
139 #define YYERRCODE 256
140 typedef short YYINT;
141 static const YYINT err_syntax20_lhs[] = { -1,
142 0,
143 };
144 static const YYINT err_syntax20_len[] = { 2,
145 3,
146 };
147 static const YYINT err_syntax20_defred[] = { 0,
148 0, 0, 0, 1,
149 };
150 static const YYINT err_syntax20_dgoto[] = { 2,
151 };
152 static const YYINT err_syntax20_sindex[] = { -40,
153 -256, 0, -39, 0,
154 };
155 static const YYINT err_syntax20_rindex[] = { 0,
156 0, 0, 0, 0,
157 };
158 static const YYINT err_syntax20_gindex[] = { 0,
159 };
160 #define YYTABLESIZE 2
161 static const YYINT err_syntax20_table[] = { 1,
162 3, 4,
163 };
164 static const YYINT err_syntax20_check[] = { 40,
165 257, 41,
166 };
167 #define YYFINAL 2
168 #ifndef YYDEBUG
169 #define YYDEBUG 0
170 #endif
171 #define YYMAXTOKEN 257
172 #define YYUNDFTOKEN 260
173 #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
174 #if YYDEBUG
175 static const char *const err_syntax20_name[] = {
176
177 "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,
178 0,0,0,0,0,0,"'('","')'",0,0,0,0,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,"recur",0,0,
184 "illegal-symbol",
185 };
186 static const char *const err_syntax20_rule[] = {
187 "$accept : expr",
188 "expr : '(' recur ')'",
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 16 "err_syntax20.y"
227
228 #include <stdio.h>
229
230 int
main(void)231 main(void)
232 {
233 printf("yyparse() = %d\n", yyparse());
234 return 0;
235 }
236
237 int
yylex(void)238 yylex(void)
239 {
240 return -1;
241 }
242
243 static void
yyerror(const char * s)244 yyerror(const char* s)
245 {
246 printf("%s\n", s);
247 }
248 #line 247 "err_syntax20.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 */
yygrowstack(YYSTACKDATA * data)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)
yyfreestack(YYSTACKDATA * data)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
YYPARSE_DECL()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 yynerrs = 0;
324 yyerrflag = 0;
325 yychar = YYEMPTY;
326 yystate = 0;
327
328 #if YYPURE
329 memset(&yystack, 0, sizeof(yystack));
330 #endif
331
332 if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
333 yystack.s_mark = yystack.s_base;
334 yystack.l_mark = yystack.l_base;
335 yystate = 0;
336 *yystack.s_mark = 0;
337
338 yyloop:
339 if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
340 if (yychar < 0)
341 {
342 if ((yychar = YYLEX) < 0) yychar = YYEOF;
343 #if YYDEBUG
344 if (yydebug)
345 {
346 yys = yyname[YYTRANSLATE(yychar)];
347 printf("%sdebug: state %d, reading %d (%s)\n",
348 YYPREFIX, yystate, yychar, yys);
349 }
350 #endif
351 }
352 if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
353 yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
354 {
355 #if YYDEBUG
356 if (yydebug)
357 printf("%sdebug: state %d, shifting to state %d\n",
358 YYPREFIX, yystate, yytable[yyn]);
359 #endif
360 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
361 {
362 goto yyoverflow;
363 }
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]) && (yyn += yychar) >= 0 &&
372 yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
373 {
374 yyn = yytable[yyn];
375 goto yyreduce;
376 }
377 if (yyerrflag) goto yyinrecovery;
378
379 YYERROR_CALL("syntax error");
380
381 goto yyerrlab;
382
383 yyerrlab:
384 ++yynerrs;
385
386 yyinrecovery:
387 if (yyerrflag < 3)
388 {
389 yyerrflag = 3;
390 for (;;)
391 {
392 if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
393 yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
394 {
395 #if YYDEBUG
396 if (yydebug)
397 printf("%sdebug: state %d, error recovery shifting\
398 to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
399 #endif
400 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
401 {
402 goto yyoverflow;
403 }
404 yystate = yytable[yyn];
405 *++yystack.s_mark = yytable[yyn];
406 *++yystack.l_mark = yylval;
407 goto yyloop;
408 }
409 else
410 {
411 #if YYDEBUG
412 if (yydebug)
413 printf("%sdebug: error recovery discarding state %d\n",
414 YYPREFIX, *yystack.s_mark);
415 #endif
416 if (yystack.s_mark <= yystack.s_base) goto yyabort;
417 --yystack.s_mark;
418 --yystack.l_mark;
419 }
420 }
421 }
422 else
423 {
424 if (yychar == YYEOF) goto yyabort;
425 #if YYDEBUG
426 if (yydebug)
427 {
428 yys = yyname[YYTRANSLATE(yychar)];
429 printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
430 YYPREFIX, yystate, yychar, yys);
431 }
432 #endif
433 yychar = YYEMPTY;
434 goto yyloop;
435 }
436
437 yyreduce:
438 #if YYDEBUG
439 if (yydebug)
440 printf("%sdebug: state %d, reducing by rule %d (%s)\n",
441 YYPREFIX, yystate, yyn, yyrule[yyn]);
442 #endif
443 yym = yylen[yyn];
444 if (yym)
445 yyval = yystack.l_mark[1-yym];
446 else
447 memset(&yyval, 0, sizeof yyval);
448 switch (yyn)
449 {
450 case 1:
451 #line 12 "err_syntax20.y"
452 { yystack.l_mark[-1].rechk = 3; }
453 break;
454 #line 453 "err_syntax20.tab.c"
455 }
456 yystack.s_mark -= yym;
457 yystate = *yystack.s_mark;
458 yystack.l_mark -= yym;
459 yym = yylhs[yyn];
460 if (yystate == 0 && yym == 0)
461 {
462 #if YYDEBUG
463 if (yydebug)
464 printf("%sdebug: after reduction, shifting from state 0 to\
465 state %d\n", YYPREFIX, YYFINAL);
466 #endif
467 yystate = YYFINAL;
468 *++yystack.s_mark = YYFINAL;
469 *++yystack.l_mark = yyval;
470 if (yychar < 0)
471 {
472 if ((yychar = YYLEX) < 0) yychar = YYEOF;
473 #if YYDEBUG
474 if (yydebug)
475 {
476 yys = yyname[YYTRANSLATE(yychar)];
477 printf("%sdebug: state %d, reading %d (%s)\n",
478 YYPREFIX, YYFINAL, yychar, yys);
479 }
480 #endif
481 }
482 if (yychar == YYEOF) goto yyaccept;
483 goto yyloop;
484 }
485 if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
486 yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
487 yystate = yytable[yyn];
488 else
489 yystate = yydgoto[yym];
490 #if YYDEBUG
491 if (yydebug)
492 printf("%sdebug: after reduction, shifting from state %d \
493 to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
494 #endif
495 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
496 {
497 goto yyoverflow;
498 }
499 *++yystack.s_mark = (YYINT) yystate;
500 *++yystack.l_mark = yyval;
501 goto yyloop;
502
503 yyoverflow:
504 YYERROR_CALL("yacc stack overflow");
505
506 yyabort:
507 yyfreestack(&yystack);
508 return (1);
509
510 yyaccept:
511 yyfreestack(&yystack);
512 return (0);
513 }
514