1 /* original parser id follows */
2 /* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */
3 /* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */
4
5 #define YYBYACC 1
6 #define YYMAJOR 1
7 #define YYMINOR 9
8 #define YYCHECK "yyyymmdd"
9
10 #define YYEMPTY (-1)
11 #define yyclearin (yychar = YYEMPTY)
12 #define yyerrok (yyerrflag = 0)
13 #define YYRECOVERING() (yyerrflag != 0)
14 #define YYENOMEM (-2)
15 #define YYEOF 0
16 #undef YYBTYACC
17 #define YYBTYACC 1
18 #define YYDEBUGSTR (yytrial ? YYPREFIX "debug(trial)" : YYPREFIX "debug")
19
20 #ifndef yyparse
21 #define yyparse destroy2_parse
22 #endif /* yyparse */
23
24 #ifndef yylex
25 #define yylex destroy2_lex
26 #endif /* yylex */
27
28 #ifndef yyerror
29 #define yyerror destroy2_error
30 #endif /* yyerror */
31
32 #ifndef yychar
33 #define yychar destroy2_char
34 #endif /* yychar */
35
36 #ifndef yyval
37 #define yyval destroy2_val
38 #endif /* yyval */
39
40 #ifndef yylval
41 #define yylval destroy2_lval
42 #endif /* yylval */
43
44 #ifndef yydebug
45 #define yydebug destroy2_debug
46 #endif /* yydebug */
47
48 #ifndef yynerrs
49 #define yynerrs destroy2_nerrs
50 #endif /* yynerrs */
51
52 #ifndef yyerrflag
53 #define yyerrflag destroy2_errflag
54 #endif /* yyerrflag */
55
56 #ifndef yylhs
57 #define yylhs destroy2_lhs
58 #endif /* yylhs */
59
60 #ifndef yylen
61 #define yylen destroy2_len
62 #endif /* yylen */
63
64 #ifndef yydefred
65 #define yydefred destroy2_defred
66 #endif /* yydefred */
67
68 #ifndef yystos
69 #define yystos destroy2_stos
70 #endif /* yystos */
71
72 #ifndef yydgoto
73 #define yydgoto destroy2_dgoto
74 #endif /* yydgoto */
75
76 #ifndef yysindex
77 #define yysindex destroy2_sindex
78 #endif /* yysindex */
79
80 #ifndef yyrindex
81 #define yyrindex destroy2_rindex
82 #endif /* yyrindex */
83
84 #ifndef yygindex
85 #define yygindex destroy2_gindex
86 #endif /* yygindex */
87
88 #ifndef yytable
89 #define yytable destroy2_table
90 #endif /* yytable */
91
92 #ifndef yycheck
93 #define yycheck destroy2_check
94 #endif /* yycheck */
95
96 #ifndef yyname
97 #define yyname destroy2_name
98 #endif /* yyname */
99
100 #ifndef yyrule
101 #define yyrule destroy2_rule
102 #endif /* yyrule */
103
104 #if YYBTYACC
105
106 #ifndef yycindex
107 #define yycindex destroy2_cindex
108 #endif /* yycindex */
109
110 #ifndef yyctable
111 #define yyctable destroy2_ctable
112 #endif /* yyctable */
113
114 #endif /* YYBTYACC */
115
116 #define YYPREFIX "destroy2_"
117
118 #define YYPURE 0
119
120 #line 4 "btyacc_destroy2.y"
121 #include <stdlib.h>
122
123 typedef enum {cGLOBAL, cLOCAL} class;
124 typedef enum {tREAL, tINTEGER} type;
125 typedef char * name;
126
127 struct symbol { class c; type t; name id; };
128 typedef struct symbol symbol;
129
130 struct namelist { symbol *s; struct namelist *next; };
131 typedef struct namelist namelist;
132
133 struct parser_param {
134 int *rtrn;
135 symbol ss;
136 };
137
138 extern symbol *mksymbol(type t, class c, name id);
139
140 #ifdef YYBISON
141 #define YYLEX_DECL() yylex(void)
142 #define YYERROR_DECL() yyerror(const char *s)
143 #endif
144 #ifdef YYSTYPE
145 #undef YYSTYPE_IS_DECLARED
146 #define YYSTYPE_IS_DECLARED 1
147 #endif
148 #ifndef YYSTYPE_IS_DECLARED
149 #define YYSTYPE_IS_DECLARED 1
150 #line 50 "btyacc_destroy2.y"
151 typedef union
152 {
153 class cval;
154 type tval;
155 namelist * nlist;
156 name id;
157 } YYSTYPE;
158 #endif /* !YYSTYPE_IS_DECLARED */
159 #line 160 "btyacc_destroy2.tab.c"
160
161 /* compatibility with bison */
162 #ifdef YYPARSE_PARAM
163 /* compatibility with FreeBSD */
164 # ifdef YYPARSE_PARAM_TYPE
165 # define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
166 # else
167 # define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
168 # endif
169 #else
170 # define YYPARSE_DECL() yyparse(struct parser_param *param, int flag)
171 #endif
172
173 /* Parameters sent to lex. */
174 #ifdef YYLEX_PARAM
175 # define YYLEX_DECL() yylex(void *YYLEX_PARAM)
176 # define YYLEX yylex(YYLEX_PARAM)
177 #else
178 # define YYLEX_DECL() yylex(void)
179 # define YYLEX yylex()
180 #endif
181
182 /* Parameters sent to yyerror. */
183 #ifndef YYERROR_DECL
184 #define YYERROR_DECL() yyerror(struct parser_param *param, int flag, const char *s)
185 #endif
186 #ifndef YYERROR_CALL
187 #define YYERROR_CALL(msg) yyerror(param, flag, msg)
188 #endif
189
190 #ifndef YYDESTRUCT_DECL
191 #define YYDESTRUCT_DECL() yydestruct(const char *msg, int psymb, YYSTYPE *val, struct parser_param *param, int flag)
192 #endif
193 #ifndef YYDESTRUCT_CALL
194 #define YYDESTRUCT_CALL(msg, psymb, val) yydestruct(msg, psymb, val, param, flag)
195 #endif
196
197 extern int YYPARSE_DECL();
198
199 #define GLOBAL 257
200 #define LOCAL 258
201 #define REAL 259
202 #define INTEGER 260
203 #define NAME 261
204 #define YYERRCODE 256
205 typedef short YYINT;
206 static const YYINT destroy2_lhs[] = { -1,
207 0, 0, 2, 2, 3, 3, 4, 4, 1,
208 };
209 static const YYINT destroy2_len[] = { 2,
210 8, 5, 1, 1, 1, 1, 2, 1, 6,
211 };
212 static const YYINT destroy2_defred[] = { 0,
213 3, 4, 5, 6, 0, 0, 0, 0, 8, 0,
214 0, 0, 0, 7, 0, 0, 0, 0, 0, 2,
215 0, 0, 0, 0, 9, 1,
216 };
217 #if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING)
218 static const YYINT destroy2_stos[] = { 0,
219 257, 258, 259, 260, 263, 265, 266, 266, 261, 264,
220 267, 267, 40, 261, 40, 40, 265, 258, 265, 41,
221 44, 44, 266, 266, 41, 41,
222 };
223 #endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */
224 static const YYINT destroy2_dgoto[] = { 5,
225 10, 6, 7, 11,
226 };
227 static const YYINT destroy2_sindex[] = { -254,
228 0, 0, 0, 0, 0, -251, -248, -248, 0, -26,
229 -40, -39, -246, 0, -243, -246, -25, -24, -23, 0,
230 -251, -251, -22, -19, 0, 0,
231 };
232 static const YYINT destroy2_rindex[] = { 0,
233 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
234 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
235 0, 0, 0, 0, 0, 0,
236 };
237 #if YYBTYACC
238 static const YYINT destroy2_cindex[] = { 0,
239 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
240 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
241 0, 0, 0, 0, 0, 0,
242 };
243 #endif
244 static const YYINT destroy2_gindex[] = { 0,
245 0, -6, -4, 15,
246 };
247 #define YYTABLESIZE 222
248 static const YYINT destroy2_table[] = { 15,
249 16, 8, 1, 2, 3, 4, 17, 3, 4, 19,
250 1, 2, 9, 13, 18, 20, 23, 24, 25, 21,
251 22, 26, 12, 0, 0, 0, 0, 0, 0, 0,
252 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
253 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
254 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
255 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
256 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
257 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
258 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
259 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
260 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
261 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
262 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
263 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
264 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
265 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
266 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
267 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
268 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
269 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
270 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
271 14, 14,
272 };
273 static const YYINT destroy2_check[] = { 40,
274 40, 6, 257, 258, 259, 260, 13, 259, 260, 16,
275 257, 258, 261, 40, 258, 41, 21, 22, 41, 44,
276 44, 41, 8, -1, -1, -1, -1, -1, -1, -1,
277 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
278 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
279 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
280 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
281 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
282 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
283 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
284 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
285 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
286 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
287 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
288 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
289 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
290 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
291 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
292 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
293 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
294 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
295 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
296 261, 261,
297 };
298 #if YYBTYACC
299 static const YYINT destroy2_ctable[] = { -1,
300 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
301 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
302 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
303 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
304 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
305 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
306 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
307 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
308 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
309 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
310 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
311 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
312 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
313 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
314 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
315 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
316 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
317 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
318 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
319 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
320 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
321 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
322 -1,
323 };
324 #endif
325 #define YYFINAL 5
326 #ifndef YYDEBUG
327 #define YYDEBUG 0
328 #endif
329 #define YYMAXTOKEN 261
330 #define YYUNDFTOKEN 268
331 #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
332 #if YYDEBUG
333 static const char *const destroy2_name[] = {
334
335 "$end",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
336 0,0,0,"'('","')'",0,0,"','",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
337 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
338 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
339 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
340 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
341 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"error","GLOBAL","LOCAL",
342 "REAL","INTEGER","NAME","$accept","declaration","locnamelist","class","type",
343 "namelist","illegal-symbol",
344 };
345 static const char *const destroy2_rule[] = {
346 "$accept : declaration",
347 "declaration : class type namelist '(' class ',' type ')'",
348 "declaration : type locnamelist '(' class ')'",
349 "class : GLOBAL",
350 "class : LOCAL",
351 "type : REAL",
352 "type : INTEGER",
353 "namelist : namelist NAME",
354 "namelist : NAME",
355 "locnamelist : namelist '(' LOCAL ',' type ')'",
356
357 };
358 #endif
359
360 int yydebug;
361 int yynerrs;
362
363 int yyerrflag;
364 int yychar;
365 YYSTYPE yyval;
366 YYSTYPE yylval;
367 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
368 YYLTYPE yyloc; /* position returned by actions */
369 YYLTYPE yylloc; /* position from the lexer */
370 #endif
371
372 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
373 #ifndef YYLLOC_DEFAULT
374 #define YYLLOC_DEFAULT(loc, rhs, n) \
375 do \
376 { \
377 if (n == 0) \
378 { \
379 (loc).first_line = ((rhs)[-1]).last_line; \
380 (loc).first_column = ((rhs)[-1]).last_column; \
381 (loc).last_line = ((rhs)[-1]).last_line; \
382 (loc).last_column = ((rhs)[-1]).last_column; \
383 } \
384 else \
385 { \
386 (loc).first_line = ((rhs)[ 0 ]).first_line; \
387 (loc).first_column = ((rhs)[ 0 ]).first_column; \
388 (loc).last_line = ((rhs)[n-1]).last_line; \
389 (loc).last_column = ((rhs)[n-1]).last_column; \
390 } \
391 } while (0)
392 #endif /* YYLLOC_DEFAULT */
393 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
394 #if YYBTYACC
395
396 #ifndef YYLVQUEUEGROWTH
397 #define YYLVQUEUEGROWTH 32
398 #endif
399 #endif /* YYBTYACC */
400
401 /* define the initial stack-sizes */
402 #ifdef YYSTACKSIZE
403 #undef YYMAXDEPTH
404 #define YYMAXDEPTH YYSTACKSIZE
405 #else
406 #ifdef YYMAXDEPTH
407 #define YYSTACKSIZE YYMAXDEPTH
408 #else
409 #define YYSTACKSIZE 10000
410 #define YYMAXDEPTH 10000
411 #endif
412 #endif
413
414 #ifndef YYINITSTACKSIZE
415 #define YYINITSTACKSIZE 200
416 #endif
417
418 typedef struct {
419 unsigned stacksize;
420 YYINT *s_base;
421 YYINT *s_mark;
422 YYINT *s_last;
423 YYSTYPE *l_base;
424 YYSTYPE *l_mark;
425 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
426 YYLTYPE *p_base;
427 YYLTYPE *p_mark;
428 #endif
429 } YYSTACKDATA;
430 #if YYBTYACC
431
432 struct YYParseState_s
433 {
434 struct YYParseState_s *save; /* Previously saved parser state */
435 YYSTACKDATA yystack; /* saved parser stack */
436 int state; /* saved parser state */
437 int errflag; /* saved error recovery status */
438 int lexeme; /* saved index of the conflict lexeme in the lexical queue */
439 YYINT ctry; /* saved index in yyctable[] for this conflict */
440 };
441 typedef struct YYParseState_s YYParseState;
442 #endif /* YYBTYACC */
443 /* variables for the parser stack */
444 static YYSTACKDATA yystack;
445 #if YYBTYACC
446
447 /* Current parser state */
448 static YYParseState *yyps = 0;
449
450 /* yypath != NULL: do the full parse, starting at *yypath parser state. */
451 static YYParseState *yypath = 0;
452
453 /* Base of the lexical value queue */
454 static YYSTYPE *yylvals = 0;
455
456 /* Current position at lexical value queue */
457 static YYSTYPE *yylvp = 0;
458
459 /* End position of lexical value queue */
460 static YYSTYPE *yylve = 0;
461
462 /* The last allocated position at the lexical value queue */
463 static YYSTYPE *yylvlim = 0;
464
465 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
466 /* Base of the lexical position queue */
467 static YYLTYPE *yylpsns = 0;
468
469 /* Current position at lexical position queue */
470 static YYLTYPE *yylpp = 0;
471
472 /* End position of lexical position queue */
473 static YYLTYPE *yylpe = 0;
474
475 /* The last allocated position at the lexical position queue */
476 static YYLTYPE *yylplim = 0;
477 #endif
478
479 /* Current position at lexical token queue */
480 static YYINT *yylexp = 0;
481
482 static YYINT *yylexemes = 0;
483 #endif /* YYBTYACC */
484 #line 89 "btyacc_destroy2.y"
485
486 extern int YYLEX_DECL();
487 extern void YYERROR_DECL();
488 #line 489 "btyacc_destroy2.tab.c"
489
490 /* Release memory associated with symbol. */
491 #if ! defined YYDESTRUCT_IS_DECLARED
492 static void
YYDESTRUCT_DECL()493 YYDESTRUCT_DECL()
494 {
495 switch (psymb)
496 {
497 case 263:
498 #line 41 "btyacc_destroy2.y"
499 {
500 namelist *p = (*val).nlist;
501 while (p != NULL)
502 { namelist *pp = p;
503 p = p->next;
504 free(pp->s); free(pp);
505 }
506 }
507 break;
508 #line 509 "btyacc_destroy2.tab.c"
509 }
510 }
511 #define YYDESTRUCT_IS_DECLARED 1
512 #endif
513
514 /* For use in generated program */
515 #define yydepth (int)(yystack.s_mark - yystack.s_base)
516 #if YYBTYACC
517 #define yytrial (yyps->save)
518 #endif /* YYBTYACC */
519
520 #if YYDEBUG
521 #include <stdio.h> /* needed for printf */
522 #endif
523
524 #include <stdlib.h> /* needed for malloc, etc */
525 #include <string.h> /* needed for memset */
526
527 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
yygrowstack(YYSTACKDATA * data)528 static int yygrowstack(YYSTACKDATA *data)
529 {
530 int i;
531 unsigned newsize;
532 YYINT *newss;
533 YYSTYPE *newvs;
534 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
535 YYLTYPE *newps;
536 #endif
537
538 if ((newsize = data->stacksize) == 0)
539 newsize = YYINITSTACKSIZE;
540 else if (newsize >= YYMAXDEPTH)
541 return YYENOMEM;
542 else if ((newsize *= 2) > YYMAXDEPTH)
543 newsize = YYMAXDEPTH;
544
545 i = (int) (data->s_mark - data->s_base);
546 newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
547 if (newss == 0)
548 return YYENOMEM;
549
550 data->s_base = newss;
551 data->s_mark = newss + i;
552
553 newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
554 if (newvs == 0)
555 return YYENOMEM;
556
557 data->l_base = newvs;
558 data->l_mark = newvs + i;
559
560 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
561 newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps));
562 if (newps == 0)
563 return YYENOMEM;
564
565 data->p_base = newps;
566 data->p_mark = newps + i;
567 #endif
568
569 data->stacksize = newsize;
570 data->s_last = data->s_base + newsize - 1;
571
572 #if YYDEBUG
573 if (yydebug)
574 fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize);
575 #endif
576 return 0;
577 }
578
579 #if YYPURE || defined(YY_NO_LEAKS)
yyfreestack(YYSTACKDATA * data)580 static void yyfreestack(YYSTACKDATA *data)
581 {
582 free(data->s_base);
583 free(data->l_base);
584 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
585 free(data->p_base);
586 #endif
587 memset(data, 0, sizeof(*data));
588 }
589 #else
590 #define yyfreestack(data) /* nothing */
591 #endif /* YYPURE || defined(YY_NO_LEAKS) */
592 #if YYBTYACC
593
594 static YYParseState *
yyNewState(unsigned size)595 yyNewState(unsigned size)
596 {
597 YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState));
598 if (p == NULL) return NULL;
599
600 p->yystack.stacksize = size;
601 if (size == 0)
602 {
603 p->yystack.s_base = NULL;
604 p->yystack.l_base = NULL;
605 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
606 p->yystack.p_base = NULL;
607 #endif
608 return p;
609 }
610 p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT));
611 if (p->yystack.s_base == NULL) return NULL;
612 p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE));
613 if (p->yystack.l_base == NULL) return NULL;
614 memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE));
615 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
616 p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE));
617 if (p->yystack.p_base == NULL) return NULL;
618 memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE));
619 #endif
620
621 return p;
622 }
623
624 static void
yyFreeState(YYParseState * p)625 yyFreeState(YYParseState *p)
626 {
627 yyfreestack(&p->yystack);
628 free(p);
629 }
630 #endif /* YYBTYACC */
631
632 #define YYABORT goto yyabort
633 #define YYREJECT goto yyabort
634 #define YYACCEPT goto yyaccept
635 #define YYERROR goto yyerrlab
636 #if YYBTYACC
637 #define YYVALID do { if (yyps->save) goto yyvalid; } while(0)
638 #define YYVALID_NESTED do { if (yyps->save && \
639 yyps->save->save == 0) goto yyvalid; } while(0)
640 #endif /* YYBTYACC */
641
642 int
YYPARSE_DECL()643 YYPARSE_DECL()
644 {
645 int yym, yyn, yystate, yyresult;
646 #if YYBTYACC
647 int yynewerrflag;
648 YYParseState *yyerrctx = NULL;
649 #endif /* YYBTYACC */
650 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
651 YYLTYPE yyerror_loc_range[2]; /* position of error start & end */
652 #endif
653 #if YYDEBUG
654 const char *yys;
655
656 if ((yys = getenv("YYDEBUG")) != 0)
657 {
658 yyn = *yys;
659 if (yyn >= '0' && yyn <= '9')
660 yydebug = yyn - '0';
661 }
662 if (yydebug)
663 fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX);
664 #endif
665 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
666 memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range));
667 #endif
668
669 #if YYBTYACC
670 yyps = yyNewState(0); if (yyps == 0) goto yyenomem;
671 yyps->save = 0;
672 #endif /* YYBTYACC */
673 yym = 0;
674 yyn = 0;
675 yynerrs = 0;
676 yyerrflag = 0;
677 yychar = YYEMPTY;
678 yystate = 0;
679
680 #if YYPURE
681 memset(&yystack, 0, sizeof(yystack));
682 #endif
683
684 if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
685 yystack.s_mark = yystack.s_base;
686 yystack.l_mark = yystack.l_base;
687 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
688 yystack.p_mark = yystack.p_base;
689 #endif
690 yystate = 0;
691 *yystack.s_mark = 0;
692
693 yyloop:
694 if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
695 if (yychar < 0)
696 {
697 #if YYBTYACC
698 do {
699 if (yylvp < yylve)
700 {
701 /* we're currently re-reading tokens */
702 yylval = *yylvp++;
703 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
704 yylloc = *yylpp++;
705 #endif
706 yychar = *yylexp++;
707 break;
708 }
709 if (yyps->save)
710 {
711 /* in trial mode; save scanner results for future parse attempts */
712 if (yylvp == yylvlim)
713 { /* Enlarge lexical value queue */
714 size_t p = (size_t) (yylvp - yylvals);
715 size_t s = (size_t) (yylvlim - yylvals);
716
717 s += YYLVQUEUEGROWTH;
718 if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
719 if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
720 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
721 if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
722 #endif
723 yylvp = yylve = yylvals + p;
724 yylvlim = yylvals + s;
725 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
726 yylpp = yylpe = yylpsns + p;
727 yylplim = yylpsns + s;
728 #endif
729 yylexp = yylexemes + p;
730 }
731 *yylexp = (YYINT) YYLEX;
732 *yylvp++ = yylval;
733 yylve++;
734 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
735 *yylpp++ = yylloc;
736 yylpe++;
737 #endif
738 yychar = *yylexp++;
739 break;
740 }
741 /* normal operation, no conflict encountered */
742 #endif /* YYBTYACC */
743 yychar = YYLEX;
744 #if YYBTYACC
745 } while (0);
746 #endif /* YYBTYACC */
747 if (yychar < 0) yychar = YYEOF;
748 #if YYDEBUG
749 if (yydebug)
750 {
751 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
752 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)",
753 YYDEBUGSTR, yydepth, yystate, yychar, yys);
754 #ifdef YYSTYPE_TOSTRING
755 #if YYBTYACC
756 if (!yytrial)
757 #endif /* YYBTYACC */
758 fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval));
759 #endif
760 fputc('\n', stderr);
761 }
762 #endif
763 }
764 #if YYBTYACC
765
766 /* Do we have a conflict? */
767 if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
768 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
769 {
770 YYINT ctry;
771
772 if (yypath)
773 {
774 YYParseState *save;
775 #if YYDEBUG
776 if (yydebug)
777 fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n",
778 YYDEBUGSTR, yydepth, yystate);
779 #endif
780 /* Switch to the next conflict context */
781 save = yypath;
782 yypath = save->save;
783 save->save = NULL;
784 ctry = save->ctry;
785 if (save->state != yystate) YYABORT;
786 yyFreeState(save);
787
788 }
789 else
790 {
791
792 /* Unresolved conflict - start/continue trial parse */
793 YYParseState *save;
794 #if YYDEBUG
795 if (yydebug)
796 {
797 fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate);
798 if (yyps->save)
799 fputs("ALREADY in conflict, continuing trial parse.\n", stderr);
800 else
801 fputs("Starting trial parse.\n", stderr);
802 }
803 #endif
804 save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
805 if (save == NULL) goto yyenomem;
806 save->save = yyps->save;
807 save->state = yystate;
808 save->errflag = yyerrflag;
809 save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base);
810 memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
811 save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base);
812 memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
813 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
814 save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base);
815 memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
816 #endif
817 ctry = yytable[yyn];
818 if (yyctable[ctry] == -1)
819 {
820 #if YYDEBUG
821 if (yydebug && yychar >= YYEOF)
822 fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth);
823 #endif
824 ctry++;
825 }
826 save->ctry = ctry;
827 if (yyps->save == NULL)
828 {
829 /* If this is a first conflict in the stack, start saving lexemes */
830 if (!yylexemes)
831 {
832 yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
833 if (yylexemes == NULL) goto yyenomem;
834 yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
835 if (yylvals == NULL) goto yyenomem;
836 yylvlim = yylvals + YYLVQUEUEGROWTH;
837 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
838 yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE));
839 if (yylpsns == NULL) goto yyenomem;
840 yylplim = yylpsns + YYLVQUEUEGROWTH;
841 #endif
842 }
843 if (yylvp == yylve)
844 {
845 yylvp = yylve = yylvals;
846 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
847 yylpp = yylpe = yylpsns;
848 #endif
849 yylexp = yylexemes;
850 if (yychar >= YYEOF)
851 {
852 *yylve++ = yylval;
853 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
854 *yylpe++ = yylloc;
855 #endif
856 *yylexp = (YYINT) yychar;
857 yychar = YYEMPTY;
858 }
859 }
860 }
861 if (yychar >= YYEOF)
862 {
863 yylvp--;
864 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
865 yylpp--;
866 #endif
867 yylexp--;
868 yychar = YYEMPTY;
869 }
870 save->lexeme = (int) (yylvp - yylvals);
871 yyps->save = save;
872 }
873 if (yytable[yyn] == ctry)
874 {
875 #if YYDEBUG
876 if (yydebug)
877 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
878 YYDEBUGSTR, yydepth, yystate, yyctable[ctry]);
879 #endif
880 if (yychar < 0)
881 {
882 yylvp++;
883 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
884 yylpp++;
885 #endif
886 yylexp++;
887 }
888 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
889 goto yyoverflow;
890 yystate = yyctable[ctry];
891 *++yystack.s_mark = (YYINT) yystate;
892 *++yystack.l_mark = yylval;
893 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
894 *++yystack.p_mark = yylloc;
895 #endif
896 yychar = YYEMPTY;
897 if (yyerrflag > 0) --yyerrflag;
898 goto yyloop;
899 }
900 else
901 {
902 yyn = yyctable[ctry];
903 goto yyreduce;
904 }
905 } /* End of code dealing with conflicts */
906 #endif /* YYBTYACC */
907 if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
908 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
909 {
910 #if YYDEBUG
911 if (yydebug)
912 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
913 YYDEBUGSTR, yydepth, yystate, yytable[yyn]);
914 #endif
915 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
916 yystate = yytable[yyn];
917 *++yystack.s_mark = yytable[yyn];
918 *++yystack.l_mark = yylval;
919 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
920 *++yystack.p_mark = yylloc;
921 #endif
922 yychar = YYEMPTY;
923 if (yyerrflag > 0) --yyerrflag;
924 goto yyloop;
925 }
926 if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
927 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
928 {
929 yyn = yytable[yyn];
930 goto yyreduce;
931 }
932 if (yyerrflag != 0) goto yyinrecovery;
933 #if YYBTYACC
934
935 yynewerrflag = 1;
936 goto yyerrhandler;
937 goto yyerrlab; /* redundant goto avoids 'unused label' warning */
938
939 yyerrlab:
940 /* explicit YYERROR from an action -- pop the rhs of the rule reduced
941 * before looking for error recovery */
942 yystack.s_mark -= yym;
943 yystate = *yystack.s_mark;
944 yystack.l_mark -= yym;
945 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
946 yystack.p_mark -= yym;
947 #endif
948
949 yynewerrflag = 0;
950 yyerrhandler:
951 while (yyps->save)
952 {
953 int ctry;
954 YYParseState *save = yyps->save;
955 #if YYDEBUG
956 if (yydebug)
957 fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n",
958 YYDEBUGSTR, yydepth, yystate, yyps->save->state,
959 (int)(yylvp - yylvals - yyps->save->lexeme));
960 #endif
961 /* Memorize most forward-looking error state in case it's really an error. */
962 if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals)
963 {
964 /* Free old saved error context state */
965 if (yyerrctx) yyFreeState(yyerrctx);
966 /* Create and fill out new saved error context state */
967 yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
968 if (yyerrctx == NULL) goto yyenomem;
969 yyerrctx->save = yyps->save;
970 yyerrctx->state = yystate;
971 yyerrctx->errflag = yyerrflag;
972 yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base);
973 memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
974 yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base);
975 memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
976 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
977 yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base);
978 memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
979 #endif
980 yyerrctx->lexeme = (int) (yylvp - yylvals);
981 }
982 yylvp = yylvals + save->lexeme;
983 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
984 yylpp = yylpsns + save->lexeme;
985 #endif
986 yylexp = yylexemes + save->lexeme;
987 yychar = YYEMPTY;
988 yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base);
989 memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
990 yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base);
991 memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
992 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
993 yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base);
994 memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
995 #endif
996 ctry = ++save->ctry;
997 yystate = save->state;
998 /* We tried shift, try reduce now */
999 if ((yyn = yyctable[ctry]) >= 0) goto yyreduce;
1000 yyps->save = save->save;
1001 save->save = NULL;
1002 yyFreeState(save);
1003
1004 /* Nothing left on the stack -- error */
1005 if (!yyps->save)
1006 {
1007 #if YYDEBUG
1008 if (yydebug)
1009 fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n",
1010 YYPREFIX, yydepth);
1011 #endif
1012 /* Restore state as it was in the most forward-advanced error */
1013 yylvp = yylvals + yyerrctx->lexeme;
1014 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1015 yylpp = yylpsns + yyerrctx->lexeme;
1016 #endif
1017 yylexp = yylexemes + yyerrctx->lexeme;
1018 yychar = yylexp[-1];
1019 yylval = yylvp[-1];
1020 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1021 yylloc = yylpp[-1];
1022 #endif
1023 yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base);
1024 memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1025 yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base);
1026 memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1027 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1028 yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base);
1029 memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1030 #endif
1031 yystate = yyerrctx->state;
1032 yyFreeState(yyerrctx);
1033 yyerrctx = NULL;
1034 }
1035 yynewerrflag = 1;
1036 }
1037 if (yynewerrflag == 0) goto yyinrecovery;
1038 #endif /* YYBTYACC */
1039
1040 YYERROR_CALL("syntax error");
1041 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1042 yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
1043 #endif
1044
1045 #if !YYBTYACC
1046 goto yyerrlab; /* redundant goto avoids 'unused label' warning */
1047 yyerrlab:
1048 #endif
1049 ++yynerrs;
1050
1051 yyinrecovery:
1052 if (yyerrflag < 3)
1053 {
1054 yyerrflag = 3;
1055 for (;;)
1056 {
1057 if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
1058 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
1059 {
1060 #if YYDEBUG
1061 if (yydebug)
1062 fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n",
1063 YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]);
1064 #endif
1065 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1066 yystate = yytable[yyn];
1067 *++yystack.s_mark = yytable[yyn];
1068 *++yystack.l_mark = yylval;
1069 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1070 /* lookahead position is error end position */
1071 yyerror_loc_range[1] = yylloc;
1072 YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
1073 *++yystack.p_mark = yyloc;
1074 #endif
1075 goto yyloop;
1076 }
1077 else
1078 {
1079 #if YYDEBUG
1080 if (yydebug)
1081 fprintf(stderr, "%s[%d]: error recovery discarding state %d\n",
1082 YYDEBUGSTR, yydepth, *yystack.s_mark);
1083 #endif
1084 if (yystack.s_mark <= yystack.s_base) goto yyabort;
1085 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1086 /* the current TOS position is the error start position */
1087 yyerror_loc_range[0] = *yystack.p_mark;
1088 #endif
1089 #if defined(YYDESTRUCT_CALL)
1090 #if YYBTYACC
1091 if (!yytrial)
1092 #endif /* YYBTYACC */
1093 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1094 YYDESTRUCT_CALL("error: discarding state",
1095 yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark);
1096 #else
1097 YYDESTRUCT_CALL("error: discarding state",
1098 yystos[*yystack.s_mark], yystack.l_mark);
1099 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1100 #endif /* defined(YYDESTRUCT_CALL) */
1101 --yystack.s_mark;
1102 --yystack.l_mark;
1103 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1104 --yystack.p_mark;
1105 #endif
1106 }
1107 }
1108 }
1109 else
1110 {
1111 if (yychar == YYEOF) goto yyabort;
1112 #if YYDEBUG
1113 if (yydebug)
1114 {
1115 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
1116 fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n",
1117 YYDEBUGSTR, yydepth, yystate, yychar, yys);
1118 }
1119 #endif
1120 #if defined(YYDESTRUCT_CALL)
1121 #if YYBTYACC
1122 if (!yytrial)
1123 #endif /* YYBTYACC */
1124 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1125 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc);
1126 #else
1127 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval);
1128 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1129 #endif /* defined(YYDESTRUCT_CALL) */
1130 yychar = YYEMPTY;
1131 goto yyloop;
1132 }
1133
1134 yyreduce:
1135 yym = yylen[yyn];
1136 #if YYDEBUG
1137 if (yydebug)
1138 {
1139 fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)",
1140 YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]);
1141 #ifdef YYSTYPE_TOSTRING
1142 #if YYBTYACC
1143 if (!yytrial)
1144 #endif /* YYBTYACC */
1145 if (yym > 0)
1146 {
1147 int i;
1148 fputc('<', stderr);
1149 for (i = yym; i > 0; i--)
1150 {
1151 if (i != yym) fputs(", ", stderr);
1152 fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]],
1153 yystack.l_mark[1-i]), stderr);
1154 }
1155 fputc('>', stderr);
1156 }
1157 #endif
1158 fputc('\n', stderr);
1159 }
1160 #endif
1161 if (yym > 0)
1162 yyval = yystack.l_mark[1-yym];
1163 else
1164 memset(&yyval, 0, sizeof yyval);
1165 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1166
1167 /* Perform position reduction */
1168 memset(&yyloc, 0, sizeof(yyloc));
1169 #if YYBTYACC
1170 if (!yytrial)
1171 #endif /* YYBTYACC */
1172 {
1173 YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
1174 /* just in case YYERROR is invoked within the action, save
1175 the start of the rhs as the error start position */
1176 yyerror_loc_range[0] = yystack.p_mark[1-yym];
1177 }
1178 #endif
1179
1180 switch (yyn)
1181 {
1182 case 1:
1183 if (!yytrial)
1184 #line 62 "btyacc_destroy2.y"
1185 { yyval.nlist = yystack.l_mark[-5].nlist; }
1186 break;
1187 case 2:
1188 if (!yytrial)
1189 #line 64 "btyacc_destroy2.y"
1190 { yyval.nlist = yystack.l_mark[-3].nlist; }
1191 break;
1192 case 3:
1193 if (!yytrial)
1194 #line 67 "btyacc_destroy2.y"
1195 { yyval.cval = cGLOBAL; }
1196 break;
1197 case 4:
1198 if (!yytrial)
1199 #line 68 "btyacc_destroy2.y"
1200 { yyval.cval = cLOCAL; }
1201 break;
1202 case 5:
1203 if (!yytrial)
1204 #line 71 "btyacc_destroy2.y"
1205 { yyval.tval = tREAL; }
1206 break;
1207 case 6:
1208 if (!yytrial)
1209 #line 72 "btyacc_destroy2.y"
1210 { yyval.tval = tINTEGER; }
1211 break;
1212 case 7:
1213 if (!yytrial)
1214 #line 76 "btyacc_destroy2.y"
1215 { yyval.nlist->s = mksymbol(yystack.l_mark[-2].tval, yystack.l_mark[-2].cval, yystack.l_mark[0].id);
1216 yyval.nlist->next = yystack.l_mark[-1].nlist;
1217 }
1218 break;
1219 case 8:
1220 if (!yytrial)
1221 #line 80 "btyacc_destroy2.y"
1222 { yyval.nlist->s = mksymbol(0, 0, yystack.l_mark[0].id);
1223 yyval.nlist->next = NULL;
1224 }
1225 break;
1226 case 9:
1227 if (!yytrial)
1228 #line 86 "btyacc_destroy2.y"
1229 { yyval.nlist = yystack.l_mark[-5].nlist; }
1230 break;
1231 #line 1232 "btyacc_destroy2.tab.c"
1232 default:
1233 break;
1234 }
1235 yystack.s_mark -= yym;
1236 yystate = *yystack.s_mark;
1237 yystack.l_mark -= yym;
1238 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1239 yystack.p_mark -= yym;
1240 #endif
1241 yym = yylhs[yyn];
1242 if (yystate == 0 && yym == 0)
1243 {
1244 #if YYDEBUG
1245 if (yydebug)
1246 {
1247 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
1248 #ifdef YYSTYPE_TOSTRING
1249 #if YYBTYACC
1250 if (!yytrial)
1251 #endif /* YYBTYACC */
1252 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval));
1253 #endif
1254 fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL);
1255 }
1256 #endif
1257 yystate = YYFINAL;
1258 *++yystack.s_mark = YYFINAL;
1259 *++yystack.l_mark = yyval;
1260 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1261 *++yystack.p_mark = yyloc;
1262 #endif
1263 if (yychar < 0)
1264 {
1265 #if YYBTYACC
1266 do {
1267 if (yylvp < yylve)
1268 {
1269 /* we're currently re-reading tokens */
1270 yylval = *yylvp++;
1271 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1272 yylloc = *yylpp++;
1273 #endif
1274 yychar = *yylexp++;
1275 break;
1276 }
1277 if (yyps->save)
1278 {
1279 /* in trial mode; save scanner results for future parse attempts */
1280 if (yylvp == yylvlim)
1281 { /* Enlarge lexical value queue */
1282 size_t p = (size_t) (yylvp - yylvals);
1283 size_t s = (size_t) (yylvlim - yylvals);
1284
1285 s += YYLVQUEUEGROWTH;
1286 if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL)
1287 goto yyenomem;
1288 if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
1289 goto yyenomem;
1290 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1291 if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
1292 goto yyenomem;
1293 #endif
1294 yylvp = yylve = yylvals + p;
1295 yylvlim = yylvals + s;
1296 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1297 yylpp = yylpe = yylpsns + p;
1298 yylplim = yylpsns + s;
1299 #endif
1300 yylexp = yylexemes + p;
1301 }
1302 *yylexp = (YYINT) YYLEX;
1303 *yylvp++ = yylval;
1304 yylve++;
1305 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1306 *yylpp++ = yylloc;
1307 yylpe++;
1308 #endif
1309 yychar = *yylexp++;
1310 break;
1311 }
1312 /* normal operation, no conflict encountered */
1313 #endif /* YYBTYACC */
1314 yychar = YYLEX;
1315 #if YYBTYACC
1316 } while (0);
1317 #endif /* YYBTYACC */
1318 if (yychar < 0) yychar = YYEOF;
1319 #if YYDEBUG
1320 if (yydebug)
1321 {
1322 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
1323 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n",
1324 YYDEBUGSTR, yydepth, YYFINAL, yychar, yys);
1325 }
1326 #endif
1327 }
1328 if (yychar == YYEOF) goto yyaccept;
1329 goto yyloop;
1330 }
1331 if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
1332 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
1333 yystate = yytable[yyn];
1334 else
1335 yystate = yydgoto[yym];
1336 #if YYDEBUG
1337 if (yydebug)
1338 {
1339 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
1340 #ifdef YYSTYPE_TOSTRING
1341 #if YYBTYACC
1342 if (!yytrial)
1343 #endif /* YYBTYACC */
1344 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval));
1345 #endif
1346 fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate);
1347 }
1348 #endif
1349 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1350 *++yystack.s_mark = (YYINT) yystate;
1351 *++yystack.l_mark = yyval;
1352 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1353 *++yystack.p_mark = yyloc;
1354 #endif
1355 goto yyloop;
1356 #if YYBTYACC
1357
1358 /* Reduction declares that this path is valid. Set yypath and do a full parse */
1359 yyvalid:
1360 if (yypath) YYABORT;
1361 while (yyps->save)
1362 {
1363 YYParseState *save = yyps->save;
1364 yyps->save = save->save;
1365 save->save = yypath;
1366 yypath = save;
1367 }
1368 #if YYDEBUG
1369 if (yydebug)
1370 fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n",
1371 YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme));
1372 #endif
1373 if (yyerrctx)
1374 {
1375 yyFreeState(yyerrctx);
1376 yyerrctx = NULL;
1377 }
1378 yylvp = yylvals + yypath->lexeme;
1379 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1380 yylpp = yylpsns + yypath->lexeme;
1381 #endif
1382 yylexp = yylexemes + yypath->lexeme;
1383 yychar = YYEMPTY;
1384 yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base);
1385 memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1386 yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base);
1387 memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1388 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1389 yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base);
1390 memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1391 #endif
1392 yystate = yypath->state;
1393 goto yyloop;
1394 #endif /* YYBTYACC */
1395
1396 yyoverflow:
1397 YYERROR_CALL("yacc stack overflow");
1398 #if YYBTYACC
1399 goto yyabort_nomem;
1400 yyenomem:
1401 YYERROR_CALL("memory exhausted");
1402 yyabort_nomem:
1403 #endif /* YYBTYACC */
1404 yyresult = 2;
1405 goto yyreturn;
1406
1407 yyabort:
1408 yyresult = 1;
1409 goto yyreturn;
1410
1411 yyaccept:
1412 #if YYBTYACC
1413 if (yyps->save) goto yyvalid;
1414 #endif /* YYBTYACC */
1415 yyresult = 0;
1416
1417 yyreturn:
1418 #if defined(YYDESTRUCT_CALL)
1419 if (yychar != YYEOF && yychar != YYEMPTY)
1420 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1421 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc);
1422 #else
1423 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval);
1424 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1425
1426 {
1427 YYSTYPE *pv;
1428 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1429 YYLTYPE *pp;
1430
1431 for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp)
1432 YYDESTRUCT_CALL("cleanup: discarding state",
1433 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp);
1434 #else
1435 for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv)
1436 YYDESTRUCT_CALL("cleanup: discarding state",
1437 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv);
1438 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1439 }
1440 #endif /* defined(YYDESTRUCT_CALL) */
1441
1442 #if YYBTYACC
1443 if (yyerrctx)
1444 {
1445 yyFreeState(yyerrctx);
1446 yyerrctx = NULL;
1447 }
1448 while (yyps)
1449 {
1450 YYParseState *save = yyps;
1451 yyps = save->save;
1452 save->save = NULL;
1453 yyFreeState(save);
1454 }
1455 while (yypath)
1456 {
1457 YYParseState *save = yypath;
1458 yypath = save->save;
1459 save->save = NULL;
1460 yyFreeState(save);
1461 }
1462 #endif /* YYBTYACC */
1463 yyfreestack(&yystack);
1464 return (yyresult);
1465 }
1466