1 /* original parser id follows */
2 /* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */
3 /* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */
8 #define YYCHECK "yyyymmdd"
11 #define yyclearin (yychar = YYEMPTY)
12 #define yyerrok (yyerrflag = 0)
13 #define YYRECOVERING() (yyerrflag != 0)
18 #define yyparse err_syntax18_parse
22 #define yylex err_syntax18_lex
26 #define yyerror err_syntax18_error
30 #define yychar err_syntax18_char
34 #define yyval err_syntax18_val
38 #define yylval err_syntax18_lval
42 #define yydebug err_syntax18_debug
46 #define yynerrs err_syntax18_nerrs
50 #define yyerrflag err_syntax18_errflag
51 #endif /* yyerrflag */
54 #define yylhs err_syntax18_lhs
58 #define yylen err_syntax18_len
62 #define yydefred err_syntax18_defred
66 #define yydgoto err_syntax18_dgoto
70 #define yysindex err_syntax18_sindex
74 #define yyrindex err_syntax18_rindex
78 #define yygindex err_syntax18_gindex
82 #define yytable err_syntax18_table
86 #define yycheck err_syntax18_check
90 #define yyname err_syntax18_name
94 #define yyrule err_syntax18_rule
96 #define YYPREFIX "err_syntax18_"
100 #line 2 "err_syntax18.y"
102 static void yyerror(const char *);
103 #line 104 "err_syntax18.tab.c"
105 #if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED)
106 /* Default: YYSTYPE is the semantic value type. */
108 # define YYSTYPE_IS_DECLARED 1
111 /* compatibility with bison */
113 /* compatibility with FreeBSD */
114 # ifdef YYPARSE_PARAM_TYPE
115 # define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
117 # define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
120 # define YYPARSE_DECL() yyparse(void)
123 /* Parameters sent to lex. */
125 # define YYLEX_DECL() yylex(void *YYLEX_PARAM)
126 # define YYLEX yylex(YYLEX_PARAM)
128 # define YYLEX_DECL() yylex(void)
129 # define YYLEX yylex()
132 /* Parameters sent to yyerror. */
134 #define YYERROR_DECL() yyerror(const char *s)
137 #define YYERROR_CALL(msg) yyerror(msg)
140 extern int YYPARSE_DECL();
142 #define YYERRCODE 256
144 static const YYINT err_syntax18_lhs[] = { -1,
147 static const YYINT err_syntax18_len[] = { 2,
150 static const YYINT err_syntax18_defred[] = { 0,
153 static const YYINT err_syntax18_dgoto[] = { 2,
155 static const YYINT err_syntax18_sindex[] = { -40,
158 static const YYINT err_syntax18_rindex[] = { 0,
161 static const YYINT err_syntax18_gindex[] = { 2,
163 #define YYTABLESIZE 3
164 static const YYINT err_syntax18_table[] = { 1,
167 static const YYINT err_syntax18_check[] = { 40,
174 #define YYMAXTOKEN 256
175 #define YYUNDFTOKEN 259
176 #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
178 static const char *const err_syntax18_name[] = {
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",
188 static const char *const err_syntax18_rule[] = {
190 "expr : '(' expr ')'",
205 /* define the initial stack-sizes */
208 #define YYMAXDEPTH YYSTACKSIZE
211 #define YYSTACKSIZE YYMAXDEPTH
213 #define YYSTACKSIZE 10000
214 #define YYMAXDEPTH 10000
218 #define YYINITSTACKSIZE 200
228 /* variables for the parser stack */
229 static YYSTACKDATA yystack;
230 #line 13 "err_syntax18.y"
237 printf("yyparse() = %d\n", yyparse());
248 yyerror(const char* s)
252 #line 253 "err_syntax18.tab.c"
255 #include <stdio.h> /* needed for printf */
258 #include <stdlib.h> /* needed for malloc, etc */
259 #include <string.h> /* needed for memset */
261 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
262 static int yygrowstack(YYSTACKDATA *data)
269 if ((newsize = data->stacksize) == 0)
270 newsize = YYINITSTACKSIZE;
271 else if (newsize >= YYMAXDEPTH)
273 else if ((newsize *= 2) > YYMAXDEPTH)
274 newsize = YYMAXDEPTH;
276 i = (int) (data->s_mark - data->s_base);
277 newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
281 data->s_base = newss;
282 data->s_mark = newss + i;
284 newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
288 data->l_base = newvs;
289 data->l_mark = newvs + i;
291 data->stacksize = newsize;
292 data->s_last = data->s_base + newsize - 1;
296 #if YYPURE || defined(YY_NO_LEAKS)
297 static void yyfreestack(YYSTACKDATA *data)
301 memset(data, 0, sizeof(*data));
304 #define yyfreestack(data) /* nothing */
307 #define YYABORT goto yyabort
308 #define YYREJECT goto yyabort
309 #define YYACCEPT goto yyaccept
310 #define YYERROR goto yyerrlab
315 int yym, yyn, yystate;
319 if ((yys = getenv("YYDEBUG")) != 0)
322 if (yyn >= '0' && yyn <= '9')
335 memset(&yystack, 0, sizeof(yystack));
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;
345 if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
349 if (yychar < 0) yychar = YYEOF;
353 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
354 printf("%sdebug: state %d, reading %d (%s)\n",
355 YYPREFIX, yystate, yychar, yys);
359 if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
360 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
364 printf("%sdebug: state %d, shifting to state %d\n",
365 YYPREFIX, yystate, yytable[yyn]);
367 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
368 yystate = yytable[yyn];
369 *++yystack.s_mark = yytable[yyn];
370 *++yystack.l_mark = yylval;
372 if (yyerrflag > 0) --yyerrflag;
375 if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
376 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
381 if (yyerrflag != 0) goto yyinrecovery;
383 YYERROR_CALL("syntax error");
385 goto yyerrlab; /* redundant goto avoids 'unused label' warning */
395 if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
396 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
400 printf("%sdebug: state %d, error recovery shifting\
401 to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
403 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
404 yystate = yytable[yyn];
405 *++yystack.s_mark = yytable[yyn];
406 *++yystack.l_mark = yylval;
413 printf("%sdebug: error recovery discarding state %d\n",
414 YYPREFIX, *yystack.s_mark);
416 if (yystack.s_mark <= yystack.s_base) goto yyabort;
424 if (yychar == YYEOF) goto yyabort;
428 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
429 printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
430 YYPREFIX, yystate, yychar, yys);
440 printf("%sdebug: state %d, reducing by rule %d (%s)\n",
441 YYPREFIX, yystate, yyn, yyrule[yyn]);
445 yyval = yystack.l_mark[1-yym];
447 memset(&yyval, 0, sizeof yyval);
452 #line 9 "err_syntax18.y"
453 { yyval = yystack.l_mark[1]; }
455 #line 456 "err_syntax18.tab.c"
457 yystack.s_mark -= yym;
458 yystate = *yystack.s_mark;
459 yystack.l_mark -= yym;
461 if (yystate == 0 && yym == 0)
465 printf("%sdebug: after reduction, shifting from state 0 to\
466 state %d\n", YYPREFIX, YYFINAL);
469 *++yystack.s_mark = YYFINAL;
470 *++yystack.l_mark = yyval;
474 if (yychar < 0) yychar = YYEOF;
478 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
479 printf("%sdebug: state %d, reading %d (%s)\n",
480 YYPREFIX, YYFINAL, yychar, yys);
484 if (yychar == YYEOF) goto yyaccept;
487 if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
488 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
489 yystate = yytable[yyn];
491 yystate = yydgoto[yym];
494 printf("%sdebug: after reduction, shifting from state %d \
495 to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
497 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
498 *++yystack.s_mark = (YYINT) yystate;
499 *++yystack.l_mark = yyval;
503 YYERROR_CALL("yacc stack overflow");
506 yyfreestack(&yystack);
510 yyfreestack(&yystack);