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