1 /* original parser id follows */
2 /* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */
3 /* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */
8 #define YYCHECK "yyyymmdd"
11 #define yyclearin (yychar = YYEMPTY)
12 #define yyerrok (yyerrflag = 0)
13 #define YYRECOVERING() (yyerrflag != 0)
18 #define YYDEBUGSTR (yytrial ? YYPREFIX "debug(trial)" : YYPREFIX "debug")
21 #define yyparse demo_parse
25 #define yylex demo_lex
29 #define yyerror demo_error
33 #define yychar demo_char
37 #define yyval demo_val
41 #define yylval demo_lval
45 #define yydebug demo_debug
49 #define yynerrs demo_nerrs
53 #define yyerrflag demo_errflag
54 #endif /* yyerrflag */
57 #define yylhs demo_lhs
61 #define yylen demo_len
65 #define yydefred demo_defred
69 #define yystos demo_stos
73 #define yydgoto demo_dgoto
77 #define yysindex demo_sindex
81 #define yyrindex demo_rindex
85 #define yygindex demo_gindex
89 #define yytable demo_table
93 #define yycheck demo_check
97 #define yyname demo_name
101 #define yyrule demo_rule
105 #define yyloc demo_loc
109 #define yylloc demo_lloc
115 #define yycindex demo_cindex
116 #endif /* yycindex */
119 #define yyctable demo_ctable
120 #endif /* yyctable */
122 #endif /* YYBTYACC */
124 #define YYPREFIX "demo_"
128 #line 15 "btyacc_demo.y"
129 /* dummy types just for compile check */
131 typedef int Decl_List;
133 typedef int Expr_List;
136 enum Operator { ADD, SUB, MUL, MOD, DIV, DEREF };
138 typedef unsigned char bool;
139 typedef struct Decl {
142 bool (*istype)(void);
145 #include "btyacc_demo.tab.h"
149 #undef YYSTYPE_IS_DECLARED
150 #define YYSTYPE_IS_DECLARED 1
152 #ifndef YYSTYPE_IS_DECLARED
153 #define YYSTYPE_IS_DECLARED 1
154 #line 36 "btyacc_demo.y"
165 #endif /* !YYSTYPE_IS_DECLARED */
166 #line 167 "btyacc_demo.tab.c"
168 #if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
169 /* Default: YYLTYPE is the text position type. */
170 typedef struct YYLTYPE
178 #define YYLTYPE_IS_DECLARED 1
180 #define YYRHSLOC(rhs, k) ((rhs)[k])
182 /* compatibility with bison */
184 /* compatibility with FreeBSD */
185 # ifdef YYPARSE_PARAM_TYPE
186 # define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
188 # define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
191 # define YYPARSE_DECL() yyparse(void)
194 /* Parameters sent to lex. */
196 # define YYLEX_DECL() yylex(void *YYLEX_PARAM)
197 # define YYLEX yylex(YYLEX_PARAM)
199 # define YYLEX_DECL() yylex(void)
200 # define YYLEX yylex()
203 /* Parameters sent to yyerror. */
205 #define YYERROR_DECL() yyerror(YYLTYPE *loc, const char *s)
208 #define YYERROR_CALL(msg) yyerror(&yylloc, msg)
211 #ifndef YYDESTRUCT_DECL
212 #define YYDESTRUCT_DECL() yydestruct(const char *msg, int psymb, YYSTYPE *val, YYLTYPE *loc)
214 #ifndef YYDESTRUCT_CALL
215 #define YYDESTRUCT_CALL(msg, psymb, val, loc) yydestruct(msg, psymb, val, loc)
218 extern int YYPARSE_DECL();
233 #define YYERRCODE 256
235 static const YYINT demo_lhs[] = { -1,
236 15, 15, 15, 12, 18, 0, 4, 19, 4, 2,
237 20, 2, 10, 10, 13, 13, 11, 11, 11, 11,
238 11, 14, 14, 21, 22, 3, 3, 8, 8, 23,
239 24, 8, 8, 8, 8, 16, 16, 17, 17, 9,
240 1, 1, 1, 1, 1, 1, 1, 1, 5, 5,
241 25, 26, 5, 5, 27, 5, 6, 6, 7,
243 static const YYINT demo_len[] = { 2,
244 0, 1, 3, 2, 0, 2, 0, 0, 3, 3,
245 0, 4, 1, 3, 0, 2, 1, 1, 1, 1,
246 1, 1, 1, 0, 0, 5, 1, 0, 1, 0,
247 0, 5, 5, 5, 6, 0, 1, 4, 1, 2,
248 4, 4, 4, 4, 4, 3, 1, 1, 1, 2,
249 0, 0, 11, 8, 0, 2, 0, 3, 4,
251 static const YYINT demo_defred[] = { 5,
252 0, 7, 0, 0, 19, 20, 21, 22, 23, 2,
253 9, 0, 13, 18, 17, 0, 15, 30, 29, 0,
254 0, 0, 0, 0, 31, 10, 24, 24, 24, 0,
255 14, 3, 16, 25, 0, 25, 0, 0, 8, 12,
256 0, 0, 0, 39, 0, 0, 0, 8, 47, 48,
257 0, 57, 0, 32, 0, 0, 15, 30, 0, 30,
258 30, 30, 30, 30, 34, 0, 0, 0, 46, 0,
259 0, 0, 0, 0, 59, 0, 38, 0, 0, 43,
260 45, 44, 0, 0, 49, 58, 0, 30, 50, 56,
261 0, 0, 0, 51, 0, 0, 52, 0, 53,
263 #if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING)
264 static const YYINT demo_stos[] = { 0,
265 271, 289, 275, 290, 261, 262, 263, 264, 265, 269,
266 273, 281, 282, 283, 285, 286, 42, 40, 259, 274,
267 279, 290, 259, 284, 294, 59, 44, 40, 91, 291,
268 282, 269, 285, 292, 295, 292, 292, 292, 123, 278,
269 293, 279, 293, 280, 281, 287, 288, 42, 259, 260,
270 272, 290, 279, 41, 279, 279, 41, 44, 290, 43,
271 45, 42, 47, 37, 93, 277, 284, 294, 272, 294,
272 294, 294, 294, 294, 125, 290, 280, 272, 272, 272,
273 272, 272, 266, 272, 273, 276, 298, 40, 59, 278,
274 294, 272, 41, 267, 296, 276, 268, 297, 276,
276 #endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */
277 static const YYINT demo_dgoto[] = { 1,
278 84, 85, 20, 3, 86, 66, 40, 21, 44, 12,
279 13, 14, 24, 15, 16, 46, 47, 2, 22, 30,
280 34, 41, 25, 35, 95, 98, 87,
282 static const YYINT demo_sindex[] = { 0,
283 0, 0, 0, -103, 0, 0, 0, 0, 0, 0,
284 0, -31, 0, 0, 0, -238, 0, 0, 0, 4,
285 -36, -103, 0, -133, 0, 0, 0, 0, 0, -94,
286 0, 0, 0, 0, -40, 0, -103, -33, 0, 0,
287 -40, -25, -40, 0, -31, 8, 15, 0, 0, 0,
288 -2, 0, -36, 0, -36, -36, 0, 0, -33, 0,
289 0, 0, 0, 0, 0, -92, -133, -103, 0, -33,
290 -33, -33, -33, -33, 0, -8, 0, 23, 23, 0,
291 0, 0, 11, 75, 0, 0, -94, 0, 0, 0,
292 -33, 96, -194, 0, -8, 0, 0, -8, 0,
294 static const YYINT demo_rindex[] = { 0,
295 0, 0, 1, -181, 0, 0, 0, 0, 0, 0,
296 0, 17, 0, 0, 0, 0, 0, 0, 0, 0,
297 -39, -181, 12, -34, 0, 0, 0, 0, 0, 0,
298 0, 0, 0, 0, -5, 0, -11, 0, 0, 0,
299 -17, 0, 28, 0, -41, 0, 47, 0, 0, 0,
300 0, 0, -13, 0, 18, 70, 0, 0, 0, 0,
301 0, 0, 0, 0, 0, -19, -27, -181, 0, 0,
302 0, 0, 0, 0, 0, -29, 0, 56, 64, 0,
303 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
304 0, 0, 0, 0, -29, -30, 0, -29, 0,
307 static const YYINT demo_cindex[] = { 0,
308 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
309 0, -22, 0, 0, 0, 0, 0, 0, 0, 0,
310 0, 0, -179, 0, 0, 0, 0, 0, 0, 0,
311 0, 0, 0, 0, 52, 0, 0, 0, 0, 0,
312 58, 0, 62, 0, -21, 0, 0, 0, 0, 0,
313 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
314 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
315 0, 0, 0, 0, 0, -146, 0, 0, 0, 0,
316 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
317 0, 0, 0, 0, -143, -147, 0, -134, 0,
320 static const YYINT demo_gindex[] = { 0,
321 9, 143, 0, 0, 50, 0, 63, 101, 83, 7,
322 130, 0, 98, 2, 0, 0, 0, 0, 19, 0,
323 10, 117, 66, 0, 0, 0, 0,
325 #define YYTABLESIZE 286
326 static const YYINT demo_table[] = { 28,
327 6, 17, 28, 28, 27, 24, 24, 24, 48, 24,
328 17, 54, 35, 35, 28, 54, 35, 0, 0, 27,
329 23, 4, 8, 28, 24, 33, 28, 33, 39, 36,
330 33, 35, 75, 48, 64, 28, 36, 37, 38, 62,
331 60, 28, 61, 45, 63, 33, 51, 27, 57, 28,
332 88, 4, 4, 4, 29, 4, 24, 52, 58, 64,
333 28, 26, 26, 35, 62, 29, 59, 69, 33, 63,
334 4, 28, 94, 28, 45, 28, 26, 1, 78, 79,
335 80, 81, 82, 11, 76, 28, 28, 37, 24, 6,
336 65, 0, 54, 55, 54, 35, 41, 0, 41, 92,
337 41, 0, 4, 8, 42, 28, 42, 28, 42, 33,
338 40, 64, 9, 40, 41, 9, 62, 60, 28, 61,
339 12, 63, 42, 68, 9, 70, 71, 72, 73, 74,
340 8, 9, 64, 89, 4, 42, 93, 62, 60, 28,
341 61, 53, 63, 55, 96, 56, 11, 99, 41, 90,
342 77, 31, 43, 91, 67, 0, 42, 5, 6, 7,
343 8, 9, 0, 0, 0, 10, 0, 0, 0, 0,
344 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
345 0, 0, 0, 0, 0, 0, 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, 19, 8,
349 8, 8, 8, 8, 24, 49, 50, 8, 54, 54,
350 54, 54, 54, 54, 54, 54, 3, 3, 54, 8,
351 8, 8, 8, 8, 8, 8, 8, 1, 0, 8,
352 0, 50, 5, 6, 7, 8, 9, 83, 0, 8,
353 10, 8, 8, 8, 8, 8, 0, 0, 0, 8,
354 4, 0, 4, 4, 4, 4, 4, 8, 8, 8,
357 static const YYINT demo_check[] = { 41,
358 0, 42, 44, 40, 44, 40, 41, 42, 42, 44,
359 42, 42, 40, 41, 40, 41, 44, 40, 40, 59,
360 259, 3, 42, 41, 59, 24, 44, 41, 123, 41,
361 44, 59, 125, 42, 37, 41, 27, 28, 29, 42,
362 43, 59, 45, 37, 47, 59, 38, 44, 41, 91,
363 40, 40, 41, 42, 91, 44, 91, 39, 44, 37,
364 44, 44, 59, 91, 42, 91, 48, 59, 67, 47,
365 59, 44, 267, 91, 68, 59, 59, 259, 70, 71,
366 72, 73, 74, 123, 66, 91, 59, 41, 123, 269,
367 93, 40, 123, 123, 125, 123, 41, 40, 43, 91,
368 45, 40, 91, 123, 41, 123, 43, 91, 45, 123,
369 41, 37, 259, 44, 59, 259, 42, 43, 91, 45,
370 268, 47, 59, 58, 259, 60, 61, 62, 63, 64,
371 264, 265, 37, 59, 123, 35, 41, 42, 43, 123,
372 45, 41, 47, 43, 95, 45, 4, 98, 93, 87,
373 68, 22, 36, 88, 57, -1, 93, 261, 262, 263,
374 264, 265, -1, -1, -1, 269, -1, -1, -1, -1,
375 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
376 -1, -1, -1, -1, -1, -1, -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, 259, 261,
380 262, 263, 264, 265, 259, 259, 260, 269, 259, 260,
381 261, 262, 263, 264, 265, 266, 259, 259, 269, 259,
382 260, 261, 262, 263, 264, 265, 266, 259, -1, 269,
383 -1, 260, 261, 262, 263, 264, 265, 266, -1, 259,
384 269, 261, 262, 263, 264, 265, -1, -1, -1, 269,
385 259, -1, 261, 262, 263, 264, 265, 261, 262, 263,
386 264, 265, -1, -1, -1, 269,
389 static const YYINT demo_ctable[] = { 18,
390 28, -1, 19, 8, -1, 32, 4, -1, 49, 1,
391 -1, 97, 54, -1, -1, -1, -1, -1, -1, -1,
392 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
393 -1, -1, -1, -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,
425 #define YYMAXTOKEN 269
426 #define YYUNDFTOKEN 299
427 #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
429 static const char *const demo_name[] = {
431 "$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,
432 "'%'",0,0,"'('","')'","'*'","'+'","','","'-'","'.'","'/'",0,0,0,0,0,0,0,0,0,0,0,
433 "';'",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,0,0,0,0,0,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,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,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,"error","PREFIX","POSTFIX","ID","CONSTANT","EXTERN",
439 "REGISTER","STATIC","CONST","VOLATILE","IF","THEN","ELSE","CLCL","$accept",
440 "input","expr","decl","declarator_list","decl_list","statement",
441 "statement_list","block_statement","declarator","formal_arg","decl_specs",
442 "decl_spec","typename","cv_quals","cv_qual","opt_scope","formal_arg_list",
443 "nonempty_formal_arg_list","$$1","$$2","$$3","$$4","$$5","$$6","$$7","$$8",
444 "$$9","$$10","illegal-symbol",
446 static const char *const demo_rule[] = {
450 "opt_scope : opt_scope ID CLCL",
451 "typename : opt_scope ID",
453 "input : $$1 decl_list",
456 "decl_list : decl_list $$2 decl",
457 "decl : decl_specs declarator_list ';'",
459 "decl : decl_specs declarator $$3 block_statement",
460 "decl_specs : decl_spec",
461 "decl_specs : decl_specs $$2 decl_spec",
463 "cv_quals : cv_quals cv_qual",
464 "decl_spec : cv_qual",
465 "decl_spec : typename",
466 "decl_spec : EXTERN",
467 "decl_spec : REGISTER",
468 "decl_spec : STATIC",
470 "cv_qual : VOLATILE",
473 "declarator_list : declarator_list ',' $$4 $$5 declarator",
474 "declarator_list : declarator",
479 "declarator : '(' $$6 $$7 declarator ')'",
480 "declarator : '*' cv_quals $$4 $$5 declarator",
481 "declarator : declarator '[' $$4 expr ']'",
482 "declarator : declarator '(' $$4 formal_arg_list ')' cv_quals",
484 "formal_arg_list : nonempty_formal_arg_list",
485 "nonempty_formal_arg_list : nonempty_formal_arg_list ',' $$6 formal_arg",
486 "nonempty_formal_arg_list : formal_arg",
487 "formal_arg : decl_specs declarator",
488 "expr : expr '+' $$6 expr",
489 "expr : expr '-' $$6 expr",
490 "expr : expr '*' $$6 expr",
491 "expr : expr '%' $$6 expr",
492 "expr : expr '/' $$6 expr",
493 "expr : '*' $$2 expr",
497 "statement : expr ';'",
500 "statement : IF '(' $$6 expr ')' THEN $$8 statement ELSE $$9 statement",
501 "statement : IF '(' $$6 expr ')' THEN $$8 statement",
503 "statement : $$10 block_statement",
505 "statement_list : statement_list $$2 statement",
506 "block_statement : '{' $$2 statement_list '}'",
521 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
522 YYLTYPE yyloc; /* position returned by actions */
523 YYLTYPE yylloc; /* position from the lexer */
526 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
527 #ifndef YYLLOC_DEFAULT
528 #define YYLLOC_DEFAULT(loc, rhs, n) \
533 (loc).first_line = YYRHSLOC(rhs, 0).last_line; \
534 (loc).first_column = YYRHSLOC(rhs, 0).last_column; \
535 (loc).last_line = YYRHSLOC(rhs, 0).last_line; \
536 (loc).last_column = YYRHSLOC(rhs, 0).last_column; \
540 (loc).first_line = YYRHSLOC(rhs, 1).first_line; \
541 (loc).first_column = YYRHSLOC(rhs, 1).first_column; \
542 (loc).last_line = YYRHSLOC(rhs, n).last_line; \
543 (loc).last_column = YYRHSLOC(rhs, n).last_column; \
546 #endif /* YYLLOC_DEFAULT */
547 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
550 #ifndef YYLVQUEUEGROWTH
551 #define YYLVQUEUEGROWTH 32
553 #endif /* YYBTYACC */
555 /* define the initial stack-sizes */
558 #define YYMAXDEPTH YYSTACKSIZE
561 #define YYSTACKSIZE YYMAXDEPTH
563 #define YYSTACKSIZE 10000
564 #define YYMAXDEPTH 10000
568 #ifndef YYINITSTACKSIZE
569 #define YYINITSTACKSIZE 200
579 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
586 struct YYParseState_s
588 struct YYParseState_s *save; /* Previously saved parser state */
589 YYSTACKDATA yystack; /* saved parser stack */
590 int state; /* saved parser state */
591 int errflag; /* saved error recovery status */
592 int lexeme; /* saved index of the conflict lexeme in the lexical queue */
593 YYINT ctry; /* saved index in yyctable[] for this conflict */
595 typedef struct YYParseState_s YYParseState;
596 #endif /* YYBTYACC */
597 /* variables for the parser stack */
598 static YYSTACKDATA yystack;
601 /* Current parser state */
602 static YYParseState *yyps = 0;
604 /* yypath != NULL: do the full parse, starting at *yypath parser state. */
605 static YYParseState *yypath = 0;
607 /* Base of the lexical value queue */
608 static YYSTYPE *yylvals = 0;
610 /* Current position at lexical value queue */
611 static YYSTYPE *yylvp = 0;
613 /* End position of lexical value queue */
614 static YYSTYPE *yylve = 0;
616 /* The last allocated position at the lexical value queue */
617 static YYSTYPE *yylvlim = 0;
619 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
620 /* Base of the lexical position queue */
621 static YYLTYPE *yylpsns = 0;
623 /* Current position at lexical position queue */
624 static YYLTYPE *yylpp = 0;
626 /* End position of lexical position queue */
627 static YYLTYPE *yylpe = 0;
629 /* The last allocated position at the lexical position queue */
630 static YYLTYPE *yylplim = 0;
633 /* Current position at lexical token queue */
634 static YYINT *yylexp = 0;
636 static YYINT *yylexemes = 0;
637 #endif /* YYBTYACC */
638 #line 200 "btyacc_demo.y"
640 extern int YYLEX_DECL();
641 extern void YYERROR_DECL();
643 extern Scope *global_scope;
645 extern Decl * lookup(Scope *scope, char *id);
646 extern Scope * new_scope(Scope *outer_scope);
647 extern Scope * start_fn_def(Scope *scope, Decl *fn_decl);
648 extern void finish_fn_def(Decl *fn_decl, Code *block);
649 extern Type * type_combine(Type *specs, Type *spec);
650 extern Type * bare_extern(void);
651 extern Type * bare_register(void);
652 extern Type * bare_static(void);
653 extern Type * bare_const(void);
654 extern Type * bare_volatile(void);
655 extern Decl * declare(Scope *scope, char *id, Type *type);
656 extern Decl * make_pointer(Decl *decl, Type *type);
657 extern Decl * make_array(Type *type, Expr *expr);
658 extern Decl * build_function(Decl *decl, Decl_List *dlist, Type *type);
659 extern Decl_List * append_dlist(Decl_List *dlist, Decl *decl);
660 extern Decl_List * build_dlist(Decl *decl);
661 extern Expr * build_expr(Expr *left, enum Operator op, Expr *right);
662 extern Expr * var_expr(Scope *scope, char *id);
663 extern Code * build_expr_code(Expr *expr);
664 extern Code * build_if(Expr *cond_expr, Code *then_stmt, Code *else_stmt);
665 extern Code * code_append(Code *stmt_list, Code *stmt);
666 #line 667 "btyacc_demo.tab.c"
668 /* Release memory associated with symbol. */
669 #if ! defined YYDESTRUCT_IS_DECLARED
676 #line 83 "btyacc_demo.y"
677 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
679 (*loc).first_line, (*loc).first_column,
680 (*loc).last_line, (*loc).last_column);
681 /* in this example, we don't know what to do here */ }
683 #line 684 "btyacc_demo.tab.c"
685 #line 83 "btyacc_demo.y"
686 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
688 (*loc).first_line, (*loc).first_column,
689 (*loc).last_line, (*loc).last_column);
690 /* in this example, we don't know what to do here */ }
692 #line 693 "btyacc_demo.tab.c"
694 #line 83 "btyacc_demo.y"
695 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
697 (*loc).first_line, (*loc).first_column,
698 (*loc).last_line, (*loc).last_column);
699 /* in this example, we don't know what to do here */ }
701 #line 702 "btyacc_demo.tab.c"
703 #line 83 "btyacc_demo.y"
704 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
706 (*loc).first_line, (*loc).first_column,
707 (*loc).last_line, (*loc).last_column);
708 /* in this example, we don't know what to do here */ }
710 #line 711 "btyacc_demo.tab.c"
712 #line 83 "btyacc_demo.y"
713 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
715 (*loc).first_line, (*loc).first_column,
716 (*loc).last_line, (*loc).last_column);
717 /* in this example, we don't know what to do here */ }
719 #line 720 "btyacc_demo.tab.c"
721 #line 83 "btyacc_demo.y"
722 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
724 (*loc).first_line, (*loc).first_column,
725 (*loc).last_line, (*loc).last_column);
726 /* in this example, we don't know what to do here */ }
728 #line 729 "btyacc_demo.tab.c"
730 #line 83 "btyacc_demo.y"
731 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
733 (*loc).first_line, (*loc).first_column,
734 (*loc).last_line, (*loc).last_column);
735 /* in this example, we don't know what to do here */ }
737 #line 738 "btyacc_demo.tab.c"
739 #line 83 "btyacc_demo.y"
740 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
742 (*loc).first_line, (*loc).first_column,
743 (*loc).last_line, (*loc).last_column);
744 /* in this example, we don't know what to do here */ }
746 #line 747 "btyacc_demo.tab.c"
748 #line 83 "btyacc_demo.y"
749 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
751 (*loc).first_line, (*loc).first_column,
752 (*loc).last_line, (*loc).last_column);
753 /* in this example, we don't know what to do here */ }
755 #line 756 "btyacc_demo.tab.c"
757 #line 83 "btyacc_demo.y"
758 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
760 (*loc).first_line, (*loc).first_column,
761 (*loc).last_line, (*loc).last_column);
762 /* in this example, we don't know what to do here */ }
764 #line 765 "btyacc_demo.tab.c"
766 #line 78 "btyacc_demo.y"
767 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
769 (*loc).first_line, (*loc).first_column,
770 (*loc).last_line, (*loc).last_column);
773 #line 774 "btyacc_demo.tab.c"
775 #line 78 "btyacc_demo.y"
776 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
778 (*loc).first_line, (*loc).first_column,
779 (*loc).last_line, (*loc).last_column);
782 #line 783 "btyacc_demo.tab.c"
784 #line 83 "btyacc_demo.y"
785 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
787 (*loc).first_line, (*loc).first_column,
788 (*loc).last_line, (*loc).last_column);
789 /* in this example, we don't know what to do here */ }
791 #line 792 "btyacc_demo.tab.c"
793 #line 83 "btyacc_demo.y"
794 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
796 (*loc).first_line, (*loc).first_column,
797 (*loc).last_line, (*loc).last_column);
798 /* in this example, we don't know what to do here */ }
800 #line 801 "btyacc_demo.tab.c"
802 #line 83 "btyacc_demo.y"
803 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
805 (*loc).first_line, (*loc).first_column,
806 (*loc).last_line, (*loc).last_column);
807 /* in this example, we don't know what to do here */ }
809 #line 810 "btyacc_demo.tab.c"
811 #line 83 "btyacc_demo.y"
812 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
814 (*loc).first_line, (*loc).first_column,
815 (*loc).last_line, (*loc).last_column);
816 /* in this example, we don't know what to do here */ }
818 #line 819 "btyacc_demo.tab.c"
820 #line 83 "btyacc_demo.y"
821 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
823 (*loc).first_line, (*loc).first_column,
824 (*loc).last_line, (*loc).last_column);
825 /* in this example, we don't know what to do here */ }
827 #line 828 "btyacc_demo.tab.c"
829 #line 83 "btyacc_demo.y"
830 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
832 (*loc).first_line, (*loc).first_column,
833 (*loc).last_line, (*loc).last_column);
834 /* in this example, we don't know what to do here */ }
836 #line 837 "btyacc_demo.tab.c"
838 #line 83 "btyacc_demo.y"
839 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
841 (*loc).first_line, (*loc).first_column,
842 (*loc).last_line, (*loc).last_column);
843 /* in this example, we don't know what to do here */ }
845 #line 846 "btyacc_demo.tab.c"
847 #line 83 "btyacc_demo.y"
848 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
850 (*loc).first_line, (*loc).first_column,
851 (*loc).last_line, (*loc).last_column);
852 /* in this example, we don't know what to do here */ }
854 #line 855 "btyacc_demo.tab.c"
856 #line 83 "btyacc_demo.y"
857 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
859 (*loc).first_line, (*loc).first_column,
860 (*loc).last_line, (*loc).last_column);
861 /* in this example, we don't know what to do here */ }
863 #line 864 "btyacc_demo.tab.c"
865 #line 83 "btyacc_demo.y"
866 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
868 (*loc).first_line, (*loc).first_column,
869 (*loc).last_line, (*loc).last_column);
870 /* in this example, we don't know what to do here */ }
872 #line 873 "btyacc_demo.tab.c"
874 #line 83 "btyacc_demo.y"
875 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
877 (*loc).first_line, (*loc).first_column,
878 (*loc).last_line, (*loc).last_column);
879 /* in this example, we don't know what to do here */ }
881 #line 882 "btyacc_demo.tab.c"
883 #line 83 "btyacc_demo.y"
884 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
886 (*loc).first_line, (*loc).first_column,
887 (*loc).last_line, (*loc).last_column);
888 /* in this example, we don't know what to do here */ }
890 #line 891 "btyacc_demo.tab.c"
892 #line 83 "btyacc_demo.y"
893 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
895 (*loc).first_line, (*loc).first_column,
896 (*loc).last_line, (*loc).last_column);
897 /* in this example, we don't know what to do here */ }
899 #line 900 "btyacc_demo.tab.c"
901 #line 83 "btyacc_demo.y"
902 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
904 (*loc).first_line, (*loc).first_column,
905 (*loc).last_line, (*loc).last_column);
906 /* in this example, we don't know what to do here */ }
908 #line 909 "btyacc_demo.tab.c"
910 #line 83 "btyacc_demo.y"
911 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
913 (*loc).first_line, (*loc).first_column,
914 (*loc).last_line, (*loc).last_column);
915 /* in this example, we don't know what to do here */ }
917 #line 918 "btyacc_demo.tab.c"
919 #line 83 "btyacc_demo.y"
920 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
922 (*loc).first_line, (*loc).first_column,
923 (*loc).last_line, (*loc).last_column);
924 /* in this example, we don't know what to do here */ }
926 #line 927 "btyacc_demo.tab.c"
928 #line 83 "btyacc_demo.y"
929 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
931 (*loc).first_line, (*loc).first_column,
932 (*loc).last_line, (*loc).last_column);
933 /* in this example, we don't know what to do here */ }
935 #line 936 "btyacc_demo.tab.c"
937 #line 78 "btyacc_demo.y"
938 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
940 (*loc).first_line, (*loc).first_column,
941 (*loc).last_line, (*loc).last_column);
944 #line 945 "btyacc_demo.tab.c"
946 #line 67 "btyacc_demo.y"
947 { /* 'msg' is a 'char *' indicating the context of destructor invocation*/
948 printf("%s accessed by symbol \"decl\" (case s.b. 273) @ position[%d,%d..%d,%d]\n",
950 (*loc).first_line, (*loc).first_column,
951 (*loc).last_line, (*loc).last_column);
952 free((*val).decl->scope); free((*val).decl->type); }
954 #line 955 "btyacc_demo.tab.c"
956 #line 83 "btyacc_demo.y"
957 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
959 (*loc).first_line, (*loc).first_column,
960 (*loc).last_line, (*loc).last_column);
961 /* in this example, we don't know what to do here */ }
963 #line 964 "btyacc_demo.tab.c"
965 #line 83 "btyacc_demo.y"
966 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
968 (*loc).first_line, (*loc).first_column,
969 (*loc).last_line, (*loc).last_column);
970 /* in this example, we don't know what to do here */ }
972 #line 973 "btyacc_demo.tab.c"
974 #line 78 "btyacc_demo.y"
975 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
977 (*loc).first_line, (*loc).first_column,
978 (*loc).last_line, (*loc).last_column);
981 #line 982 "btyacc_demo.tab.c"
983 #line 78 "btyacc_demo.y"
984 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
986 (*loc).first_line, (*loc).first_column,
987 (*loc).last_line, (*loc).last_column);
990 #line 991 "btyacc_demo.tab.c"
992 #line 78 "btyacc_demo.y"
993 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
995 (*loc).first_line, (*loc).first_column,
996 (*loc).last_line, (*loc).last_column);
999 #line 1000 "btyacc_demo.tab.c"
1001 #line 73 "btyacc_demo.y"
1002 { printf("%s accessed by symbol with type <decl> (case s.b. 279 & 280) @ position[%d,%d..%d,%d]\n",
1004 (*loc).first_line, (*loc).first_column,
1005 (*loc).last_line, (*loc).last_column);
1006 free((*val).decl); }
1008 #line 1009 "btyacc_demo.tab.c"
1010 #line 73 "btyacc_demo.y"
1011 { printf("%s accessed by symbol with type <decl> (case s.b. 279 & 280) @ position[%d,%d..%d,%d]\n",
1013 (*loc).first_line, (*loc).first_column,
1014 (*loc).last_line, (*loc).last_column);
1015 free((*val).decl); }
1017 #line 1018 "btyacc_demo.tab.c"
1019 #line 78 "btyacc_demo.y"
1020 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1022 (*loc).first_line, (*loc).first_column,
1023 (*loc).last_line, (*loc).last_column);
1024 free((*val).type); }
1026 #line 1027 "btyacc_demo.tab.c"
1028 #line 78 "btyacc_demo.y"
1029 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1031 (*loc).first_line, (*loc).first_column,
1032 (*loc).last_line, (*loc).last_column);
1033 free((*val).type); }
1035 #line 1036 "btyacc_demo.tab.c"
1037 #line 78 "btyacc_demo.y"
1038 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1040 (*loc).first_line, (*loc).first_column,
1041 (*loc).last_line, (*loc).last_column);
1042 free((*val).type); }
1044 #line 1045 "btyacc_demo.tab.c"
1046 #line 78 "btyacc_demo.y"
1047 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1049 (*loc).first_line, (*loc).first_column,
1050 (*loc).last_line, (*loc).last_column);
1051 free((*val).type); }
1053 #line 1054 "btyacc_demo.tab.c"
1055 #line 78 "btyacc_demo.y"
1056 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1058 (*loc).first_line, (*loc).first_column,
1059 (*loc).last_line, (*loc).last_column);
1060 free((*val).type); }
1062 #line 1063 "btyacc_demo.tab.c"
1064 #line 78 "btyacc_demo.y"
1065 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1067 (*loc).first_line, (*loc).first_column,
1068 (*loc).last_line, (*loc).last_column);
1069 free((*val).scope); }
1071 #line 1072 "btyacc_demo.tab.c"
1073 #line 78 "btyacc_demo.y"
1074 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1076 (*loc).first_line, (*loc).first_column,
1077 (*loc).last_line, (*loc).last_column);
1078 free((*val).dlist); }
1080 #line 1081 "btyacc_demo.tab.c"
1082 #line 78 "btyacc_demo.y"
1083 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1085 (*loc).first_line, (*loc).first_column,
1086 (*loc).last_line, (*loc).last_column);
1087 free((*val).dlist); }
1089 #line 1090 "btyacc_demo.tab.c"
1091 #line 78 "btyacc_demo.y"
1092 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1094 (*loc).first_line, (*loc).first_column,
1095 (*loc).last_line, (*loc).last_column);
1096 free((*val).scope); }
1098 #line 1099 "btyacc_demo.tab.c"
1100 #line 78 "btyacc_demo.y"
1101 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1103 (*loc).first_line, (*loc).first_column,
1104 (*loc).last_line, (*loc).last_column);
1105 free((*val).scope); }
1107 #line 1108 "btyacc_demo.tab.c"
1109 #line 78 "btyacc_demo.y"
1110 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1112 (*loc).first_line, (*loc).first_column,
1113 (*loc).last_line, (*loc).last_column);
1114 free((*val).scope); }
1116 #line 1117 "btyacc_demo.tab.c"
1118 #line 78 "btyacc_demo.y"
1119 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1121 (*loc).first_line, (*loc).first_column,
1122 (*loc).last_line, (*loc).last_column);
1123 free((*val).scope); }
1125 #line 1126 "btyacc_demo.tab.c"
1127 #line 78 "btyacc_demo.y"
1128 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1130 (*loc).first_line, (*loc).first_column,
1131 (*loc).last_line, (*loc).last_column);
1132 free((*val).type); }
1134 #line 1135 "btyacc_demo.tab.c"
1136 #line 78 "btyacc_demo.y"
1137 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1139 (*loc).first_line, (*loc).first_column,
1140 (*loc).last_line, (*loc).last_column);
1141 free((*val).scope); }
1143 #line 1144 "btyacc_demo.tab.c"
1145 #line 78 "btyacc_demo.y"
1146 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1148 (*loc).first_line, (*loc).first_column,
1149 (*loc).last_line, (*loc).last_column);
1150 free((*val).type); }
1152 #line 1153 "btyacc_demo.tab.c"
1154 #line 78 "btyacc_demo.y"
1155 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1157 (*loc).first_line, (*loc).first_column,
1158 (*loc).last_line, (*loc).last_column);
1159 free((*val).scope); }
1161 #line 1162 "btyacc_demo.tab.c"
1163 #line 78 "btyacc_demo.y"
1164 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1166 (*loc).first_line, (*loc).first_column,
1167 (*loc).last_line, (*loc).last_column);
1168 free((*val).scope); }
1170 #line 1171 "btyacc_demo.tab.c"
1172 #line 78 "btyacc_demo.y"
1173 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1175 (*loc).first_line, (*loc).first_column,
1176 (*loc).last_line, (*loc).last_column);
1177 free((*val).scope); }
1179 #line 1180 "btyacc_demo.tab.c"
1182 #define YYDESTRUCT_IS_DECLARED 1
1185 /* For use in generated program */
1186 #define yydepth (int)(yystack.s_mark - yystack.s_base)
1188 #define yytrial (yyps->save)
1189 #endif /* YYBTYACC */
1192 #include <stdio.h> /* needed for printf */
1195 #include <stdlib.h> /* needed for malloc, etc */
1196 #include <string.h> /* needed for memset */
1198 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
1199 static int yygrowstack(YYSTACKDATA *data)
1205 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1209 if ((newsize = data->stacksize) == 0)
1210 newsize = YYINITSTACKSIZE;
1211 else if (newsize >= YYMAXDEPTH)
1213 else if ((newsize *= 2) > YYMAXDEPTH)
1214 newsize = YYMAXDEPTH;
1216 i = (int) (data->s_mark - data->s_base);
1217 newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
1221 data->s_base = newss;
1222 data->s_mark = newss + i;
1224 newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
1228 data->l_base = newvs;
1229 data->l_mark = newvs + i;
1231 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1232 newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps));
1236 data->p_base = newps;
1237 data->p_mark = newps + i;
1240 data->stacksize = newsize;
1241 data->s_last = data->s_base + newsize - 1;
1245 fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize);
1250 #if YYPURE || defined(YY_NO_LEAKS)
1251 static void yyfreestack(YYSTACKDATA *data)
1255 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1258 memset(data, 0, sizeof(*data));
1261 #define yyfreestack(data) /* nothing */
1262 #endif /* YYPURE || defined(YY_NO_LEAKS) */
1265 static YYParseState *
1266 yyNewState(unsigned size)
1268 YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState));
1269 if (p == NULL) return NULL;
1271 p->yystack.stacksize = size;
1274 p->yystack.s_base = NULL;
1275 p->yystack.l_base = NULL;
1276 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1277 p->yystack.p_base = NULL;
1281 p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT));
1282 if (p->yystack.s_base == NULL) return NULL;
1283 p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE));
1284 if (p->yystack.l_base == NULL) return NULL;
1285 memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE));
1286 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1287 p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE));
1288 if (p->yystack.p_base == NULL) return NULL;
1289 memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE));
1296 yyFreeState(YYParseState *p)
1298 yyfreestack(&p->yystack);
1301 #endif /* YYBTYACC */
1303 #define YYABORT goto yyabort
1304 #define YYREJECT goto yyabort
1305 #define YYACCEPT goto yyaccept
1306 #define YYERROR goto yyerrlab
1308 #define YYVALID do { if (yyps->save) goto yyvalid; } while(0)
1309 #define YYVALID_NESTED do { if (yyps->save && \
1310 yyps->save->save == 0) goto yyvalid; } while(0)
1311 #endif /* YYBTYACC */
1316 int yym, yyn, yystate, yyresult;
1319 YYParseState *yyerrctx = NULL;
1320 #endif /* YYBTYACC */
1321 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1322 YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */
1327 if ((yys = getenv("YYDEBUG")) != 0)
1330 if (yyn >= '0' && yyn <= '9')
1331 yydebug = yyn - '0';
1334 fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX);
1336 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1337 memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range));
1341 yyps = yyNewState(0); if (yyps == 0) goto yyenomem;
1343 #endif /* YYBTYACC */
1352 memset(&yystack, 0, sizeof(yystack));
1355 if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1356 yystack.s_mark = yystack.s_base;
1357 yystack.l_mark = yystack.l_base;
1358 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1359 yystack.p_mark = yystack.p_base;
1362 *yystack.s_mark = 0;
1365 if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
1372 /* we're currently re-reading tokens */
1374 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1382 /* in trial mode; save scanner results for future parse attempts */
1383 if (yylvp == yylvlim)
1384 { /* Enlarge lexical value queue */
1385 size_t p = (size_t) (yylvp - yylvals);
1386 size_t s = (size_t) (yylvlim - yylvals);
1388 s += YYLVQUEUEGROWTH;
1389 if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
1390 if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
1391 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1392 if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
1394 yylvp = yylve = yylvals + p;
1395 yylvlim = yylvals + s;
1396 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1397 yylpp = yylpe = yylpsns + p;
1398 yylplim = yylpsns + s;
1400 yylexp = yylexemes + p;
1402 *yylexp = (YYINT) YYLEX;
1405 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1412 /* normal operation, no conflict encountered */
1413 #endif /* YYBTYACC */
1417 #endif /* YYBTYACC */
1418 if (yychar < 0) yychar = YYEOF;
1422 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
1423 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)",
1424 YYDEBUGSTR, yydepth, yystate, yychar, yys);
1425 #ifdef YYSTYPE_TOSTRING
1428 #endif /* YYBTYACC */
1429 fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval));
1431 fputc('\n', stderr);
1437 /* Do we have a conflict? */
1438 if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
1439 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
1448 fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n",
1449 YYDEBUGSTR, yydepth, yystate);
1451 /* Switch to the next conflict context */
1453 yypath = save->save;
1456 if (save->state != yystate) YYABORT;
1463 /* Unresolved conflict - start/continue trial parse */
1468 fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate);
1470 fputs("ALREADY in conflict, continuing trial parse.\n", stderr);
1472 fputs("Starting trial parse.\n", stderr);
1475 save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
1476 if (save == NULL) goto yyenomem;
1477 save->save = yyps->save;
1478 save->state = yystate;
1479 save->errflag = yyerrflag;
1480 save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base);
1481 memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1482 save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base);
1483 memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1484 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1485 save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base);
1486 memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1488 ctry = yytable[yyn];
1489 if (yyctable[ctry] == -1)
1492 if (yydebug && yychar >= YYEOF)
1493 fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth);
1498 if (yyps->save == NULL)
1500 /* If this is a first conflict in the stack, start saving lexemes */
1503 yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
1504 if (yylexemes == NULL) goto yyenomem;
1505 yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
1506 if (yylvals == NULL) goto yyenomem;
1507 yylvlim = yylvals + YYLVQUEUEGROWTH;
1508 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1509 yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE));
1510 if (yylpsns == NULL) goto yyenomem;
1511 yylplim = yylpsns + YYLVQUEUEGROWTH;
1516 yylvp = yylve = yylvals;
1517 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1518 yylpp = yylpe = yylpsns;
1521 if (yychar >= YYEOF)
1524 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1527 *yylexp = (YYINT) yychar;
1532 if (yychar >= YYEOF)
1535 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1541 save->lexeme = (int) (yylvp - yylvals);
1544 if (yytable[yyn] == ctry)
1548 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
1549 YYDEBUGSTR, yydepth, yystate, yyctable[ctry]);
1554 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1559 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
1561 yystate = yyctable[ctry];
1562 *++yystack.s_mark = (YYINT) yystate;
1563 *++yystack.l_mark = yylval;
1564 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1565 *++yystack.p_mark = yylloc;
1568 if (yyerrflag > 0) --yyerrflag;
1573 yyn = yyctable[ctry];
1576 } /* End of code dealing with conflicts */
1577 #endif /* YYBTYACC */
1578 if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
1579 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
1583 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
1584 YYDEBUGSTR, yydepth, yystate, yytable[yyn]);
1586 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1587 yystate = yytable[yyn];
1588 *++yystack.s_mark = yytable[yyn];
1589 *++yystack.l_mark = yylval;
1590 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1591 *++yystack.p_mark = yylloc;
1594 if (yyerrflag > 0) --yyerrflag;
1597 if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
1598 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
1603 if (yyerrflag != 0) goto yyinrecovery;
1608 goto yyerrlab; /* redundant goto avoids 'unused label' warning */
1611 /* explicit YYERROR from an action -- pop the rhs of the rule reduced
1612 * before looking for error recovery */
1613 yystack.s_mark -= yym;
1614 yystate = *yystack.s_mark;
1615 yystack.l_mark -= yym;
1616 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1617 yystack.p_mark -= yym;
1625 YYParseState *save = yyps->save;
1628 fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n",
1629 YYDEBUGSTR, yydepth, yystate, yyps->save->state,
1630 (int)(yylvp - yylvals - yyps->save->lexeme));
1632 /* Memorize most forward-looking error state in case it's really an error. */
1633 if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals)
1635 /* Free old saved error context state */
1636 if (yyerrctx) yyFreeState(yyerrctx);
1637 /* Create and fill out new saved error context state */
1638 yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
1639 if (yyerrctx == NULL) goto yyenomem;
1640 yyerrctx->save = yyps->save;
1641 yyerrctx->state = yystate;
1642 yyerrctx->errflag = yyerrflag;
1643 yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base);
1644 memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1645 yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base);
1646 memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1647 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1648 yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base);
1649 memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1651 yyerrctx->lexeme = (int) (yylvp - yylvals);
1653 yylvp = yylvals + save->lexeme;
1654 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1655 yylpp = yylpsns + save->lexeme;
1657 yylexp = yylexemes + save->lexeme;
1659 yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base);
1660 memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1661 yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base);
1662 memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1663 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1664 yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base);
1665 memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1667 ctry = ++save->ctry;
1668 yystate = save->state;
1669 /* We tried shift, try reduce now */
1670 if ((yyn = yyctable[ctry]) >= 0) goto yyreduce;
1671 yyps->save = save->save;
1675 /* Nothing left on the stack -- error */
1680 fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n",
1683 /* Restore state as it was in the most forward-advanced error */
1684 yylvp = yylvals + yyerrctx->lexeme;
1685 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1686 yylpp = yylpsns + yyerrctx->lexeme;
1688 yylexp = yylexemes + yyerrctx->lexeme;
1689 yychar = yylexp[-1];
1691 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1694 yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base);
1695 memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1696 yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base);
1697 memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1698 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1699 yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base);
1700 memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1702 yystate = yyerrctx->state;
1703 yyFreeState(yyerrctx);
1708 if (yynewerrflag == 0) goto yyinrecovery;
1709 #endif /* YYBTYACC */
1711 YYERROR_CALL("syntax error");
1712 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1713 yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */
1717 goto yyerrlab; /* redundant goto avoids 'unused label' warning */
1728 if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
1729 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
1733 fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n",
1734 YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]);
1736 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1737 yystate = yytable[yyn];
1738 *++yystack.s_mark = yytable[yyn];
1739 *++yystack.l_mark = yylval;
1740 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1741 /* lookahead position is error end position */
1742 yyerror_loc_range[2] = yylloc;
1743 YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
1744 *++yystack.p_mark = yyloc;
1752 fprintf(stderr, "%s[%d]: error recovery discarding state %d\n",
1753 YYDEBUGSTR, yydepth, *yystack.s_mark);
1755 if (yystack.s_mark <= yystack.s_base) goto yyabort;
1756 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1757 /* the current TOS position is the error start position */
1758 yyerror_loc_range[1] = *yystack.p_mark;
1760 #if defined(YYDESTRUCT_CALL)
1763 #endif /* YYBTYACC */
1764 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1765 YYDESTRUCT_CALL("error: discarding state",
1766 yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark);
1768 YYDESTRUCT_CALL("error: discarding state",
1769 yystos[*yystack.s_mark], yystack.l_mark);
1770 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1771 #endif /* defined(YYDESTRUCT_CALL) */
1774 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1782 if (yychar == YYEOF) goto yyabort;
1786 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
1787 fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n",
1788 YYDEBUGSTR, yydepth, yystate, yychar, yys);
1791 #if defined(YYDESTRUCT_CALL)
1794 #endif /* YYBTYACC */
1795 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1796 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc);
1798 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval);
1799 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1800 #endif /* defined(YYDESTRUCT_CALL) */
1810 fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)",
1811 YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]);
1812 #ifdef YYSTYPE_TOSTRING
1815 #endif /* YYBTYACC */
1820 for (i = yym; i > 0; i--)
1822 if (i != yym) fputs(", ", stderr);
1823 fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]],
1824 yystack.l_mark[1-i]), stderr);
1829 fputc('\n', stderr);
1833 yyval = yystack.l_mark[1-yym];
1835 memset(&yyval, 0, sizeof yyval);
1836 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1838 /* Perform position reduction */
1839 memset(&yyloc, 0, sizeof(yyloc));
1842 #endif /* YYBTYACC */
1844 YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym);
1845 /* just in case YYERROR is invoked within the action, save
1846 the start of the rhs as the error start position */
1847 yyerror_loc_range[1] = yystack.p_mark[1-yym];
1854 #line 93 "btyacc_demo.y"
1855 { yyval.scope = yystack.l_mark[0].scope; }
1858 #line 94 "btyacc_demo.y"
1859 { yyval.scope = global_scope; }
1862 #line 95 "btyacc_demo.y"
1863 { Decl *d = lookup(yystack.l_mark[-2].scope, yystack.l_mark[-1].id);
1864 if (!d || !d->scope) YYERROR;
1865 yyval.scope = d->scope; }
1868 #line 101 "btyacc_demo.y"
1869 { Decl *d = lookup(yystack.l_mark[-1].scope, yystack.l_mark[0].id);
1870 if (d == NULL || d->istype() == 0) YYERROR;
1871 yyval.type = d->type; }
1874 #line 106 "btyacc_demo.y"
1875 yyval.scope = global_scope = new_scope(0);
1878 #line 107 "btyacc_demo.y"
1879 yyval.scope = yystack.l_mark[-1].scope;
1882 #line 109 "btyacc_demo.y"
1886 #line 110 "btyacc_demo.y"
1887 yyval.scope = start_fn_def(yystack.l_mark[-2].scope, yystack.l_mark[0].decl);
1891 #line 111 "btyacc_demo.y"
1892 { /* demonstrate use of @$ & @N, although this is just the
1893 default computation and so is not necessary */
1894 yyloc.first_line = yystack.p_mark[-3].first_line;
1895 yyloc.first_column = yystack.p_mark[-3].first_column;
1896 yyloc.last_line = yystack.p_mark[0].last_line;
1897 yyloc.last_column = yystack.p_mark[0].last_column;
1898 finish_fn_def(yystack.l_mark[-2].decl, yystack.l_mark[0].code); }
1901 #line 121 "btyacc_demo.y"
1902 { yyval.type = yystack.l_mark[0].type; }
1905 #line 122 "btyacc_demo.y"
1906 { yyval.type = type_combine(yystack.l_mark[-2].type, yystack.l_mark[0].type); }
1909 #line 125 "btyacc_demo.y"
1913 #line 126 "btyacc_demo.y"
1914 { yyval.type = type_combine(yystack.l_mark[-1].type, yystack.l_mark[0].type); }
1917 #line 130 "btyacc_demo.y"
1918 { yyval.type = yystack.l_mark[0].type; }
1921 #line 131 "btyacc_demo.y"
1922 { yyval.type = yystack.l_mark[0].type; }
1925 #line 132 "btyacc_demo.y"
1926 { yyval.type = bare_extern(); }
1929 #line 133 "btyacc_demo.y"
1930 { yyval.type = bare_register(); }
1933 #line 134 "btyacc_demo.y"
1934 { yyval.type = bare_static(); }
1937 #line 138 "btyacc_demo.y"
1938 { yyval.type = bare_const(); }
1941 #line 139 "btyacc_demo.y"
1942 { yyval.type = bare_volatile(); }
1945 #line 143 "btyacc_demo.y"
1946 yyval.scope = yystack.l_mark[-3].scope;
1949 #line 143 "btyacc_demo.y"
1950 yyval.type = yystack.l_mark[-3].type;
1953 #line 148 "btyacc_demo.y"
1954 { if (!yystack.l_mark[0].type) YYERROR; } if (!yytrial)
1955 #line 149 "btyacc_demo.y"
1956 { yyval.decl = declare(yystack.l_mark[-1].scope, 0, yystack.l_mark[0].type); }
1960 #line 150 "btyacc_demo.y"
1961 { yyval.decl = declare(yystack.l_mark[-2].scope, yystack.l_mark[0].id, yystack.l_mark[-1].type); }
1964 #line 151 "btyacc_demo.y"
1965 yyval.scope = yystack.l_mark[-2].scope;
1968 #line 151 "btyacc_demo.y"
1969 yyval.type = yystack.l_mark[-2].type;
1973 #line 151 "btyacc_demo.y"
1974 { yyval.decl = yystack.l_mark[-1].decl; }
1978 #line 153 "btyacc_demo.y"
1979 { yyval.decl = make_pointer(yystack.l_mark[0].decl, yystack.l_mark[-3].type); }
1983 #line 155 "btyacc_demo.y"
1984 { yyval.decl = make_array(yystack.l_mark[-4].decl->type, yystack.l_mark[-1].expr); }
1988 #line 157 "btyacc_demo.y"
1989 { yyval.decl = build_function(yystack.l_mark[-5].decl, yystack.l_mark[-2].dlist, yystack.l_mark[0].type); }
1993 #line 160 "btyacc_demo.y"
1994 { yyval.dlist = 0; }
1998 #line 161 "btyacc_demo.y"
1999 { yyval.dlist = yystack.l_mark[0].dlist; }
2003 #line 164 "btyacc_demo.y"
2004 { yyval.dlist = append_dlist(yystack.l_mark[-3].dlist, yystack.l_mark[0].decl); }
2008 #line 165 "btyacc_demo.y"
2009 { yyval.dlist = build_dlist(yystack.l_mark[0].decl); }
2013 #line 168 "btyacc_demo.y"
2014 { yyval.decl = yystack.l_mark[0].decl; }
2018 #line 172 "btyacc_demo.y"
2019 { yyval.expr = build_expr(yystack.l_mark[-3].expr, ADD, yystack.l_mark[0].expr); }
2023 #line 173 "btyacc_demo.y"
2024 { yyval.expr = build_expr(yystack.l_mark[-3].expr, SUB, yystack.l_mark[0].expr); }
2028 #line 174 "btyacc_demo.y"
2029 { yyval.expr = build_expr(yystack.l_mark[-3].expr, MUL, yystack.l_mark[0].expr); }
2033 #line 175 "btyacc_demo.y"
2034 { yyval.expr = build_expr(yystack.l_mark[-3].expr, MOD, yystack.l_mark[0].expr); }
2038 #line 176 "btyacc_demo.y"
2039 { yyval.expr = build_expr(yystack.l_mark[-3].expr, DIV, yystack.l_mark[0].expr); }
2043 #line 177 "btyacc_demo.y"
2044 { yyval.expr = build_expr(0, DEREF, yystack.l_mark[0].expr); }
2048 #line 178 "btyacc_demo.y"
2049 { yyval.expr = var_expr(yystack.l_mark[-1].scope, yystack.l_mark[0].id); }
2053 #line 179 "btyacc_demo.y"
2054 { yyval.expr = yystack.l_mark[0].expr; }
2058 #line 183 "btyacc_demo.y"
2062 #line 184 "btyacc_demo.y"
2063 {YYVALID;} if (!yytrial)
2064 #line 184 "btyacc_demo.y"
2065 { yyval.code = build_expr_code(yystack.l_mark[-1].expr); }
2068 #line 185 "btyacc_demo.y"
2069 yyval.scope = yystack.l_mark[-6].scope;
2072 #line 185 "btyacc_demo.y"
2073 yyval.scope = yystack.l_mark[-9].scope;
2076 #line 185 "btyacc_demo.y"
2077 {YYVALID;} if (!yytrial)
2078 #line 186 "btyacc_demo.y"
2079 { yyval.code = build_if(yystack.l_mark[-7].expr, yystack.l_mark[-3].code, yystack.l_mark[0].code); }
2082 #line 187 "btyacc_demo.y"
2083 {YYVALID;} if (!yytrial)
2084 #line 188 "btyacc_demo.y"
2085 { yyval.code = build_if(yystack.l_mark[-4].expr, yystack.l_mark[0].code, 0); }
2088 #line 189 "btyacc_demo.y"
2089 yyval.scope = new_scope(yystack.l_mark[0].scope);
2092 #line 189 "btyacc_demo.y"
2093 {YYVALID;} if (!yytrial)
2094 #line 189 "btyacc_demo.y"
2095 { yyval.code = yystack.l_mark[0].code; }
2099 #line 192 "btyacc_demo.y"
2104 #line 193 "btyacc_demo.y"
2105 { yyval.code = code_append(yystack.l_mark[-2].code, yystack.l_mark[0].code); }
2109 #line 197 "btyacc_demo.y"
2110 { yyval.code = yystack.l_mark[-1].code; }
2112 #line 2113 "btyacc_demo.tab.c"
2116 yystack.s_mark -= yym;
2117 yystate = *yystack.s_mark;
2118 yystack.l_mark -= yym;
2119 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2120 yystack.p_mark -= yym;
2123 if (yystate == 0 && yym == 0)
2128 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
2129 #ifdef YYSTYPE_TOSTRING
2132 #endif /* YYBTYACC */
2133 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval));
2135 fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL);
2139 *++yystack.s_mark = YYFINAL;
2140 *++yystack.l_mark = yyval;
2141 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2142 *++yystack.p_mark = yyloc;
2150 /* we're currently re-reading tokens */
2152 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2160 /* in trial mode; save scanner results for future parse attempts */
2161 if (yylvp == yylvlim)
2162 { /* Enlarge lexical value queue */
2163 size_t p = (size_t) (yylvp - yylvals);
2164 size_t s = (size_t) (yylvlim - yylvals);
2166 s += YYLVQUEUEGROWTH;
2167 if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL)
2169 if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
2171 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2172 if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
2175 yylvp = yylve = yylvals + p;
2176 yylvlim = yylvals + s;
2177 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2178 yylpp = yylpe = yylpsns + p;
2179 yylplim = yylpsns + s;
2181 yylexp = yylexemes + p;
2183 *yylexp = (YYINT) YYLEX;
2186 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2193 /* normal operation, no conflict encountered */
2194 #endif /* YYBTYACC */
2198 #endif /* YYBTYACC */
2199 if (yychar < 0) yychar = YYEOF;
2203 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
2204 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n",
2205 YYDEBUGSTR, yydepth, YYFINAL, yychar, yys);
2209 if (yychar == YYEOF) goto yyaccept;
2212 if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
2213 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
2214 yystate = yytable[yyn];
2216 yystate = yydgoto[yym];
2220 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
2221 #ifdef YYSTYPE_TOSTRING
2224 #endif /* YYBTYACC */
2225 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval));
2227 fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate);
2230 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
2231 *++yystack.s_mark = (YYINT) yystate;
2232 *++yystack.l_mark = yyval;
2233 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2234 *++yystack.p_mark = yyloc;
2239 /* Reduction declares that this path is valid. Set yypath and do a full parse */
2241 if (yypath) YYABORT;
2244 YYParseState *save = yyps->save;
2245 yyps->save = save->save;
2246 save->save = yypath;
2251 fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n",
2252 YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme));
2256 yyFreeState(yyerrctx);
2259 yylvp = yylvals + yypath->lexeme;
2260 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2261 yylpp = yylpsns + yypath->lexeme;
2263 yylexp = yylexemes + yypath->lexeme;
2265 yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base);
2266 memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
2267 yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base);
2268 memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
2269 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2270 yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base);
2271 memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
2273 yystate = yypath->state;
2275 #endif /* YYBTYACC */
2278 YYERROR_CALL("yacc stack overflow");
2282 YYERROR_CALL("memory exhausted");
2284 #endif /* YYBTYACC */
2294 if (yyps->save) goto yyvalid;
2295 #endif /* YYBTYACC */
2299 #if defined(YYDESTRUCT_CALL)
2300 if (yychar != YYEOF && yychar != YYEMPTY)
2301 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2302 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc);
2304 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval);
2305 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
2309 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2312 for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp)
2313 YYDESTRUCT_CALL("cleanup: discarding state",
2314 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp);
2316 for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv)
2317 YYDESTRUCT_CALL("cleanup: discarding state",
2318 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv);
2319 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
2321 #endif /* defined(YYDESTRUCT_CALL) */
2326 yyFreeState(yyerrctx);
2331 YYParseState *save = yyps;
2338 YYParseState *save = yypath;
2339 yypath = save->save;
2343 #endif /* YYBTYACC */
2344 yyfreestack(&yystack);