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