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);
1335 yyps = yyNewState(0); if (yyps == 0) goto yyenomem;
1337 #endif /* YYBTYACC */
1346 memset(&yystack, 0, sizeof(yystack));
1349 if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1350 yystack.s_mark = yystack.s_base;
1351 yystack.l_mark = yystack.l_base;
1352 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1353 yystack.p_mark = yystack.p_base;
1356 *yystack.s_mark = 0;
1359 if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
1366 /* we're currently re-reading tokens */
1368 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1376 /* in trial mode; save scanner results for future parse attempts */
1377 if (yylvp == yylvlim)
1378 { /* Enlarge lexical value queue */
1379 size_t p = (size_t) (yylvp - yylvals);
1380 size_t s = (size_t) (yylvlim - yylvals);
1382 s += YYLVQUEUEGROWTH;
1383 if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
1384 if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
1385 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1386 if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
1388 yylvp = yylve = yylvals + p;
1389 yylvlim = yylvals + s;
1390 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1391 yylpp = yylpe = yylpsns + p;
1392 yylplim = yylpsns + s;
1394 yylexp = yylexemes + p;
1396 *yylexp = (YYINT) YYLEX;
1399 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1406 /* normal operation, no conflict encountered */
1407 #endif /* YYBTYACC */
1411 #endif /* YYBTYACC */
1412 if (yychar < 0) yychar = YYEOF;
1416 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
1417 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)",
1418 YYDEBUGSTR, yydepth, yystate, yychar, yys);
1419 #ifdef YYSTYPE_TOSTRING
1422 #endif /* YYBTYACC */
1423 fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval));
1425 fputc('\n', stderr);
1431 /* Do we have a conflict? */
1432 if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
1433 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
1442 fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n",
1443 YYDEBUGSTR, yydepth, yystate);
1445 /* Switch to the next conflict context */
1447 yypath = save->save;
1450 if (save->state != yystate) YYABORT;
1457 /* Unresolved conflict - start/continue trial parse */
1462 fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate);
1464 fputs("ALREADY in conflict, continuing trial parse.\n", stderr);
1466 fputs("Starting trial parse.\n", stderr);
1469 save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
1470 if (save == NULL) goto yyenomem;
1471 save->save = yyps->save;
1472 save->state = yystate;
1473 save->errflag = yyerrflag;
1474 save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base);
1475 memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1476 save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base);
1477 memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1478 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1479 save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base);
1480 memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1482 ctry = yytable[yyn];
1483 if (yyctable[ctry] == -1)
1486 if (yydebug && yychar >= YYEOF)
1487 fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth);
1492 if (yyps->save == NULL)
1494 /* If this is a first conflict in the stack, start saving lexemes */
1497 yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
1498 if (yylexemes == NULL) goto yyenomem;
1499 yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
1500 if (yylvals == NULL) goto yyenomem;
1501 yylvlim = yylvals + YYLVQUEUEGROWTH;
1502 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1503 yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE));
1504 if (yylpsns == NULL) goto yyenomem;
1505 yylplim = yylpsns + YYLVQUEUEGROWTH;
1510 yylvp = yylve = yylvals;
1511 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1512 yylpp = yylpe = yylpsns;
1515 if (yychar >= YYEOF)
1518 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1521 *yylexp = (YYINT) yychar;
1526 if (yychar >= YYEOF)
1529 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1535 save->lexeme = (int) (yylvp - yylvals);
1538 if (yytable[yyn] == ctry)
1542 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
1543 YYDEBUGSTR, yydepth, yystate, yyctable[ctry]);
1548 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1553 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
1555 yystate = yyctable[ctry];
1556 *++yystack.s_mark = (YYINT) yystate;
1557 *++yystack.l_mark = yylval;
1558 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1559 *++yystack.p_mark = yylloc;
1562 if (yyerrflag > 0) --yyerrflag;
1567 yyn = yyctable[ctry];
1570 } /* End of code dealing with conflicts */
1571 #endif /* YYBTYACC */
1572 if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
1573 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
1577 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
1578 YYDEBUGSTR, yydepth, yystate, yytable[yyn]);
1580 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1581 yystate = yytable[yyn];
1582 *++yystack.s_mark = yytable[yyn];
1583 *++yystack.l_mark = yylval;
1584 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1585 *++yystack.p_mark = yylloc;
1588 if (yyerrflag > 0) --yyerrflag;
1591 if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
1592 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
1597 if (yyerrflag != 0) goto yyinrecovery;
1602 goto yyerrlab; /* redundant goto avoids 'unused label' warning */
1605 /* explicit YYERROR from an action -- pop the rhs of the rule reduced
1606 * before looking for error recovery */
1607 yystack.s_mark -= yym;
1608 yystate = *yystack.s_mark;
1609 yystack.l_mark -= yym;
1610 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1611 yystack.p_mark -= yym;
1619 YYParseState *save = yyps->save;
1622 fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n",
1623 YYDEBUGSTR, yydepth, yystate, yyps->save->state,
1624 (int)(yylvp - yylvals - yyps->save->lexeme));
1626 /* Memorize most forward-looking error state in case it's really an error. */
1627 if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals)
1629 /* Free old saved error context state */
1630 if (yyerrctx) yyFreeState(yyerrctx);
1631 /* Create and fill out new saved error context state */
1632 yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
1633 if (yyerrctx == NULL) goto yyenomem;
1634 yyerrctx->save = yyps->save;
1635 yyerrctx->state = yystate;
1636 yyerrctx->errflag = yyerrflag;
1637 yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base);
1638 memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1639 yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base);
1640 memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1641 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1642 yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base);
1643 memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1645 yyerrctx->lexeme = (int) (yylvp - yylvals);
1647 yylvp = yylvals + save->lexeme;
1648 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1649 yylpp = yylpsns + save->lexeme;
1651 yylexp = yylexemes + save->lexeme;
1653 yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base);
1654 memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1655 yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base);
1656 memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1657 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1658 yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base);
1659 memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1661 ctry = ++save->ctry;
1662 yystate = save->state;
1663 /* We tried shift, try reduce now */
1664 if ((yyn = yyctable[ctry]) >= 0) goto yyreduce;
1665 yyps->save = save->save;
1669 /* Nothing left on the stack -- error */
1674 fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n",
1677 /* Restore state as it was in the most forward-advanced error */
1678 yylvp = yylvals + yyerrctx->lexeme;
1679 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1680 yylpp = yylpsns + yyerrctx->lexeme;
1682 yylexp = yylexemes + yyerrctx->lexeme;
1683 yychar = yylexp[-1];
1685 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1688 yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base);
1689 memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1690 yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base);
1691 memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1692 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1693 yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base);
1694 memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1696 yystate = yyerrctx->state;
1697 yyFreeState(yyerrctx);
1702 if (yynewerrflag == 0) goto yyinrecovery;
1703 #endif /* YYBTYACC */
1705 YYERROR_CALL("syntax error");
1706 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1707 yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
1711 goto yyerrlab; /* redundant goto avoids 'unused label' warning */
1722 if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
1723 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
1727 fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n",
1728 YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]);
1730 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1731 yystate = yytable[yyn];
1732 *++yystack.s_mark = yytable[yyn];
1733 *++yystack.l_mark = yylval;
1734 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1735 /* lookahead position is error end position */
1736 yyerror_loc_range[1] = yylloc;
1737 YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
1738 *++yystack.p_mark = yyloc;
1746 fprintf(stderr, "%s[%d]: error recovery discarding state %d\n",
1747 YYDEBUGSTR, yydepth, *yystack.s_mark);
1749 if (yystack.s_mark <= yystack.s_base) goto yyabort;
1750 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1751 /* the current TOS position is the error start position */
1752 yyerror_loc_range[0] = *yystack.p_mark;
1754 #if defined(YYDESTRUCT_CALL)
1757 #endif /* YYBTYACC */
1758 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1759 YYDESTRUCT_CALL("error: discarding state",
1760 yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark);
1762 YYDESTRUCT_CALL("error: discarding state",
1763 yystos[*yystack.s_mark], yystack.l_mark);
1764 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1765 #endif /* defined(YYDESTRUCT_CALL) */
1768 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1776 if (yychar == YYEOF) goto yyabort;
1780 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
1781 fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n",
1782 YYDEBUGSTR, yydepth, yystate, yychar, yys);
1785 #if defined(YYDESTRUCT_CALL)
1788 #endif /* YYBTYACC */
1789 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1790 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc);
1792 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval);
1793 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1794 #endif /* defined(YYDESTRUCT_CALL) */
1804 fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)",
1805 YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]);
1806 #ifdef YYSTYPE_TOSTRING
1809 #endif /* YYBTYACC */
1814 for (i = yym; i > 0; i--)
1816 if (i != yym) fputs(", ", stderr);
1817 fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]],
1818 yystack.l_mark[1-i]), stderr);
1823 fputc('\n', stderr);
1827 yyval = yystack.l_mark[1-yym];
1829 memset(&yyval, 0, sizeof yyval);
1830 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1832 /* Perform position reduction */
1833 memset(&yyloc, 0, sizeof(yyloc));
1836 #endif /* YYBTYACC */
1838 YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
1839 /* just in case YYERROR is invoked within the action, save
1840 the start of the rhs as the error start position */
1841 yyerror_loc_range[0] = yystack.p_mark[1-yym];
1848 #line 93 "btyacc_demo.y"
1849 { yyval.scope = yystack.l_mark[0].scope; }
1852 #line 94 "btyacc_demo.y"
1853 { yyval.scope = global_scope; }
1856 #line 95 "btyacc_demo.y"
1857 { Decl *d = lookup(yystack.l_mark[-2].scope, yystack.l_mark[-1].id);
1858 if (!d || !d->scope) YYERROR;
1859 yyval.scope = d->scope; }
1862 #line 101 "btyacc_demo.y"
1863 { Decl *d = lookup(yystack.l_mark[-1].scope, yystack.l_mark[0].id);
1864 if (d == NULL || d->istype() == 0) YYERROR;
1865 yyval.type = d->type; }
1868 #line 106 "btyacc_demo.y"
1869 yyval.scope = global_scope = new_scope(0);
1872 #line 107 "btyacc_demo.y"
1873 yyval.scope = yystack.l_mark[-1].scope;
1876 #line 109 "btyacc_demo.y"
1880 #line 110 "btyacc_demo.y"
1881 yyval.scope = start_fn_def(yystack.l_mark[-2].scope, yystack.l_mark[0].decl);
1885 #line 111 "btyacc_demo.y"
1886 { /* demonstrate use of @$ & @N, although this is just the
1887 default computation and so is not necessary */
1888 yyloc.first_line = yystack.p_mark[-3].first_line;
1889 yyloc.first_column = yystack.p_mark[-3].first_column;
1890 yyloc.last_line = yystack.p_mark[0].last_line;
1891 yyloc.last_column = yystack.p_mark[0].last_column;
1892 finish_fn_def(yystack.l_mark[-2].decl, yystack.l_mark[0].code); }
1895 #line 121 "btyacc_demo.y"
1896 { yyval.type = yystack.l_mark[0].type; }
1899 #line 122 "btyacc_demo.y"
1900 { yyval.type = type_combine(yystack.l_mark[-2].type, yystack.l_mark[0].type); }
1903 #line 125 "btyacc_demo.y"
1907 #line 126 "btyacc_demo.y"
1908 { yyval.type = type_combine(yystack.l_mark[-1].type, yystack.l_mark[0].type); }
1911 #line 130 "btyacc_demo.y"
1912 { yyval.type = yystack.l_mark[0].type; }
1915 #line 131 "btyacc_demo.y"
1916 { yyval.type = yystack.l_mark[0].type; }
1919 #line 132 "btyacc_demo.y"
1920 { yyval.type = bare_extern(); }
1923 #line 133 "btyacc_demo.y"
1924 { yyval.type = bare_register(); }
1927 #line 134 "btyacc_demo.y"
1928 { yyval.type = bare_static(); }
1931 #line 138 "btyacc_demo.y"
1932 { yyval.type = bare_const(); }
1935 #line 139 "btyacc_demo.y"
1936 { yyval.type = bare_volatile(); }
1939 #line 143 "btyacc_demo.y"
1940 yyval.scope = yystack.l_mark[-3].scope;
1943 #line 143 "btyacc_demo.y"
1944 yyval.type = yystack.l_mark[-3].type;
1947 #line 148 "btyacc_demo.y"
1948 { if (!yystack.l_mark[0].type) YYERROR; } if (!yytrial)
1949 #line 149 "btyacc_demo.y"
1950 { yyval.decl = declare(yystack.l_mark[-1].scope, 0, yystack.l_mark[0].type); }
1954 #line 150 "btyacc_demo.y"
1955 { yyval.decl = declare(yystack.l_mark[-2].scope, yystack.l_mark[0].id, yystack.l_mark[-1].type); }
1958 #line 151 "btyacc_demo.y"
1959 yyval.scope = yystack.l_mark[-2].scope;
1962 #line 151 "btyacc_demo.y"
1963 yyval.type = yystack.l_mark[-2].type;
1967 #line 151 "btyacc_demo.y"
1968 { yyval.decl = yystack.l_mark[-1].decl; }
1972 #line 153 "btyacc_demo.y"
1973 { yyval.decl = make_pointer(yystack.l_mark[0].decl, yystack.l_mark[-3].type); }
1977 #line 155 "btyacc_demo.y"
1978 { yyval.decl = make_array(yystack.l_mark[-4].decl->type, yystack.l_mark[-1].expr); }
1982 #line 157 "btyacc_demo.y"
1983 { yyval.decl = build_function(yystack.l_mark[-5].decl, yystack.l_mark[-2].dlist, yystack.l_mark[0].type); }
1987 #line 160 "btyacc_demo.y"
1988 { yyval.dlist = 0; }
1992 #line 161 "btyacc_demo.y"
1993 { yyval.dlist = yystack.l_mark[0].dlist; }
1997 #line 164 "btyacc_demo.y"
1998 { yyval.dlist = append_dlist(yystack.l_mark[-3].dlist, yystack.l_mark[0].decl); }
2002 #line 165 "btyacc_demo.y"
2003 { yyval.dlist = build_dlist(yystack.l_mark[0].decl); }
2007 #line 168 "btyacc_demo.y"
2008 { yyval.decl = yystack.l_mark[0].decl; }
2012 #line 172 "btyacc_demo.y"
2013 { yyval.expr = build_expr(yystack.l_mark[-3].expr, ADD, yystack.l_mark[0].expr); }
2017 #line 173 "btyacc_demo.y"
2018 { yyval.expr = build_expr(yystack.l_mark[-3].expr, SUB, yystack.l_mark[0].expr); }
2022 #line 174 "btyacc_demo.y"
2023 { yyval.expr = build_expr(yystack.l_mark[-3].expr, MUL, yystack.l_mark[0].expr); }
2027 #line 175 "btyacc_demo.y"
2028 { yyval.expr = build_expr(yystack.l_mark[-3].expr, MOD, yystack.l_mark[0].expr); }
2032 #line 176 "btyacc_demo.y"
2033 { yyval.expr = build_expr(yystack.l_mark[-3].expr, DIV, yystack.l_mark[0].expr); }
2037 #line 177 "btyacc_demo.y"
2038 { yyval.expr = build_expr(0, DEREF, yystack.l_mark[0].expr); }
2042 #line 178 "btyacc_demo.y"
2043 { yyval.expr = var_expr(yystack.l_mark[-1].scope, yystack.l_mark[0].id); }
2047 #line 179 "btyacc_demo.y"
2048 { yyval.expr = yystack.l_mark[0].expr; }
2052 #line 183 "btyacc_demo.y"
2056 #line 184 "btyacc_demo.y"
2057 {YYVALID;} if (!yytrial)
2058 #line 184 "btyacc_demo.y"
2059 { yyval.code = build_expr_code(yystack.l_mark[-1].expr); }
2062 #line 185 "btyacc_demo.y"
2063 yyval.scope = yystack.l_mark[-6].scope;
2066 #line 185 "btyacc_demo.y"
2067 yyval.scope = yystack.l_mark[-9].scope;
2070 #line 185 "btyacc_demo.y"
2071 {YYVALID;} if (!yytrial)
2072 #line 186 "btyacc_demo.y"
2073 { yyval.code = build_if(yystack.l_mark[-7].expr, yystack.l_mark[-3].code, yystack.l_mark[0].code); }
2076 #line 187 "btyacc_demo.y"
2077 {YYVALID;} if (!yytrial)
2078 #line 188 "btyacc_demo.y"
2079 { yyval.code = build_if(yystack.l_mark[-4].expr, yystack.l_mark[0].code, 0); }
2082 #line 189 "btyacc_demo.y"
2083 yyval.scope = new_scope(yystack.l_mark[0].scope);
2086 #line 189 "btyacc_demo.y"
2087 {YYVALID;} if (!yytrial)
2088 #line 189 "btyacc_demo.y"
2089 { yyval.code = yystack.l_mark[0].code; }
2093 #line 192 "btyacc_demo.y"
2098 #line 193 "btyacc_demo.y"
2099 { yyval.code = code_append(yystack.l_mark[-2].code, yystack.l_mark[0].code); }
2103 #line 197 "btyacc_demo.y"
2104 { yyval.code = yystack.l_mark[-1].code; }
2106 #line 2107 "btyacc_demo.tab.c"
2110 yystack.s_mark -= yym;
2111 yystate = *yystack.s_mark;
2112 yystack.l_mark -= yym;
2113 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2114 yystack.p_mark -= yym;
2117 if (yystate == 0 && yym == 0)
2122 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
2123 #ifdef YYSTYPE_TOSTRING
2126 #endif /* YYBTYACC */
2127 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval));
2129 fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL);
2133 *++yystack.s_mark = YYFINAL;
2134 *++yystack.l_mark = yyval;
2135 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2136 *++yystack.p_mark = yyloc;
2144 /* we're currently re-reading tokens */
2146 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2154 /* in trial mode; save scanner results for future parse attempts */
2155 if (yylvp == yylvlim)
2156 { /* Enlarge lexical value queue */
2157 size_t p = (size_t) (yylvp - yylvals);
2158 size_t s = (size_t) (yylvlim - yylvals);
2160 s += YYLVQUEUEGROWTH;
2161 if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL)
2163 if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
2165 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2166 if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
2169 yylvp = yylve = yylvals + p;
2170 yylvlim = yylvals + s;
2171 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2172 yylpp = yylpe = yylpsns + p;
2173 yylplim = yylpsns + s;
2175 yylexp = yylexemes + p;
2177 *yylexp = (YYINT) YYLEX;
2180 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2187 /* normal operation, no conflict encountered */
2188 #endif /* YYBTYACC */
2192 #endif /* YYBTYACC */
2193 if (yychar < 0) yychar = YYEOF;
2197 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
2198 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n",
2199 YYDEBUGSTR, yydepth, YYFINAL, yychar, yys);
2203 if (yychar == YYEOF) goto yyaccept;
2206 if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
2207 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
2208 yystate = yytable[yyn];
2210 yystate = yydgoto[yym];
2214 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
2215 #ifdef YYSTYPE_TOSTRING
2218 #endif /* YYBTYACC */
2219 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval));
2221 fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate);
2224 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
2225 *++yystack.s_mark = (YYINT) yystate;
2226 *++yystack.l_mark = yyval;
2227 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2228 *++yystack.p_mark = yyloc;
2233 /* Reduction declares that this path is valid. Set yypath and do a full parse */
2235 if (yypath) YYABORT;
2238 YYParseState *save = yyps->save;
2239 yyps->save = save->save;
2240 save->save = yypath;
2245 fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n",
2246 YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme));
2250 yyFreeState(yyerrctx);
2253 yylvp = yylvals + yypath->lexeme;
2254 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2255 yylpp = yylpsns + yypath->lexeme;
2257 yylexp = yylexemes + yypath->lexeme;
2259 yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base);
2260 memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
2261 yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base);
2262 memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
2263 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2264 yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base);
2265 memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
2267 yystate = yypath->state;
2269 #endif /* YYBTYACC */
2272 YYERROR_CALL("yacc stack overflow");
2276 YYERROR_CALL("memory exhausted");
2278 #endif /* YYBTYACC */
2288 if (yyps->save) goto yyvalid;
2289 #endif /* YYBTYACC */
2293 #if defined(YYDESTRUCT_CALL)
2294 if (yychar != YYEOF && yychar != YYEMPTY)
2295 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2296 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc);
2298 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval);
2299 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
2303 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
2306 for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp)
2307 YYDESTRUCT_CALL("cleanup: discarding state",
2308 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp);
2310 for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv)
2311 YYDESTRUCT_CALL("cleanup: discarding state",
2312 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv);
2313 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
2315 #endif /* defined(YYDESTRUCT_CALL) */
2320 yyFreeState(yyerrctx);
2325 YYParseState *save = yyps;
2332 YYParseState *save = yypath;
2333 yypath = save->save;
2337 #endif /* YYBTYACC */
2338 yyfreestack(&yystack);