1 /* $NetBSD: code_error.code.c,v 1.1.1.4 2013/04/06 14:45:27 christos Exp $ */
4 static const char yysccsid
[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
12 #define yyclearin (yychar = YYEMPTY)
13 #define yyerrok (yyerrflag = 0)
14 #define YYRECOVERING() (yyerrflag != 0)
19 #line 2 "code_error.y"
23 static void yyerror(const char *);
26 #line 25 "code_error.code.c"
32 /* compatibility with bison */
34 /* compatibility with FreeBSD */
35 # ifdef YYPARSE_PARAM_TYPE
36 # define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
38 # define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
41 # define YYPARSE_DECL() yyparse(void)
44 /* Parameters sent to lex. */
46 # define YYLEX_DECL() yylex(void *YYLEX_PARAM)
47 # define YYLEX yylex(YYLEX_PARAM)
49 # define YYLEX_DECL() yylex(void)
50 # define YYLEX yylex()
53 /* Parameters sent to yyerror. */
55 #define YYERROR_DECL() yyerror(const char *s)
58 #define YYERROR_CALL(msg) yyerror(msg)
61 extern int YYPARSE_DECL();
72 #define yyparse error_parse
76 #define yylex error_lex
80 #define yyerror error_error
84 #define yychar error_char
88 #define yyval error_val
92 #define yylval error_lval
96 #define yydebug error_debug
100 #define yynerrs error_nerrs
104 #define yyerrflag error_errflag
105 #endif /* yyerrflag */
108 #define yylhs error_lhs
112 #define yylen error_len
116 #define yydefred error_defred
117 #endif /* yydefred */
120 #define yydgoto error_dgoto
124 #define yysindex error_sindex
125 #endif /* yysindex */
128 #define yyrindex error_rindex
129 #endif /* yyrindex */
132 #define yygindex error_gindex
133 #endif /* yygindex */
136 #define yytable error_table
140 #define yycheck error_check
144 #define yyname error_name
148 #define yyrule error_rule
150 #define YYPREFIX "error_"
152 extern int YYPARSE_DECL();
153 extern short yylhs
[];
154 extern short yylen
[];
155 extern short yydefred
[];
156 extern short yydgoto
[];
157 extern short yysindex
[];
158 extern short yyrindex
[];
159 extern short yygindex
[];
160 extern short yytable
[];
161 extern short yycheck
[];
164 extern char *yyname
[];
165 extern char *yyrule
[];
176 /* define the initial stack-sizes */
179 #define YYMAXDEPTH YYSTACKSIZE
182 #define YYSTACKSIZE YYMAXDEPTH
184 #define YYSTACKSIZE 500
185 #define YYMAXDEPTH 500
189 #define YYINITSTACKSIZE 500
199 /* variables for the parser stack */
200 static YYSTACKDATA yystack
;
201 #line 12 "code_error.y"
206 extern int YYLEX_DECL();
212 printf("yyparse() = %d\n", yyparse());
223 yyerror(const char* s
)
227 #line 226 "code_error.code.c"
230 #include <stdio.h> /* needed for printf */
233 #include <stdlib.h> /* needed for malloc, etc */
234 #include <string.h> /* needed for memset */
236 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
237 static int yygrowstack(YYSTACKDATA
*data
)
244 if ((newsize
= data
->stacksize
) == 0)
245 newsize
= YYINITSTACKSIZE
;
246 else if (newsize
>= YYMAXDEPTH
)
248 else if ((newsize
*= 2) > YYMAXDEPTH
)
249 newsize
= YYMAXDEPTH
;
251 i
= (int) (data
->s_mark
- data
->s_base
);
252 newss
= (short *)realloc(data
->s_base
, newsize
* sizeof(*newss
));
256 data
->s_base
= newss
;
257 data
->s_mark
= newss
+ i
;
259 newvs
= (YYSTYPE
*)realloc(data
->l_base
, newsize
* sizeof(*newvs
));
263 data
->l_base
= newvs
;
264 data
->l_mark
= newvs
+ i
;
266 data
->stacksize
= newsize
;
267 data
->s_last
= data
->s_base
+ newsize
- 1;
271 #if YYPURE || defined(YY_NO_LEAKS)
272 static void yyfreestack(YYSTACKDATA
*data
)
276 memset(data
, 0, sizeof(*data
));
279 #define yyfreestack(data) /* nothing */
282 #define YYABORT goto yyabort
283 #define YYREJECT goto yyabort
284 #define YYACCEPT goto yyaccept
285 #define YYERROR goto yyerrlab
290 int yym
, yyn
, yystate
;
294 if ((yys
= getenv("YYDEBUG")) != 0)
297 if (yyn
>= '0' && yyn
<= '9')
308 memset(&yystack
, 0, sizeof(yystack
));
311 if (yystack
.s_base
== NULL
&& yygrowstack(&yystack
)) goto yyoverflow
;
312 yystack
.s_mark
= yystack
.s_base
;
313 yystack
.l_mark
= yystack
.l_base
;
318 if ((yyn
= yydefred
[yystate
]) != 0) goto yyreduce
;
321 if ((yychar
= YYLEX
) < 0) yychar
= 0;
326 if (yychar
<= YYMAXTOKEN
) yys
= yyname
[yychar
];
327 if (!yys
) yys
= "illegal-symbol";
328 printf("%sdebug: state %d, reading %d (%s)\n",
329 YYPREFIX
, yystate
, yychar
, yys
);
333 if ((yyn
= yysindex
[yystate
]) && (yyn
+= yychar
) >= 0 &&
334 yyn
<= YYTABLESIZE
&& yycheck
[yyn
] == yychar
)
338 printf("%sdebug: state %d, shifting to state %d\n",
339 YYPREFIX
, yystate
, yytable
[yyn
]);
341 if (yystack
.s_mark
>= yystack
.s_last
&& yygrowstack(&yystack
))
345 yystate
= yytable
[yyn
];
346 *++yystack
.s_mark
= yytable
[yyn
];
347 *++yystack
.l_mark
= yylval
;
349 if (yyerrflag
> 0) --yyerrflag
;
352 if ((yyn
= yyrindex
[yystate
]) && (yyn
+= yychar
) >= 0 &&
353 yyn
<= YYTABLESIZE
&& yycheck
[yyn
] == yychar
)
358 if (yyerrflag
) goto yyinrecovery
;
360 yyerror("syntax error");
373 if ((yyn
= yysindex
[*yystack
.s_mark
]) && (yyn
+= YYERRCODE
) >= 0 &&
374 yyn
<= YYTABLESIZE
&& yycheck
[yyn
] == YYERRCODE
)
378 printf("%sdebug: state %d, error recovery shifting\
379 to state %d\n", YYPREFIX
, *yystack
.s_mark
, yytable
[yyn
]);
381 if (yystack
.s_mark
>= yystack
.s_last
&& yygrowstack(&yystack
))
385 yystate
= yytable
[yyn
];
386 *++yystack
.s_mark
= yytable
[yyn
];
387 *++yystack
.l_mark
= yylval
;
394 printf("%sdebug: error recovery discarding state %d\n",
395 YYPREFIX
, *yystack
.s_mark
);
397 if (yystack
.s_mark
<= yystack
.s_base
) goto yyabort
;
405 if (yychar
== 0) goto yyabort
;
410 if (yychar
<= YYMAXTOKEN
) yys
= yyname
[yychar
];
411 if (!yys
) yys
= "illegal-symbol";
412 printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
413 YYPREFIX
, yystate
, yychar
, yys
);
423 printf("%sdebug: state %d, reducing by rule %d (%s)\n",
424 YYPREFIX
, yystate
, yyn
, yyrule
[yyn
]);
428 yyval
= yystack
.l_mark
[1-yym
];
430 memset(&yyval
, 0, sizeof yyval
);
434 yystack
.s_mark
-= yym
;
435 yystate
= *yystack
.s_mark
;
436 yystack
.l_mark
-= yym
;
438 if (yystate
== 0 && yym
== 0)
442 printf("%sdebug: after reduction, shifting from state 0 to\
443 state %d\n", YYPREFIX
, YYFINAL
);
446 *++yystack
.s_mark
= YYFINAL
;
447 *++yystack
.l_mark
= yyval
;
450 if ((yychar
= YYLEX
) < 0) yychar
= 0;
455 if (yychar
<= YYMAXTOKEN
) yys
= yyname
[yychar
];
456 if (!yys
) yys
= "illegal-symbol";
457 printf("%sdebug: state %d, reading %d (%s)\n",
458 YYPREFIX
, YYFINAL
, yychar
, yys
);
462 if (yychar
== 0) goto yyaccept
;
465 if ((yyn
= yygindex
[yym
]) && (yyn
+= yystate
) >= 0 &&
466 yyn
<= YYTABLESIZE
&& yycheck
[yyn
] == yystate
)
467 yystate
= yytable
[yyn
];
469 yystate
= yydgoto
[yym
];
472 printf("%sdebug: after reduction, shifting from state %d \
473 to state %d\n", YYPREFIX
, *yystack
.s_mark
, yystate
);
475 if (yystack
.s_mark
>= yystack
.s_last
&& yygrowstack(&yystack
))
479 *++yystack
.s_mark
= (short) yystate
;
480 *++yystack
.l_mark
= yyval
;
484 yyerror("yacc stack overflow");
487 yyfreestack(&yystack
);
491 yyfreestack(&yystack
);