1 /* original parser id follows */
2 /* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */
3 /* (use YYMAJOR/YYMINOR for ifdefs dependent of 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"
148 #line 36 "btyacc_demo.y"
150 #undef YYSTYPE_IS_DECLARED
151 #define YYSTYPE_IS_DECLARED 1
153 #ifndef YYSTYPE_IS_DECLARED
154 #define YYSTYPE_IS_DECLARED 1
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
177 #define YYLTYPE_IS_DECLARED 1
180 /* compatibility with bison */
182 /* compatibility with FreeBSD */
183 # ifdef YYPARSE_PARAM_TYPE
184 # define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
186 # define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
189 # define YYPARSE_DECL() yyparse(void)
192 /* Parameters sent to lex. */
194 # define YYLEX_DECL() yylex(void *YYLEX_PARAM)
195 # define YYLEX yylex(YYLEX_PARAM)
197 # define YYLEX_DECL() yylex(void)
198 # define YYLEX yylex()
201 /* Parameters sent to yyerror. */
203 #define YYERROR_DECL() yyerror(YYLTYPE loc, const char *s)
206 #define YYERROR_CALL(msg) yyerror(yylloc, msg)
209 #ifndef YYDESTRUCT_DECL
210 #define YYDESTRUCT_DECL() yydestruct(const char *msg, int psymb, YYSTYPE *val, YYLTYPE *loc)
212 #ifndef YYDESTRUCT_CALL
213 #define YYDESTRUCT_CALL(msg, psymb, val, loc) yydestruct(msg, psymb, val, loc)
216 extern int YYPARSE_DECL();
231 #define YYERRCODE 256
233 static const YYINT demo_lhs[] = { -1,
234 15, 15, 15, 12, 18, 0, 4, 19, 4, 20,
235 2, 21, 2, 10, 10, 13, 13, 11, 11, 11,
236 11, 11, 14, 14, 22, 23, 3, 3, 8, 8,
237 24, 25, 8, 8, 8, 8, 16, 16, 17, 17,
238 9, 1, 1, 1, 1, 1, 1, 1, 1, 5,
239 26, 5, 27, 28, 5, 5, 29, 5, 6, 6,
242 static const YYINT demo_len[] = { 2,
243 0, 1, 3, 2, 0, 2, 0, 0, 3, 0,
244 5, 0, 6, 1, 3, 0, 2, 1, 1, 1,
245 1, 1, 1, 1, 0, 0, 5, 1, 0, 1,
246 0, 0, 5, 5, 5, 6, 0, 1, 4, 1,
247 4, 4, 4, 4, 4, 4, 3, 1, 1, 1,
248 0, 3, 0, 0, 11, 8, 0, 2, 0, 3,
251 static const YYINT demo_defred[] = { 5,
252 0, 7, 0, 0, 20, 21, 22, 23, 24, 2,
253 9, 8, 14, 19, 18, 0, 0, 0, 15, 0,
254 3, 16, 31, 30, 0, 0, 0, 32, 11, 25,
255 25, 25, 0, 17, 26, 0, 26, 0, 0, 8,
256 13, 0, 0, 0, 40, 8, 0, 0, 8, 48,
257 49, 0, 59, 0, 33, 0, 0, 16, 31, 0,
258 31, 31, 31, 31, 31, 35, 0, 0, 0, 0,
259 47, 0, 0, 0, 0, 0, 61, 0, 0, 39,
260 0, 0, 44, 46, 45, 0, 50, 60, 0, 0,
261 31, 0, 58, 0, 52, 0, 0, 53, 0, 0,
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, 290, 259, 282, 291,
267 269, 42, 40, 259, 274, 279, 284, 295, 59, 44,
268 40, 91, 292, 285, 293, 296, 293, 293, 293, 123,
269 278, 294, 279, 294, 280, 281, 287, 288, 42, 259,
270 260, 272, 290, 279, 41, 279, 290, 41, 44, 290,
271 43, 45, 42, 47, 37, 93, 277, 291, 284, 295,
272 272, 295, 295, 295, 295, 295, 125, 290, 279, 280,
273 272, 272, 272, 272, 272, 266, 273, 276, 297, 300,
274 40, 272, 278, 295, 59, 272, 41, 267, 298, 276,
277 static const YYINT demo_dgoto[] = { 1,
278 52, 87, 25, 3, 88, 67, 41, 26, 45, 12,
279 13, 14, 27, 15, 16, 47, 48, 2, 4, 20,
280 33, 35, 42, 28, 36, 89, 99, 102, 90,
282 static const YYINT demo_sindex[] = { 0,
283 0, 0, 0, -124, 0, 0, 0, 0, 0, 0,
284 0, 0, 0, 0, 0, -256, -124, 0, 0, -33,
285 0, 0, 0, 0, 34, -4, -205, 0, 0, 0,
286 0, 0, -110, 0, 0, -33, 0, -124, -15, 0,
287 0, -33, -36, -33, 0, 0, 4, 7, 0, 0,
288 0, 5, 0, -4, 0, -4, -124, 0, 0, -15,
289 0, 0, 0, 0, 0, 0, -46, -33, -205, -124,
290 0, -15, -15, -15, -15, -15, 0, -91, -4, 0,
291 122, 122, 0, 0, 0, 40, 0, 0, -15, -110,
292 0, 106, 0, -15, 0, 113, -183, 0, -91, 0,
295 static const YYINT demo_rindex[] = { 0,
296 0, 0, 1, -157, 0, 0, 0, 0, 0, 0,
297 0, 0, 0, 0, 0, 0, -28, -22, 0, -29,
298 0, 0, 0, 0, 0, -27, -34, 0, 0, 0,
299 0, 0, 0, 0, 0, 8, 0, -12, 0, 0,
300 0, -20, 0, 32, 0, 0, 0, 69, 0, 0,
301 0, 0, 0, -18, 0, 56, 33, 0, 0, 0,
302 0, 0, 0, 0, 0, 0, -31, -1, -6, -157,
303 0, 0, 0, 0, 0, 0, 0, -14, 63, 0,
304 13, 23, 0, 0, 0, 0, 0, 0, 0, 0,
305 0, 0, 0, 0, 0, 0, 0, 0, -14, -42,
309 static const YYINT demo_cindex[] = { 0,
310 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
311 0, 0, 0, 0, 0, 0, -145, -150, 0, 81,
312 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
313 0, 0, 0, 0, 0, 82, 0, 0, 0, 0,
314 0, 91, 0, 112, 0, 0, 0, 0, 0, 0,
315 0, 0, 0, 0, 0, 0, -113, 0, 0, 0,
316 0, 0, 0, 0, 0, 0, 0, 117, 0, 0,
317 0, 0, 0, 0, 0, 0, 0, -98, 0, 0,
318 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
319 0, 0, 0, 0, 0, 0, 0, 0, -96, -92,
323 static const YYINT demo_gindex[] = { 0,
324 53, 175, 0, 0, 9, 0, 90, 76, 111, 27,
325 29, 0, 124, -25, 0, 0, 0, 0, 21, 126,
326 0, 136, 147, 71, 0, 0, 0, 0, 0,
328 #define YYTABLESIZE 270
329 static const YYINT demo_table[] = { 56,
330 6, 34, 18, 31, 55, 25, 25, 25, 22, 25,
331 8, 10, 40, 10, 29, 10, 28, 4, 4, 4,
332 29, 4, 34, 29, 25, 34, 49, 51, 37, 29,
333 10, 28, 17, 36, 36, 31, 4, 36, 29, 29,
334 34, 65, 29, 34, 58, 19, 63, 61, 29, 62,
335 59, 64, 36, 42, 32, 42, 25, 42, 8, 9,
336 53, 29, 10, 43, 46, 43, 57, 43, 4, 60,
337 29, 42, 10, 10, 10, 29, 10, 30, 77, 91,
338 56, 43, 56, 98, 36, 19, 32, 78, 25, 29,
339 29, 8, 29, 29, 10, 12, 46, 66, 29, 27,
340 4, 1, 29, 41, 34, 42, 41, 100, 57, 38,
341 103, 43, 71, 0, 27, 43, 36, 54, 4, 56,
342 7, 7, 29, 10, 81, 82, 83, 84, 85, 70,
343 7, 72, 73, 74, 75, 76, 5, 6, 7, 8,
344 9, 92, 65, 79, 10, 0, 96, 63, 61, 65,
345 62, 7, 64, 97, 63, 61, 7, 62, 65, 64,
346 9, 94, 9, 63, 95, 37, 38, 39, 64, 5,
347 6, 7, 8, 9, 86, 13, 9, 10, 11, 93,
348 80, 69, 68, 44, 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, 0, 0,
351 0, 0, 0, 0, 0, 0, 56, 56, 56, 56,
352 56, 56, 56, 56, 25, 24, 56, 8, 8, 8,
353 8, 8, 8, 8, 8, 0, 4, 8, 4, 4,
354 4, 4, 4, 50, 51, 51, 1, 0, 0, 0,
355 0, 0, 0, 0, 0, 0, 0, 0, 0, 8,
356 0, 8, 8, 8, 8, 8, 0, 0, 0, 8,
358 static const YYINT demo_check[] = { 42,
359 0, 27, 259, 40, 41, 40, 41, 42, 42, 44,
360 42, 40, 123, 42, 44, 44, 44, 40, 41, 42,
361 41, 44, 41, 44, 59, 44, 42, 42, 41, 59,
362 59, 59, 12, 40, 41, 40, 59, 44, 59, 41,
363 59, 37, 44, 69, 41, 17, 42, 43, 41, 45,
364 44, 47, 59, 41, 91, 43, 91, 45, 264, 265,
365 40, 91, 91, 41, 38, 43, 46, 45, 91, 49,
366 91, 59, 40, 41, 42, 44, 44, 44, 125, 40,
367 123, 59, 125, 267, 91, 57, 91, 67, 123, 91,
368 59, 123, 59, 123, 123, 123, 70, 93, 91, 44,
369 123, 259, 123, 41, 123, 93, 44, 99, 123, 41,
370 102, 36, 60, 259, 59, 93, 123, 42, 269, 44,
371 40, 40, 91, 91, 72, 73, 74, 75, 76, 59,
372 40, 61, 62, 63, 64, 65, 261, 262, 263, 264,
373 265, 89, 37, 68, 269, 259, 94, 42, 43, 37,
374 45, 40, 47, 41, 42, 43, 40, 45, 37, 47,
375 259, 91, 259, 42, 59, 30, 31, 32, 47, 261,
376 262, 263, 264, 265, 266, 268, 259, 269, 4, 90,
377 70, 58, 57, 37, -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, 259, 260, 261, 262,
381 263, 264, 265, 266, 259, 259, 269, 259, 260, 261,
382 262, 263, 264, 265, 266, -1, 259, 269, 261, 262,
383 263, 264, 265, 259, 260, 260, 259, -1, -1, -1,
384 -1, -1, -1, -1, -1, -1, -1, -1, -1, 259,
385 -1, 261, 262, 263, 264, 265, -1, -1, -1, 269,
388 static const YYINT demo_ctable[] = { -1,
389 1, 10, -1, 21, 4, -1, 23, 29, -1, 1,
390 51, -1, 101, 56, -1, -1, -1, -1, -1, -1,
391 -1, -1, -1, -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,
422 #define YYMAXTOKEN 269
423 #define YYUNDFTOKEN 301
424 #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
426 static const char *const demo_name[] = {
428 "$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,
429 "'%'",0,0,"'('","')'","'*'","'+'","','","'-'","'.'","'/'",0,0,0,0,0,0,0,0,0,0,0,
430 "';'",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,
431 "']'",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,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,
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,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,0,0,0,0,0,0,0,0,0,
435 0,0,0,0,0,0,0,0,0,"error","PREFIX","POSTFIX","ID","CONSTANT","EXTERN",
436 "REGISTER","STATIC","CONST","VOLATILE","IF","THEN","ELSE","CLCL","$accept",
437 "input","expr","decl","declarator_list","decl_list","statement",
438 "statement_list","block_statement","declarator","formal_arg","decl_specs",
439 "decl_spec","typename","cv_quals","cv_qual","opt_scope","formal_arg_list",
440 "nonempty_formal_arg_list","$$1","$$2","$$3","$$4","$$5","$$6","$$7","$$8",
441 "$$9","$$10","$$11","$$12","illegal-symbol",
443 static const char *const demo_rule[] = {
447 "opt_scope : opt_scope ID CLCL",
448 "typename : opt_scope ID",
450 "input : $$1 decl_list",
453 "decl_list : decl_list $$2 decl",
455 "decl : decl_specs $$2 $$3 declarator_list ';'",
457 "decl : decl_specs $$2 $$3 declarator $$4 block_statement",
458 "decl_specs : decl_spec",
459 "decl_specs : decl_specs $$2 decl_spec",
461 "cv_quals : cv_quals cv_qual",
462 "decl_spec : cv_qual",
463 "decl_spec : typename",
464 "decl_spec : EXTERN",
465 "decl_spec : REGISTER",
466 "decl_spec : STATIC",
468 "cv_qual : VOLATILE",
471 "declarator_list : declarator_list ',' $$5 $$6 declarator",
472 "declarator_list : declarator",
477 "declarator : '(' $$7 $$8 declarator ')'",
478 "declarator : '*' cv_quals $$5 $$6 declarator",
479 "declarator : declarator '[' $$5 expr ']'",
480 "declarator : declarator '(' $$5 formal_arg_list ')' cv_quals",
482 "formal_arg_list : nonempty_formal_arg_list",
483 "nonempty_formal_arg_list : nonempty_formal_arg_list ',' $$7 formal_arg",
484 "nonempty_formal_arg_list : formal_arg",
485 "formal_arg : decl_specs $$2 $$3 declarator",
486 "expr : expr '+' $$7 expr",
487 "expr : expr '-' $$7 expr",
488 "expr : expr '*' $$7 expr",
489 "expr : expr '%' $$7 expr",
490 "expr : expr '/' $$7 expr",
491 "expr : '*' $$2 expr",
496 "statement : $$9 expr ';'",
499 "statement : IF '(' $$7 expr ')' THEN $$10 statement ELSE $$11 statement",
500 "statement : IF '(' $$7 expr ')' THEN $$10 statement",
502 "statement : $$12 block_statement",
504 "statement_list : statement_list $$2 statement",
505 "block_statement : '{' $$2 statement_list '}'",
517 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
518 YYLTYPE yyloc; /* position returned by actions */
519 YYLTYPE yylloc; /* position from the lexer */
522 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
523 #ifndef YYLLOC_DEFAULT
524 #define YYLLOC_DEFAULT(loc, rhs, n) \
529 (loc).first_line = ((rhs)[-1]).last_line; \
530 (loc).first_column = ((rhs)[-1]).last_column; \
531 (loc).last_line = ((rhs)[-1]).last_line; \
532 (loc).last_column = ((rhs)[-1]).last_column; \
536 (loc).first_line = ((rhs)[ 0 ]).first_line; \
537 (loc).first_column = ((rhs)[ 0 ]).first_column; \
538 (loc).last_line = ((rhs)[n-1]).last_line; \
539 (loc).last_column = ((rhs)[n-1]).last_column; \
542 #endif /* YYLLOC_DEFAULT */
543 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
546 #ifndef YYLVQUEUEGROWTH
547 #define YYLVQUEUEGROWTH 32
549 #endif /* YYBTYACC */
551 /* define the initial stack-sizes */
554 #define YYMAXDEPTH YYSTACKSIZE
557 #define YYSTACKSIZE YYMAXDEPTH
559 #define YYSTACKSIZE 10000
560 #define YYMAXDEPTH 10000
564 #ifndef YYINITSTACKSIZE
565 #define YYINITSTACKSIZE 200
575 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
582 struct YYParseState_s
584 struct YYParseState_s *save; /* Previously saved parser state */
585 YYSTACKDATA yystack; /* saved parser stack */
586 int state; /* saved parser state */
587 int errflag; /* saved error recovery status */
588 int lexeme; /* saved index of the conflict lexeme in the lexical queue */
589 YYINT ctry; /* saved index in yyctable[] for this conflict */
591 typedef struct YYParseState_s YYParseState;
592 #endif /* YYBTYACC */
593 /* variables for the parser stack */
594 static YYSTACKDATA yystack;
597 /* Current parser state */
598 static YYParseState *yyps = 0;
600 /* yypath != NULL: do the full parse, starting at *yypath parser state. */
601 static YYParseState *yypath = 0;
603 /* Base of the lexical value queue */
604 static YYSTYPE *yylvals = 0;
606 /* Current position at lexical value queue */
607 static YYSTYPE *yylvp = 0;
609 /* End position of lexical value queue */
610 static YYSTYPE *yylve = 0;
612 /* The last allocated position at the lexical value queue */
613 static YYSTYPE *yylvlim = 0;
615 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
616 /* Base of the lexical position queue */
617 static YYLTYPE *yylpsns = 0;
619 /* Current position at lexical position queue */
620 static YYLTYPE *yylpp = 0;
622 /* End position of lexical position queue */
623 static YYLTYPE *yylpe = 0;
625 /* The last allocated position at the lexical position queue */
626 static YYLTYPE *yylplim = 0;
629 /* Current position at lexical token queue */
630 static short *yylexp = 0;
632 static short *yylexemes = 0;
633 #endif /* YYBTYACC */
634 #line 200 "btyacc_demo.y"
636 extern int YYLEX_DECL();
637 extern void YYERROR_DECL();
639 extern Scope *global_scope;
641 extern Decl * lookup(Scope *scope, char *id);
642 extern Scope * new_scope(Scope *outer_scope);
643 extern Scope * start_fn_def(Scope *scope, Decl *fn_decl);
644 extern void finish_fn_def(Decl *fn_decl, Code *block);
645 extern Type * type_combine(Type *specs, Type *spec);
646 extern Type * bare_extern(void);
647 extern Type * bare_register(void);
648 extern Type * bare_static(void);
649 extern Type * bare_const(void);
650 extern Type * bare_volatile(void);
651 extern Decl * declare(Scope *scope, char *id, Type *type);
652 extern Decl * make_pointer(Decl *decl, Type *type);
653 extern Decl * make_array(Type *type, Expr *expr);
654 extern Decl * build_function(Decl *decl, Decl_List *dlist, Type *type);
655 extern Decl_List * append_dlist(Decl_List *dlist, Decl *decl);
656 extern Decl_List * build_dlist(Decl *decl);
657 extern Expr * build_expr(Expr *left, enum Operator op, Expr *right);
658 extern Expr * var_expr(Scope *scope, char *id);
659 extern Code * build_expr_code(Expr *expr);
660 extern Code * build_if(Expr *cond_expr, Code *then_stmt, Code *else_stmt);
661 extern Code * code_append(Code *stmt_list, Code *stmt);
662 #line 663 "btyacc_demo.tab.c"
664 /* Release memory associated with symbol. */
665 #if ! defined YYDESTRUCT_IS_DECLARED
672 #line 83 "btyacc_demo.y"
673 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
675 (*loc).first_line, (*loc).first_column,
676 (*loc).last_line, (*loc).last_column);
677 /* in this example, we don't know what to do here */ }
679 #line 680 "btyacc_demo.tab.c"
681 #line 83 "btyacc_demo.y"
682 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
684 (*loc).first_line, (*loc).first_column,
685 (*loc).last_line, (*loc).last_column);
686 /* in this example, we don't know what to do here */ }
688 #line 689 "btyacc_demo.tab.c"
690 #line 83 "btyacc_demo.y"
691 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
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 */ }
697 #line 698 "btyacc_demo.tab.c"
699 #line 83 "btyacc_demo.y"
700 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
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 */ }
706 #line 707 "btyacc_demo.tab.c"
708 #line 83 "btyacc_demo.y"
709 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
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 */ }
715 #line 716 "btyacc_demo.tab.c"
717 #line 83 "btyacc_demo.y"
718 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
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 */ }
724 #line 725 "btyacc_demo.tab.c"
726 #line 83 "btyacc_demo.y"
727 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
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 */ }
733 #line 734 "btyacc_demo.tab.c"
735 #line 83 "btyacc_demo.y"
736 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
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 */ }
742 #line 743 "btyacc_demo.tab.c"
744 #line 83 "btyacc_demo.y"
745 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
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 */ }
751 #line 752 "btyacc_demo.tab.c"
753 #line 83 "btyacc_demo.y"
754 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
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 */ }
760 #line 761 "btyacc_demo.tab.c"
762 #line 78 "btyacc_demo.y"
763 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
765 (*loc).first_line, (*loc).first_column,
766 (*loc).last_line, (*loc).last_column);
769 #line 770 "btyacc_demo.tab.c"
771 #line 78 "btyacc_demo.y"
772 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
774 (*loc).first_line, (*loc).first_column,
775 (*loc).last_line, (*loc).last_column);
778 #line 779 "btyacc_demo.tab.c"
780 #line 83 "btyacc_demo.y"
781 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
783 (*loc).first_line, (*loc).first_column,
784 (*loc).last_line, (*loc).last_column);
785 /* in this example, we don't know what to do here */ }
787 #line 788 "btyacc_demo.tab.c"
789 #line 83 "btyacc_demo.y"
790 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
792 (*loc).first_line, (*loc).first_column,
793 (*loc).last_line, (*loc).last_column);
794 /* in this example, we don't know what to do here */ }
796 #line 797 "btyacc_demo.tab.c"
798 #line 83 "btyacc_demo.y"
799 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
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 */ }
805 #line 806 "btyacc_demo.tab.c"
807 #line 83 "btyacc_demo.y"
808 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
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 */ }
814 #line 815 "btyacc_demo.tab.c"
816 #line 83 "btyacc_demo.y"
817 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
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 */ }
823 #line 824 "btyacc_demo.tab.c"
825 #line 83 "btyacc_demo.y"
826 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
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 */ }
832 #line 833 "btyacc_demo.tab.c"
834 #line 83 "btyacc_demo.y"
835 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
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 */ }
841 #line 842 "btyacc_demo.tab.c"
843 #line 83 "btyacc_demo.y"
844 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
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 */ }
850 #line 851 "btyacc_demo.tab.c"
852 #line 83 "btyacc_demo.y"
853 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
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 */ }
859 #line 860 "btyacc_demo.tab.c"
861 #line 83 "btyacc_demo.y"
862 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
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 */ }
868 #line 869 "btyacc_demo.tab.c"
870 #line 83 "btyacc_demo.y"
871 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
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 */ }
877 #line 878 "btyacc_demo.tab.c"
879 #line 83 "btyacc_demo.y"
880 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
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 */ }
886 #line 887 "btyacc_demo.tab.c"
888 #line 83 "btyacc_demo.y"
889 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
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 */ }
895 #line 896 "btyacc_demo.tab.c"
897 #line 83 "btyacc_demo.y"
898 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
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 */ }
904 #line 905 "btyacc_demo.tab.c"
906 #line 83 "btyacc_demo.y"
907 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
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 */ }
913 #line 914 "btyacc_demo.tab.c"
915 #line 83 "btyacc_demo.y"
916 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
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 */ }
922 #line 923 "btyacc_demo.tab.c"
924 #line 83 "btyacc_demo.y"
925 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
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 */ }
931 #line 932 "btyacc_demo.tab.c"
933 #line 78 "btyacc_demo.y"
934 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
936 (*loc).first_line, (*loc).first_column,
937 (*loc).last_line, (*loc).last_column);
940 #line 941 "btyacc_demo.tab.c"
942 #line 67 "btyacc_demo.y"
943 { /* 'msg' is a 'char *' indicating the context of destructor invocation*/
944 printf("%s accessed by symbol \"decl\" (case s.b. 273) @ position[%d,%d..%d,%d]\n",
946 (*loc).first_line, (*loc).first_column,
947 (*loc).last_line, (*loc).last_column);
948 free((*val).decl->scope); free((*val).decl->type); }
950 #line 951 "btyacc_demo.tab.c"
952 #line 83 "btyacc_demo.y"
953 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
955 (*loc).first_line, (*loc).first_column,
956 (*loc).last_line, (*loc).last_column);
957 /* in this example, we don't know what to do here */ }
959 #line 960 "btyacc_demo.tab.c"
961 #line 83 "btyacc_demo.y"
962 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
964 (*loc).first_line, (*loc).first_column,
965 (*loc).last_line, (*loc).last_column);
966 /* in this example, we don't know what to do here */ }
968 #line 969 "btyacc_demo.tab.c"
970 #line 78 "btyacc_demo.y"
971 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
973 (*loc).first_line, (*loc).first_column,
974 (*loc).last_line, (*loc).last_column);
977 #line 978 "btyacc_demo.tab.c"
979 #line 78 "btyacc_demo.y"
980 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
982 (*loc).first_line, (*loc).first_column,
983 (*loc).last_line, (*loc).last_column);
986 #line 987 "btyacc_demo.tab.c"
988 #line 78 "btyacc_demo.y"
989 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
991 (*loc).first_line, (*loc).first_column,
992 (*loc).last_line, (*loc).last_column);
995 #line 996 "btyacc_demo.tab.c"
997 #line 73 "btyacc_demo.y"
998 { printf("%s accessed by symbol with type <decl> (case s.b. 279 & 280) @ position[%d,%d..%d,%d]\n",
1000 (*loc).first_line, (*loc).first_column,
1001 (*loc).last_line, (*loc).last_column);
1002 free((*val).decl); }
1004 #line 1005 "btyacc_demo.tab.c"
1006 #line 73 "btyacc_demo.y"
1007 { printf("%s accessed by symbol with type <decl> (case s.b. 279 & 280) @ position[%d,%d..%d,%d]\n",
1009 (*loc).first_line, (*loc).first_column,
1010 (*loc).last_line, (*loc).last_column);
1011 free((*val).decl); }
1013 #line 1014 "btyacc_demo.tab.c"
1015 #line 78 "btyacc_demo.y"
1016 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1018 (*loc).first_line, (*loc).first_column,
1019 (*loc).last_line, (*loc).last_column);
1020 free((*val).type); }
1022 #line 1023 "btyacc_demo.tab.c"
1024 #line 78 "btyacc_demo.y"
1025 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1027 (*loc).first_line, (*loc).first_column,
1028 (*loc).last_line, (*loc).last_column);
1029 free((*val).type); }
1031 #line 1032 "btyacc_demo.tab.c"
1033 #line 78 "btyacc_demo.y"
1034 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1036 (*loc).first_line, (*loc).first_column,
1037 (*loc).last_line, (*loc).last_column);
1038 free((*val).type); }
1040 #line 1041 "btyacc_demo.tab.c"
1042 #line 78 "btyacc_demo.y"
1043 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1045 (*loc).first_line, (*loc).first_column,
1046 (*loc).last_line, (*loc).last_column);
1047 free((*val).type); }
1049 #line 1050 "btyacc_demo.tab.c"
1051 #line 78 "btyacc_demo.y"
1052 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1054 (*loc).first_line, (*loc).first_column,
1055 (*loc).last_line, (*loc).last_column);
1056 free((*val).type); }
1058 #line 1059 "btyacc_demo.tab.c"
1060 #line 78 "btyacc_demo.y"
1061 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1063 (*loc).first_line, (*loc).first_column,
1064 (*loc).last_line, (*loc).last_column);
1065 free((*val).scope); }
1067 #line 1068 "btyacc_demo.tab.c"
1069 #line 78 "btyacc_demo.y"
1070 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1072 (*loc).first_line, (*loc).first_column,
1073 (*loc).last_line, (*loc).last_column);
1074 free((*val).dlist); }
1076 #line 1077 "btyacc_demo.tab.c"
1078 #line 78 "btyacc_demo.y"
1079 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1081 (*loc).first_line, (*loc).first_column,
1082 (*loc).last_line, (*loc).last_column);
1083 free((*val).dlist); }
1085 #line 1086 "btyacc_demo.tab.c"
1087 #line 78 "btyacc_demo.y"
1088 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1090 (*loc).first_line, (*loc).first_column,
1091 (*loc).last_line, (*loc).last_column);
1092 free((*val).scope); }
1094 #line 1095 "btyacc_demo.tab.c"
1096 #line 78 "btyacc_demo.y"
1097 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1099 (*loc).first_line, (*loc).first_column,
1100 (*loc).last_line, (*loc).last_column);
1101 free((*val).scope); }
1103 #line 1104 "btyacc_demo.tab.c"
1105 #line 78 "btyacc_demo.y"
1106 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1108 (*loc).first_line, (*loc).first_column,
1109 (*loc).last_line, (*loc).last_column);
1110 free((*val).type); }
1112 #line 1113 "btyacc_demo.tab.c"
1114 #line 78 "btyacc_demo.y"
1115 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1117 (*loc).first_line, (*loc).first_column,
1118 (*loc).last_line, (*loc).last_column);
1119 free((*val).scope); }
1121 #line 1122 "btyacc_demo.tab.c"
1123 #line 78 "btyacc_demo.y"
1124 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1126 (*loc).first_line, (*loc).first_column,
1127 (*loc).last_line, (*loc).last_column);
1128 free((*val).scope); }
1130 #line 1131 "btyacc_demo.tab.c"
1132 #line 78 "btyacc_demo.y"
1133 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1135 (*loc).first_line, (*loc).first_column,
1136 (*loc).last_line, (*loc).last_column);
1137 free((*val).type); }
1139 #line 1140 "btyacc_demo.tab.c"
1141 #line 78 "btyacc_demo.y"
1142 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1144 (*loc).first_line, (*loc).first_column,
1145 (*loc).last_line, (*loc).last_column);
1146 free((*val).scope); }
1148 #line 1149 "btyacc_demo.tab.c"
1150 #line 78 "btyacc_demo.y"
1151 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1153 (*loc).first_line, (*loc).first_column,
1154 (*loc).last_line, (*loc).last_column);
1155 free((*val).type); }
1157 #line 1158 "btyacc_demo.tab.c"
1159 #line 78 "btyacc_demo.y"
1160 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1162 (*loc).first_line, (*loc).first_column,
1163 (*loc).last_line, (*loc).last_column);
1164 free((*val).scope); }
1166 #line 1167 "btyacc_demo.tab.c"
1168 #line 78 "btyacc_demo.y"
1169 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1171 (*loc).first_line, (*loc).first_column,
1172 (*loc).last_line, (*loc).last_column);
1173 free((*val).scope); }
1175 #line 1176 "btyacc_demo.tab.c"
1177 #line 78 "btyacc_demo.y"
1178 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1180 (*loc).first_line, (*loc).first_column,
1181 (*loc).last_line, (*loc).last_column);
1182 free((*val).scope); }
1184 #line 1185 "btyacc_demo.tab.c"
1186 #line 78 "btyacc_demo.y"
1187 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1189 (*loc).first_line, (*loc).first_column,
1190 (*loc).last_line, (*loc).last_column);
1191 free((*val).scope); }
1193 #line 1194 "btyacc_demo.tab.c"
1196 #define YYDESTRUCT_IS_DECLARED 1
1199 /* For use in generated program */
1200 #define yydepth (int)(yystack.s_mark - yystack.s_base)
1202 #define yytrial (yyps->save)
1203 #endif /* YYBTYACC */
1206 #include <stdio.h> /* needed for printf */
1209 #include <stdlib.h> /* needed for malloc, etc */
1210 #include <string.h> /* needed for memset */
1212 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
1213 static int yygrowstack(YYSTACKDATA *data)
1219 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1223 if ((newsize = data->stacksize) == 0)
1224 newsize = YYINITSTACKSIZE;
1225 else if (newsize >= YYMAXDEPTH)
1227 else if ((newsize *= 2) > YYMAXDEPTH)
1228 newsize = YYMAXDEPTH;
1230 i = (int) (data->s_mark - data->s_base);
1231 newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
1235 data->s_base = newss;
1236 data->s_mark = newss + i;
1238 newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
1242 data->l_base = newvs;
1243 data->l_mark = newvs + i;
1245 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1246 newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps));
1250 data->p_base = newps;
1251 data->p_mark = newps + i;
1254 data->stacksize = newsize;
1255 data->s_last = data->s_base + newsize - 1;
1259 fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize);
1264 #if YYPURE || defined(YY_NO_LEAKS)
1265 static void yyfreestack(YYSTACKDATA *data)
1269 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1272 memset(data, 0, sizeof(*data));
1275 #define yyfreestack(data) /* nothing */
1276 #endif /* YYPURE || defined(YY_NO_LEAKS) */
1279 static YYParseState *
1280 yyNewState(unsigned size)
1282 YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState));
1283 if (p == NULL) return NULL;
1285 p->yystack.stacksize = size;
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;
1295 p->yystack.s_base = (short *) malloc(size * sizeof(short));
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));
1310 yyFreeState(YYParseState *p)
1312 yyfreestack(&p->yystack);
1315 #endif /* YYBTYACC */
1317 #define YYABORT goto yyabort
1318 #define YYREJECT goto yyabort
1319 #define YYACCEPT goto yyaccept
1320 #define YYERROR goto yyerrlab
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 */
1330 int yym, yyn, yystate, yyresult;
1333 YYParseState *yyerrctx = NULL;
1334 #endif /* YYBTYACC */
1335 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1336 YYLTYPE yyerror_loc_range[2]; /* position of error start & end */
1341 if ((yys = getenv("YYDEBUG")) != 0)
1344 if (yyn >= '0' && yyn <= '9')
1345 yydebug = yyn - '0';
1348 fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX);
1352 yyps = yyNewState(0); if (yyps == 0) goto yyenomem;
1354 #endif /* YYBTYACC */
1361 memset(&yystack, 0, sizeof(yystack));
1364 if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1365 yystack.s_mark = yystack.s_base;
1366 yystack.l_mark = yystack.l_base;
1367 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1368 yystack.p_mark = yystack.p_base;
1371 *yystack.s_mark = 0;
1374 if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
1381 /* we're currently re-reading tokens */
1383 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1391 /* in trial mode; save scanner results for future parse attempts */
1392 if (yylvp == yylvlim)
1393 { /* Enlarge lexical value queue */
1394 size_t p = (size_t) (yylvp - yylvals);
1395 size_t s = (size_t) (yylvlim - yylvals);
1397 s += YYLVQUEUEGROWTH;
1398 if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) goto yyenomem;
1399 if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
1400 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1401 if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
1403 yylvp = yylve = yylvals + p;
1404 yylvlim = yylvals + s;
1405 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1406 yylpp = yylpe = yylpsns + p;
1407 yylplim = yylpsns + s;
1409 yylexp = yylexemes + p;
1411 *yylexp = (short) YYLEX;
1414 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1421 /* normal operation, no conflict encountered */
1422 #endif /* YYBTYACC */
1426 #endif /* YYBTYACC */
1427 if (yychar < 0) yychar = YYEOF;
1428 /* if ((yychar = YYLEX) < 0) yychar = YYEOF; */
1432 yys = yyname[YYTRANSLATE(yychar)];
1433 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)",
1434 YYDEBUGSTR, yydepth, yystate, yychar, yys);
1435 #ifdef YYSTYPE_TOSTRING
1438 #endif /* YYBTYACC */
1439 fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval));
1441 fputc('\n', stderr);
1447 /* Do we have a conflict? */
1448 if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
1449 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
1458 fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n",
1459 YYDEBUGSTR, yydepth, yystate);
1461 /* Switch to the next conflict context */
1463 yypath = save->save;
1466 if (save->state != yystate) YYABORT;
1473 /* Unresolved conflict - start/continue trial parse */
1478 fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate);
1480 fputs("ALREADY in conflict, continuing trial parse.\n", stderr);
1482 fputs("Starting trial parse.\n", stderr);
1485 save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
1486 if (save == NULL) goto yyenomem;
1487 save->save = yyps->save;
1488 save->state = yystate;
1489 save->errflag = yyerrflag;
1490 save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base);
1491 memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
1492 save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base);
1493 memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1494 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1495 save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base);
1496 memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1498 ctry = yytable[yyn];
1499 if (yyctable[ctry] == -1)
1502 if (yydebug && yychar >= YYEOF)
1503 fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth);
1508 if (yyps->save == NULL)
1510 /* If this is a first conflict in the stack, start saving lexemes */
1513 yylexemes = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short));
1514 if (yylexemes == NULL) goto yyenomem;
1515 yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
1516 if (yylvals == NULL) goto yyenomem;
1517 yylvlim = yylvals + YYLVQUEUEGROWTH;
1518 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1519 yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE));
1520 if (yylpsns == NULL) goto yyenomem;
1521 yylplim = yylpsns + YYLVQUEUEGROWTH;
1526 yylvp = yylve = yylvals;
1527 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1528 yylpp = yylpe = yylpsns;
1531 if (yychar >= YYEOF)
1534 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1537 *yylexp = (short) yychar;
1542 if (yychar >= YYEOF)
1545 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1551 save->lexeme = (int) (yylvp - yylvals);
1554 if (yytable[yyn] == ctry)
1558 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
1559 YYDEBUGSTR, yydepth, yystate, yyctable[ctry]);
1564 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1569 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
1571 yystate = yyctable[ctry];
1572 *++yystack.s_mark = (short) yystate;
1573 *++yystack.l_mark = yylval;
1574 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1575 *++yystack.p_mark = yylloc;
1578 if (yyerrflag > 0) --yyerrflag;
1583 yyn = yyctable[ctry];
1586 } /* End of code dealing with conflicts */
1587 #endif /* YYBTYACC */
1588 if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
1589 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
1593 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
1594 YYDEBUGSTR, yydepth, yystate, yytable[yyn]);
1596 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1597 yystate = yytable[yyn];
1598 *++yystack.s_mark = yytable[yyn];
1599 *++yystack.l_mark = yylval;
1600 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1601 *++yystack.p_mark = yylloc;
1604 if (yyerrflag > 0) --yyerrflag;
1607 if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
1608 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
1613 if (yyerrflag != 0) goto yyinrecovery;
1626 YYParseState *save = yyps->save;
1629 fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n",
1630 YYDEBUGSTR, yydepth, yystate, yyps->save->state,
1631 (int)(yylvp - yylvals - yyps->save->lexeme));
1633 /* Memorize most forward-looking error state in case it's really an error. */
1634 if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals)
1636 /* Free old saved error context state */
1637 if (yyerrctx) yyFreeState(yyerrctx);
1638 /* Create and fill out new saved error context state */
1639 yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
1640 if (yyerrctx == NULL) goto yyenomem;
1641 yyerrctx->save = yyps->save;
1642 yyerrctx->state = yystate;
1643 yyerrctx->errflag = yyerrflag;
1644 yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base);
1645 memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
1646 yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base);
1647 memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1648 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1649 yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base);
1650 memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1652 yyerrctx->lexeme = (int) (yylvp - yylvals);
1654 yylvp = yylvals + save->lexeme;
1655 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1656 yylpp = yylpsns + save->lexeme;
1658 yylexp = yylexemes + save->lexeme;
1660 yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base);
1661 memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
1662 yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base);
1663 memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1664 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1665 yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base);
1666 memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1668 ctry = ++save->ctry;
1669 yystate = save->state;
1670 /* We tried shift, try reduce now */
1671 if ((yyn = yyctable[ctry]) >= 0) goto yyreduce;
1672 yyps->save = save->save;
1676 /* Nothing left on the stack -- error */
1681 fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n",
1684 /* Restore state as it was in the most forward-advanced error */
1685 yylvp = yylvals + yyerrctx->lexeme;
1686 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1687 yylpp = yylpsns + yyerrctx->lexeme;
1689 yylexp = yylexemes + yyerrctx->lexeme;
1690 yychar = yylexp[-1];
1692 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1695 yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base);
1696 memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
1697 yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base);
1698 memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1699 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1700 yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base);
1701 memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1703 yystate = yyerrctx->state;
1704 yyFreeState(yyerrctx);
1709 if (yynewerrflag == 0) goto yyinrecovery;
1710 #endif /* YYBTYACC */
1712 YYERROR_CALL("syntax error");
1713 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1714 yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
1729 if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
1730 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
1734 fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n",
1735 YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]);
1737 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1738 yystate = yytable[yyn];
1739 *++yystack.s_mark = yytable[yyn];
1740 *++yystack.l_mark = yylval;
1741 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1742 /* lookahead position is error end position */
1743 yyerror_loc_range[1] = yylloc;
1744 YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
1745 *++yystack.p_mark = yyloc;
1753 fprintf(stderr, "%s[%d]: error recovery discarding state %d\n",
1754 YYDEBUGSTR, yydepth, *yystack.s_mark);
1756 if (yystack.s_mark <= yystack.s_base) goto yyabort;
1757 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1758 /* the current TOS position is the error start position */
1759 yyerror_loc_range[0] = *yystack.p_mark;
1761 #if defined(YYDESTRUCT_CALL)
1764 #endif /* YYBTYACC */
1765 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1766 YYDESTRUCT_CALL("error: discarding state",
1767 yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark);
1769 YYDESTRUCT_CALL("error: discarding state",
1770 yystos[*yystack.s_mark], yystack.l_mark);
1771 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1772 #endif /* defined(YYDESTRUCT_CALL) */
1775 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1783 if (yychar == YYEOF) goto yyabort;
1787 yys = yyname[YYTRANSLATE(yychar)];
1788 fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n",
1789 YYDEBUGSTR, yydepth, yystate, yychar, yys);
1792 #if defined(YYDESTRUCT_CALL)
1795 #endif /* YYBTYACC */
1796 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1797 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc);
1799 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval);
1800 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1801 #endif /* defined(YYDESTRUCT_CALL) */
1811 fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)",
1812 YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]);
1813 #ifdef YYSTYPE_TOSTRING
1816 #endif /* YYBTYACC */
1821 for (i = yym; i > 0; i--)
1823 if (i != yym) fputs(", ", stderr);
1824 fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]],
1825 yystack.l_mark[1-i]), stderr);
1830 fputc('\n', stderr);
1834 yyval = yystack.l_mark[1-yym];
1836 memset(&yyval, 0, sizeof yyval);
1837 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1839 /* Perform position reduction */
1840 memset(&yyloc, 0, sizeof(yyloc));
1843 #endif /* YYBTYACC */
1845 YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
1846 /* just in case YYERROR is invoked within the action, save
1847 the start of the rhs as the error start position */
1848 yyerror_loc_range[0] = yystack.p_mark[1-yym];
1855 #line 93 "btyacc_demo.y"
1856 { yyval.scope = yystack.l_mark[0].scope; }
1859 #line 94 "btyacc_demo.y"
1860 { yyval.scope = global_scope; }
1863 #line 95 "btyacc_demo.y"
1864 { Decl *d = lookup(yystack.l_mark[-2].scope, yystack.l_mark[-1].id);
1865 if (!d || !d->scope) YYERROR;
1866 yyval.scope = d->scope; }
1869 #line 101 "btyacc_demo.y"
1870 { Decl *d = lookup(yystack.l_mark[-1].scope, yystack.l_mark[0].id);
1871 if (d == NULL || d->istype() == 0) YYERROR;
1872 yyval.type = d->type; }
1875 #line 106 "btyacc_demo.y"
1876 yyval.scope = global_scope = new_scope(0);
1879 #line 107 "btyacc_demo.y"
1880 yyval.scope = yystack.l_mark[-1].scope;
1883 #line 109 "btyacc_demo.y"
1884 yyval.type = yystack.l_mark[-1].type;
1887 #line 109 "btyacc_demo.y"
1891 #line 110 "btyacc_demo.y"
1892 yyval.scope = start_fn_def(yystack.l_mark[-4].scope, yystack.l_mark[0].decl);
1896 #line 111 "btyacc_demo.y"
1897 { /* demonstrate use of @$ & @N, although this is just the
1898 default computation and so is not necessary */
1899 yyloc.first_line = yystack.p_mark[-5].first_line;
1900 yyloc.first_column = yystack.p_mark[-5].first_column;
1901 yyloc.last_line = yystack.p_mark[0].last_line;
1902 yyloc.last_column = yystack.p_mark[0].last_column;
1903 finish_fn_def(yystack.l_mark[-2].decl, yystack.l_mark[0].code); }
1906 #line 121 "btyacc_demo.y"
1907 { yyval.type = yystack.l_mark[0].type; }
1910 #line 122 "btyacc_demo.y"
1911 { yyval.type = type_combine(yystack.l_mark[-2].type, yystack.l_mark[0].type); }
1914 #line 125 "btyacc_demo.y"
1918 #line 126 "btyacc_demo.y"
1919 { yyval.type = type_combine(yystack.l_mark[-1].type, yystack.l_mark[0].type); }
1922 #line 130 "btyacc_demo.y"
1923 { yyval.type = yystack.l_mark[0].type; }
1926 #line 131 "btyacc_demo.y"
1927 { yyval.type = yystack.l_mark[0].type; }
1930 #line 132 "btyacc_demo.y"
1931 { yyval.type = bare_extern(); }
1934 #line 133 "btyacc_demo.y"
1935 { yyval.type = bare_register(); }
1938 #line 134 "btyacc_demo.y"
1939 { yyval.type = bare_static(); }
1942 #line 138 "btyacc_demo.y"
1943 { yyval.type = bare_const(); }
1946 #line 139 "btyacc_demo.y"
1947 { yyval.type = bare_volatile(); }
1950 #line 143 "btyacc_demo.y"
1951 yyval.scope = yystack.l_mark[-3].scope;
1954 #line 143 "btyacc_demo.y"
1955 yyval.type = yystack.l_mark[-3].type;
1958 #line 148 "btyacc_demo.y"
1959 { if (!yystack.l_mark[0].type) YYERROR; } if (!yytrial)
1960 #line 149 "btyacc_demo.y"
1961 { yyval.decl = declare(yystack.l_mark[-1].scope, 0, yystack.l_mark[0].type); }
1965 #line 150 "btyacc_demo.y"
1966 { yyval.decl = declare(yystack.l_mark[-2].scope, yystack.l_mark[0].id, yystack.l_mark[-1].type); }
1969 #line 151 "btyacc_demo.y"
1970 yyval.scope = yystack.l_mark[-2].scope;
1973 #line 151 "btyacc_demo.y"
1974 yyval.type = yystack.l_mark[-2].type;
1978 #line 151 "btyacc_demo.y"
1979 { yyval.decl = yystack.l_mark[-1].decl; }
1983 #line 153 "btyacc_demo.y"
1984 { yyval.decl = make_pointer(yystack.l_mark[0].decl, yystack.l_mark[-3].type); }
1988 #line 155 "btyacc_demo.y"
1989 { yyval.decl = make_array(yystack.l_mark[-4].decl->type, yystack.l_mark[-1].expr); }
1993 #line 157 "btyacc_demo.y"
1994 { yyval.decl = build_function(yystack.l_mark[-5].decl, yystack.l_mark[-2].dlist, yystack.l_mark[0].type); }
1998 #line 160 "btyacc_demo.y"
1999 { yyval.dlist = 0; }
2003 #line 161 "btyacc_demo.y"
2004 { yyval.dlist = yystack.l_mark[0].dlist; }
2008 #line 164 "btyacc_demo.y"
2009 { yyval.dlist = append_dlist(yystack.l_mark[-3].dlist, yystack.l_mark[0].decl); }
2013 #line 165 "btyacc_demo.y"
2014 { yyval.dlist = build_dlist(yystack.l_mark[0].decl); }
2018 #line 168 "btyacc_demo.y"
2019 { yyval.decl = yystack.l_mark[0].decl; }
2023 #line 172 "btyacc_demo.y"
2024 { yyval.expr = build_expr(yystack.l_mark[-3].expr, ADD, yystack.l_mark[0].expr); }
2028 #line 173 "btyacc_demo.y"
2029 { yyval.expr = build_expr(yystack.l_mark[-3].expr, SUB, yystack.l_mark[0].expr); }
2033 #line 174 "btyacc_demo.y"
2034 { yyval.expr = build_expr(yystack.l_mark[-3].expr, MUL, yystack.l_mark[0].expr); }
2038 #line 175 "btyacc_demo.y"
2039 { yyval.expr = build_expr(yystack.l_mark[-3].expr, MOD, yystack.l_mark[0].expr); }
2043 #line 176 "btyacc_demo.y"
2044 { yyval.expr = build_expr(yystack.l_mark[-3].expr, DIV, yystack.l_mark[0].expr); }
2048 #line 177 "btyacc_demo.y"
2049 { yyval.expr = build_expr(0, DEREF, yystack.l_mark[0].expr); }
2053 #line 178 "btyacc_demo.y"
2054 { yyval.expr = var_expr(yystack.l_mark[-1].scope, yystack.l_mark[0].id); }
2058 #line 179 "btyacc_demo.y"
2059 { yyval.expr = yystack.l_mark[0].expr; }
2063 #line 183 "btyacc_demo.y"
2067 #line 184 "btyacc_demo.y"
2068 yyval.scope = yystack.l_mark[0].scope;
2071 #line 184 "btyacc_demo.y"
2072 {YYVALID;} if (!yytrial)
2073 #line 184 "btyacc_demo.y"
2074 { yyval.code = build_expr_code(yystack.l_mark[-1].expr); }
2077 #line 185 "btyacc_demo.y"
2078 yyval.scope = yystack.l_mark[-6].scope;
2081 #line 185 "btyacc_demo.y"
2082 yyval.scope = yystack.l_mark[-9].scope;
2085 #line 185 "btyacc_demo.y"
2086 {YYVALID;} if (!yytrial)
2087 #line 186 "btyacc_demo.y"
2088 { yyval.code = build_if(yystack.l_mark[-7].expr, yystack.l_mark[-3].code, yystack.l_mark[0].code); }
2091 #line 187 "btyacc_demo.y"
2092 {YYVALID;} if (!yytrial)
2093 #line 188 "btyacc_demo.y"
2094 { yyval.code = build_if(yystack.l_mark[-4].expr, yystack.l_mark[0].code, 0); }
2097 #line 189 "btyacc_demo.y"
2098 yyval.scope = new_scope(yystack.l_mark[0].scope);
2101 #line 189 "btyacc_demo.y"
2102 {YYVALID;} if (!yytrial)
2103 #line 189 "btyacc_demo.y"
2104 { yyval.code = yystack.l_mark[0].code; }
2108 #line 192 "btyacc_demo.y"
2113 #line 193 "btyacc_demo.y"
2114 { yyval.code = code_append(yystack.l_mark[-2].code, yystack.l_mark[0].code); }
2118 #line 197 "btyacc_demo.y"
2119 { yyval.code = yystack.l_mark[-1].code; }
2121 #line 2122 "btyacc_demo.tab.c"
2125 yystack.s_mark -= yym;
2126 yystate = *yystack.s_mark;
2127 yystack.l_mark -= yym;
2128 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2129 yystack.p_mark -= yym;
2132 if (yystate == 0 && yym == 0)
2137 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
2138 #ifdef YYSTYPE_TOSTRING
2141 #endif /* YYBTYACC */
2142 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval));
2144 fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL);
2148 *++yystack.s_mark = YYFINAL;
2149 *++yystack.l_mark = yyval;
2150 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2151 *++yystack.p_mark = yyloc;
2159 /* we're currently re-reading tokens */
2161 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2169 /* in trial mode; save scanner results for future parse attempts */
2170 if (yylvp == yylvlim)
2171 { /* Enlarge lexical value queue */
2172 size_t p = (size_t) (yylvp - yylvals);
2173 size_t s = (size_t) (yylvlim - yylvals);
2175 s += YYLVQUEUEGROWTH;
2176 if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL)
2178 if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
2180 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2181 if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
2184 yylvp = yylve = yylvals + p;
2185 yylvlim = yylvals + s;
2186 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2187 yylpp = yylpe = yylpsns + p;
2188 yylplim = yylpsns + s;
2190 yylexp = yylexemes + p;
2192 *yylexp = (short) YYLEX;
2195 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2202 /* normal operation, no conflict encountered */
2203 #endif /* YYBTYACC */
2207 #endif /* YYBTYACC */
2208 if (yychar < 0) yychar = YYEOF;
2209 /* if ((yychar = YYLEX) < 0) yychar = YYEOF; */
2213 yys = yyname[YYTRANSLATE(yychar)];
2214 fprintf(stderr, "%s[%d]: state %d, reading %d (%s)\n",
2215 YYDEBUGSTR, yydepth, YYFINAL, yychar, yys);
2219 if (yychar == YYEOF) goto yyaccept;
2222 if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
2223 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
2224 yystate = yytable[yyn];
2226 yystate = yydgoto[yym];
2230 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
2231 #ifdef YYSTYPE_TOSTRING
2234 #endif /* YYBTYACC */
2235 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval));
2237 fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate);
2240 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
2241 *++yystack.s_mark = (short) yystate;
2242 *++yystack.l_mark = yyval;
2243 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2244 *++yystack.p_mark = yyloc;
2249 /* Reduction declares that this path is valid. Set yypath and do a full parse */
2251 if (yypath) YYABORT;
2254 YYParseState *save = yyps->save;
2255 yyps->save = save->save;
2256 save->save = yypath;
2261 fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n",
2262 YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme));
2266 yyFreeState(yyerrctx);
2269 yylvp = yylvals + yypath->lexeme;
2270 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2271 yylpp = yylpsns + yypath->lexeme;
2273 yylexp = yylexemes + yypath->lexeme;
2275 yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base);
2276 memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
2277 yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base);
2278 memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
2279 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2280 yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base);
2281 memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
2283 yystate = yypath->state;
2285 #endif /* YYBTYACC */
2288 YYERROR_CALL("yacc stack overflow");
2292 YYERROR_CALL("memory exhausted");
2294 #endif /* YYBTYACC */
2304 if (yyps->save) goto yyvalid;
2305 #endif /* YYBTYACC */
2309 #if defined(YYDESTRUCT_CALL)
2310 if (yychar != YYEOF && yychar != YYEMPTY)
2311 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2312 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc);
2314 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval);
2315 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
2319 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2322 for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp)
2323 YYDESTRUCT_CALL("cleanup: discarding state",
2324 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp);
2326 for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv)
2327 YYDESTRUCT_CALL("cleanup: discarding state",
2328 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv);
2329 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
2331 #endif /* defined(YYDESTRUCT_CALL) */
2336 yyFreeState(yyerrctx);
2341 YYParseState *save = yyps;
2348 YYParseState *save = yypath;
2349 yypath = save->save;
2353 #endif /* YYBTYACC */
2354 yyfreestack(&yystack);