1 /* $NetBSD: error.tab.c,v 1.5 2013/04/06 14:52:24 christos Exp $ */
4 /* static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93"; */
5 static char rcsid
[] = "$NetBSD: error.tab.c,v 1.5 2013/04/06 14:52:24 christos Exp $";
13 #define yyclearin (yychar = YYEMPTY)
14 #define yyerrok (yyerrflag = 0)
15 #define YYRECOVERING() (yyerrflag != 0)
19 #define yyparse error_parse
23 #define yylex error_lex
27 #define yyerror error_error
31 #define yychar error_char
35 #define yyval error_val
39 #define yylval error_lval
43 #define yydebug error_debug
47 #define yynerrs error_nerrs
51 #define yyerrflag error_errflag
52 #endif /* yyerrflag */
55 #define yylhs error_lhs
59 #define yylen error_len
63 #define yydefred error_defred
67 #define yydgoto error_dgoto
71 #define yysindex error_sindex
75 #define yyrindex error_rindex
79 #define yygindex error_gindex
83 #define yytable error_table
87 #define yycheck error_check
91 #define yyname error_name
95 #define yyrule error_rule
97 #define YYPREFIX "error_"
103 static void yyerror(const char *);
104 #line 102 "error.tab.c"
110 /* compatibility with bison */
112 /* compatibility with FreeBSD */
113 # ifdef YYPARSE_PARAM_TYPE
114 # define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
116 # define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
119 # define YYPARSE_DECL() yyparse(void)
122 /* Parameters sent to lex. */
124 # define YYLEX_DECL() yylex(void *YYLEX_PARAM)
125 # define YYLEX yylex(YYLEX_PARAM)
127 # define YYLEX_DECL() yylex(void)
128 # define YYLEX yylex()
131 /* Parameters sent to yyerror. */
133 #define YYERROR_DECL() yyerror(const char *s)
136 #define YYERROR_CALL(msg) yyerror(msg)
139 extern int YYPARSE_DECL();
141 #define YYERRCODE 256
142 static const short error_lhs
[] = { -1,
145 static const short error_len
[] = { 2,
148 static const short error_defred
[] = { 0,
151 static const short error_dgoto
[] = { 2,
153 static const short error_sindex
[] = { -256,
156 static const short error_rindex
[] = { 0,
159 static const short error_gindex
[] = { 0,
161 #define YYTABLESIZE 0
162 static const short error_table
[] = { 1,
164 static const short error_check
[] = { 256,
172 static const char *yyname
[] = {
176 static const char *yyrule
[] = {
191 /* define the initial stack-sizes */
194 #define YYMAXDEPTH YYSTACKSIZE
197 #define YYSTACKSIZE YYMAXDEPTH
199 #define YYSTACKSIZE 500
200 #define YYMAXDEPTH 500
204 #define YYINITSTACKSIZE 500
214 /* variables for the parser stack */
215 static YYSTACKDATA yystack
;
223 printf("yyparse() = %d\n", yyparse());
234 yyerror(const char* s
)
238 #line 236 "error.tab.c"
241 #include <stdio.h> /* needed for printf */
244 #include <stdlib.h> /* needed for malloc, etc */
245 #include <string.h> /* needed for memset */
247 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
248 static int yygrowstack(YYSTACKDATA
*data
)
255 if ((newsize
= data
->stacksize
) == 0)
256 newsize
= YYINITSTACKSIZE
;
257 else if (newsize
>= YYMAXDEPTH
)
259 else if ((newsize
*= 2) > YYMAXDEPTH
)
260 newsize
= YYMAXDEPTH
;
262 i
= (int) (data
->s_mark
- data
->s_base
);
263 newss
= (short *)realloc(data
->s_base
, newsize
* sizeof(*newss
));
267 data
->s_base
= newss
;
268 data
->s_mark
= newss
+ i
;
270 newvs
= (YYSTYPE
*)realloc(data
->l_base
, newsize
* sizeof(*newvs
));
274 data
->l_base
= newvs
;
275 data
->l_mark
= newvs
+ i
;
277 data
->stacksize
= newsize
;
278 data
->s_last
= data
->s_base
+ newsize
- 1;
282 #if YYPURE || defined(YY_NO_LEAKS)
283 static void yyfreestack(YYSTACKDATA
*data
)
287 memset(data
, 0, sizeof(*data
));
290 #define yyfreestack(data) /* nothing */
293 #define YYABORT goto yyabort
294 #define YYREJECT goto yyabort
295 #define YYACCEPT goto yyaccept
296 #define YYERROR goto yyerrlab
301 int yym
, yyn
, yystate
;
305 if ((yys
= getenv("YYDEBUG")) != 0)
308 if (yyn
>= '0' && yyn
<= '9')
319 memset(&yystack
, 0, sizeof(yystack
));
322 if (yystack
.s_base
== NULL
&& yygrowstack(&yystack
)) goto yyoverflow
;
323 yystack
.s_mark
= yystack
.s_base
;
324 yystack
.l_mark
= yystack
.l_base
;
329 if ((yyn
= yydefred
[yystate
]) != 0) goto yyreduce
;
332 if ((yychar
= YYLEX
) < 0) yychar
= 0;
337 if (yychar
<= YYMAXTOKEN
) yys
= yyname
[yychar
];
338 if (!yys
) yys
= "illegal-symbol";
339 printf("%sdebug: state %d, reading %d (%s)\n",
340 YYPREFIX
, yystate
, yychar
, yys
);
344 if ((yyn
= yysindex
[yystate
]) && (yyn
+= yychar
) >= 0 &&
345 yyn
<= YYTABLESIZE
&& yycheck
[yyn
] == yychar
)
349 printf("%sdebug: state %d, shifting to state %d\n",
350 YYPREFIX
, yystate
, yytable
[yyn
]);
352 if (yystack
.s_mark
>= yystack
.s_last
&& yygrowstack(&yystack
))
356 yystate
= yytable
[yyn
];
357 *++yystack
.s_mark
= yytable
[yyn
];
358 *++yystack
.l_mark
= yylval
;
360 if (yyerrflag
> 0) --yyerrflag
;
363 if ((yyn
= yyrindex
[yystate
]) && (yyn
+= yychar
) >= 0 &&
364 yyn
<= YYTABLESIZE
&& yycheck
[yyn
] == yychar
)
369 if (yyerrflag
) goto yyinrecovery
;
371 yyerror("syntax error");
384 if ((yyn
= yysindex
[*yystack
.s_mark
]) && (yyn
+= YYERRCODE
) >= 0 &&
385 yyn
<= YYTABLESIZE
&& yycheck
[yyn
] == YYERRCODE
)
389 printf("%sdebug: state %d, error recovery shifting\
390 to state %d\n", YYPREFIX
, *yystack
.s_mark
, yytable
[yyn
]);
392 if (yystack
.s_mark
>= yystack
.s_last
&& yygrowstack(&yystack
))
396 yystate
= yytable
[yyn
];
397 *++yystack
.s_mark
= yytable
[yyn
];
398 *++yystack
.l_mark
= yylval
;
405 printf("%sdebug: error recovery discarding state %d\n",
406 YYPREFIX
, *yystack
.s_mark
);
408 if (yystack
.s_mark
<= yystack
.s_base
) goto yyabort
;
416 if (yychar
== 0) goto yyabort
;
421 if (yychar
<= YYMAXTOKEN
) yys
= yyname
[yychar
];
422 if (!yys
) yys
= "illegal-symbol";
423 printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
424 YYPREFIX
, yystate
, yychar
, yys
);
434 printf("%sdebug: state %d, reducing by rule %d (%s)\n",
435 YYPREFIX
, yystate
, yyn
, yyrule
[yyn
]);
439 yyval
= yystack
.l_mark
[1-yym
];
441 memset(&yyval
, 0, sizeof yyval
);
445 yystack
.s_mark
-= yym
;
446 yystate
= *yystack
.s_mark
;
447 yystack
.l_mark
-= yym
;
449 if (yystate
== 0 && yym
== 0)
453 printf("%sdebug: after reduction, shifting from state 0 to\
454 state %d\n", YYPREFIX
, YYFINAL
);
457 *++yystack
.s_mark
= YYFINAL
;
458 *++yystack
.l_mark
= yyval
;
461 if ((yychar
= YYLEX
) < 0) yychar
= 0;
466 if (yychar
<= YYMAXTOKEN
) yys
= yyname
[yychar
];
467 if (!yys
) yys
= "illegal-symbol";
468 printf("%sdebug: state %d, reading %d (%s)\n",
469 YYPREFIX
, YYFINAL
, yychar
, yys
);
473 if (yychar
== 0) goto yyaccept
;
476 if ((yyn
= yygindex
[yym
]) && (yyn
+= yystate
) >= 0 &&
477 yyn
<= YYTABLESIZE
&& yycheck
[yyn
] == yystate
)
478 yystate
= yytable
[yyn
];
480 yystate
= yydgoto
[yym
];
483 printf("%sdebug: after reduction, shifting from state %d \
484 to state %d\n", YYPREFIX
, *yystack
.s_mark
, yystate
);
486 if (yystack
.s_mark
>= yystack
.s_last
&& yygrowstack(&yystack
))
490 *++yystack
.s_mark
= (short) yystate
;
491 *++yystack
.l_mark
= yyval
;
495 yyerror("yacc stack overflow");
498 yyfreestack(&yystack
);
502 yyfreestack(&yystack
);