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 '}'",
518 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
519 YYLTYPE yyloc; /* position returned by actions */
520 YYLTYPE yylloc; /* position from the lexer */
523 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
524 #ifndef YYLLOC_DEFAULT
525 #define YYLLOC_DEFAULT(loc, rhs, n) \
530 (loc).first_line = ((rhs)[-1]).last_line; \
531 (loc).first_column = ((rhs)[-1]).last_column; \
532 (loc).last_line = ((rhs)[-1]).last_line; \
533 (loc).last_column = ((rhs)[-1]).last_column; \
537 (loc).first_line = ((rhs)[ 0 ]).first_line; \
538 (loc).first_column = ((rhs)[ 0 ]).first_column; \
539 (loc).last_line = ((rhs)[n-1]).last_line; \
540 (loc).last_column = ((rhs)[n-1]).last_column; \
543 #endif /* YYLLOC_DEFAULT */
544 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
547 #ifndef YYLVQUEUEGROWTH
548 #define YYLVQUEUEGROWTH 32
550 #endif /* YYBTYACC */
552 /* define the initial stack-sizes */
555 #define YYMAXDEPTH YYSTACKSIZE
558 #define YYSTACKSIZE YYMAXDEPTH
560 #define YYSTACKSIZE 10000
561 #define YYMAXDEPTH 10000
565 #ifndef YYINITSTACKSIZE
566 #define YYINITSTACKSIZE 200
576 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
583 struct YYParseState_s
585 struct YYParseState_s *save; /* Previously saved parser state */
586 YYSTACKDATA yystack; /* saved parser stack */
587 int state; /* saved parser state */
588 int errflag; /* saved error recovery status */
589 int lexeme; /* saved index of the conflict lexeme in the lexical queue */
590 YYINT ctry; /* saved index in yyctable[] for this conflict */
592 typedef struct YYParseState_s YYParseState;
593 #endif /* YYBTYACC */
594 /* variables for the parser stack */
595 static YYSTACKDATA yystack;
598 /* Current parser state */
599 static YYParseState *yyps = 0;
601 /* yypath != NULL: do the full parse, starting at *yypath parser state. */
602 static YYParseState *yypath = 0;
604 /* Base of the lexical value queue */
605 static YYSTYPE *yylvals = 0;
607 /* Current position at lexical value queue */
608 static YYSTYPE *yylvp = 0;
610 /* End position of lexical value queue */
611 static YYSTYPE *yylve = 0;
613 /* The last allocated position at the lexical value queue */
614 static YYSTYPE *yylvlim = 0;
616 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
617 /* Base of the lexical position queue */
618 static YYLTYPE *yylpsns = 0;
620 /* Current position at lexical position queue */
621 static YYLTYPE *yylpp = 0;
623 /* End position of lexical position queue */
624 static YYLTYPE *yylpe = 0;
626 /* The last allocated position at the lexical position queue */
627 static YYLTYPE *yylplim = 0;
630 /* Current position at lexical token queue */
631 static YYINT *yylexp = 0;
633 static YYINT *yylexemes = 0;
634 #endif /* YYBTYACC */
635 #line 200 "btyacc_demo.y"
637 extern int YYLEX_DECL();
638 extern void YYERROR_DECL();
640 extern Scope *global_scope;
642 extern Decl * lookup(Scope *scope, char *id);
643 extern Scope * new_scope(Scope *outer_scope);
644 extern Scope * start_fn_def(Scope *scope, Decl *fn_decl);
645 extern void finish_fn_def(Decl *fn_decl, Code *block);
646 extern Type * type_combine(Type *specs, Type *spec);
647 extern Type * bare_extern(void);
648 extern Type * bare_register(void);
649 extern Type * bare_static(void);
650 extern Type * bare_const(void);
651 extern Type * bare_volatile(void);
652 extern Decl * declare(Scope *scope, char *id, Type *type);
653 extern Decl * make_pointer(Decl *decl, Type *type);
654 extern Decl * make_array(Type *type, Expr *expr);
655 extern Decl * build_function(Decl *decl, Decl_List *dlist, Type *type);
656 extern Decl_List * append_dlist(Decl_List *dlist, Decl *decl);
657 extern Decl_List * build_dlist(Decl *decl);
658 extern Expr * build_expr(Expr *left, enum Operator op, Expr *right);
659 extern Expr * var_expr(Scope *scope, char *id);
660 extern Code * build_expr_code(Expr *expr);
661 extern Code * build_if(Expr *cond_expr, Code *then_stmt, Code *else_stmt);
662 extern Code * code_append(Code *stmt_list, Code *stmt);
663 #line 664 "btyacc_demo.tab.c"
665 /* Release memory associated with symbol. */
666 #if ! defined YYDESTRUCT_IS_DECLARED
673 #line 83 "btyacc_demo.y"
674 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
676 (*loc).first_line, (*loc).first_column,
677 (*loc).last_line, (*loc).last_column);
678 /* in this example, we don't know what to do here */ }
680 #line 681 "btyacc_demo.tab.c"
682 #line 83 "btyacc_demo.y"
683 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
685 (*loc).first_line, (*loc).first_column,
686 (*loc).last_line, (*loc).last_column);
687 /* in this example, we don't know what to do here */ }
689 #line 690 "btyacc_demo.tab.c"
691 #line 83 "btyacc_demo.y"
692 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
694 (*loc).first_line, (*loc).first_column,
695 (*loc).last_line, (*loc).last_column);
696 /* in this example, we don't know what to do here */ }
698 #line 699 "btyacc_demo.tab.c"
700 #line 83 "btyacc_demo.y"
701 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
703 (*loc).first_line, (*loc).first_column,
704 (*loc).last_line, (*loc).last_column);
705 /* in this example, we don't know what to do here */ }
707 #line 708 "btyacc_demo.tab.c"
709 #line 83 "btyacc_demo.y"
710 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
712 (*loc).first_line, (*loc).first_column,
713 (*loc).last_line, (*loc).last_column);
714 /* in this example, we don't know what to do here */ }
716 #line 717 "btyacc_demo.tab.c"
718 #line 83 "btyacc_demo.y"
719 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
721 (*loc).first_line, (*loc).first_column,
722 (*loc).last_line, (*loc).last_column);
723 /* in this example, we don't know what to do here */ }
725 #line 726 "btyacc_demo.tab.c"
727 #line 83 "btyacc_demo.y"
728 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
730 (*loc).first_line, (*loc).first_column,
731 (*loc).last_line, (*loc).last_column);
732 /* in this example, we don't know what to do here */ }
734 #line 735 "btyacc_demo.tab.c"
736 #line 83 "btyacc_demo.y"
737 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
739 (*loc).first_line, (*loc).first_column,
740 (*loc).last_line, (*loc).last_column);
741 /* in this example, we don't know what to do here */ }
743 #line 744 "btyacc_demo.tab.c"
745 #line 83 "btyacc_demo.y"
746 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
748 (*loc).first_line, (*loc).first_column,
749 (*loc).last_line, (*loc).last_column);
750 /* in this example, we don't know what to do here */ }
752 #line 753 "btyacc_demo.tab.c"
754 #line 83 "btyacc_demo.y"
755 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
757 (*loc).first_line, (*loc).first_column,
758 (*loc).last_line, (*loc).last_column);
759 /* in this example, we don't know what to do here */ }
761 #line 762 "btyacc_demo.tab.c"
763 #line 78 "btyacc_demo.y"
764 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
766 (*loc).first_line, (*loc).first_column,
767 (*loc).last_line, (*loc).last_column);
770 #line 771 "btyacc_demo.tab.c"
772 #line 78 "btyacc_demo.y"
773 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
775 (*loc).first_line, (*loc).first_column,
776 (*loc).last_line, (*loc).last_column);
779 #line 780 "btyacc_demo.tab.c"
781 #line 83 "btyacc_demo.y"
782 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
784 (*loc).first_line, (*loc).first_column,
785 (*loc).last_line, (*loc).last_column);
786 /* in this example, we don't know what to do here */ }
788 #line 789 "btyacc_demo.tab.c"
790 #line 83 "btyacc_demo.y"
791 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
793 (*loc).first_line, (*loc).first_column,
794 (*loc).last_line, (*loc).last_column);
795 /* in this example, we don't know what to do here */ }
797 #line 798 "btyacc_demo.tab.c"
799 #line 83 "btyacc_demo.y"
800 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
802 (*loc).first_line, (*loc).first_column,
803 (*loc).last_line, (*loc).last_column);
804 /* in this example, we don't know what to do here */ }
806 #line 807 "btyacc_demo.tab.c"
808 #line 83 "btyacc_demo.y"
809 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
811 (*loc).first_line, (*loc).first_column,
812 (*loc).last_line, (*loc).last_column);
813 /* in this example, we don't know what to do here */ }
815 #line 816 "btyacc_demo.tab.c"
817 #line 83 "btyacc_demo.y"
818 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
820 (*loc).first_line, (*loc).first_column,
821 (*loc).last_line, (*loc).last_column);
822 /* in this example, we don't know what to do here */ }
824 #line 825 "btyacc_demo.tab.c"
826 #line 83 "btyacc_demo.y"
827 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
829 (*loc).first_line, (*loc).first_column,
830 (*loc).last_line, (*loc).last_column);
831 /* in this example, we don't know what to do here */ }
833 #line 834 "btyacc_demo.tab.c"
835 #line 83 "btyacc_demo.y"
836 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
838 (*loc).first_line, (*loc).first_column,
839 (*loc).last_line, (*loc).last_column);
840 /* in this example, we don't know what to do here */ }
842 #line 843 "btyacc_demo.tab.c"
844 #line 83 "btyacc_demo.y"
845 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
847 (*loc).first_line, (*loc).first_column,
848 (*loc).last_line, (*loc).last_column);
849 /* in this example, we don't know what to do here */ }
851 #line 852 "btyacc_demo.tab.c"
853 #line 83 "btyacc_demo.y"
854 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
856 (*loc).first_line, (*loc).first_column,
857 (*loc).last_line, (*loc).last_column);
858 /* in this example, we don't know what to do here */ }
860 #line 861 "btyacc_demo.tab.c"
862 #line 83 "btyacc_demo.y"
863 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
865 (*loc).first_line, (*loc).first_column,
866 (*loc).last_line, (*loc).last_column);
867 /* in this example, we don't know what to do here */ }
869 #line 870 "btyacc_demo.tab.c"
871 #line 83 "btyacc_demo.y"
872 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
874 (*loc).first_line, (*loc).first_column,
875 (*loc).last_line, (*loc).last_column);
876 /* in this example, we don't know what to do here */ }
878 #line 879 "btyacc_demo.tab.c"
880 #line 83 "btyacc_demo.y"
881 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
883 (*loc).first_line, (*loc).first_column,
884 (*loc).last_line, (*loc).last_column);
885 /* in this example, we don't know what to do here */ }
887 #line 888 "btyacc_demo.tab.c"
889 #line 83 "btyacc_demo.y"
890 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
892 (*loc).first_line, (*loc).first_column,
893 (*loc).last_line, (*loc).last_column);
894 /* in this example, we don't know what to do here */ }
896 #line 897 "btyacc_demo.tab.c"
898 #line 83 "btyacc_demo.y"
899 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
901 (*loc).first_line, (*loc).first_column,
902 (*loc).last_line, (*loc).last_column);
903 /* in this example, we don't know what to do here */ }
905 #line 906 "btyacc_demo.tab.c"
907 #line 83 "btyacc_demo.y"
908 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
910 (*loc).first_line, (*loc).first_column,
911 (*loc).last_line, (*loc).last_column);
912 /* in this example, we don't know what to do here */ }
914 #line 915 "btyacc_demo.tab.c"
916 #line 83 "btyacc_demo.y"
917 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
919 (*loc).first_line, (*loc).first_column,
920 (*loc).last_line, (*loc).last_column);
921 /* in this example, we don't know what to do here */ }
923 #line 924 "btyacc_demo.tab.c"
925 #line 83 "btyacc_demo.y"
926 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
928 (*loc).first_line, (*loc).first_column,
929 (*loc).last_line, (*loc).last_column);
930 /* in this example, we don't know what to do here */ }
932 #line 933 "btyacc_demo.tab.c"
934 #line 78 "btyacc_demo.y"
935 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
937 (*loc).first_line, (*loc).first_column,
938 (*loc).last_line, (*loc).last_column);
941 #line 942 "btyacc_demo.tab.c"
943 #line 67 "btyacc_demo.y"
944 { /* 'msg' is a 'char *' indicating the context of destructor invocation*/
945 printf("%s accessed by symbol \"decl\" (case s.b. 273) @ position[%d,%d..%d,%d]\n",
947 (*loc).first_line, (*loc).first_column,
948 (*loc).last_line, (*loc).last_column);
949 free((*val).decl->scope); free((*val).decl->type); }
951 #line 952 "btyacc_demo.tab.c"
953 #line 83 "btyacc_demo.y"
954 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
956 (*loc).first_line, (*loc).first_column,
957 (*loc).last_line, (*loc).last_column);
958 /* in this example, we don't know what to do here */ }
960 #line 961 "btyacc_demo.tab.c"
962 #line 83 "btyacc_demo.y"
963 { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",
965 (*loc).first_line, (*loc).first_column,
966 (*loc).last_line, (*loc).last_column);
967 /* in this example, we don't know what to do here */ }
969 #line 970 "btyacc_demo.tab.c"
971 #line 78 "btyacc_demo.y"
972 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
974 (*loc).first_line, (*loc).first_column,
975 (*loc).last_line, (*loc).last_column);
978 #line 979 "btyacc_demo.tab.c"
980 #line 78 "btyacc_demo.y"
981 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
983 (*loc).first_line, (*loc).first_column,
984 (*loc).last_line, (*loc).last_column);
987 #line 988 "btyacc_demo.tab.c"
989 #line 78 "btyacc_demo.y"
990 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
992 (*loc).first_line, (*loc).first_column,
993 (*loc).last_line, (*loc).last_column);
996 #line 997 "btyacc_demo.tab.c"
998 #line 73 "btyacc_demo.y"
999 { printf("%s accessed by symbol with type <decl> (case s.b. 279 & 280) @ position[%d,%d..%d,%d]\n",
1001 (*loc).first_line, (*loc).first_column,
1002 (*loc).last_line, (*loc).last_column);
1003 free((*val).decl); }
1005 #line 1006 "btyacc_demo.tab.c"
1007 #line 73 "btyacc_demo.y"
1008 { printf("%s accessed by symbol with type <decl> (case s.b. 279 & 280) @ position[%d,%d..%d,%d]\n",
1010 (*loc).first_line, (*loc).first_column,
1011 (*loc).last_line, (*loc).last_column);
1012 free((*val).decl); }
1014 #line 1015 "btyacc_demo.tab.c"
1016 #line 78 "btyacc_demo.y"
1017 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1019 (*loc).first_line, (*loc).first_column,
1020 (*loc).last_line, (*loc).last_column);
1021 free((*val).type); }
1023 #line 1024 "btyacc_demo.tab.c"
1025 #line 78 "btyacc_demo.y"
1026 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1028 (*loc).first_line, (*loc).first_column,
1029 (*loc).last_line, (*loc).last_column);
1030 free((*val).type); }
1032 #line 1033 "btyacc_demo.tab.c"
1034 #line 78 "btyacc_demo.y"
1035 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1037 (*loc).first_line, (*loc).first_column,
1038 (*loc).last_line, (*loc).last_column);
1039 free((*val).type); }
1041 #line 1042 "btyacc_demo.tab.c"
1043 #line 78 "btyacc_demo.y"
1044 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1046 (*loc).first_line, (*loc).first_column,
1047 (*loc).last_line, (*loc).last_column);
1048 free((*val).type); }
1050 #line 1051 "btyacc_demo.tab.c"
1052 #line 78 "btyacc_demo.y"
1053 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1055 (*loc).first_line, (*loc).first_column,
1056 (*loc).last_line, (*loc).last_column);
1057 free((*val).type); }
1059 #line 1060 "btyacc_demo.tab.c"
1061 #line 78 "btyacc_demo.y"
1062 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1064 (*loc).first_line, (*loc).first_column,
1065 (*loc).last_line, (*loc).last_column);
1066 free((*val).scope); }
1068 #line 1069 "btyacc_demo.tab.c"
1070 #line 78 "btyacc_demo.y"
1071 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1073 (*loc).first_line, (*loc).first_column,
1074 (*loc).last_line, (*loc).last_column);
1075 free((*val).dlist); }
1077 #line 1078 "btyacc_demo.tab.c"
1079 #line 78 "btyacc_demo.y"
1080 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1082 (*loc).first_line, (*loc).first_column,
1083 (*loc).last_line, (*loc).last_column);
1084 free((*val).dlist); }
1086 #line 1087 "btyacc_demo.tab.c"
1088 #line 78 "btyacc_demo.y"
1089 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1091 (*loc).first_line, (*loc).first_column,
1092 (*loc).last_line, (*loc).last_column);
1093 free((*val).scope); }
1095 #line 1096 "btyacc_demo.tab.c"
1097 #line 78 "btyacc_demo.y"
1098 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1100 (*loc).first_line, (*loc).first_column,
1101 (*loc).last_line, (*loc).last_column);
1102 free((*val).scope); }
1104 #line 1105 "btyacc_demo.tab.c"
1106 #line 78 "btyacc_demo.y"
1107 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1109 (*loc).first_line, (*loc).first_column,
1110 (*loc).last_line, (*loc).last_column);
1111 free((*val).scope); }
1113 #line 1114 "btyacc_demo.tab.c"
1115 #line 78 "btyacc_demo.y"
1116 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1118 (*loc).first_line, (*loc).first_column,
1119 (*loc).last_line, (*loc).last_column);
1120 free((*val).scope); }
1122 #line 1123 "btyacc_demo.tab.c"
1124 #line 78 "btyacc_demo.y"
1125 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1127 (*loc).first_line, (*loc).first_column,
1128 (*loc).last_line, (*loc).last_column);
1129 free((*val).type); }
1131 #line 1132 "btyacc_demo.tab.c"
1133 #line 78 "btyacc_demo.y"
1134 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1136 (*loc).first_line, (*loc).first_column,
1137 (*loc).last_line, (*loc).last_column);
1138 free((*val).scope); }
1140 #line 1141 "btyacc_demo.tab.c"
1142 #line 78 "btyacc_demo.y"
1143 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1145 (*loc).first_line, (*loc).first_column,
1146 (*loc).last_line, (*loc).last_column);
1147 free((*val).type); }
1149 #line 1150 "btyacc_demo.tab.c"
1151 #line 78 "btyacc_demo.y"
1152 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1154 (*loc).first_line, (*loc).first_column,
1155 (*loc).last_line, (*loc).last_column);
1156 free((*val).scope); }
1158 #line 1159 "btyacc_demo.tab.c"
1160 #line 78 "btyacc_demo.y"
1161 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1163 (*loc).first_line, (*loc).first_column,
1164 (*loc).last_line, (*loc).last_column);
1165 free((*val).scope); }
1167 #line 1168 "btyacc_demo.tab.c"
1169 #line 78 "btyacc_demo.y"
1170 { printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",
1172 (*loc).first_line, (*loc).first_column,
1173 (*loc).last_line, (*loc).last_column);
1174 free((*val).scope); }
1176 #line 1177 "btyacc_demo.tab.c"
1179 #define YYDESTRUCT_IS_DECLARED 1
1182 /* For use in generated program */
1183 #define yydepth (int)(yystack.s_mark - yystack.s_base)
1185 #define yytrial (yyps->save)
1186 #endif /* YYBTYACC */
1189 #include <stdio.h> /* needed for printf */
1192 #include <stdlib.h> /* needed for malloc, etc */
1193 #include <string.h> /* needed for memset */
1195 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
1196 static int yygrowstack(YYSTACKDATA *data)
1202 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1206 if ((newsize = data->stacksize) == 0)
1207 newsize = YYINITSTACKSIZE;
1208 else if (newsize >= YYMAXDEPTH)
1210 else if ((newsize *= 2) > YYMAXDEPTH)
1211 newsize = YYMAXDEPTH;
1213 i = (int) (data->s_mark - data->s_base);
1214 newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
1218 data->s_base = newss;
1219 data->s_mark = newss + i;
1221 newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
1225 data->l_base = newvs;
1226 data->l_mark = newvs + i;
1228 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1229 newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps));
1233 data->p_base = newps;
1234 data->p_mark = newps + i;
1237 data->stacksize = newsize;
1238 data->s_last = data->s_base + newsize - 1;
1242 fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize);
1247 #if YYPURE || defined(YY_NO_LEAKS)
1248 static void yyfreestack(YYSTACKDATA *data)
1252 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1255 memset(data, 0, sizeof(*data));
1258 #define yyfreestack(data) /* nothing */
1259 #endif /* YYPURE || defined(YY_NO_LEAKS) */
1262 static YYParseState *
1263 yyNewState(unsigned size)
1265 YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState));
1266 if (p == NULL) return NULL;
1268 p->yystack.stacksize = size;
1271 p->yystack.s_base = NULL;
1272 p->yystack.l_base = NULL;
1273 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1274 p->yystack.p_base = NULL;
1278 p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT));
1279 if (p->yystack.s_base == NULL) return NULL;
1280 p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE));
1281 if (p->yystack.l_base == NULL) return NULL;
1282 memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE));
1283 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1284 p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE));
1285 if (p->yystack.p_base == NULL) return NULL;
1286 memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE));
1293 yyFreeState(YYParseState *p)
1295 yyfreestack(&p->yystack);
1298 #endif /* YYBTYACC */
1300 #define YYABORT goto yyabort
1301 #define YYREJECT goto yyabort
1302 #define YYACCEPT goto yyaccept
1303 #define YYERROR goto yyerrlab
1305 #define YYVALID do { if (yyps->save) goto yyvalid; } while(0)
1306 #define YYVALID_NESTED do { if (yyps->save && \
1307 yyps->save->save == 0) goto yyvalid; } while(0)
1308 #endif /* YYBTYACC */
1313 int yym, yyn, yystate, yyresult;
1316 YYParseState *yyerrctx = NULL;
1317 #endif /* YYBTYACC */
1318 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1319 YYLTYPE yyerror_loc_range[2]; /* position of error start & end */
1324 if ((yys = getenv("YYDEBUG")) != 0)
1327 if (yyn >= '0' && yyn <= '9')
1328 yydebug = yyn - '0';
1331 fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX);
1333 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1334 memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range));
1338 yyps = yyNewState(0); if (yyps == 0) goto yyenomem;
1340 #endif /* YYBTYACC */
1349 memset(&yystack, 0, sizeof(yystack));
1352 if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1353 yystack.s_mark = yystack.s_base;
1354 yystack.l_mark = yystack.l_base;
1355 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1356 yystack.p_mark = yystack.p_base;
1359 *yystack.s_mark = 0;
1362 if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
1369 /* we're currently re-reading tokens */
1371 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1379 /* in trial mode; save scanner results for future parse attempts */
1380 if (yylvp == yylvlim)
1381 { /* Enlarge lexical value queue */
1382 size_t p = (size_t) (yylvp - yylvals);
1383 size_t s = (size_t) (yylvlim - yylvals);
1385 s += YYLVQUEUEGROWTH;
1386 if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
1387 if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
1388 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1389 if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
1391 yylvp = yylve = yylvals + p;
1392 yylvlim = yylvals + s;
1393 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1394 yylpp = yylpe = yylpsns + p;
1395 yylplim = yylpsns + s;
1397 yylexp = yylexemes + p;
1399 *yylexp = (YYINT) YYLEX;
1402 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1409 /* normal operation, no conflict encountered */
1410 #endif /* YYBTYACC */
1414 #endif /* YYBTYACC */
1415 if (yychar < 0) yychar = YYEOF;
1419 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
1420 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)",
1421 YYDEBUGSTR, yydepth, yystate, yychar, yys);
1422 #ifdef YYSTYPE_TOSTRING
1425 #endif /* YYBTYACC */
1426 fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval));
1428 fputc('\n', stderr);
1434 /* Do we have a conflict? */
1435 if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
1436 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
1445 fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n",
1446 YYDEBUGSTR, yydepth, yystate);
1448 /* Switch to the next conflict context */
1450 yypath = save->save;
1453 if (save->state != yystate) YYABORT;
1460 /* Unresolved conflict - start/continue trial parse */
1465 fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate);
1467 fputs("ALREADY in conflict, continuing trial parse.\n", stderr);
1469 fputs("Starting trial parse.\n", stderr);
1472 save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
1473 if (save == NULL) goto yyenomem;
1474 save->save = yyps->save;
1475 save->state = yystate;
1476 save->errflag = yyerrflag;
1477 save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base);
1478 memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1479 save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base);
1480 memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1481 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1482 save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base);
1483 memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1485 ctry = yytable[yyn];
1486 if (yyctable[ctry] == -1)
1489 if (yydebug && yychar >= YYEOF)
1490 fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth);
1495 if (yyps->save == NULL)
1497 /* If this is a first conflict in the stack, start saving lexemes */
1500 yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
1501 if (yylexemes == NULL) goto yyenomem;
1502 yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
1503 if (yylvals == NULL) goto yyenomem;
1504 yylvlim = yylvals + YYLVQUEUEGROWTH;
1505 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1506 yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE));
1507 if (yylpsns == NULL) goto yyenomem;
1508 yylplim = yylpsns + YYLVQUEUEGROWTH;
1513 yylvp = yylve = yylvals;
1514 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1515 yylpp = yylpe = yylpsns;
1518 if (yychar >= YYEOF)
1521 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1524 *yylexp = (YYINT) yychar;
1529 if (yychar >= YYEOF)
1532 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1538 save->lexeme = (int) (yylvp - yylvals);
1541 if (yytable[yyn] == ctry)
1545 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
1546 YYDEBUGSTR, yydepth, yystate, yyctable[ctry]);
1551 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1556 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
1558 yystate = yyctable[ctry];
1559 *++yystack.s_mark = (YYINT) yystate;
1560 *++yystack.l_mark = yylval;
1561 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1562 *++yystack.p_mark = yylloc;
1565 if (yyerrflag > 0) --yyerrflag;
1570 yyn = yyctable[ctry];
1573 } /* End of code dealing with conflicts */
1574 #endif /* YYBTYACC */
1575 if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
1576 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
1580 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
1581 YYDEBUGSTR, yydepth, yystate, yytable[yyn]);
1583 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1584 yystate = yytable[yyn];
1585 *++yystack.s_mark = yytable[yyn];
1586 *++yystack.l_mark = yylval;
1587 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1588 *++yystack.p_mark = yylloc;
1591 if (yyerrflag > 0) --yyerrflag;
1594 if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
1595 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
1600 if (yyerrflag != 0) goto yyinrecovery;
1605 goto yyerrlab; /* redundant goto avoids 'unused label' warning */
1608 /* explicit YYERROR from an action -- pop the rhs of the rule reduced
1609 * before looking for error recovery */
1610 yystack.s_mark -= yym;
1611 yystate = *yystack.s_mark;
1612 yystack.l_mark -= yym;
1613 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1614 yystack.p_mark -= yym;
1622 YYParseState *save = yyps->save;
1625 fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n",
1626 YYDEBUGSTR, yydepth, yystate, yyps->save->state,
1627 (int)(yylvp - yylvals - yyps->save->lexeme));
1629 /* Memorize most forward-looking error state in case it's really an error. */
1630 if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals)
1632 /* Free old saved error context state */
1633 if (yyerrctx) yyFreeState(yyerrctx);
1634 /* Create and fill out new saved error context state */
1635 yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
1636 if (yyerrctx == NULL) goto yyenomem;
1637 yyerrctx->save = yyps->save;
1638 yyerrctx->state = yystate;
1639 yyerrctx->errflag = yyerrflag;
1640 yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base);
1641 memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1642 yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base);
1643 memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1644 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1645 yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base);
1646 memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1648 yyerrctx->lexeme = (int) (yylvp - yylvals);
1650 yylvp = yylvals + save->lexeme;
1651 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1652 yylpp = yylpsns + save->lexeme;
1654 yylexp = yylexemes + save->lexeme;
1656 yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base);
1657 memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1658 yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base);
1659 memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1660 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1661 yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base);
1662 memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1664 ctry = ++save->ctry;
1665 yystate = save->state;
1666 /* We tried shift, try reduce now */
1667 if ((yyn = yyctable[ctry]) >= 0) goto yyreduce;
1668 yyps->save = save->save;
1672 /* Nothing left on the stack -- error */
1677 fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n",
1680 /* Restore state as it was in the most forward-advanced error */
1681 yylvp = yylvals + yyerrctx->lexeme;
1682 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1683 yylpp = yylpsns + yyerrctx->lexeme;
1685 yylexp = yylexemes + yyerrctx->lexeme;
1686 yychar = yylexp[-1];
1688 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1691 yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base);
1692 memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1693 yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base);
1694 memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1695 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1696 yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base);
1697 memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1699 yystate = yyerrctx->state;
1700 yyFreeState(yyerrctx);
1705 if (yynewerrflag == 0) goto yyinrecovery;
1706 #endif /* YYBTYACC */
1708 YYERROR_CALL("syntax error");
1709 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1710 yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
1714 goto yyerrlab; /* redundant goto avoids 'unused label' warning */
1725 if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
1726 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
1730 fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n",
1731 YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]);
1733 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1734 yystate = yytable[yyn];
1735 *++yystack.s_mark = yytable[yyn];
1736 *++yystack.l_mark = yylval;
1737 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1738 /* lookahead position is error end position */
1739 yyerror_loc_range[1] = yylloc;
1740 YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
1741 *++yystack.p_mark = yyloc;
1749 fprintf(stderr, "%s[%d]: error recovery discarding state %d\n",
1750 YYDEBUGSTR, yydepth, *yystack.s_mark);
1752 if (yystack.s_mark <= yystack.s_base) goto yyabort;
1753 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1754 /* the current TOS position is the error start position */
1755 yyerror_loc_range[0] = *yystack.p_mark;
1757 #if defined(YYDESTRUCT_CALL)
1760 #endif /* YYBTYACC */
1761 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1762 YYDESTRUCT_CALL("error: discarding state",
1763 yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark);
1765 YYDESTRUCT_CALL("error: discarding state",
1766 yystos[*yystack.s_mark], yystack.l_mark);
1767 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1768 #endif /* defined(YYDESTRUCT_CALL) */
1771 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1779 if (yychar == YYEOF) goto yyabort;
1783 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
1784 fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n",
1785 YYDEBUGSTR, yydepth, yystate, yychar, yys);
1788 #if defined(YYDESTRUCT_CALL)
1791 #endif /* YYBTYACC */
1792 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1793 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc);
1795 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval);
1796 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1797 #endif /* defined(YYDESTRUCT_CALL) */
1807 fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)",
1808 YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]);
1809 #ifdef YYSTYPE_TOSTRING
1812 #endif /* YYBTYACC */
1817 for (i = yym; i > 0; i--)
1819 if (i != yym) fputs(", ", stderr);
1820 fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]],
1821 yystack.l_mark[1-i]), stderr);
1826 fputc('\n', stderr);
1830 yyval = yystack.l_mark[1-yym];
1832 memset(&yyval, 0, sizeof yyval);
1833 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1835 /* Perform position reduction */
1836 memset(&yyloc, 0, sizeof(yyloc));
1839 #endif /* YYBTYACC */
1841 YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
1842 /* just in case YYERROR is invoked within the action, save
1843 the start of the rhs as the error start position */
1844 yyerror_loc_range[0] = yystack.p_mark[1-yym];
1851 #line 93 "btyacc_demo.y"
1852 { yyval.scope = yystack.l_mark[0].scope; }
1855 #line 94 "btyacc_demo.y"
1856 { yyval.scope = global_scope; }
1859 #line 95 "btyacc_demo.y"
1860 { Decl *d = lookup(yystack.l_mark[-2].scope, yystack.l_mark[-1].id);
1861 if (!d || !d->scope) YYERROR;
1862 yyval.scope = d->scope; }
1865 #line 101 "btyacc_demo.y"
1866 { Decl *d = lookup(yystack.l_mark[-1].scope, yystack.l_mark[0].id);
1867 if (d == NULL || d->istype() == 0) YYERROR;
1868 yyval.type = d->type; }
1871 #line 106 "btyacc_demo.y"
1872 yyval.scope = global_scope = new_scope(0);
1875 #line 107 "btyacc_demo.y"
1876 yyval.scope = yystack.l_mark[-1].scope;
1879 #line 109 "btyacc_demo.y"
1883 #line 110 "btyacc_demo.y"
1884 yyval.scope = start_fn_def(yystack.l_mark[-2].scope, yystack.l_mark[0].decl);
1888 #line 111 "btyacc_demo.y"
1889 { /* demonstrate use of @$ & @N, although this is just the
1890 default computation and so is not necessary */
1891 yyloc.first_line = yystack.p_mark[-3].first_line;
1892 yyloc.first_column = yystack.p_mark[-3].first_column;
1893 yyloc.last_line = yystack.p_mark[0].last_line;
1894 yyloc.last_column = yystack.p_mark[0].last_column;
1895 finish_fn_def(yystack.l_mark[-2].decl, yystack.l_mark[0].code); }
1898 #line 121 "btyacc_demo.y"
1899 { yyval.type = yystack.l_mark[0].type; }
1902 #line 122 "btyacc_demo.y"
1903 { yyval.type = type_combine(yystack.l_mark[-2].type, yystack.l_mark[0].type); }
1906 #line 125 "btyacc_demo.y"
1910 #line 126 "btyacc_demo.y"
1911 { yyval.type = type_combine(yystack.l_mark[-1].type, yystack.l_mark[0].type); }
1914 #line 130 "btyacc_demo.y"
1915 { yyval.type = yystack.l_mark[0].type; }
1918 #line 131 "btyacc_demo.y"
1919 { yyval.type = yystack.l_mark[0].type; }
1922 #line 132 "btyacc_demo.y"
1923 { yyval.type = bare_extern(); }
1926 #line 133 "btyacc_demo.y"
1927 { yyval.type = bare_register(); }
1930 #line 134 "btyacc_demo.y"
1931 { yyval.type = bare_static(); }
1934 #line 138 "btyacc_demo.y"
1935 { yyval.type = bare_const(); }
1938 #line 139 "btyacc_demo.y"
1939 { yyval.type = bare_volatile(); }
1942 #line 143 "btyacc_demo.y"
1943 yyval.scope = yystack.l_mark[-3].scope;
1946 #line 143 "btyacc_demo.y"
1947 yyval.type = yystack.l_mark[-3].type;
1950 #line 148 "btyacc_demo.y"
1951 { if (!yystack.l_mark[0].type) YYERROR; } if (!yytrial)
1952 #line 149 "btyacc_demo.y"
1953 { yyval.decl = declare(yystack.l_mark[-1].scope, 0, yystack.l_mark[0].type); }
1957 #line 150 "btyacc_demo.y"
1958 { yyval.decl = declare(yystack.l_mark[-2].scope, yystack.l_mark[0].id, yystack.l_mark[-1].type); }
1961 #line 151 "btyacc_demo.y"
1962 yyval.scope = yystack.l_mark[-2].scope;
1965 #line 151 "btyacc_demo.y"
1966 yyval.type = yystack.l_mark[-2].type;
1970 #line 151 "btyacc_demo.y"
1971 { yyval.decl = yystack.l_mark[-1].decl; }
1975 #line 153 "btyacc_demo.y"
1976 { yyval.decl = make_pointer(yystack.l_mark[0].decl, yystack.l_mark[-3].type); }
1980 #line 155 "btyacc_demo.y"
1981 { yyval.decl = make_array(yystack.l_mark[-4].decl->type, yystack.l_mark[-1].expr); }
1985 #line 157 "btyacc_demo.y"
1986 { yyval.decl = build_function(yystack.l_mark[-5].decl, yystack.l_mark[-2].dlist, yystack.l_mark[0].type); }
1990 #line 160 "btyacc_demo.y"
1991 { yyval.dlist = 0; }
1995 #line 161 "btyacc_demo.y"
1996 { yyval.dlist = yystack.l_mark[0].dlist; }
2000 #line 164 "btyacc_demo.y"
2001 { yyval.dlist = append_dlist(yystack.l_mark[-3].dlist, yystack.l_mark[0].decl); }
2005 #line 165 "btyacc_demo.y"
2006 { yyval.dlist = build_dlist(yystack.l_mark[0].decl); }
2010 #line 168 "btyacc_demo.y"
2011 { yyval.decl = yystack.l_mark[0].decl; }
2015 #line 172 "btyacc_demo.y"
2016 { yyval.expr = build_expr(yystack.l_mark[-3].expr, ADD, yystack.l_mark[0].expr); }
2020 #line 173 "btyacc_demo.y"
2021 { yyval.expr = build_expr(yystack.l_mark[-3].expr, SUB, yystack.l_mark[0].expr); }
2025 #line 174 "btyacc_demo.y"
2026 { yyval.expr = build_expr(yystack.l_mark[-3].expr, MUL, yystack.l_mark[0].expr); }
2030 #line 175 "btyacc_demo.y"
2031 { yyval.expr = build_expr(yystack.l_mark[-3].expr, MOD, yystack.l_mark[0].expr); }
2035 #line 176 "btyacc_demo.y"
2036 { yyval.expr = build_expr(yystack.l_mark[-3].expr, DIV, yystack.l_mark[0].expr); }
2040 #line 177 "btyacc_demo.y"
2041 { yyval.expr = build_expr(0, DEREF, yystack.l_mark[0].expr); }
2045 #line 178 "btyacc_demo.y"
2046 { yyval.expr = var_expr(yystack.l_mark[-1].scope, yystack.l_mark[0].id); }
2050 #line 179 "btyacc_demo.y"
2051 { yyval.expr = yystack.l_mark[0].expr; }
2055 #line 183 "btyacc_demo.y"
2059 #line 184 "btyacc_demo.y"
2060 {YYVALID;} if (!yytrial)
2061 #line 184 "btyacc_demo.y"
2062 { yyval.code = build_expr_code(yystack.l_mark[-1].expr); }
2065 #line 185 "btyacc_demo.y"
2066 yyval.scope = yystack.l_mark[-6].scope;
2069 #line 185 "btyacc_demo.y"
2070 yyval.scope = yystack.l_mark[-9].scope;
2073 #line 185 "btyacc_demo.y"
2074 {YYVALID;} if (!yytrial)
2075 #line 186 "btyacc_demo.y"
2076 { yyval.code = build_if(yystack.l_mark[-7].expr, yystack.l_mark[-3].code, yystack.l_mark[0].code); }
2079 #line 187 "btyacc_demo.y"
2080 {YYVALID;} if (!yytrial)
2081 #line 188 "btyacc_demo.y"
2082 { yyval.code = build_if(yystack.l_mark[-4].expr, yystack.l_mark[0].code, 0); }
2085 #line 189 "btyacc_demo.y"
2086 yyval.scope = new_scope(yystack.l_mark[0].scope);
2089 #line 189 "btyacc_demo.y"
2090 {YYVALID;} if (!yytrial)
2091 #line 189 "btyacc_demo.y"
2092 { yyval.code = yystack.l_mark[0].code; }
2096 #line 192 "btyacc_demo.y"
2101 #line 193 "btyacc_demo.y"
2102 { yyval.code = code_append(yystack.l_mark[-2].code, yystack.l_mark[0].code); }
2106 #line 197 "btyacc_demo.y"
2107 { yyval.code = yystack.l_mark[-1].code; }
2109 #line 2110 "btyacc_demo.tab.c"
2113 yystack.s_mark -= yym;
2114 yystate = *yystack.s_mark;
2115 yystack.l_mark -= yym;
2116 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2117 yystack.p_mark -= yym;
2120 if (yystate == 0 && yym == 0)
2125 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
2126 #ifdef YYSTYPE_TOSTRING
2129 #endif /* YYBTYACC */
2130 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval));
2132 fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL);
2136 *++yystack.s_mark = YYFINAL;
2137 *++yystack.l_mark = yyval;
2138 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2139 *++yystack.p_mark = yyloc;
2147 /* we're currently re-reading tokens */
2149 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2157 /* in trial mode; save scanner results for future parse attempts */
2158 if (yylvp == yylvlim)
2159 { /* Enlarge lexical value queue */
2160 size_t p = (size_t) (yylvp - yylvals);
2161 size_t s = (size_t) (yylvlim - yylvals);
2163 s += YYLVQUEUEGROWTH;
2164 if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL)
2166 if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
2168 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2169 if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
2172 yylvp = yylve = yylvals + p;
2173 yylvlim = yylvals + s;
2174 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2175 yylpp = yylpe = yylpsns + p;
2176 yylplim = yylpsns + s;
2178 yylexp = yylexemes + p;
2180 *yylexp = (YYINT) YYLEX;
2183 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2190 /* normal operation, no conflict encountered */
2191 #endif /* YYBTYACC */
2195 #endif /* YYBTYACC */
2196 if (yychar < 0) yychar = YYEOF;
2200 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
2201 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n",
2202 YYDEBUGSTR, yydepth, YYFINAL, yychar, yys);
2206 if (yychar == YYEOF) goto yyaccept;
2209 if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
2210 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
2211 yystate = yytable[yyn];
2213 yystate = yydgoto[yym];
2217 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
2218 #ifdef YYSTYPE_TOSTRING
2221 #endif /* YYBTYACC */
2222 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval));
2224 fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate);
2227 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
2228 *++yystack.s_mark = (YYINT) yystate;
2229 *++yystack.l_mark = yyval;
2230 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2231 *++yystack.p_mark = yyloc;
2236 /* Reduction declares that this path is valid. Set yypath and do a full parse */
2238 if (yypath) YYABORT;
2241 YYParseState *save = yyps->save;
2242 yyps->save = save->save;
2243 save->save = yypath;
2248 fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n",
2249 YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme));
2253 yyFreeState(yyerrctx);
2256 yylvp = yylvals + yypath->lexeme;
2257 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2258 yylpp = yylpsns + yypath->lexeme;
2260 yylexp = yylexemes + yypath->lexeme;
2262 yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base);
2263 memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
2264 yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base);
2265 memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
2266 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2267 yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base);
2268 memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
2270 yystate = yypath->state;
2272 #endif /* YYBTYACC */
2275 YYERROR_CALL("yacc stack overflow");
2279 YYERROR_CALL("memory exhausted");
2281 #endif /* YYBTYACC */
2291 if (yyps->save) goto yyvalid;
2292 #endif /* YYBTYACC */
2296 #if defined(YYDESTRUCT_CALL)
2297 if (yychar != YYEOF && yychar != YYEMPTY)
2298 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2299 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc);
2301 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval);
2302 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
2306 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2309 for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp)
2310 YYDESTRUCT_CALL("cleanup: discarding state",
2311 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp);
2313 for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv)
2314 YYDESTRUCT_CALL("cleanup: discarding state",
2315 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv);
2316 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
2318 #endif /* defined(YYDESTRUCT_CALL) */
2323 yyFreeState(yyerrctx);
2328 YYParseState *save = yyps;
2335 YYParseState *save = yypath;
2336 yypath = save->save;
2340 #endif /* YYBTYACC */
2341 yyfreestack(&yystack);