btyacc_demo.tab.c revision 1.1.1.8 1 /* $NetBSD: btyacc_demo.tab.c,v 1.1.1.8 2024/09/14 21:25:38 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 2
9 #define YYMINOR 0
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 #undef YYBTYACC
19 #define YYBTYACC 1
20 #define YYDEBUGSTR (yytrial ? YYPREFIX "debug(trial)" : YYPREFIX "debug")
21
22 #ifndef yyparse
23 #define yyparse demo_parse
24 #endif /* yyparse */
25
26 #ifndef yylex
27 #define yylex demo_lex
28 #endif /* yylex */
29
30 #ifndef yyerror
31 #define yyerror demo_error
32 #endif /* yyerror */
33
34 #ifndef yychar
35 #define yychar demo_char
36 #endif /* yychar */
37
38 #ifndef yyval
39 #define yyval demo_val
40 #endif /* yyval */
41
42 #ifndef yylval
43 #define yylval demo_lval
44 #endif /* yylval */
45
46 #ifndef yydebug
47 #define yydebug demo_debug
48 #endif /* yydebug */
49
50 #ifndef yynerrs
51 #define yynerrs demo_nerrs
52 #endif /* yynerrs */
53
54 #ifndef yyerrflag
55 #define yyerrflag demo_errflag
56 #endif /* yyerrflag */
57
58 #ifndef yylhs
59 #define yylhs demo_lhs
60 #endif /* yylhs */
61
62 #ifndef yylen
63 #define yylen demo_len
64 #endif /* yylen */
65
66 #ifndef yydefred
67 #define yydefred demo_defred
68 #endif /* yydefred */
69
70 #ifndef yystos
71 #define yystos demo_stos
72 #endif /* yystos */
73
74 #ifndef yydgoto
75 #define yydgoto demo_dgoto
76 #endif /* yydgoto */
77
78 #ifndef yysindex
79 #define yysindex demo_sindex
80 #endif /* yysindex */
81
82 #ifndef yyrindex
83 #define yyrindex demo_rindex
84 #endif /* yyrindex */
85
86 #ifndef yygindex
87 #define yygindex demo_gindex
88 #endif /* yygindex */
89
90 #ifndef yytable
91 #define yytable demo_table
92 #endif /* yytable */
93
94 #ifndef yycheck
95 #define yycheck demo_check
96 #endif /* yycheck */
97
98 #ifndef yyname
99 #define yyname demo_name
100 #endif /* yyname */
101
102 #ifndef yyrule
103 #define yyrule demo_rule
104 #endif /* yyrule */
105
106 #ifndef yyloc
107 #define yyloc demo_loc
108 #endif /* yyloc */
109
110 #ifndef yylloc
111 #define yylloc demo_lloc
112 #endif /* yylloc */
113
114 #if YYBTYACC
115
116 #ifndef yycindex
117 #define yycindex demo_cindex
118 #endif /* yycindex */
119
120 #ifndef yyctable
121 #define yyctable demo_ctable
122 #endif /* yyctable */
123
124 #endif /* YYBTYACC */
125
126 #define YYPREFIX "demo_"
127
128 #define YYPURE 0
129
130 #line 15 "btyacc_demo.y"
131 /* dummy types just for compile check */
132 typedef int Code;
133 typedef int Decl_List;
134 typedef int Expr;
135 typedef int Expr_List;
136 typedef int Scope;
137 typedef int Type;
138 enum Operator { ADD, SUB, MUL, MOD, DIV, DEREF };
139
140 typedef unsigned char bool;
141 typedef struct Decl {
142 Scope *scope;
143 Type *type;
144 bool (*istype)(void);
145 } Decl;
146
147 #include "btyacc_demo.tab.h"
148 #include <stdlib.h>
149 #include <stdio.h>
150 #ifdef YYSTYPE
151 #undef YYSTYPE_IS_DECLARED
152 #define YYSTYPE_IS_DECLARED 1
153 #endif
154 #ifndef YYSTYPE_IS_DECLARED
155 #define YYSTYPE_IS_DECLARED 1
156 #line 36 "btyacc_demo.y"
157 typedef union YYSTYPE {
158 Scope *scope;
159 Expr *expr;
160 Expr_List *elist;
161 Type *type;
162 Decl *decl;
163 Decl_List *dlist;
164 Code *code;
165 char *id;
166 } YYSTYPE;
167 #endif /* !YYSTYPE_IS_DECLARED */
168 #line 167 "btyacc_demo.tab.c"
169
170 #if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
171 /* Default: YYLTYPE is the text position type. */
172 typedef struct YYLTYPE
173 {
174 int first_line;
175 int first_column;
176 int last_line;
177 int last_column;
178 unsigned source;
179 } YYLTYPE;
180 #define YYLTYPE_IS_DECLARED 1
181 #endif
182 #define YYRHSLOC(rhs, k) ((rhs)[k])
183
184 /* compatibility with bison */
185 #ifdef YYPARSE_PARAM
186 /* compatibility with FreeBSD */
187 # ifdef YYPARSE_PARAM_TYPE
188 # define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
189 # else
190 # define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
191 # endif
192 #else
193 # define YYPARSE_DECL() yyparse(void)
194 #endif
195
196 /* Parameters sent to lex. */
197 #ifdef YYLEX_PARAM
198 # define YYLEX_DECL() yylex(void *YYLEX_PARAM)
199 # define YYLEX yylex(YYLEX_PARAM)
200 #else
201 # define YYLEX_DECL() yylex(void)
202 # define YYLEX yylex()
203 #endif
204
205 /* Parameters sent to yyerror. */
206 #ifndef YYERROR_DECL
207 #define YYERROR_DECL() yyerror(YYLTYPE *loc, const char *s)
208 #endif
209 #ifndef YYERROR_CALL
210 #define YYERROR_CALL(msg) yyerror(&yylloc, msg)
211 #endif
212
213 #ifndef YYDESTRUCT_DECL
214 #define YYDESTRUCT_DECL() yydestruct(const char *msg, int psymb, YYSTYPE *val, YYLTYPE *loc)
215 #endif
216 #ifndef YYDESTRUCT_CALL
217 #define YYDESTRUCT_CALL(msg, psymb, val, loc) yydestruct(msg, psymb, val, loc)
218 #endif
219
220 extern int YYPARSE_DECL();
221
222 #define PREFIX 257
223 #define POSTFIX 258
224 #define ID 259
225 #define CONSTANT 260
226 #define EXTERN 261
227 #define REGISTER 262
228 #define STATIC 263
229 #define CONST 264
230 #define VOLATILE 265
231 #define IF 266
232 #define THEN 267
233 #define ELSE 268
234 #define CLCL 269
235 #define YYERRCODE 256
236 typedef int YYINT;
237 static const YYINT demo_lhs[] = { -1,
238 15, 15, 15, 12, 18, 0, 4, 19, 4, 2,
239 20, 2, 10, 10, 13, 13, 11, 11, 11, 11,
240 11, 14, 14, 21, 22, 3, 3, 8, 8, 23,
241 24, 8, 8, 8, 8, 16, 16, 17, 17, 9,
242 1, 1, 1, 1, 1, 1, 1, 1, 5, 5,
243 25, 26, 5, 5, 27, 5, 6, 6, 7,
244 };
245 static const YYINT demo_len[] = { 2,
246 0, 1, 3, 2, 0, 2, 0, 0, 3, 3,
247 0, 4, 1, 3, 0, 2, 1, 1, 1, 1,
248 1, 1, 1, 0, 0, 5, 1, 0, 1, 0,
249 0, 5, 5, 5, 6, 0, 1, 4, 1, 2,
250 4, 4, 4, 4, 4, 3, 1, 1, 1, 2,
251 0, 0, 11, 8, 0, 2, 0, 3, 4,
252 };
253 static const YYINT demo_defred[] = { 5,
254 0, 7, 0, 0, 19, 20, 21, 22, 23, 2,
255 9, 0, 13, 18, 17, 0, 15, 30, 29, 0,
256 0, 0, 0, 0, 31, 10, 24, 24, 24, 0,
257 14, 3, 16, 25, 0, 25, 0, 0, 8, 12,
258 0, 0, 0, 39, 0, 0, 0, 8, 47, 48,
259 0, 57, 0, 32, 0, 0, 15, 30, 0, 30,
260 30, 30, 30, 30, 34, 0, 0, 0, 46, 0,
261 0, 0, 0, 0, 59, 0, 38, 0, 0, 43,
262 45, 44, 0, 0, 49, 58, 0, 30, 50, 56,
263 0, 0, 0, 51, 0, 0, 52, 0, 53,
264 };
265 #if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING)
266 static const YYINT demo_stos[] = { 0,
267 271, 289, 275, 290, 261, 262, 263, 264, 265, 269,
268 273, 281, 282, 283, 285, 286, 42, 40, 259, 274,
269 279, 290, 259, 284, 294, 59, 44, 40, 91, 291,
270 282, 269, 285, 292, 295, 292, 292, 292, 123, 278,
271 293, 279, 293, 280, 281, 287, 288, 42, 259, 260,
272 272, 290, 279, 41, 279, 279, 41, 44, 290, 43,
273 45, 42, 47, 37, 93, 277, 284, 294, 272, 294,
274 294, 294, 294, 294, 125, 290, 280, 272, 272, 272,
275 272, 272, 266, 272, 273, 276, 298, 40, 59, 278,
276 294, 272, 41, 267, 296, 276, 268, 297, 276,
277 };
278 #endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */
279 static const YYINT demo_dgoto[] = { 1,
280 84, 85, 20, 3, 86, 66, 40, 21, 44, 12,
281 13, 14, 24, 15, 16, 46, 47, 2, 22, 30,
282 34, 41, 25, 35, 95, 98, 87,
283 };
284 static const YYINT demo_sindex[] = { 0,
285 0, 0, 0, -103, 0, 0, 0, 0, 0, 0,
286 0, -31, 0, 0, 0, -238, 0, 0, 0, 4,
287 -36, -103, 0, -133, 0, 0, 0, 0, 0, -94,
288 0, 0, 0, 0, -40, 0, -103, -33, 0, 0,
289 -40, -25, -40, 0, -31, 8, 15, 0, 0, 0,
290 -2, 0, -36, 0, -36, -36, 0, 0, -33, 0,
291 0, 0, 0, 0, 0, -92, -133, -103, 0, -33,
292 -33, -33, -33, -33, 0, -8, 0, 23, 23, 0,
293 0, 0, 11, 75, 0, 0, -94, 0, 0, 0,
294 -33, 96, -194, 0, -8, 0, 0, -8, 0,
295 };
296 static const YYINT demo_rindex[] = { 0,
297 0, 0, 1, -181, 0, 0, 0, 0, 0, 0,
298 0, 17, 0, 0, 0, 0, 0, 0, 0, 0,
299 -39, -181, 12, -34, 0, 0, 0, 0, 0, 0,
300 0, 0, 0, 0, -5, 0, -11, 0, 0, 0,
301 -17, 0, 28, 0, -41, 0, 47, 0, 0, 0,
302 0, 0, -13, 0, 18, 70, 0, 0, 0, 0,
303 0, 0, 0, 0, 0, -19, -27, -181, 0, 0,
304 0, 0, 0, 0, 0, -29, 0, 56, 64, 0,
305 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
306 0, 0, 0, 0, -29, -30, 0, -29, 0,
307 };
308 #if YYBTYACC
309 static const YYINT demo_cindex[] = { 0,
310 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
311 0, -22, 0, 0, 0, 0, 0, 0, 0, 0,
312 0, 0, -179, 0, 0, 0, 0, 0, 0, 0,
313 0, 0, 0, 0, 52, 0, 0, 0, 0, 0,
314 58, 0, 62, 0, -21, 0, 0, 0, 0, 0,
315 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
316 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
317 0, 0, 0, 0, 0, -146, 0, 0, 0, 0,
318 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
319 0, 0, 0, 0, -143, -147, 0, -134, 0,
320 };
321 #endif
322 static const YYINT demo_gindex[] = { 0,
323 9, 143, 0, 0, 50, 0, 63, 101, 83, 7,
324 130, 0, 98, 2, 0, 0, 0, 0, 19, 0,
325 10, 117, 66, 0, 0, 0, 0,
326 };
327 #define YYTABLESIZE 286
328 static const YYINT demo_table[] = { 28,
329 6, 17, 28, 28, 27, 24, 24, 24, 48, 24,
330 17, 54, 35, 35, 28, 54, 35, 0, 0, 27,
331 23, 4, 8, 28, 24, 33, 28, 33, 39, 36,
332 33, 35, 75, 48, 64, 28, 36, 37, 38, 62,
333 60, 28, 61, 45, 63, 33, 51, 27, 57, 28,
334 88, 4, 4, 4, 29, 4, 24, 52, 58, 64,
335 28, 26, 26, 35, 62, 29, 59, 69, 33, 63,
336 4, 28, 94, 28, 45, 28, 26, 1, 78, 79,
337 80, 81, 82, 11, 76, 28, 28, 37, 24, 6,
338 65, 0, 54, 55, 54, 35, 41, 0, 41, 92,
339 41, 0, 4, 8, 42, 28, 42, 28, 42, 33,
340 40, 64, 9, 40, 41, 9, 62, 60, 28, 61,
341 12, 63, 42, 68, 9, 70, 71, 72, 73, 74,
342 8, 9, 64, 89, 4, 42, 93, 62, 60, 28,
343 61, 53, 63, 55, 96, 56, 11, 99, 41, 90,
344 77, 31, 43, 91, 67, 0, 42, 5, 6, 7,
345 8, 9, 0, 0, 0, 10, 0, 0, 0, 0,
346 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
347 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
348 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
349 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
350 0, 0, 0, 0, 0, 0, 0, 0, 19, 8,
351 8, 8, 8, 8, 24, 49, 50, 8, 54, 54,
352 54, 54, 54, 54, 54, 54, 3, 3, 54, 8,
353 8, 8, 8, 8, 8, 8, 8, 1, 0, 8,
354 0, 50, 5, 6, 7, 8, 9, 83, 0, 8,
355 10, 8, 8, 8, 8, 8, 0, 0, 0, 8,
356 4, 0, 4, 4, 4, 4, 4, 8, 8, 8,
357 8, 8, 0, 0, 0, 8,
358 };
359 static const YYINT demo_check[] = { 41,
360 0, 42, 44, 40, 44, 40, 41, 42, 42, 44,
361 42, 42, 40, 41, 40, 41, 44, 40, 40, 59,
362 259, 3, 42, 41, 59, 24, 44, 41, 123, 41,
363 44, 59, 125, 42, 37, 41, 27, 28, 29, 42,
364 43, 59, 45, 37, 47, 59, 38, 44, 41, 91,
365 40, 40, 41, 42, 91, 44, 91, 39, 44, 37,
366 44, 44, 59, 91, 42, 91, 48, 59, 67, 47,
367 59, 44, 267, 91, 68, 59, 59, 259, 70, 71,
368 72, 73, 74, 123, 66, 91, 59, 41, 123, 269,
369 93, 40, 123, 123, 125, 123, 41, 40, 43, 91,
370 45, 40, 91, 123, 41, 123, 43, 91, 45, 123,
371 41, 37, 259, 44, 59, 259, 42, 43, 91, 45,
372 268, 47, 59, 58, 259, 60, 61, 62, 63, 64,
373 264, 265, 37, 59, 123, 35, 41, 42, 43, 123,
374 45, 41, 47, 43, 95, 45, 4, 98, 93, 87,
375 68, 22, 36, 88, 57, -1, 93, 261, 262, 263,
376 264, 265, -1, -1, -1, 269, -1, -1, -1, -1,
377 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
378 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
379 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
380 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
381 -1, -1, -1, -1, -1, -1, -1, -1, 259, 261,
382 262, 263, 264, 265, 259, 259, 260, 269, 259, 260,
383 261, 262, 263, 264, 265, 266, 259, 259, 269, 259,
384 260, 261, 262, 263, 264, 265, 266, 259, -1, 269,
385 -1, 260, 261, 262, 263, 264, 265, 266, -1, 259,
386 269, 261, 262, 263, 264, 265, -1, -1, -1, 269,
387 259, -1, 261, 262, 263, 264, 265, 261, 262, 263,
388 264, 265, -1, -1, -1, 269,
389 };
390 #if YYBTYACC
391 static const YYINT demo_ctable[] = { 18,
392 28, -1, 19, 8, -1, 32, 4, -1, 49, 1,
393 -1, 97, 54, -1, -1, -1, -1, -1, -1, -1,
394 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
395 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
396 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
397 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
398 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
399 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
400 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
401 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
402 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
403 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
404 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
405 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
406 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
407 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
408 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
409 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
410 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
411 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
412 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
413 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
414 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
415 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
416 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
417 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
418 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
419 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
420 -1, -1, -1, -1, -1,
421 };
422 #endif
423 #define YYFINAL 1
424 #ifndef YYDEBUG
425 #define YYDEBUG 0
426 #endif
427 #define YYMAXTOKEN 269
428 #define YYUNDFTOKEN 299
429 #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
430 #if YYDEBUG
431 static const char *const demo_name[] = {
432
433 "$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,
434 "'%'",0,0,"'('","')'","'*'","'+'","','","'-'","'.'","'/'",0,0,0,0,0,0,0,0,0,0,0,
435 "';'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'['",0,
436 "']'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'{'",0,"'}'",0,
437 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
438 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
439 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
440 0,0,0,0,0,0,0,0,0,"error","PREFIX","POSTFIX","ID","CONSTANT","EXTERN",
441 "REGISTER","STATIC","CONST","VOLATILE","IF","THEN","ELSE","CLCL","$accept",
442 "input","expr","decl","declarator_list","decl_list","statement",
443 "statement_list","block_statement","declarator","formal_arg","decl_specs",
444 "decl_spec","typename","cv_quals","cv_qual","opt_scope","formal_arg_list",
445 "nonempty_formal_arg_list","$$1","$$2","$$3","$$4","$$5","$$6","$$7","$$8",
446 "$$9","$$10","illegal-symbol",
447 };
448 static const char *const demo_rule[] = {
449 "$accept : input",
450 "opt_scope :",
451 "opt_scope : CLCL",
452 "opt_scope : opt_scope ID CLCL",
453 "typename : opt_scope ID",
454 "$$1 :",
455 "input : $$1 decl_list",
456 "decl_list :",
457 "$$2 :",
458 "decl_list : decl_list $$2 decl",
459 "decl : decl_specs declarator_list ';'",
460 "$$3 :",
461 "decl : decl_specs declarator $$3 block_statement",
462 "decl_specs : decl_spec",
463 "decl_specs : decl_specs $$2 decl_spec",
464 "cv_quals :",
465 "cv_quals : cv_quals cv_qual",
466 "decl_spec : cv_qual",
467 "decl_spec : typename",
468 "decl_spec : EXTERN",
469 "decl_spec : REGISTER",
470 "decl_spec : STATIC",
471 "cv_qual : CONST",
472 "cv_qual : VOLATILE",
473 "$$4 :",
474 "$$5 :",
475 "declarator_list : declarator_list ',' $$4 $$5 declarator",
476 "declarator_list : declarator",
477 "declarator :",
478 "declarator : ID",
479 "$$6 :",
480 "$$7 :",
481 "declarator : '(' $$6 $$7 declarator ')'",
482 "declarator : '*' cv_quals $$4 $$5 declarator",
483 "declarator : declarator '[' $$4 expr ']'",
484 "declarator : declarator '(' $$4 formal_arg_list ')' cv_quals",
485 "formal_arg_list :",
486 "formal_arg_list : nonempty_formal_arg_list",
487 "nonempty_formal_arg_list : nonempty_formal_arg_list ',' $$6 formal_arg",
488 "nonempty_formal_arg_list : formal_arg",
489 "formal_arg : decl_specs declarator",
490 "expr : expr '+' $$6 expr",
491 "expr : expr '-' $$6 expr",
492 "expr : expr '*' $$6 expr",
493 "expr : expr '%' $$6 expr",
494 "expr : expr '/' $$6 expr",
495 "expr : '*' $$2 expr",
496 "expr : ID",
497 "expr : CONSTANT",
498 "statement : decl",
499 "statement : expr ';'",
500 "$$8 :",
501 "$$9 :",
502 "statement : IF '(' $$6 expr ')' THEN $$8 statement ELSE $$9 statement",
503 "statement : IF '(' $$6 expr ')' THEN $$8 statement",
504 "$$10 :",
505 "statement : $$10 block_statement",
506 "statement_list :",
507 "statement_list : statement_list $$2 statement",
508 "block_statement : '{' $$2 statement_list '}'",
509
510 };
511 #endif
512
513 #if YYDEBUG
514 int yydebug;
515 #endif
516
517 int yyerrflag;
518 int yychar;
519 YYSTYPE yyval;
520 YYSTYPE yylval;
521 int yynerrs;
522
523 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
524 YYLTYPE yyloc; /* position returned by actions */
525 YYLTYPE yylloc; /* position from the lexer */
526 #endif
527
528 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
529 #ifndef YYLLOC_DEFAULT
530 #define YYLLOC_DEFAULT(loc, rhs, n) \
531 do \
532 { \
533 if (n == 0) \
534 { \
535 (loc).first_line = YYRHSLOC(rhs, 0).last_line; \
536 (loc).first_column = YYRHSLOC(rhs, 0).last_column; \
537 (loc).last_line = YYRHSLOC(rhs, 0).last_line; \
538 (loc).last_column = YYRHSLOC(rhs, 0).last_column; \
539 } \
540 else \
541 { \
542 (loc).first_line = YYRHSLOC(rhs, 1).first_line; \
543 (loc).first_column = YYRHSLOC(rhs, 1).first_column; \
544 (loc).last_line = YYRHSLOC(rhs, n).last_line; \
545 (loc).last_column = YYRHSLOC(rhs, n).last_column; \
546 } \
547 } while (0)
548 #endif /* YYLLOC_DEFAULT */
549 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
550 #if YYBTYACC
551
552 #ifndef YYLVQUEUEGROWTH
553 #define YYLVQUEUEGROWTH 32
554 #endif
555 #endif /* YYBTYACC */
556
557 /* define the initial stack-sizes */
558 #ifdef YYSTACKSIZE
559 #undef YYMAXDEPTH
560 #define YYMAXDEPTH YYSTACKSIZE
561 #else
562 #ifdef YYMAXDEPTH
563 #define YYSTACKSIZE YYMAXDEPTH
564 #else
565 #define YYSTACKSIZE 10000
566 #define YYMAXDEPTH 10000
567 #endif
568 #endif
569
570 #ifndef YYINITSTACKSIZE
571 #define YYINITSTACKSIZE 200
572 #endif
573
574 typedef struct {
575 unsigned stacksize;
576 YYINT *s_base;
577 YYINT *s_mark;
578 YYINT *s_last;
579 YYSTYPE *l_base;
580 YYSTYPE *l_mark;
581 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
582 YYLTYPE *p_base;
583 YYLTYPE *p_mark;
584 #endif
585 } YYSTACKDATA;
586 #if YYBTYACC
587
588 struct YYParseState_s
589 {
590 struct YYParseState_s *save; /* Previously saved parser state */
591 YYSTACKDATA yystack; /* saved parser stack */
592 int state; /* saved parser state */
593 int errflag; /* saved error recovery status */
594 int lexeme; /* saved index of the conflict lexeme in the lexical queue */
595 YYINT ctry; /* saved index in yyctable[] for this conflict */
596 };
597 typedef struct YYParseState_s YYParseState;
598 #endif /* YYBTYACC */
599 /* variables for the parser stack */
600 static YYSTACKDATA yystack;
601 #if YYBTYACC
602
603 /* Current parser state */
604 static YYParseState *yyps = 0;
605
606 /* yypath != NULL: do the full parse, starting at *yypath parser state. */
607 static YYParseState *yypath = 0;
608
609 /* Base of the lexical value queue */
610 static YYSTYPE *yylvals = 0;
611
612 /* Current position at lexical value queue */
613 static YYSTYPE *yylvp = 0;
614
615 /* End position of lexical value queue */
616 static YYSTYPE *yylve = 0;
617
618 /* The last allocated position at the lexical value queue */
619 static YYSTYPE *yylvlim = 0;
620
621 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
622 /* Base of the lexical position queue */
623 static YYLTYPE *yylpsns = 0;
624
625 /* Current position at lexical position queue */
626 static YYLTYPE *yylpp = 0;
627
628 /* End position of lexical position queue */
629 static YYLTYPE *yylpe = 0;
630
631 /* The last allocated position at the lexical position queue */
632 static YYLTYPE *yylplim = 0;
633 #endif
634
635 /* Current position at lexical token queue */
636 static YYINT *yylexp = 0;
637
638 static YYINT *yylexemes = 0;
639 #endif /* YYBTYACC */
640 #line 200 "btyacc_demo.y"
641
642 extern int YYLEX_DECL();
643 extern void YYERROR_DECL();
644
645 extern Scope *global_scope;
646
647 extern Decl * lookup(Scope *scope, char *id);
648 extern Scope * new_scope(Scope *outer_scope);
649 extern Scope * start_fn_def(Scope *scope, Decl *fn_decl);
650 extern void finish_fn_def(Decl *fn_decl, Code *block);
651 extern Type * type_combine(Type *specs, Type *spec);
652 extern Type * bare_extern(void);
653 extern Type * bare_register(void);
654 extern Type * bare_static(void);
655 extern Type * bare_const(void);
656 extern Type * bare_volatile(void);
657 extern Decl * declare(Scope *scope, char *id, Type *type);
658 extern Decl * make_pointer(Decl *decl, Type *type);
659 extern Decl * make_array(Type *type, Expr *expr);
660 extern Decl * build_function(Decl *decl, Decl_List *dlist, Type *type);
661 extern Decl_List * append_dlist(Decl_List *dlist, Decl *decl);
662 extern Decl_List * build_dlist(Decl *decl);
663 extern Expr * build_expr(Expr *left, enum Operator op, Expr *right);
664 extern Expr * var_expr(Scope *scope, char *id);
665 extern Code * build_expr_code(Expr *expr);
666 extern Code * build_if(Expr *cond_expr, Code *then_stmt, Code *else_stmt);
667 extern Code * code_append(Code *stmt_list, Code *stmt);
668 #line 667 "btyacc_demo.tab.c"
669
670 /* Release memory associated with symbol. */
671 #if ! defined YYDESTRUCT_IS_DECLARED
672 static void
673 YYDESTRUCT_DECL()
674 {
675 switch (psymb)
676 {
677 case 43:
678 #line 83 "btyacc_demo.y"
679 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
680 msg,
681 (*loc).first_line, (*loc).first_column,
682 (*loc).last_line, (*loc).last_column);
683 /* in this example, we don't know what to do here */ }
684 #line 683 "btyacc_demo.tab.c"
685 break;
686 case 45:
687 #line 83 "btyacc_demo.y"
688 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
689 msg,
690 (*loc).first_line, (*loc).first_column,
691 (*loc).last_line, (*loc).last_column);
692 /* in this example, we don't know what to do here */ }
693 #line 692 "btyacc_demo.tab.c"
694 break;
695 case 42:
696 #line 83 "btyacc_demo.y"
697 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
698 msg,
699 (*loc).first_line, (*loc).first_column,
700 (*loc).last_line, (*loc).last_column);
701 /* in this example, we don't know what to do here */ }
702 #line 701 "btyacc_demo.tab.c"
703 break;
704 case 47:
705 #line 83 "btyacc_demo.y"
706 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
707 msg,
708 (*loc).first_line, (*loc).first_column,
709 (*loc).last_line, (*loc).last_column);
710 /* in this example, we don't know what to do here */ }
711 #line 710 "btyacc_demo.tab.c"
712 break;
713 case 37:
714 #line 83 "btyacc_demo.y"
715 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
716 msg,
717 (*loc).first_line, (*loc).first_column,
718 (*loc).last_line, (*loc).last_column);
719 /* in this example, we don't know what to do here */ }
720 #line 719 "btyacc_demo.tab.c"
721 break;
722 case 257:
723 #line 83 "btyacc_demo.y"
724 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
725 msg,
726 (*loc).first_line, (*loc).first_column,
727 (*loc).last_line, (*loc).last_column);
728 /* in this example, we don't know what to do here */ }
729 #line 728 "btyacc_demo.tab.c"
730 break;
731 case 258:
732 #line 83 "btyacc_demo.y"
733 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
734 msg,
735 (*loc).first_line, (*loc).first_column,
736 (*loc).last_line, (*loc).last_column);
737 /* in this example, we don't know what to do here */ }
738 #line 737 "btyacc_demo.tab.c"
739 break;
740 case 40:
741 #line 83 "btyacc_demo.y"
742 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
743 msg,
744 (*loc).first_line, (*loc).first_column,
745 (*loc).last_line, (*loc).last_column);
746 /* in this example, we don't know what to do here */ }
747 #line 746 "btyacc_demo.tab.c"
748 break;
749 case 91:
750 #line 83 "btyacc_demo.y"
751 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
752 msg,
753 (*loc).first_line, (*loc).first_column,
754 (*loc).last_line, (*loc).last_column);
755 /* in this example, we don't know what to do here */ }
756 #line 755 "btyacc_demo.tab.c"
757 break;
758 case 46:
759 #line 83 "btyacc_demo.y"
760 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
761 msg,
762 (*loc).first_line, (*loc).first_column,
763 (*loc).last_line, (*loc).last_column);
764 /* in this example, we don't know what to do here */ }
765 #line 764 "btyacc_demo.tab.c"
766 break;
767 case 259:
768 #line 78 "btyacc_demo.y"
769 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
770 msg,
771 (*loc).first_line, (*loc).first_column,
772 (*loc).last_line, (*loc).last_column);
773 free((*val).id); }
774 #line 773 "btyacc_demo.tab.c"
775 break;
776 case 260:
777 #line 78 "btyacc_demo.y"
778 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
779 msg,
780 (*loc).first_line, (*loc).first_column,
781 (*loc).last_line, (*loc).last_column);
782 free((*val).expr); }
783 #line 782 "btyacc_demo.tab.c"
784 break;
785 case 261:
786 #line 83 "btyacc_demo.y"
787 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
788 msg,
789 (*loc).first_line, (*loc).first_column,
790 (*loc).last_line, (*loc).last_column);
791 /* in this example, we don't know what to do here */ }
792 #line 791 "btyacc_demo.tab.c"
793 break;
794 case 262:
795 #line 83 "btyacc_demo.y"
796 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
797 msg,
798 (*loc).first_line, (*loc).first_column,
799 (*loc).last_line, (*loc).last_column);
800 /* in this example, we don't know what to do here */ }
801 #line 800 "btyacc_demo.tab.c"
802 break;
803 case 263:
804 #line 83 "btyacc_demo.y"
805 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
806 msg,
807 (*loc).first_line, (*loc).first_column,
808 (*loc).last_line, (*loc).last_column);
809 /* in this example, we don't know what to do here */ }
810 #line 809 "btyacc_demo.tab.c"
811 break;
812 case 264:
813 #line 83 "btyacc_demo.y"
814 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
815 msg,
816 (*loc).first_line, (*loc).first_column,
817 (*loc).last_line, (*loc).last_column);
818 /* in this example, we don't know what to do here */ }
819 #line 818 "btyacc_demo.tab.c"
820 break;
821 case 265:
822 #line 83 "btyacc_demo.y"
823 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
824 msg,
825 (*loc).first_line, (*loc).first_column,
826 (*loc).last_line, (*loc).last_column);
827 /* in this example, we don't know what to do here */ }
828 #line 827 "btyacc_demo.tab.c"
829 break;
830 case 266:
831 #line 83 "btyacc_demo.y"
832 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
833 msg,
834 (*loc).first_line, (*loc).first_column,
835 (*loc).last_line, (*loc).last_column);
836 /* in this example, we don't know what to do here */ }
837 #line 836 "btyacc_demo.tab.c"
838 break;
839 case 267:
840 #line 83 "btyacc_demo.y"
841 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
842 msg,
843 (*loc).first_line, (*loc).first_column,
844 (*loc).last_line, (*loc).last_column);
845 /* in this example, we don't know what to do here */ }
846 #line 845 "btyacc_demo.tab.c"
847 break;
848 case 268:
849 #line 83 "btyacc_demo.y"
850 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
851 msg,
852 (*loc).first_line, (*loc).first_column,
853 (*loc).last_line, (*loc).last_column);
854 /* in this example, we don't know what to do here */ }
855 #line 854 "btyacc_demo.tab.c"
856 break;
857 case 269:
858 #line 83 "btyacc_demo.y"
859 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
860 msg,
861 (*loc).first_line, (*loc).first_column,
862 (*loc).last_line, (*loc).last_column);
863 /* in this example, we don't know what to do here */ }
864 #line 863 "btyacc_demo.tab.c"
865 break;
866 case 59:
867 #line 83 "btyacc_demo.y"
868 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
869 msg,
870 (*loc).first_line, (*loc).first_column,
871 (*loc).last_line, (*loc).last_column);
872 /* in this example, we don't know what to do here */ }
873 #line 872 "btyacc_demo.tab.c"
874 break;
875 case 44:
876 #line 83 "btyacc_demo.y"
877 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
878 msg,
879 (*loc).first_line, (*loc).first_column,
880 (*loc).last_line, (*loc).last_column);
881 /* in this example, we don't know what to do here */ }
882 #line 881 "btyacc_demo.tab.c"
883 break;
884 case 41:
885 #line 83 "btyacc_demo.y"
886 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
887 msg,
888 (*loc).first_line, (*loc).first_column,
889 (*loc).last_line, (*loc).last_column);
890 /* in this example, we don't know what to do here */ }
891 #line 890 "btyacc_demo.tab.c"
892 break;
893 case 93:
894 #line 83 "btyacc_demo.y"
895 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
896 msg,
897 (*loc).first_line, (*loc).first_column,
898 (*loc).last_line, (*loc).last_column);
899 /* in this example, we don't know what to do here */ }
900 #line 899 "btyacc_demo.tab.c"
901 break;
902 case 123:
903 #line 83 "btyacc_demo.y"
904 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
905 msg,
906 (*loc).first_line, (*loc).first_column,
907 (*loc).last_line, (*loc).last_column);
908 /* in this example, we don't know what to do here */ }
909 #line 908 "btyacc_demo.tab.c"
910 break;
911 case 125:
912 #line 83 "btyacc_demo.y"
913 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
914 msg,
915 (*loc).first_line, (*loc).first_column,
916 (*loc).last_line, (*loc).last_column);
917 /* in this example, we don't know what to do here */ }
918 #line 917 "btyacc_demo.tab.c"
919 break;
920 case 270:
921 #line 83 "btyacc_demo.y"
922 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
923 msg,
924 (*loc).first_line, (*loc).first_column,
925 (*loc).last_line, (*loc).last_column);
926 /* in this example, we don't know what to do here */ }
927 #line 926 "btyacc_demo.tab.c"
928 break;
929 case 271:
930 #line 83 "btyacc_demo.y"
931 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
932 msg,
933 (*loc).first_line, (*loc).first_column,
934 (*loc).last_line, (*loc).last_column);
935 /* in this example, we don't know what to do here */ }
936 #line 935 "btyacc_demo.tab.c"
937 break;
938 case 272:
939 #line 78 "btyacc_demo.y"
940 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
941 msg,
942 (*loc).first_line, (*loc).first_column,
943 (*loc).last_line, (*loc).last_column);
944 free((*val).expr); }
945 #line 944 "btyacc_demo.tab.c"
946 break;
947 case 273:
948 #line 67 "btyacc_demo.y"
949 { /* 'msg' is a 'char *' indicating the context of destructor invocation*/
950 printf("%s accessed by symbol \"decl\" (case s.b. 273) @ position[%d,%d..%d,%d]\n",
951 msg,
952 (*loc).first_line, (*loc).first_column,
953 (*loc).last_line, (*loc).last_column);
954 free((*val).decl->scope); free((*val).decl->type); }
955 #line 954 "btyacc_demo.tab.c"
956 break;
957 case 274:
958 #line 83 "btyacc_demo.y"
959 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
960 msg,
961 (*loc).first_line, (*loc).first_column,
962 (*loc).last_line, (*loc).last_column);
963 /* in this example, we don't know what to do here */ }
964 #line 963 "btyacc_demo.tab.c"
965 break;
966 case 275:
967 #line 83 "btyacc_demo.y"
968 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
969 msg,
970 (*loc).first_line, (*loc).first_column,
971 (*loc).last_line, (*loc).last_column);
972 /* in this example, we don't know what to do here */ }
973 #line 972 "btyacc_demo.tab.c"
974 break;
975 case 276:
976 #line 78 "btyacc_demo.y"
977 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
978 msg,
979 (*loc).first_line, (*loc).first_column,
980 (*loc).last_line, (*loc).last_column);
981 free((*val).code); }
982 #line 981 "btyacc_demo.tab.c"
983 break;
984 case 277:
985 #line 78 "btyacc_demo.y"
986 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
987 msg,
988 (*loc).first_line, (*loc).first_column,
989 (*loc).last_line, (*loc).last_column);
990 free((*val).code); }
991 #line 990 "btyacc_demo.tab.c"
992 break;
993 case 278:
994 #line 78 "btyacc_demo.y"
995 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
996 msg,
997 (*loc).first_line, (*loc).first_column,
998 (*loc).last_line, (*loc).last_column);
999 free((*val).code); }
1000 #line 999 "btyacc_demo.tab.c"
1001 break;
1002 case 279:
1003 #line 73 "btyacc_demo.y"
1004 { printf("%s accessed by symbol with type <decl> (case s.b. 279 & 280) @ position[%d,%d..%d,%d]\n",
1005 msg,
1006 (*loc).first_line, (*loc).first_column,
1007 (*loc).last_line, (*loc).last_column);
1008 free((*val).decl); }
1009 #line 1008 "btyacc_demo.tab.c"
1010 break;
1011 case 280:
1012 #line 73 "btyacc_demo.y"
1013 { printf("%s accessed by symbol with type <decl> (case s.b. 279 & 280) @ position[%d,%d..%d,%d]\n",
1014 msg,
1015 (*loc).first_line, (*loc).first_column,
1016 (*loc).last_line, (*loc).last_column);
1017 free((*val).decl); }
1018 #line 1017 "btyacc_demo.tab.c"
1019 break;
1020 case 281:
1021 #line 78 "btyacc_demo.y"
1022 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1023 msg,
1024 (*loc).first_line, (*loc).first_column,
1025 (*loc).last_line, (*loc).last_column);
1026 free((*val).type); }
1027 #line 1026 "btyacc_demo.tab.c"
1028 break;
1029 case 282:
1030 #line 78 "btyacc_demo.y"
1031 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1032 msg,
1033 (*loc).first_line, (*loc).first_column,
1034 (*loc).last_line, (*loc).last_column);
1035 free((*val).type); }
1036 #line 1035 "btyacc_demo.tab.c"
1037 break;
1038 case 283:
1039 #line 78 "btyacc_demo.y"
1040 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1041 msg,
1042 (*loc).first_line, (*loc).first_column,
1043 (*loc).last_line, (*loc).last_column);
1044 free((*val).type); }
1045 #line 1044 "btyacc_demo.tab.c"
1046 break;
1047 case 284:
1048 #line 78 "btyacc_demo.y"
1049 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1050 msg,
1051 (*loc).first_line, (*loc).first_column,
1052 (*loc).last_line, (*loc).last_column);
1053 free((*val).type); }
1054 #line 1053 "btyacc_demo.tab.c"
1055 break;
1056 case 285:
1057 #line 78 "btyacc_demo.y"
1058 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1059 msg,
1060 (*loc).first_line, (*loc).first_column,
1061 (*loc).last_line, (*loc).last_column);
1062 free((*val).type); }
1063 #line 1062 "btyacc_demo.tab.c"
1064 break;
1065 case 286:
1066 #line 78 "btyacc_demo.y"
1067 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1068 msg,
1069 (*loc).first_line, (*loc).first_column,
1070 (*loc).last_line, (*loc).last_column);
1071 free((*val).scope); }
1072 #line 1071 "btyacc_demo.tab.c"
1073 break;
1074 case 287:
1075 #line 78 "btyacc_demo.y"
1076 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1077 msg,
1078 (*loc).first_line, (*loc).first_column,
1079 (*loc).last_line, (*loc).last_column);
1080 free((*val).dlist); }
1081 #line 1080 "btyacc_demo.tab.c"
1082 break;
1083 case 288:
1084 #line 78 "btyacc_demo.y"
1085 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1086 msg,
1087 (*loc).first_line, (*loc).first_column,
1088 (*loc).last_line, (*loc).last_column);
1089 free((*val).dlist); }
1090 #line 1089 "btyacc_demo.tab.c"
1091 break;
1092 case 289:
1093 #line 78 "btyacc_demo.y"
1094 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1095 msg,
1096 (*loc).first_line, (*loc).first_column,
1097 (*loc).last_line, (*loc).last_column);
1098 free((*val).scope); }
1099 #line 1098 "btyacc_demo.tab.c"
1100 break;
1101 case 290:
1102 #line 78 "btyacc_demo.y"
1103 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1104 msg,
1105 (*loc).first_line, (*loc).first_column,
1106 (*loc).last_line, (*loc).last_column);
1107 free((*val).scope); }
1108 #line 1107 "btyacc_demo.tab.c"
1109 break;
1110 case 291:
1111 #line 78 "btyacc_demo.y"
1112 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1113 msg,
1114 (*loc).first_line, (*loc).first_column,
1115 (*loc).last_line, (*loc).last_column);
1116 free((*val).scope); }
1117 #line 1116 "btyacc_demo.tab.c"
1118 break;
1119 case 292:
1120 #line 78 "btyacc_demo.y"
1121 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1122 msg,
1123 (*loc).first_line, (*loc).first_column,
1124 (*loc).last_line, (*loc).last_column);
1125 free((*val).scope); }
1126 #line 1125 "btyacc_demo.tab.c"
1127 break;
1128 case 293:
1129 #line 78 "btyacc_demo.y"
1130 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1131 msg,
1132 (*loc).first_line, (*loc).first_column,
1133 (*loc).last_line, (*loc).last_column);
1134 free((*val).type); }
1135 #line 1134 "btyacc_demo.tab.c"
1136 break;
1137 case 294:
1138 #line 78 "btyacc_demo.y"
1139 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1140 msg,
1141 (*loc).first_line, (*loc).first_column,
1142 (*loc).last_line, (*loc).last_column);
1143 free((*val).scope); }
1144 #line 1143 "btyacc_demo.tab.c"
1145 break;
1146 case 295:
1147 #line 78 "btyacc_demo.y"
1148 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1149 msg,
1150 (*loc).first_line, (*loc).first_column,
1151 (*loc).last_line, (*loc).last_column);
1152 free((*val).type); }
1153 #line 1152 "btyacc_demo.tab.c"
1154 break;
1155 case 296:
1156 #line 78 "btyacc_demo.y"
1157 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1158 msg,
1159 (*loc).first_line, (*loc).first_column,
1160 (*loc).last_line, (*loc).last_column);
1161 free((*val).scope); }
1162 #line 1161 "btyacc_demo.tab.c"
1163 break;
1164 case 297:
1165 #line 78 "btyacc_demo.y"
1166 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1167 msg,
1168 (*loc).first_line, (*loc).first_column,
1169 (*loc).last_line, (*loc).last_column);
1170 free((*val).scope); }
1171 #line 1170 "btyacc_demo.tab.c"
1172 break;
1173 case 298:
1174 #line 78 "btyacc_demo.y"
1175 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1176 msg,
1177 (*loc).first_line, (*loc).first_column,
1178 (*loc).last_line, (*loc).last_column);
1179 free((*val).scope); }
1180 #line 1179 "btyacc_demo.tab.c"
1181 break;
1182 }
1183 }
1184 #define YYDESTRUCT_IS_DECLARED 1
1185 #endif
1186
1187 /* For use in generated program */
1188 #define yydepth (int)(yystack.s_mark - yystack.s_base)
1189 #if YYBTYACC
1190 #define yytrial (yyps->save)
1191 #endif /* YYBTYACC */
1192
1193 #if YYDEBUG
1194 #include <stdio.h> /* needed for printf */
1195 #endif
1196
1197 #include <stdlib.h> /* needed for malloc, etc */
1198 #include <string.h> /* needed for memset */
1199
1200 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
1201 static int yygrowstack(YYSTACKDATA *data)
1202 {
1203 int i;
1204 unsigned newsize;
1205 YYINT *newss;
1206 YYSTYPE *newvs;
1207 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1208 YYLTYPE *newps;
1209 #endif
1210
1211 if ((newsize = data->stacksize) == 0)
1212 newsize = YYINITSTACKSIZE;
1213 else if (newsize >= YYMAXDEPTH)
1214 return YYENOMEM;
1215 else if ((newsize *= 2) > YYMAXDEPTH)
1216 newsize = YYMAXDEPTH;
1217
1218 i = (int) (data->s_mark - data->s_base);
1219 newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
1220 if (newss == 0)
1221 return YYENOMEM;
1222
1223 data->s_base = newss;
1224 data->s_mark = newss + i;
1225
1226 newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
1227 if (newvs == 0)
1228 return YYENOMEM;
1229
1230 data->l_base = newvs;
1231 data->l_mark = newvs + i;
1232
1233 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1234 newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps));
1235 if (newps == 0)
1236 return YYENOMEM;
1237
1238 data->p_base = newps;
1239 data->p_mark = newps + i;
1240 #endif
1241
1242 data->stacksize = newsize;
1243 data->s_last = data->s_base + newsize - 1;
1244
1245 #if YYDEBUG
1246 if (yydebug)
1247 fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize);
1248 #endif
1249 return 0;
1250 }
1251
1252 #if YYPURE || defined(YY_NO_LEAKS)
1253 static void yyfreestack(YYSTACKDATA *data)
1254 {
1255 free(data->s_base);
1256 free(data->l_base);
1257 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1258 free(data->p_base);
1259 #endif
1260 memset(data, 0, sizeof(*data));
1261 }
1262 #else
1263 #define yyfreestack(data) /* nothing */
1264 #endif /* YYPURE || defined(YY_NO_LEAKS) */
1265 #if YYBTYACC
1266
1267 static YYParseState *
1268 yyNewState(unsigned size)
1269 {
1270 YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState));
1271 if (p == NULL) return NULL;
1272
1273 p->yystack.stacksize = size;
1274 if (size == 0)
1275 {
1276 p->yystack.s_base = NULL;
1277 p->yystack.l_base = NULL;
1278 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1279 p->yystack.p_base = NULL;
1280 #endif
1281 return p;
1282 }
1283 p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT));
1284 if (p->yystack.s_base == NULL) return NULL;
1285 p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE));
1286 if (p->yystack.l_base == NULL) return NULL;
1287 memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE));
1288 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1289 p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE));
1290 if (p->yystack.p_base == NULL) return NULL;
1291 memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE));
1292 #endif
1293
1294 return p;
1295 }
1296
1297 static void
1298 yyFreeState(YYParseState *p)
1299 {
1300 yyfreestack(&p->yystack);
1301 free(p);
1302 }
1303 #endif /* YYBTYACC */
1304
1305 #define YYABORT goto yyabort
1306 #define YYREJECT goto yyabort
1307 #define YYACCEPT goto yyaccept
1308 #define YYERROR goto yyerrlab
1309 #if YYBTYACC
1310 #define YYVALID do { if (yyps->save) goto yyvalid; } while(0)
1311 #define YYVALID_NESTED do { if (yyps->save && \
1312 yyps->save->save == 0) goto yyvalid; } while(0)
1313 #endif /* YYBTYACC */
1314
1315 int
1316 YYPARSE_DECL()
1317 {
1318 int yym, yyn, yystate, yyresult;
1319 #if YYBTYACC
1320 int yynewerrflag;
1321 YYParseState *yyerrctx = NULL;
1322 #endif /* YYBTYACC */
1323 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1324 YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */
1325 #endif
1326 #if YYDEBUG
1327 const char *yys;
1328
1329 if ((yys = getenv("YYDEBUG")) != 0)
1330 {
1331 yyn = *yys;
1332 if (yyn >= '0' && yyn <= '9')
1333 yydebug = yyn - '0';
1334 }
1335 if (yydebug)
1336 fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX);
1337 #endif
1338 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1339 memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range));
1340 #endif
1341
1342 #if YYBTYACC
1343 yyps = yyNewState(0); if (yyps == 0) goto yyenomem;
1344 yyps->save = 0;
1345 #endif /* YYBTYACC */
1346 yym = 0;
1347 /* yyn is set below */
1348 yynerrs = 0;
1349 yyerrflag = 0;
1350 yychar = YYEMPTY;
1351 yystate = 0;
1352
1353 #if YYPURE
1354 memset(&yystack, 0, sizeof(yystack));
1355 #endif
1356
1357 if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1358 yystack.s_mark = yystack.s_base;
1359 yystack.l_mark = yystack.l_base;
1360 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1361 yystack.p_mark = yystack.p_base;
1362 #endif
1363 yystate = 0;
1364 *yystack.s_mark = 0;
1365
1366 yyloop:
1367 if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
1368 if (yychar < 0)
1369 {
1370 #if YYBTYACC
1371 do {
1372 if (yylvp < yylve)
1373 {
1374 /* we're currently re-reading tokens */
1375 yylval = *yylvp++;
1376 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1377 yylloc = *yylpp++;
1378 #endif
1379 yychar = *yylexp++;
1380 break;
1381 }
1382 if (yyps->save)
1383 {
1384 /* in trial mode; save scanner results for future parse attempts */
1385 if (yylvp == yylvlim)
1386 { /* Enlarge lexical value queue */
1387 size_t p = (size_t) (yylvp - yylvals);
1388 size_t s = (size_t) (yylvlim - yylvals);
1389
1390 s += YYLVQUEUEGROWTH;
1391 if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
1392 if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
1393 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1394 if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
1395 #endif
1396 yylvp = yylve = yylvals + p;
1397 yylvlim = yylvals + s;
1398 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1399 yylpp = yylpe = yylpsns + p;
1400 yylplim = yylpsns + s;
1401 #endif
1402 yylexp = yylexemes + p;
1403 }
1404 *yylexp = (YYINT) YYLEX;
1405 *yylvp++ = yylval;
1406 yylve++;
1407 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1408 *yylpp++ = yylloc;
1409 yylpe++;
1410 #endif
1411 yychar = *yylexp++;
1412 break;
1413 }
1414 /* normal operation, no conflict encountered */
1415 #endif /* YYBTYACC */
1416 yychar = YYLEX;
1417 #if YYBTYACC
1418 } while (0);
1419 #endif /* YYBTYACC */
1420 if (yychar < 0) yychar = YYEOF;
1421 #if YYDEBUG
1422 if (yydebug)
1423 {
1424 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
1425 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)",
1426 YYDEBUGSTR, yydepth, yystate, yychar, yys);
1427 #ifdef YYSTYPE_TOSTRING
1428 #if YYBTYACC
1429 if (!yytrial)
1430 #endif /* YYBTYACC */
1431 fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval));
1432 #endif
1433 fputc('\n', stderr);
1434 }
1435 #endif
1436 }
1437 #if YYBTYACC
1438
1439 /* Do we have a conflict? */
1440 if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
1441 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
1442 {
1443 YYINT ctry;
1444
1445 if (yypath)
1446 {
1447 YYParseState *save;
1448 #if YYDEBUG
1449 if (yydebug)
1450 fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n",
1451 YYDEBUGSTR, yydepth, yystate);
1452 #endif
1453 /* Switch to the next conflict context */
1454 save = yypath;
1455 yypath = save->save;
1456 save->save = NULL;
1457 ctry = save->ctry;
1458 if (save->state != yystate) YYABORT;
1459 yyFreeState(save);
1460
1461 }
1462 else
1463 {
1464
1465 /* Unresolved conflict - start/continue trial parse */
1466 YYParseState *save;
1467 #if YYDEBUG
1468 if (yydebug)
1469 {
1470 fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate);
1471 if (yyps->save)
1472 fputs("ALREADY in conflict, continuing trial parse.\n", stderr);
1473 else
1474 fputs("Starting trial parse.\n", stderr);
1475 }
1476 #endif
1477 save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
1478 if (save == NULL) goto yyenomem;
1479 save->save = yyps->save;
1480 save->state = yystate;
1481 save->errflag = yyerrflag;
1482 save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base);
1483 memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1484 save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base);
1485 memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1486 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1487 save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base);
1488 memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1489 #endif
1490 ctry = yytable[yyn];
1491 if (yyctable[ctry] == -1)
1492 {
1493 #if YYDEBUG
1494 if (yydebug && yychar >= YYEOF)
1495 fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth);
1496 #endif
1497 ctry++;
1498 }
1499 save->ctry = ctry;
1500 if (yyps->save == NULL)
1501 {
1502 /* If this is a first conflict in the stack, start saving lexemes */
1503 if (!yylexemes)
1504 {
1505 yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
1506 if (yylexemes == NULL) goto yyenomem;
1507 yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
1508 if (yylvals == NULL) goto yyenomem;
1509 yylvlim = yylvals + YYLVQUEUEGROWTH;
1510 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1511 yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE));
1512 if (yylpsns == NULL) goto yyenomem;
1513 yylplim = yylpsns + YYLVQUEUEGROWTH;
1514 #endif
1515 }
1516 if (yylvp == yylve)
1517 {
1518 yylvp = yylve = yylvals;
1519 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1520 yylpp = yylpe = yylpsns;
1521 #endif
1522 yylexp = yylexemes;
1523 if (yychar >= YYEOF)
1524 {
1525 *yylve++ = yylval;
1526 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1527 *yylpe++ = yylloc;
1528 #endif
1529 *yylexp = (YYINT) yychar;
1530 yychar = YYEMPTY;
1531 }
1532 }
1533 }
1534 if (yychar >= YYEOF)
1535 {
1536 yylvp--;
1537 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1538 yylpp--;
1539 #endif
1540 yylexp--;
1541 yychar = YYEMPTY;
1542 }
1543 save->lexeme = (int) (yylvp - yylvals);
1544 yyps->save = save;
1545 }
1546 if (yytable[yyn] == ctry)
1547 {
1548 #if YYDEBUG
1549 if (yydebug)
1550 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
1551 YYDEBUGSTR, yydepth, yystate, yyctable[ctry]);
1552 #endif
1553 if (yychar < 0)
1554 {
1555 yylvp++;
1556 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1557 yylpp++;
1558 #endif
1559 yylexp++;
1560 }
1561 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
1562 goto yyoverflow;
1563 yystate = yyctable[ctry];
1564 *++yystack.s_mark = (YYINT) yystate;
1565 *++yystack.l_mark = yylval;
1566 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1567 *++yystack.p_mark = yylloc;
1568 #endif
1569 yychar = YYEMPTY;
1570 if (yyerrflag > 0) --yyerrflag;
1571 goto yyloop;
1572 }
1573 else
1574 {
1575 yyn = yyctable[ctry];
1576 goto yyreduce;
1577 }
1578 } /* End of code dealing with conflicts */
1579 #endif /* YYBTYACC */
1580 if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
1581 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
1582 {
1583 #if YYDEBUG
1584 if (yydebug)
1585 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
1586 YYDEBUGSTR, yydepth, yystate, yytable[yyn]);
1587 #endif
1588 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1589 yystate = yytable[yyn];
1590 *++yystack.s_mark = yytable[yyn];
1591 *++yystack.l_mark = yylval;
1592 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1593 *++yystack.p_mark = yylloc;
1594 #endif
1595 yychar = YYEMPTY;
1596 if (yyerrflag > 0) --yyerrflag;
1597 goto yyloop;
1598 }
1599 if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
1600 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
1601 {
1602 yyn = yytable[yyn];
1603 goto yyreduce;
1604 }
1605 if (yyerrflag != 0) goto yyinrecovery;
1606 #if YYBTYACC
1607
1608 yynewerrflag = 1;
1609 goto yyerrhandler;
1610 goto yyerrlab; /* redundant goto avoids 'unused label' warning */
1611
1612 yyerrlab:
1613 /* explicit YYERROR from an action -- pop the rhs of the rule reduced
1614 * before looking for error recovery */
1615 yystack.s_mark -= yym;
1616 yystate = *yystack.s_mark;
1617 yystack.l_mark -= yym;
1618 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1619 yystack.p_mark -= yym;
1620 #endif
1621
1622 yynewerrflag = 0;
1623 yyerrhandler:
1624 while (yyps->save)
1625 {
1626 int ctry;
1627 YYParseState *save = yyps->save;
1628 #if YYDEBUG
1629 if (yydebug)
1630 fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n",
1631 YYDEBUGSTR, yydepth, yystate, yyps->save->state,
1632 (int)(yylvp - yylvals - yyps->save->lexeme));
1633 #endif
1634 /* Memorize most forward-looking error state in case it's really an error. */
1635 if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals)
1636 {
1637 /* Free old saved error context state */
1638 if (yyerrctx) yyFreeState(yyerrctx);
1639 /* Create and fill out new saved error context state */
1640 yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
1641 if (yyerrctx == NULL) goto yyenomem;
1642 yyerrctx->save = yyps->save;
1643 yyerrctx->state = yystate;
1644 yyerrctx->errflag = yyerrflag;
1645 yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base);
1646 memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1647 yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base);
1648 memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1649 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1650 yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base);
1651 memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1652 #endif
1653 yyerrctx->lexeme = (int) (yylvp - yylvals);
1654 }
1655 yylvp = yylvals + save->lexeme;
1656 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1657 yylpp = yylpsns + save->lexeme;
1658 #endif
1659 yylexp = yylexemes + save->lexeme;
1660 yychar = YYEMPTY;
1661 yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base);
1662 memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1663 yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base);
1664 memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1665 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1666 yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base);
1667 memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1668 #endif
1669 ctry = ++save->ctry;
1670 yystate = save->state;
1671 /* We tried shift, try reduce now */
1672 if ((yyn = yyctable[ctry]) >= 0) goto yyreduce;
1673 yyps->save = save->save;
1674 save->save = NULL;
1675 yyFreeState(save);
1676
1677 /* Nothing left on the stack -- error */
1678 if (!yyps->save)
1679 {
1680 #if YYDEBUG
1681 if (yydebug)
1682 fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n",
1683 YYPREFIX, yydepth);
1684 #endif
1685 /* Restore state as it was in the most forward-advanced error */
1686 yylvp = yylvals + yyerrctx->lexeme;
1687 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1688 yylpp = yylpsns + yyerrctx->lexeme;
1689 #endif
1690 yylexp = yylexemes + yyerrctx->lexeme;
1691 yychar = yylexp[-1];
1692 yylval = yylvp[-1];
1693 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1694 yylloc = yylpp[-1];
1695 #endif
1696 yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base);
1697 memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1698 yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base);
1699 memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1700 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1701 yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base);
1702 memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1703 #endif
1704 yystate = yyerrctx->state;
1705 yyFreeState(yyerrctx);
1706 yyerrctx = NULL;
1707 }
1708 yynewerrflag = 1;
1709 }
1710 if (yynewerrflag == 0) goto yyinrecovery;
1711 #endif /* YYBTYACC */
1712
1713 YYERROR_CALL("syntax error");
1714 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1715 yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */
1716 #endif
1717
1718 #if !YYBTYACC
1719 goto yyerrlab; /* redundant goto avoids 'unused label' warning */
1720 yyerrlab:
1721 #endif
1722 ++yynerrs;
1723
1724 yyinrecovery:
1725 if (yyerrflag < 3)
1726 {
1727 yyerrflag = 3;
1728 for (;;)
1729 {
1730 if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
1731 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
1732 {
1733 #if YYDEBUG
1734 if (yydebug)
1735 fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n",
1736 YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]);
1737 #endif
1738 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1739 yystate = yytable[yyn];
1740 *++yystack.s_mark = yytable[yyn];
1741 *++yystack.l_mark = yylval;
1742 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1743 /* lookahead position is error end position */
1744 yyerror_loc_range[2] = yylloc;
1745 YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
1746 *++yystack.p_mark = yyloc;
1747 #endif
1748 goto yyloop;
1749 }
1750 else
1751 {
1752 #if YYDEBUG
1753 if (yydebug)
1754 fprintf(stderr, "%s[%d]: error recovery discarding state %d\n",
1755 YYDEBUGSTR, yydepth, *yystack.s_mark);
1756 #endif
1757 if (yystack.s_mark <= yystack.s_base) goto yyabort;
1758 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1759 /* the current TOS position is the error start position */
1760 yyerror_loc_range[1] = *yystack.p_mark;
1761 #endif
1762 #if defined(YYDESTRUCT_CALL)
1763 #if YYBTYACC
1764 if (!yytrial)
1765 #endif /* YYBTYACC */
1766 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1767 YYDESTRUCT_CALL("error: discarding state",
1768 yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark);
1769 #else
1770 YYDESTRUCT_CALL("error: discarding state",
1771 yystos[*yystack.s_mark], yystack.l_mark);
1772 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1773 #endif /* defined(YYDESTRUCT_CALL) */
1774 --yystack.s_mark;
1775 --yystack.l_mark;
1776 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1777 --yystack.p_mark;
1778 #endif
1779 }
1780 }
1781 }
1782 else
1783 {
1784 if (yychar == YYEOF) goto yyabort;
1785 #if YYDEBUG
1786 if (yydebug)
1787 {
1788 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
1789 fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n",
1790 YYDEBUGSTR, yydepth, yystate, yychar, yys);
1791 }
1792 #endif
1793 #if defined(YYDESTRUCT_CALL)
1794 #if YYBTYACC
1795 if (!yytrial)
1796 #endif /* YYBTYACC */
1797 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1798 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc);
1799 #else
1800 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval);
1801 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1802 #endif /* defined(YYDESTRUCT_CALL) */
1803 yychar = YYEMPTY;
1804 goto yyloop;
1805 }
1806
1807 yyreduce:
1808 yym = yylen[yyn];
1809 #if YYDEBUG
1810 if (yydebug)
1811 {
1812 fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)",
1813 YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]);
1814 #ifdef YYSTYPE_TOSTRING
1815 #if YYBTYACC
1816 if (!yytrial)
1817 #endif /* YYBTYACC */
1818 if (yym > 0)
1819 {
1820 int i;
1821 fputc('<', stderr);
1822 for (i = yym; i > 0; i--)
1823 {
1824 if (i != yym) fputs(", ", stderr);
1825 fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]],
1826 yystack.l_mark[1-i]), stderr);
1827 }
1828 fputc('>', stderr);
1829 }
1830 #endif
1831 fputc('\n', stderr);
1832 }
1833 #endif
1834 if (yym > 0)
1835 yyval = yystack.l_mark[1-yym];
1836 else
1837 memset(&yyval, 0, sizeof yyval);
1838 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1839
1840 /* Perform position reduction */
1841 memset(&yyloc, 0, sizeof(yyloc));
1842 #if YYBTYACC
1843 if (!yytrial)
1844 #endif /* YYBTYACC */
1845 {
1846 YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym);
1847 /* just in case YYERROR is invoked within the action, save
1848 the start of the rhs as the error start position */
1849 yyerror_loc_range[1] = yystack.p_mark[1-yym];
1850 }
1851 #endif
1852
1853 switch (yyn)
1854 {
1855 case 1:
1856 #line 93 "btyacc_demo.y"
1857 { yyval.scope = yystack.l_mark[0].scope; }
1858 #line 1857 "btyacc_demo.tab.c"
1859 break;
1860 case 2:
1861 #line 94 "btyacc_demo.y"
1862 { yyval.scope = global_scope; }
1863 #line 1862 "btyacc_demo.tab.c"
1864 break;
1865 case 3:
1866 #line 95 "btyacc_demo.y"
1867 { Decl *d = lookup(yystack.l_mark[-2].scope, yystack.l_mark[-1].id);
1868 if (!d || !d->scope) YYERROR;
1869 yyval.scope = d->scope; }
1870 #line 1869 "btyacc_demo.tab.c"
1871 break;
1872 case 4:
1873 #line 101 "btyacc_demo.y"
1874 { Decl *d = lookup(yystack.l_mark[-1].scope, yystack.l_mark[0].id);
1875 if (d == NULL || d->istype() == 0) YYERROR;
1876 yyval.type = d->type; }
1877 #line 1876 "btyacc_demo.tab.c"
1878 break;
1879 case 5:
1880 #line 106 "btyacc_demo.y"
1881 yyval.scope = global_scope = new_scope(0);
1882 #line 1881 "btyacc_demo.tab.c"
1883 break;
1884 case 8:
1885 #line 107 "btyacc_demo.y"
1886 yyval.scope = yystack.l_mark[-1].scope;
1887 #line 1886 "btyacc_demo.tab.c"
1888 break;
1889 case 10:
1890 #line 109 "btyacc_demo.y"
1891 {YYVALID;}
1892 #line 1891 "btyacc_demo.tab.c"
1893 break;
1894 case 11:
1895 #line 110 "btyacc_demo.y"
1896 yyval.scope = start_fn_def(yystack.l_mark[-2].scope, yystack.l_mark[0].decl);
1897 #line 1896 "btyacc_demo.tab.c"
1898 break;
1899 case 12:
1900 if (!yytrial)
1901 #line 111 "btyacc_demo.y"
1902 { /* demonstrate use of @$ & @N, although this is just the
1903 default computation and so is not necessary */
1904 yyloc.first_line = yystack.p_mark[-3].first_line;
1905 yyloc.first_column = yystack.p_mark[-3].first_column;
1906 yyloc.last_line = yystack.p_mark[0].last_line;
1907 yyloc.last_column = yystack.p_mark[0].last_column;
1908 finish_fn_def(yystack.l_mark[-2].decl, yystack.l_mark[0].code); }
1909 #line 1908 "btyacc_demo.tab.c"
1910 break;
1911 case 13:
1912 #line 121 "btyacc_demo.y"
1913 { yyval.type = yystack.l_mark[0].type; }
1914 #line 1913 "btyacc_demo.tab.c"
1915 break;
1916 case 14:
1917 #line 122 "btyacc_demo.y"
1918 { yyval.type = type_combine(yystack.l_mark[-2].type, yystack.l_mark[0].type); }
1919 #line 1918 "btyacc_demo.tab.c"
1920 break;
1921 case 15:
1922 #line 125 "btyacc_demo.y"
1923 { yyval.type = 0; }
1924 #line 1923 "btyacc_demo.tab.c"
1925 break;
1926 case 16:
1927 #line 126 "btyacc_demo.y"
1928 { yyval.type = type_combine(yystack.l_mark[-1].type, yystack.l_mark[0].type); }
1929 #line 1928 "btyacc_demo.tab.c"
1930 break;
1931 case 17:
1932 #line 130 "btyacc_demo.y"
1933 { yyval.type = yystack.l_mark[0].type; }
1934 #line 1933 "btyacc_demo.tab.c"
1935 break;
1936 case 18:
1937 #line 131 "btyacc_demo.y"
1938 { yyval.type = yystack.l_mark[0].type; }
1939 #line 1938 "btyacc_demo.tab.c"
1940 break;
1941 case 19:
1942 #line 132 "btyacc_demo.y"
1943 { yyval.type = bare_extern(); }
1944 #line 1943 "btyacc_demo.tab.c"
1945 break;
1946 case 20:
1947 #line 133 "btyacc_demo.y"
1948 { yyval.type = bare_register(); }
1949 #line 1948 "btyacc_demo.tab.c"
1950 break;
1951 case 21:
1952 #line 134 "btyacc_demo.y"
1953 { yyval.type = bare_static(); }
1954 #line 1953 "btyacc_demo.tab.c"
1955 break;
1956 case 22:
1957 #line 138 "btyacc_demo.y"
1958 { yyval.type = bare_const(); }
1959 #line 1958 "btyacc_demo.tab.c"
1960 break;
1961 case 23:
1962 #line 139 "btyacc_demo.y"
1963 { yyval.type = bare_volatile(); }
1964 #line 1963 "btyacc_demo.tab.c"
1965 break;
1966 case 24:
1967 #line 143 "btyacc_demo.y"
1968 yyval.scope = yystack.l_mark[-3].scope;
1969 #line 1968 "btyacc_demo.tab.c"
1970 break;
1971 case 25:
1972 #line 143 "btyacc_demo.y"
1973 yyval.type = yystack.l_mark[-3].type;
1974 #line 1973 "btyacc_demo.tab.c"
1975 break;
1976 case 28:
1977 #line 148 "btyacc_demo.y"
1978 { if (!yystack.l_mark[0].type) YYERROR; } if (!yytrial)
1979 #line 149 "btyacc_demo.y"
1980 { yyval.decl = declare(yystack.l_mark[-1].scope, 0, yystack.l_mark[0].type); }
1981 #line 1980 "btyacc_demo.tab.c"
1982 break;
1983 case 29:
1984 if (!yytrial)
1985 #line 150 "btyacc_demo.y"
1986 { yyval.decl = declare(yystack.l_mark[-2].scope, yystack.l_mark[0].id, yystack.l_mark[-1].type); }
1987 #line 1986 "btyacc_demo.tab.c"
1988 break;
1989 case 30:
1990 #line 151 "btyacc_demo.y"
1991 yyval.scope = yystack.l_mark[-2].scope;
1992 #line 1991 "btyacc_demo.tab.c"
1993 break;
1994 case 31:
1995 #line 151 "btyacc_demo.y"
1996 yyval.type = yystack.l_mark[-2].type;
1997 #line 1996 "btyacc_demo.tab.c"
1998 break;
1999 case 32:
2000 if (!yytrial)
2001 #line 151 "btyacc_demo.y"
2002 { yyval.decl = yystack.l_mark[-1].decl; }
2003 #line 2002 "btyacc_demo.tab.c"
2004 break;
2005 case 33:
2006 if (!yytrial)
2007 #line 153 "btyacc_demo.y"
2008 { yyval.decl = make_pointer(yystack.l_mark[0].decl, yystack.l_mark[-3].type); }
2009 #line 2008 "btyacc_demo.tab.c"
2010 break;
2011 case 34:
2012 if (!yytrial)
2013 #line 155 "btyacc_demo.y"
2014 { yyval.decl = make_array(yystack.l_mark[-4].decl->type, yystack.l_mark[-1].expr); }
2015 #line 2014 "btyacc_demo.tab.c"
2016 break;
2017 case 35:
2018 if (!yytrial)
2019 #line 157 "btyacc_demo.y"
2020 { yyval.decl = build_function(yystack.l_mark[-5].decl, yystack.l_mark[-2].dlist, yystack.l_mark[0].type); }
2021 #line 2020 "btyacc_demo.tab.c"
2022 break;
2023 case 36:
2024 if (!yytrial)
2025 #line 160 "btyacc_demo.y"
2026 { yyval.dlist = 0; }
2027 #line 2026 "btyacc_demo.tab.c"
2028 break;
2029 case 37:
2030 if (!yytrial)
2031 #line 161 "btyacc_demo.y"
2032 { yyval.dlist = yystack.l_mark[0].dlist; }
2033 #line 2032 "btyacc_demo.tab.c"
2034 break;
2035 case 38:
2036 if (!yytrial)
2037 #line 164 "btyacc_demo.y"
2038 { yyval.dlist = append_dlist(yystack.l_mark[-3].dlist, yystack.l_mark[0].decl); }
2039 #line 2038 "btyacc_demo.tab.c"
2040 break;
2041 case 39:
2042 if (!yytrial)
2043 #line 165 "btyacc_demo.y"
2044 { yyval.dlist = build_dlist(yystack.l_mark[0].decl); }
2045 #line 2044 "btyacc_demo.tab.c"
2046 break;
2047 case 40:
2048 if (!yytrial)
2049 #line 168 "btyacc_demo.y"
2050 { yyval.decl = yystack.l_mark[0].decl; }
2051 #line 2050 "btyacc_demo.tab.c"
2052 break;
2053 case 41:
2054 if (!yytrial)
2055 #line 172 "btyacc_demo.y"
2056 { yyval.expr = build_expr(yystack.l_mark[-3].expr, ADD, yystack.l_mark[0].expr); }
2057 #line 2056 "btyacc_demo.tab.c"
2058 break;
2059 case 42:
2060 if (!yytrial)
2061 #line 173 "btyacc_demo.y"
2062 { yyval.expr = build_expr(yystack.l_mark[-3].expr, SUB, yystack.l_mark[0].expr); }
2063 #line 2062 "btyacc_demo.tab.c"
2064 break;
2065 case 43:
2066 if (!yytrial)
2067 #line 174 "btyacc_demo.y"
2068 { yyval.expr = build_expr(yystack.l_mark[-3].expr, MUL, yystack.l_mark[0].expr); }
2069 #line 2068 "btyacc_demo.tab.c"
2070 break;
2071 case 44:
2072 if (!yytrial)
2073 #line 175 "btyacc_demo.y"
2074 { yyval.expr = build_expr(yystack.l_mark[-3].expr, MOD, yystack.l_mark[0].expr); }
2075 #line 2074 "btyacc_demo.tab.c"
2076 break;
2077 case 45:
2078 if (!yytrial)
2079 #line 176 "btyacc_demo.y"
2080 { yyval.expr = build_expr(yystack.l_mark[-3].expr, DIV, yystack.l_mark[0].expr); }
2081 #line 2080 "btyacc_demo.tab.c"
2082 break;
2083 case 46:
2084 if (!yytrial)
2085 #line 177 "btyacc_demo.y"
2086 { yyval.expr = build_expr(0, DEREF, yystack.l_mark[0].expr); }
2087 #line 2086 "btyacc_demo.tab.c"
2088 break;
2089 case 47:
2090 if (!yytrial)
2091 #line 178 "btyacc_demo.y"
2092 { yyval.expr = var_expr(yystack.l_mark[-1].scope, yystack.l_mark[0].id); }
2093 #line 2092 "btyacc_demo.tab.c"
2094 break;
2095 case 48:
2096 if (!yytrial)
2097 #line 179 "btyacc_demo.y"
2098 { yyval.expr = yystack.l_mark[0].expr; }
2099 #line 2098 "btyacc_demo.tab.c"
2100 break;
2101 case 49:
2102 if (!yytrial)
2103 #line 183 "btyacc_demo.y"
2104 { yyval.code = 0; }
2105 #line 2104 "btyacc_demo.tab.c"
2106 break;
2107 case 50:
2108 #line 184 "btyacc_demo.y"
2109 {YYVALID;} if (!yytrial)
2110 #line 184 "btyacc_demo.y"
2111 { yyval.code = build_expr_code(yystack.l_mark[-1].expr); }
2112 #line 2111 "btyacc_demo.tab.c"
2113 break;
2114 case 51:
2115 #line 185 "btyacc_demo.y"
2116 yyval.scope = yystack.l_mark[-6].scope;
2117 #line 2116 "btyacc_demo.tab.c"
2118 break;
2119 case 52:
2120 #line 185 "btyacc_demo.y"
2121 yyval.scope = yystack.l_mark[-9].scope;
2122 #line 2121 "btyacc_demo.tab.c"
2123 break;
2124 case 53:
2125 #line 185 "btyacc_demo.y"
2126 {YYVALID;} if (!yytrial)
2127 #line 186 "btyacc_demo.y"
2128 { yyval.code = build_if(yystack.l_mark[-7].expr, yystack.l_mark[-3].code, yystack.l_mark[0].code); }
2129 #line 2128 "btyacc_demo.tab.c"
2130 break;
2131 case 54:
2132 #line 187 "btyacc_demo.y"
2133 {YYVALID;} if (!yytrial)
2134 #line 188 "btyacc_demo.y"
2135 { yyval.code = build_if(yystack.l_mark[-4].expr, yystack.l_mark[0].code, 0); }
2136 #line 2135 "btyacc_demo.tab.c"
2137 break;
2138 case 55:
2139 #line 189 "btyacc_demo.y"
2140 yyval.scope = new_scope(yystack.l_mark[0].scope);
2141 #line 2140 "btyacc_demo.tab.c"
2142 break;
2143 case 56:
2144 #line 189 "btyacc_demo.y"
2145 {YYVALID;} if (!yytrial)
2146 #line 189 "btyacc_demo.y"
2147 { yyval.code = yystack.l_mark[0].code; }
2148 #line 2147 "btyacc_demo.tab.c"
2149 break;
2150 case 57:
2151 if (!yytrial)
2152 #line 192 "btyacc_demo.y"
2153 { yyval.code = 0; }
2154 #line 2153 "btyacc_demo.tab.c"
2155 break;
2156 case 58:
2157 if (!yytrial)
2158 #line 193 "btyacc_demo.y"
2159 { yyval.code = code_append(yystack.l_mark[-2].code, yystack.l_mark[0].code); }
2160 #line 2159 "btyacc_demo.tab.c"
2161 break;
2162 case 59:
2163 if (!yytrial)
2164 #line 197 "btyacc_demo.y"
2165 { yyval.code = yystack.l_mark[-1].code; }
2166 #line 2165 "btyacc_demo.tab.c"
2167 break;
2168 #line 2167 "btyacc_demo.tab.c"
2169 default:
2170 break;
2171 }
2172 yystack.s_mark -= yym;
2173 yystate = *yystack.s_mark;
2174 yystack.l_mark -= yym;
2175 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2176 yystack.p_mark -= yym;
2177 #endif
2178 yym = yylhs[yyn];
2179 if (yystate == 0 && yym == 0)
2180 {
2181 #if YYDEBUG
2182 if (yydebug)
2183 {
2184 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
2185 #ifdef YYSTYPE_TOSTRING
2186 #if YYBTYACC
2187 if (!yytrial)
2188 #endif /* YYBTYACC */
2189 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval));
2190 #endif
2191 fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL);
2192 }
2193 #endif
2194 yystate = YYFINAL;
2195 *++yystack.s_mark = YYFINAL;
2196 *++yystack.l_mark = yyval;
2197 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2198 *++yystack.p_mark = yyloc;
2199 #endif
2200 if (yychar < 0)
2201 {
2202 #if YYBTYACC
2203 do {
2204 if (yylvp < yylve)
2205 {
2206 /* we're currently re-reading tokens */
2207 yylval = *yylvp++;
2208 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2209 yylloc = *yylpp++;
2210 #endif
2211 yychar = *yylexp++;
2212 break;
2213 }
2214 if (yyps->save)
2215 {
2216 /* in trial mode; save scanner results for future parse attempts */
2217 if (yylvp == yylvlim)
2218 { /* Enlarge lexical value queue */
2219 size_t p = (size_t) (yylvp - yylvals);
2220 size_t s = (size_t) (yylvlim - yylvals);
2221
2222 s += YYLVQUEUEGROWTH;
2223 if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL)
2224 goto yyenomem;
2225 if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
2226 goto yyenomem;
2227 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2228 if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
2229 goto yyenomem;
2230 #endif
2231 yylvp = yylve = yylvals + p;
2232 yylvlim = yylvals + s;
2233 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2234 yylpp = yylpe = yylpsns + p;
2235 yylplim = yylpsns + s;
2236 #endif
2237 yylexp = yylexemes + p;
2238 }
2239 *yylexp = (YYINT) YYLEX;
2240 *yylvp++ = yylval;
2241 yylve++;
2242 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2243 *yylpp++ = yylloc;
2244 yylpe++;
2245 #endif
2246 yychar = *yylexp++;
2247 break;
2248 }
2249 /* normal operation, no conflict encountered */
2250 #endif /* YYBTYACC */
2251 yychar = YYLEX;
2252 #if YYBTYACC
2253 } while (0);
2254 #endif /* YYBTYACC */
2255 if (yychar < 0) yychar = YYEOF;
2256 #if YYDEBUG
2257 if (yydebug)
2258 {
2259 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
2260 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n",
2261 YYDEBUGSTR, yydepth, YYFINAL, yychar, yys);
2262 }
2263 #endif
2264 }
2265 if (yychar == YYEOF) goto yyaccept;
2266 goto yyloop;
2267 }
2268 if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
2269 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
2270 yystate = yytable[yyn];
2271 else
2272 yystate = yydgoto[yym];
2273 #if YYDEBUG
2274 if (yydebug)
2275 {
2276 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
2277 #ifdef YYSTYPE_TOSTRING
2278 #if YYBTYACC
2279 if (!yytrial)
2280 #endif /* YYBTYACC */
2281 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval));
2282 #endif
2283 fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate);
2284 }
2285 #endif
2286 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
2287 *++yystack.s_mark = (YYINT) yystate;
2288 *++yystack.l_mark = yyval;
2289 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2290 *++yystack.p_mark = yyloc;
2291 #endif
2292 goto yyloop;
2293 #if YYBTYACC
2294
2295 /* Reduction declares that this path is valid. Set yypath and do a full parse */
2296 yyvalid:
2297 if (yypath) YYABORT;
2298 while (yyps->save)
2299 {
2300 YYParseState *save = yyps->save;
2301 yyps->save = save->save;
2302 save->save = yypath;
2303 yypath = save;
2304 }
2305 #if YYDEBUG
2306 if (yydebug)
2307 fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n",
2308 YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme));
2309 #endif
2310 if (yyerrctx)
2311 {
2312 yyFreeState(yyerrctx);
2313 yyerrctx = NULL;
2314 }
2315 yylvp = yylvals + yypath->lexeme;
2316 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2317 yylpp = yylpsns + yypath->lexeme;
2318 #endif
2319 yylexp = yylexemes + yypath->lexeme;
2320 yychar = YYEMPTY;
2321 yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base);
2322 memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
2323 yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base);
2324 memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
2325 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2326 yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base);
2327 memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
2328 #endif
2329 yystate = yypath->state;
2330 goto yyloop;
2331 #endif /* YYBTYACC */
2332
2333 yyoverflow:
2334 YYERROR_CALL("yacc stack overflow");
2335 #if YYBTYACC
2336 goto yyabort_nomem;
2337 yyenomem:
2338 YYERROR_CALL("memory exhausted");
2339 yyabort_nomem:
2340 #endif /* YYBTYACC */
2341 yyresult = 2;
2342 goto yyreturn;
2343
2344 yyabort:
2345 yyresult = 1;
2346 goto yyreturn;
2347
2348 yyaccept:
2349 #if YYBTYACC
2350 if (yyps->save) goto yyvalid;
2351 #endif /* YYBTYACC */
2352 yyresult = 0;
2353
2354 yyreturn:
2355 #if defined(YYDESTRUCT_CALL)
2356 if (yychar != YYEOF && yychar != YYEMPTY)
2357 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2358 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc);
2359 #else
2360 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval);
2361 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
2362
2363 {
2364 YYSTYPE *pv;
2365 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2366 YYLTYPE *pp;
2367
2368 for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp)
2369 YYDESTRUCT_CALL("cleanup: discarding state",
2370 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp);
2371 #else
2372 for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv)
2373 YYDESTRUCT_CALL("cleanup: discarding state",
2374 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv);
2375 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
2376 }
2377 #endif /* defined(YYDESTRUCT_CALL) */
2378
2379 #if YYBTYACC
2380 if (yyerrctx)
2381 {
2382 yyFreeState(yyerrctx);
2383 yyerrctx = NULL;
2384 }
2385 while (yyps)
2386 {
2387 YYParseState *save = yyps;
2388 yyps = save->save;
2389 save->save = NULL;
2390 yyFreeState(save);
2391 }
2392 while (yypath)
2393 {
2394 YYParseState *save = yypath;
2395 yypath = save->save;
2396 save->save = NULL;
2397 yyFreeState(save);
2398 }
2399 #endif /* YYBTYACC */
2400 yyfreestack(&yystack);
2401 return (yyresult);
2402 }
2403