Path: blob/main/contrib/byacc/test/btyacc/btyacc_demo.tab.c
109934 views
/* original parser id follows */1/* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */2/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */34#define YYBYACC 15#define YYMAJOR 26#define YYMINOR 07#define YYCHECK "yyyymmdd"89#define YYEMPTY (-1)10#define yyclearin (yychar = YYEMPTY)11#define yyerrok (yyerrflag = 0)12#define YYRECOVERING() (yyerrflag != 0)13#define YYENOMEM (-2)14#define YYEOF 015#undef YYBTYACC16#define YYBTYACC 117#define YYDEBUGSTR (yytrial ? YYPREFIX "debug(trial)" : YYPREFIX "debug")1819#ifndef yyparse20#define yyparse demo_parse21#endif /* yyparse */2223#ifndef yylex24#define yylex demo_lex25#endif /* yylex */2627#ifndef yyerror28#define yyerror demo_error29#endif /* yyerror */3031#ifndef yychar32#define yychar demo_char33#endif /* yychar */3435#ifndef yyval36#define yyval demo_val37#endif /* yyval */3839#ifndef yylval40#define yylval demo_lval41#endif /* yylval */4243#ifndef yydebug44#define yydebug demo_debug45#endif /* yydebug */4647#ifndef yynerrs48#define yynerrs demo_nerrs49#endif /* yynerrs */5051#ifndef yyerrflag52#define yyerrflag demo_errflag53#endif /* yyerrflag */5455#ifndef yylhs56#define yylhs demo_lhs57#endif /* yylhs */5859#ifndef yylen60#define yylen demo_len61#endif /* yylen */6263#ifndef yydefred64#define yydefred demo_defred65#endif /* yydefred */6667#ifndef yystos68#define yystos demo_stos69#endif /* yystos */7071#ifndef yydgoto72#define yydgoto demo_dgoto73#endif /* yydgoto */7475#ifndef yysindex76#define yysindex demo_sindex77#endif /* yysindex */7879#ifndef yyrindex80#define yyrindex demo_rindex81#endif /* yyrindex */8283#ifndef yygindex84#define yygindex demo_gindex85#endif /* yygindex */8687#ifndef yytable88#define yytable demo_table89#endif /* yytable */9091#ifndef yycheck92#define yycheck demo_check93#endif /* yycheck */9495#ifndef yyname96#define yyname demo_name97#endif /* yyname */9899#ifndef yyrule100#define yyrule demo_rule101#endif /* yyrule */102103#ifndef yyloc104#define yyloc demo_loc105#endif /* yyloc */106107#ifndef yylloc108#define yylloc demo_lloc109#endif /* yylloc */110111#if YYBTYACC112113#ifndef yycindex114#define yycindex demo_cindex115#endif /* yycindex */116117#ifndef yyctable118#define yyctable demo_ctable119#endif /* yyctable */120121#endif /* YYBTYACC */122123#define YYPREFIX "demo_"124125#define YYPURE 0126127#line 15 "btyacc_demo.y"128/* dummy types just for compile check */129typedef int Code;130typedef int Decl_List;131typedef int Expr;132typedef int Expr_List;133typedef int Scope;134typedef int Type;135enum Operator { ADD, SUB, MUL, MOD, DIV, DEREF };136137typedef unsigned char bool;138typedef struct Decl {139Scope *scope;140Type *type;141bool (*istype)(void);142} Decl;143144#include "btyacc_demo.tab.h"145#include <stdlib.h>146#include <stdio.h>147#ifdef YYSTYPE148#undef YYSTYPE_IS_DECLARED149#define YYSTYPE_IS_DECLARED 1150#endif151#ifndef YYSTYPE_IS_DECLARED152#define YYSTYPE_IS_DECLARED 1153#line 36 "btyacc_demo.y"154typedef union YYSTYPE {155Scope *scope;156Expr *expr;157Expr_List *elist;158Type *type;159Decl *decl;160Decl_List *dlist;161Code *code;162char *id;163} YYSTYPE;164#endif /* !YYSTYPE_IS_DECLARED */165#line 167 "btyacc_demo.tab.c"166167#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED168/* Default: YYLTYPE is the text position type. */169typedef struct YYLTYPE170{171int first_line;172int first_column;173int last_line;174int last_column;175unsigned source;176} YYLTYPE;177#define YYLTYPE_IS_DECLARED 1178#endif179#define YYRHSLOC(rhs, k) ((rhs)[k])180181/* compatibility with bison */182#ifdef YYPARSE_PARAM183/* compatibility with FreeBSD */184# ifdef YYPARSE_PARAM_TYPE185# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)186# else187# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)188# endif189#else190# define YYPARSE_DECL() yyparse(void)191#endif192193/* Parameters sent to lex. */194#ifdef YYLEX_PARAM195# define YYLEX_DECL() yylex(void *YYLEX_PARAM)196# define YYLEX yylex(YYLEX_PARAM)197#else198# define YYLEX_DECL() yylex(void)199# define YYLEX yylex()200#endif201202/* Parameters sent to yyerror. */203#ifndef YYERROR_DECL204#define YYERROR_DECL() yyerror(YYLTYPE *loc, const char *s)205#endif206#ifndef YYERROR_CALL207#define YYERROR_CALL(msg) yyerror(&yylloc, msg)208#endif209210#ifndef YYDESTRUCT_DECL211#define YYDESTRUCT_DECL() yydestruct(const char *msg, int psymb, YYSTYPE *val, YYLTYPE *loc)212#endif213#ifndef YYDESTRUCT_CALL214#define YYDESTRUCT_CALL(msg, psymb, val, loc) yydestruct(msg, psymb, val, loc)215#endif216217extern int YYPARSE_DECL();218219#define PREFIX 257220#define POSTFIX 258221#define ID 259222#define CONSTANT 260223#define EXTERN 261224#define REGISTER 262225#define STATIC 263226#define CONST 264227#define VOLATILE 265228#define IF 266229#define THEN 267230#define ELSE 268231#define CLCL 269232#define YYERRCODE 256233typedef int YYINT;234static const YYINT demo_lhs[] = { -1,23515, 15, 15, 12, 18, 0, 4, 19, 4, 2,23620, 2, 10, 10, 13, 13, 11, 11, 11, 11,23711, 14, 14, 21, 22, 3, 3, 8, 8, 23,23824, 8, 8, 8, 8, 16, 16, 17, 17, 9,2391, 1, 1, 1, 1, 1, 1, 1, 5, 5,24025, 26, 5, 5, 27, 5, 6, 6, 7,241};242static const YYINT demo_len[] = { 2,2430, 1, 3, 2, 0, 2, 0, 0, 3, 3,2440, 4, 1, 3, 0, 2, 1, 1, 1, 1,2451, 1, 1, 0, 0, 5, 1, 0, 1, 0,2460, 5, 5, 5, 6, 0, 1, 4, 1, 2,2474, 4, 4, 4, 4, 3, 1, 1, 1, 2,2480, 0, 11, 8, 0, 2, 0, 3, 4,249};250static const YYINT demo_defred[] = { 5,2510, 7, 0, 0, 19, 20, 21, 22, 23, 2,2529, 0, 13, 18, 17, 0, 15, 30, 29, 0,2530, 0, 0, 0, 31, 10, 24, 24, 24, 0,25414, 3, 16, 25, 0, 25, 0, 0, 8, 12,2550, 0, 0, 39, 0, 0, 0, 8, 47, 48,2560, 57, 0, 32, 0, 0, 15, 30, 0, 30,25730, 30, 30, 30, 34, 0, 0, 0, 46, 0,2580, 0, 0, 0, 59, 0, 38, 0, 0, 43,25945, 44, 0, 0, 49, 58, 0, 30, 50, 56,2600, 0, 0, 51, 0, 0, 52, 0, 53,261};262#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING)263static const YYINT demo_stos[] = { 0,264271, 289, 275, 290, 261, 262, 263, 264, 265, 269,265273, 281, 282, 283, 285, 286, 42, 40, 259, 274,266279, 290, 259, 284, 294, 59, 44, 40, 91, 291,267282, 269, 285, 292, 295, 292, 292, 292, 123, 278,268293, 279, 293, 280, 281, 287, 288, 42, 259, 260,269272, 290, 279, 41, 279, 279, 41, 44, 290, 43,27045, 42, 47, 37, 93, 277, 284, 294, 272, 294,271294, 294, 294, 294, 125, 290, 280, 272, 272, 272,272272, 272, 266, 272, 273, 276, 298, 40, 59, 278,273294, 272, 41, 267, 296, 276, 268, 297, 276,274};275#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */276static const YYINT demo_dgoto[] = { 1,27784, 85, 20, 3, 86, 66, 40, 21, 44, 12,27813, 14, 24, 15, 16, 46, 47, 2, 22, 30,27934, 41, 25, 35, 95, 98, 87,280};281static const YYINT demo_sindex[] = { 0,2820, 0, 0, -103, 0, 0, 0, 0, 0, 0,2830, -31, 0, 0, 0, -238, 0, 0, 0, 4,284-36, -103, 0, -133, 0, 0, 0, 0, 0, -94,2850, 0, 0, 0, -40, 0, -103, -33, 0, 0,286-40, -25, -40, 0, -31, 8, 15, 0, 0, 0,287-2, 0, -36, 0, -36, -36, 0, 0, -33, 0,2880, 0, 0, 0, 0, -92, -133, -103, 0, -33,289-33, -33, -33, -33, 0, -8, 0, 23, 23, 0,2900, 0, 11, 75, 0, 0, -94, 0, 0, 0,291-33, 96, -194, 0, -8, 0, 0, -8, 0,292};293static const YYINT demo_rindex[] = { 0,2940, 0, 1, -181, 0, 0, 0, 0, 0, 0,2950, 17, 0, 0, 0, 0, 0, 0, 0, 0,296-39, -181, 12, -34, 0, 0, 0, 0, 0, 0,2970, 0, 0, 0, -5, 0, -11, 0, 0, 0,298-17, 0, 28, 0, -41, 0, 47, 0, 0, 0,2990, 0, -13, 0, 18, 70, 0, 0, 0, 0,3000, 0, 0, 0, 0, -19, -27, -181, 0, 0,3010, 0, 0, 0, 0, -29, 0, 56, 64, 0,3020, 0, 0, 0, 0, 0, 0, 0, 0, 0,3030, 0, 0, 0, -29, -30, 0, -29, 0,304};305#if YYBTYACC306static const YYINT demo_cindex[] = { 0,3070, 0, 0, 0, 0, 0, 0, 0, 0, 0,3080, -22, 0, 0, 0, 0, 0, 0, 0, 0,3090, 0, -179, 0, 0, 0, 0, 0, 0, 0,3100, 0, 0, 0, 52, 0, 0, 0, 0, 0,31158, 0, 62, 0, -21, 0, 0, 0, 0, 0,3120, 0, 0, 0, 0, 0, 0, 0, 0, 0,3130, 0, 0, 0, 0, 0, 0, 0, 0, 0,3140, 0, 0, 0, 0, -146, 0, 0, 0, 0,3150, 0, 0, 0, 0, 0, 0, 0, 0, 0,3160, 0, 0, 0, -143, -147, 0, -134, 0,317};318#endif319static const YYINT demo_gindex[] = { 0,3209, 143, 0, 0, 50, 0, 63, 101, 83, 7,321130, 0, 98, 2, 0, 0, 0, 0, 19, 0,32210, 117, 66, 0, 0, 0, 0,323};324#define YYTABLESIZE 286325static const YYINT demo_table[] = { 28,3266, 17, 28, 28, 27, 24, 24, 24, 48, 24,32717, 54, 35, 35, 28, 54, 35, 0, 0, 27,32823, 4, 8, 28, 24, 33, 28, 33, 39, 36,32933, 35, 75, 48, 64, 28, 36, 37, 38, 62,33060, 28, 61, 45, 63, 33, 51, 27, 57, 28,33188, 4, 4, 4, 29, 4, 24, 52, 58, 64,33228, 26, 26, 35, 62, 29, 59, 69, 33, 63,3334, 28, 94, 28, 45, 28, 26, 1, 78, 79,33480, 81, 82, 11, 76, 28, 28, 37, 24, 6,33565, 0, 54, 55, 54, 35, 41, 0, 41, 92,33641, 0, 4, 8, 42, 28, 42, 28, 42, 33,33740, 64, 9, 40, 41, 9, 62, 60, 28, 61,33812, 63, 42, 68, 9, 70, 71, 72, 73, 74,3398, 9, 64, 89, 4, 42, 93, 62, 60, 28,34061, 53, 63, 55, 96, 56, 11, 99, 41, 90,34177, 31, 43, 91, 67, 0, 42, 5, 6, 7,3428, 9, 0, 0, 0, 10, 0, 0, 0, 0,3430, 0, 0, 0, 0, 0, 0, 0, 0, 0,3440, 0, 0, 0, 0, 0, 0, 0, 0, 0,3450, 0, 0, 0, 0, 0, 0, 0, 0, 0,3460, 0, 0, 0, 0, 0, 0, 0, 0, 0,3470, 0, 0, 0, 0, 0, 0, 0, 19, 8,3488, 8, 8, 8, 24, 49, 50, 8, 54, 54,34954, 54, 54, 54, 54, 54, 3, 3, 54, 8,3508, 8, 8, 8, 8, 8, 8, 1, 0, 8,3510, 50, 5, 6, 7, 8, 9, 83, 0, 8,35210, 8, 8, 8, 8, 8, 0, 0, 0, 8,3534, 0, 4, 4, 4, 4, 4, 8, 8, 8,3548, 8, 0, 0, 0, 8,355};356static const YYINT demo_check[] = { 41,3570, 42, 44, 40, 44, 40, 41, 42, 42, 44,35842, 42, 40, 41, 40, 41, 44, 40, 40, 59,359259, 3, 42, 41, 59, 24, 44, 41, 123, 41,36044, 59, 125, 42, 37, 41, 27, 28, 29, 42,36143, 59, 45, 37, 47, 59, 38, 44, 41, 91,36240, 40, 41, 42, 91, 44, 91, 39, 44, 37,36344, 44, 59, 91, 42, 91, 48, 59, 67, 47,36459, 44, 267, 91, 68, 59, 59, 259, 70, 71,36572, 73, 74, 123, 66, 91, 59, 41, 123, 269,36693, 40, 123, 123, 125, 123, 41, 40, 43, 91,36745, 40, 91, 123, 41, 123, 43, 91, 45, 123,36841, 37, 259, 44, 59, 259, 42, 43, 91, 45,369268, 47, 59, 58, 259, 60, 61, 62, 63, 64,370264, 265, 37, 59, 123, 35, 41, 42, 43, 123,37145, 41, 47, 43, 95, 45, 4, 98, 93, 87,37268, 22, 36, 88, 57, -1, 93, 261, 262, 263,373264, 265, -1, -1, -1, 269, -1, -1, -1, -1,374-1, -1, -1, -1, -1, -1, -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, 259, 261,379262, 263, 264, 265, 259, 259, 260, 269, 259, 260,380261, 262, 263, 264, 265, 266, 259, 259, 269, 259,381260, 261, 262, 263, 264, 265, 266, 259, -1, 269,382-1, 260, 261, 262, 263, 264, 265, 266, -1, 259,383269, 261, 262, 263, 264, 265, -1, -1, -1, 269,384259, -1, 261, 262, 263, 264, 265, 261, 262, 263,385264, 265, -1, -1, -1, 269,386};387#if YYBTYACC388static const YYINT demo_ctable[] = { 18,38928, -1, 19, 8, -1, 32, 4, -1, 49, 1,390-1, 97, 54, -1, -1, -1, -1, -1, -1, -1,391-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,392-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,393-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,394-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,395-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,396-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,397-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,398-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,399-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,400-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,401-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,402-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,403-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,404-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,405-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,406-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,407-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,408-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,409-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,410-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,411-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,412-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,413-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,414-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,415-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,416-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,417-1, -1, -1, -1, -1,418};419#endif420#define YYFINAL 1421#ifndef YYDEBUG422#define YYDEBUG 0423#endif424#define YYMAXTOKEN 269425#define YYUNDFTOKEN 299426#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))427#if YYDEBUG428static const char *const demo_name[] = {429430"$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,431"'%'",0,0,"'('","')'","'*'","'+'","','","'-'","'.'","'/'",0,0,0,0,0,0,0,0,0,0,0,432"';'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'['",0,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,4340,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4350,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4360,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4370,0,0,0,0,0,0,0,0,"error","PREFIX","POSTFIX","ID","CONSTANT","EXTERN",438"REGISTER","STATIC","CONST","VOLATILE","IF","THEN","ELSE","CLCL","$accept",439"input","expr","decl","declarator_list","decl_list","statement",440"statement_list","block_statement","declarator","formal_arg","decl_specs",441"decl_spec","typename","cv_quals","cv_qual","opt_scope","formal_arg_list",442"nonempty_formal_arg_list","$$1","$$2","$$3","$$4","$$5","$$6","$$7","$$8",443"$$9","$$10","illegal-symbol",444};445static const char *const demo_rule[] = {446"$accept : input",447"opt_scope :",448"opt_scope : CLCL",449"opt_scope : opt_scope ID CLCL",450"typename : opt_scope ID",451"$$1 :",452"input : $$1 decl_list",453"decl_list :",454"$$2 :",455"decl_list : decl_list $$2 decl",456"decl : decl_specs declarator_list ';'",457"$$3 :",458"decl : decl_specs declarator $$3 block_statement",459"decl_specs : decl_spec",460"decl_specs : decl_specs $$2 decl_spec",461"cv_quals :",462"cv_quals : cv_quals cv_qual",463"decl_spec : cv_qual",464"decl_spec : typename",465"decl_spec : EXTERN",466"decl_spec : REGISTER",467"decl_spec : STATIC",468"cv_qual : CONST",469"cv_qual : VOLATILE",470"$$4 :",471"$$5 :",472"declarator_list : declarator_list ',' $$4 $$5 declarator",473"declarator_list : declarator",474"declarator :",475"declarator : ID",476"$$6 :",477"$$7 :",478"declarator : '(' $$6 $$7 declarator ')'",479"declarator : '*' cv_quals $$4 $$5 declarator",480"declarator : declarator '[' $$4 expr ']'",481"declarator : declarator '(' $$4 formal_arg_list ')' cv_quals",482"formal_arg_list :",483"formal_arg_list : nonempty_formal_arg_list",484"nonempty_formal_arg_list : nonempty_formal_arg_list ',' $$6 formal_arg",485"nonempty_formal_arg_list : formal_arg",486"formal_arg : decl_specs declarator",487"expr : expr '+' $$6 expr",488"expr : expr '-' $$6 expr",489"expr : expr '*' $$6 expr",490"expr : expr '%' $$6 expr",491"expr : expr '/' $$6 expr",492"expr : '*' $$2 expr",493"expr : ID",494"expr : CONSTANT",495"statement : decl",496"statement : expr ';'",497"$$8 :",498"$$9 :",499"statement : IF '(' $$6 expr ')' THEN $$8 statement ELSE $$9 statement",500"statement : IF '(' $$6 expr ')' THEN $$8 statement",501"$$10 :",502"statement : $$10 block_statement",503"statement_list :",504"statement_list : statement_list $$2 statement",505"block_statement : '{' $$2 statement_list '}'",506507};508#endif509510#if YYDEBUG511int yydebug;512#endif513514int yyerrflag;515int yychar;516YYSTYPE yyval;517YYSTYPE yylval;518int yynerrs;519520#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)521YYLTYPE yyloc; /* position returned by actions */522YYLTYPE yylloc; /* position from the lexer */523#endif524525#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)526#ifndef YYLLOC_DEFAULT527#define YYLLOC_DEFAULT(loc, rhs, n) \528do \529{ \530if (n == 0) \531{ \532(loc).first_line = YYRHSLOC(rhs, 0).last_line; \533(loc).first_column = YYRHSLOC(rhs, 0).last_column; \534(loc).last_line = YYRHSLOC(rhs, 0).last_line; \535(loc).last_column = YYRHSLOC(rhs, 0).last_column; \536} \537else \538{ \539(loc).first_line = YYRHSLOC(rhs, 1).first_line; \540(loc).first_column = YYRHSLOC(rhs, 1).first_column; \541(loc).last_line = YYRHSLOC(rhs, n).last_line; \542(loc).last_column = YYRHSLOC(rhs, n).last_column; \543} \544} while (0)545#endif /* YYLLOC_DEFAULT */546#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */547#if YYBTYACC548549#ifndef YYLVQUEUEGROWTH550#define YYLVQUEUEGROWTH 32551#endif552#endif /* YYBTYACC */553554/* define the initial stack-sizes */555#ifdef YYSTACKSIZE556#undef YYMAXDEPTH557#define YYMAXDEPTH YYSTACKSIZE558#else559#ifdef YYMAXDEPTH560#define YYSTACKSIZE YYMAXDEPTH561#else562#define YYSTACKSIZE 10000563#define YYMAXDEPTH 10000564#endif565#endif566567#ifndef YYINITSTACKSIZE568#define YYINITSTACKSIZE 200569#endif570571typedef struct {572unsigned stacksize;573YYINT *s_base;574YYINT *s_mark;575YYINT *s_last;576YYSTYPE *l_base;577YYSTYPE *l_mark;578#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)579YYLTYPE *p_base;580YYLTYPE *p_mark;581#endif582} YYSTACKDATA;583#if YYBTYACC584585struct YYParseState_s586{587struct YYParseState_s *save; /* Previously saved parser state */588YYSTACKDATA yystack; /* saved parser stack */589int state; /* saved parser state */590int errflag; /* saved error recovery status */591int lexeme; /* saved index of the conflict lexeme in the lexical queue */592YYINT ctry; /* saved index in yyctable[] for this conflict */593};594typedef struct YYParseState_s YYParseState;595#endif /* YYBTYACC */596/* variables for the parser stack */597static YYSTACKDATA yystack;598#if YYBTYACC599600/* Current parser state */601static YYParseState *yyps = 0;602603/* yypath != NULL: do the full parse, starting at *yypath parser state. */604static YYParseState *yypath = 0;605606/* Base of the lexical value queue */607static YYSTYPE *yylvals = 0;608609/* Current position at lexical value queue */610static YYSTYPE *yylvp = 0;611612/* End position of lexical value queue */613static YYSTYPE *yylve = 0;614615/* The last allocated position at the lexical value queue */616static YYSTYPE *yylvlim = 0;617618#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)619/* Base of the lexical position queue */620static YYLTYPE *yylpsns = 0;621622/* Current position at lexical position queue */623static YYLTYPE *yylpp = 0;624625/* End position of lexical position queue */626static YYLTYPE *yylpe = 0;627628/* The last allocated position at the lexical position queue */629static YYLTYPE *yylplim = 0;630#endif631632/* Current position at lexical token queue */633static YYINT *yylexp = 0;634635static YYINT *yylexemes = 0;636#endif /* YYBTYACC */637#line 200 "btyacc_demo.y"638639extern int YYLEX_DECL();640extern void YYERROR_DECL();641642extern Scope *global_scope;643644extern Decl * lookup(Scope *scope, char *id);645extern Scope * new_scope(Scope *outer_scope);646extern Scope * start_fn_def(Scope *scope, Decl *fn_decl);647extern void finish_fn_def(Decl *fn_decl, Code *block);648extern Type * type_combine(Type *specs, Type *spec);649extern Type * bare_extern(void);650extern Type * bare_register(void);651extern Type * bare_static(void);652extern Type * bare_const(void);653extern Type * bare_volatile(void);654extern Decl * declare(Scope *scope, char *id, Type *type);655extern Decl * make_pointer(Decl *decl, Type *type);656extern Decl * make_array(Type *type, Expr *expr);657extern Decl * build_function(Decl *decl, Decl_List *dlist, Type *type);658extern Decl_List * append_dlist(Decl_List *dlist, Decl *decl);659extern Decl_List * build_dlist(Decl *decl);660extern Expr * build_expr(Expr *left, enum Operator op, Expr *right);661extern Expr * var_expr(Scope *scope, char *id);662extern Code * build_expr_code(Expr *expr);663extern Code * build_if(Expr *cond_expr, Code *then_stmt, Code *else_stmt);664extern Code * code_append(Code *stmt_list, Code *stmt);665#line 667 "btyacc_demo.tab.c"666667/* Release memory associated with symbol. */668#if ! defined YYDESTRUCT_IS_DECLARED669static void670YYDESTRUCT_DECL()671{672switch (psymb)673{674case 43:675#line 83 "btyacc_demo.y"676{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",677msg,678(*loc).first_line, (*loc).first_column,679(*loc).last_line, (*loc).last_column);680/* in this example, we don't know what to do here */ }681#line 683 "btyacc_demo.tab.c"682break;683case 45:684#line 83 "btyacc_demo.y"685{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",686msg,687(*loc).first_line, (*loc).first_column,688(*loc).last_line, (*loc).last_column);689/* in this example, we don't know what to do here */ }690#line 692 "btyacc_demo.tab.c"691break;692case 42:693#line 83 "btyacc_demo.y"694{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",695msg,696(*loc).first_line, (*loc).first_column,697(*loc).last_line, (*loc).last_column);698/* in this example, we don't know what to do here */ }699#line 701 "btyacc_demo.tab.c"700break;701case 47:702#line 83 "btyacc_demo.y"703{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",704msg,705(*loc).first_line, (*loc).first_column,706(*loc).last_line, (*loc).last_column);707/* in this example, we don't know what to do here */ }708#line 710 "btyacc_demo.tab.c"709break;710case 37:711#line 83 "btyacc_demo.y"712{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",713msg,714(*loc).first_line, (*loc).first_column,715(*loc).last_line, (*loc).last_column);716/* in this example, we don't know what to do here */ }717#line 719 "btyacc_demo.tab.c"718break;719case 257:720#line 83 "btyacc_demo.y"721{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",722msg,723(*loc).first_line, (*loc).first_column,724(*loc).last_line, (*loc).last_column);725/* in this example, we don't know what to do here */ }726#line 728 "btyacc_demo.tab.c"727break;728case 258:729#line 83 "btyacc_demo.y"730{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",731msg,732(*loc).first_line, (*loc).first_column,733(*loc).last_line, (*loc).last_column);734/* in this example, we don't know what to do here */ }735#line 737 "btyacc_demo.tab.c"736break;737case 40:738#line 83 "btyacc_demo.y"739{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",740msg,741(*loc).first_line, (*loc).first_column,742(*loc).last_line, (*loc).last_column);743/* in this example, we don't know what to do here */ }744#line 746 "btyacc_demo.tab.c"745break;746case 91:747#line 83 "btyacc_demo.y"748{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",749msg,750(*loc).first_line, (*loc).first_column,751(*loc).last_line, (*loc).last_column);752/* in this example, we don't know what to do here */ }753#line 755 "btyacc_demo.tab.c"754break;755case 46:756#line 83 "btyacc_demo.y"757{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",758msg,759(*loc).first_line, (*loc).first_column,760(*loc).last_line, (*loc).last_column);761/* in this example, we don't know what to do here */ }762#line 764 "btyacc_demo.tab.c"763break;764case 259:765#line 78 "btyacc_demo.y"766{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",767msg,768(*loc).first_line, (*loc).first_column,769(*loc).last_line, (*loc).last_column);770free((*val).id); }771#line 773 "btyacc_demo.tab.c"772break;773case 260:774#line 78 "btyacc_demo.y"775{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",776msg,777(*loc).first_line, (*loc).first_column,778(*loc).last_line, (*loc).last_column);779free((*val).expr); }780#line 782 "btyacc_demo.tab.c"781break;782case 261:783#line 83 "btyacc_demo.y"784{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",785msg,786(*loc).first_line, (*loc).first_column,787(*loc).last_line, (*loc).last_column);788/* in this example, we don't know what to do here */ }789#line 791 "btyacc_demo.tab.c"790break;791case 262:792#line 83 "btyacc_demo.y"793{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",794msg,795(*loc).first_line, (*loc).first_column,796(*loc).last_line, (*loc).last_column);797/* in this example, we don't know what to do here */ }798#line 800 "btyacc_demo.tab.c"799break;800case 263:801#line 83 "btyacc_demo.y"802{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",803msg,804(*loc).first_line, (*loc).first_column,805(*loc).last_line, (*loc).last_column);806/* in this example, we don't know what to do here */ }807#line 809 "btyacc_demo.tab.c"808break;809case 264:810#line 83 "btyacc_demo.y"811{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",812msg,813(*loc).first_line, (*loc).first_column,814(*loc).last_line, (*loc).last_column);815/* in this example, we don't know what to do here */ }816#line 818 "btyacc_demo.tab.c"817break;818case 265:819#line 83 "btyacc_demo.y"820{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",821msg,822(*loc).first_line, (*loc).first_column,823(*loc).last_line, (*loc).last_column);824/* in this example, we don't know what to do here */ }825#line 827 "btyacc_demo.tab.c"826break;827case 266:828#line 83 "btyacc_demo.y"829{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",830msg,831(*loc).first_line, (*loc).first_column,832(*loc).last_line, (*loc).last_column);833/* in this example, we don't know what to do here */ }834#line 836 "btyacc_demo.tab.c"835break;836case 267:837#line 83 "btyacc_demo.y"838{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",839msg,840(*loc).first_line, (*loc).first_column,841(*loc).last_line, (*loc).last_column);842/* in this example, we don't know what to do here */ }843#line 845 "btyacc_demo.tab.c"844break;845case 268:846#line 83 "btyacc_demo.y"847{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",848msg,849(*loc).first_line, (*loc).first_column,850(*loc).last_line, (*loc).last_column);851/* in this example, we don't know what to do here */ }852#line 854 "btyacc_demo.tab.c"853break;854case 269:855#line 83 "btyacc_demo.y"856{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",857msg,858(*loc).first_line, (*loc).first_column,859(*loc).last_line, (*loc).last_column);860/* in this example, we don't know what to do here */ }861#line 863 "btyacc_demo.tab.c"862break;863case 59:864#line 83 "btyacc_demo.y"865{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",866msg,867(*loc).first_line, (*loc).first_column,868(*loc).last_line, (*loc).last_column);869/* in this example, we don't know what to do here */ }870#line 872 "btyacc_demo.tab.c"871break;872case 44:873#line 83 "btyacc_demo.y"874{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",875msg,876(*loc).first_line, (*loc).first_column,877(*loc).last_line, (*loc).last_column);878/* in this example, we don't know what to do here */ }879#line 881 "btyacc_demo.tab.c"880break;881case 41:882#line 83 "btyacc_demo.y"883{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",884msg,885(*loc).first_line, (*loc).first_column,886(*loc).last_line, (*loc).last_column);887/* in this example, we don't know what to do here */ }888#line 890 "btyacc_demo.tab.c"889break;890case 93:891#line 83 "btyacc_demo.y"892{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",893msg,894(*loc).first_line, (*loc).first_column,895(*loc).last_line, (*loc).last_column);896/* in this example, we don't know what to do here */ }897#line 899 "btyacc_demo.tab.c"898break;899case 123:900#line 83 "btyacc_demo.y"901{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",902msg,903(*loc).first_line, (*loc).first_column,904(*loc).last_line, (*loc).last_column);905/* in this example, we don't know what to do here */ }906#line 908 "btyacc_demo.tab.c"907break;908case 125:909#line 83 "btyacc_demo.y"910{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",911msg,912(*loc).first_line, (*loc).first_column,913(*loc).last_line, (*loc).last_column);914/* in this example, we don't know what to do here */ }915#line 917 "btyacc_demo.tab.c"916break;917case 270:918#line 83 "btyacc_demo.y"919{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",920msg,921(*loc).first_line, (*loc).first_column,922(*loc).last_line, (*loc).last_column);923/* in this example, we don't know what to do here */ }924#line 926 "btyacc_demo.tab.c"925break;926case 271:927#line 83 "btyacc_demo.y"928{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",929msg,930(*loc).first_line, (*loc).first_column,931(*loc).last_line, (*loc).last_column);932/* in this example, we don't know what to do here */ }933#line 935 "btyacc_demo.tab.c"934break;935case 272:936#line 78 "btyacc_demo.y"937{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",938msg,939(*loc).first_line, (*loc).first_column,940(*loc).last_line, (*loc).last_column);941free((*val).expr); }942#line 944 "btyacc_demo.tab.c"943break;944case 273:945#line 67 "btyacc_demo.y"946{ /* 'msg' is a 'char *' indicating the context of destructor invocation*/947printf("%s accessed by symbol \"decl\" (case s.b. 273) @ position[%d,%d..%d,%d]\n",948msg,949(*loc).first_line, (*loc).first_column,950(*loc).last_line, (*loc).last_column);951free((*val).decl->scope); free((*val).decl->type); }952#line 954 "btyacc_demo.tab.c"953break;954case 274:955#line 83 "btyacc_demo.y"956{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",957msg,958(*loc).first_line, (*loc).first_column,959(*loc).last_line, (*loc).last_column);960/* in this example, we don't know what to do here */ }961#line 963 "btyacc_demo.tab.c"962break;963case 275:964#line 83 "btyacc_demo.y"965{ printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n",966msg,967(*loc).first_line, (*loc).first_column,968(*loc).last_line, (*loc).last_column);969/* in this example, we don't know what to do here */ }970#line 972 "btyacc_demo.tab.c"971break;972case 276:973#line 78 "btyacc_demo.y"974{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",975msg,976(*loc).first_line, (*loc).first_column,977(*loc).last_line, (*loc).last_column);978free((*val).code); }979#line 981 "btyacc_demo.tab.c"980break;981case 277:982#line 78 "btyacc_demo.y"983{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",984msg,985(*loc).first_line, (*loc).first_column,986(*loc).last_line, (*loc).last_column);987free((*val).code); }988#line 990 "btyacc_demo.tab.c"989break;990case 278:991#line 78 "btyacc_demo.y"992{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",993msg,994(*loc).first_line, (*loc).first_column,995(*loc).last_line, (*loc).last_column);996free((*val).code); }997#line 999 "btyacc_demo.tab.c"998break;999case 279:1000#line 73 "btyacc_demo.y"1001{ printf("%s accessed by symbol with type <decl> (case s.b. 279 & 280) @ position[%d,%d..%d,%d]\n",1002msg,1003(*loc).first_line, (*loc).first_column,1004(*loc).last_line, (*loc).last_column);1005free((*val).decl); }1006#line 1008 "btyacc_demo.tab.c"1007break;1008case 280:1009#line 73 "btyacc_demo.y"1010{ printf("%s accessed by symbol with type <decl> (case s.b. 279 & 280) @ position[%d,%d..%d,%d]\n",1011msg,1012(*loc).first_line, (*loc).first_column,1013(*loc).last_line, (*loc).last_column);1014free((*val).decl); }1015#line 1017 "btyacc_demo.tab.c"1016break;1017case 281:1018#line 78 "btyacc_demo.y"1019{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",1020msg,1021(*loc).first_line, (*loc).first_column,1022(*loc).last_line, (*loc).last_column);1023free((*val).type); }1024#line 1026 "btyacc_demo.tab.c"1025break;1026case 282:1027#line 78 "btyacc_demo.y"1028{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",1029msg,1030(*loc).first_line, (*loc).first_column,1031(*loc).last_line, (*loc).last_column);1032free((*val).type); }1033#line 1035 "btyacc_demo.tab.c"1034break;1035case 283:1036#line 78 "btyacc_demo.y"1037{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",1038msg,1039(*loc).first_line, (*loc).first_column,1040(*loc).last_line, (*loc).last_column);1041free((*val).type); }1042#line 1044 "btyacc_demo.tab.c"1043break;1044case 284:1045#line 78 "btyacc_demo.y"1046{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",1047msg,1048(*loc).first_line, (*loc).first_column,1049(*loc).last_line, (*loc).last_column);1050free((*val).type); }1051#line 1053 "btyacc_demo.tab.c"1052break;1053case 285:1054#line 78 "btyacc_demo.y"1055{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",1056msg,1057(*loc).first_line, (*loc).first_column,1058(*loc).last_line, (*loc).last_column);1059free((*val).type); }1060#line 1062 "btyacc_demo.tab.c"1061break;1062case 286:1063#line 78 "btyacc_demo.y"1064{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",1065msg,1066(*loc).first_line, (*loc).first_column,1067(*loc).last_line, (*loc).last_column);1068free((*val).scope); }1069#line 1071 "btyacc_demo.tab.c"1070break;1071case 287:1072#line 78 "btyacc_demo.y"1073{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",1074msg,1075(*loc).first_line, (*loc).first_column,1076(*loc).last_line, (*loc).last_column);1077free((*val).dlist); }1078#line 1080 "btyacc_demo.tab.c"1079break;1080case 288:1081#line 78 "btyacc_demo.y"1082{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",1083msg,1084(*loc).first_line, (*loc).first_column,1085(*loc).last_line, (*loc).last_column);1086free((*val).dlist); }1087#line 1089 "btyacc_demo.tab.c"1088break;1089case 289:1090#line 78 "btyacc_demo.y"1091{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",1092msg,1093(*loc).first_line, (*loc).first_column,1094(*loc).last_line, (*loc).last_column);1095free((*val).scope); }1096#line 1098 "btyacc_demo.tab.c"1097break;1098case 290:1099#line 78 "btyacc_demo.y"1100{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",1101msg,1102(*loc).first_line, (*loc).first_column,1103(*loc).last_line, (*loc).last_column);1104free((*val).scope); }1105#line 1107 "btyacc_demo.tab.c"1106break;1107case 291:1108#line 78 "btyacc_demo.y"1109{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",1110msg,1111(*loc).first_line, (*loc).first_column,1112(*loc).last_line, (*loc).last_column);1113free((*val).scope); }1114#line 1116 "btyacc_demo.tab.c"1115break;1116case 292:1117#line 78 "btyacc_demo.y"1118{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",1119msg,1120(*loc).first_line, (*loc).first_column,1121(*loc).last_line, (*loc).last_column);1122free((*val).scope); }1123#line 1125 "btyacc_demo.tab.c"1124break;1125case 293:1126#line 78 "btyacc_demo.y"1127{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",1128msg,1129(*loc).first_line, (*loc).first_column,1130(*loc).last_line, (*loc).last_column);1131free((*val).type); }1132#line 1134 "btyacc_demo.tab.c"1133break;1134case 294:1135#line 78 "btyacc_demo.y"1136{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",1137msg,1138(*loc).first_line, (*loc).first_column,1139(*loc).last_line, (*loc).last_column);1140free((*val).scope); }1141#line 1143 "btyacc_demo.tab.c"1142break;1143case 295:1144#line 78 "btyacc_demo.y"1145{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",1146msg,1147(*loc).first_line, (*loc).first_column,1148(*loc).last_line, (*loc).last_column);1149free((*val).type); }1150#line 1152 "btyacc_demo.tab.c"1151break;1152case 296:1153#line 78 "btyacc_demo.y"1154{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",1155msg,1156(*loc).first_line, (*loc).first_column,1157(*loc).last_line, (*loc).last_column);1158free((*val).scope); }1159#line 1161 "btyacc_demo.tab.c"1160break;1161case 297:1162#line 78 "btyacc_demo.y"1163{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",1164msg,1165(*loc).first_line, (*loc).first_column,1166(*loc).last_line, (*loc).last_column);1167free((*val).scope); }1168#line 1170 "btyacc_demo.tab.c"1169break;1170case 298:1171#line 78 "btyacc_demo.y"1172{ printf("%s accessed by symbol of any type other than <decl> @ position[%d,%d..%d,%d]\n",1173msg,1174(*loc).first_line, (*loc).first_column,1175(*loc).last_line, (*loc).last_column);1176free((*val).scope); }1177#line 1179 "btyacc_demo.tab.c"1178break;1179}1180}1181#define YYDESTRUCT_IS_DECLARED 11182#endif11831184/* For use in generated program */1185#define yydepth (int)(yystack.s_mark - yystack.s_base)1186#if YYBTYACC1187#define yytrial (yyps->save)1188#endif /* YYBTYACC */11891190#if YYDEBUG1191#include <stdio.h> /* needed for printf */1192#endif11931194#include <stdlib.h> /* needed for malloc, etc */1195#include <string.h> /* needed for memset */11961197/* allocate initial stack or double stack size, up to YYMAXDEPTH */1198static int yygrowstack(YYSTACKDATA *data)1199{1200int i;1201unsigned newsize;1202YYINT *newss;1203YYSTYPE *newvs;1204#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)1205YYLTYPE *newps;1206#endif12071208if ((newsize = data->stacksize) == 0)1209newsize = YYINITSTACKSIZE;1210else if (newsize >= YYMAXDEPTH)1211return YYENOMEM;1212else if ((newsize *= 2) > YYMAXDEPTH)1213newsize = YYMAXDEPTH;12141215i = (int) (data->s_mark - data->s_base);1216newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));1217if (newss == NULL)1218return YYENOMEM;12191220data->s_base = newss;1221data->s_mark = newss + i;12221223newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));1224if (newvs == NULL)1225return YYENOMEM;12261227data->l_base = newvs;1228data->l_mark = newvs + i;12291230#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)1231newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps));1232if (newps == NULL)1233return YYENOMEM;12341235data->p_base = newps;1236data->p_mark = newps + i;1237#endif12381239data->stacksize = newsize;1240data->s_last = data->s_base + newsize - 1;12411242#if YYDEBUG1243if (yydebug)1244fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize);1245#endif1246return 0;1247}12481249#if YYPURE || defined(YY_NO_LEAKS)1250static void yyfreestack(YYSTACKDATA *data)1251{1252free(data->s_base);1253free(data->l_base);1254#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)1255free(data->p_base);1256#endif1257memset(data, 0, sizeof(*data));1258}1259#else1260#define yyfreestack(data) /* nothing */1261#endif /* YYPURE || defined(YY_NO_LEAKS) */1262#if YYBTYACC12631264static YYParseState *1265yyNewState(unsigned size)1266{1267YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState));1268if (p == NULL) return NULL;12691270p->yystack.stacksize = size;1271if (size == 0)1272{1273p->yystack.s_base = NULL;1274p->yystack.l_base = NULL;1275#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)1276p->yystack.p_base = NULL;1277#endif1278return p;1279}1280p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT));1281if (p->yystack.s_base == NULL) return NULL;1282p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE));1283if (p->yystack.l_base == NULL) return NULL;1284memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE));1285#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)1286p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE));1287if (p->yystack.p_base == NULL) return NULL;1288memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE));1289#endif12901291return p;1292}12931294static void1295yyFreeState(YYParseState *p)1296{1297yyfreestack(&p->yystack);1298free(p);1299}1300#endif /* YYBTYACC */13011302#define YYABORT goto yyabort1303#define YYREJECT goto yyabort1304#define YYACCEPT goto yyaccept1305#define YYERROR goto yyerrlab1306#if YYBTYACC1307#define YYVALID do { if (yyps->save) goto yyvalid; } while(0)1308#define YYVALID_NESTED do { if (yyps->save && \1309yyps->save->save == 0) goto yyvalid; } while(0)1310#endif /* YYBTYACC */13111312int1313YYPARSE_DECL()1314{1315int yym, yyn, yystate, yyresult;1316#if YYBTYACC1317int yynewerrflag;1318YYParseState *yyerrctx = NULL;1319#endif /* YYBTYACC */1320#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)1321YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */1322#endif1323#if YYDEBUG1324const char *yys;13251326if ((yys = getenv("YYDEBUG")) != NULL)1327{1328yyn = *yys;1329if (yyn >= '0' && yyn <= '9')1330yydebug = yyn - '0';1331}1332if (yydebug)1333fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX);1334#endif1335#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)1336memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range));1337#endif13381339#if YYBTYACC1340yyps = yyNewState(0); if (yyps == 0) goto yyenomem;1341yyps->save = 0;1342#endif /* YYBTYACC */1343yym = 0;1344/* yyn is set below */1345yynerrs = 0;1346yyerrflag = 0;1347yychar = YYEMPTY;1348yystate = 0;13491350#if YYPURE1351memset(&yystack, 0, sizeof(yystack));1352#endif13531354if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;1355yystack.s_mark = yystack.s_base;1356yystack.l_mark = yystack.l_base;1357#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)1358yystack.p_mark = yystack.p_base;1359#endif1360yystate = 0;1361*yystack.s_mark = 0;13621363yyloop:1364if ((yyn = yydefred[yystate]) != 0) goto yyreduce;1365if (yychar < 0)1366{1367#if YYBTYACC1368do {1369if (yylvp < yylve)1370{1371/* we're currently re-reading tokens */1372yylval = *yylvp++;1373#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)1374yylloc = *yylpp++;1375#endif1376yychar = *yylexp++;1377break;1378}1379if (yyps->save)1380{1381/* in trial mode; save scanner results for future parse attempts */1382if (yylvp == yylvlim)1383{ /* Enlarge lexical value queue */1384size_t p = (size_t) (yylvp - yylvals);1385size_t s = (size_t) (yylvlim - yylvals);13861387s += YYLVQUEUEGROWTH;1388if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;1389if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;1390#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)1391if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;1392#endif1393yylvp = yylve = yylvals + p;1394yylvlim = yylvals + s;1395#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)1396yylpp = yylpe = yylpsns + p;1397yylplim = yylpsns + s;1398#endif1399yylexp = yylexemes + p;1400}1401*yylexp = (YYINT) YYLEX;1402*yylvp++ = yylval;1403yylve++;1404#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)1405*yylpp++ = yylloc;1406yylpe++;1407#endif1408yychar = *yylexp++;1409break;1410}1411/* normal operation, no conflict encountered */1412#endif /* YYBTYACC */1413yychar = YYLEX;1414#if YYBTYACC1415} while (0);1416#endif /* YYBTYACC */1417if (yychar < 0) yychar = YYEOF;1418#if YYDEBUG1419if (yydebug)1420{1421if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];1422fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)",1423YYDEBUGSTR, yydepth, yystate, yychar, yys);1424#ifdef YYSTYPE_TOSTRING1425#if YYBTYACC1426if (!yytrial)1427#endif /* YYBTYACC */1428fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval));1429#endif1430fputc('\n', stderr);1431}1432#endif1433}1434#if YYBTYACC14351436/* Do we have a conflict? */1437if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 &&1438yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)1439{1440YYINT ctry;14411442if (yypath)1443{1444YYParseState *save;1445#if YYDEBUG1446if (yydebug)1447fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n",1448YYDEBUGSTR, yydepth, yystate);1449#endif1450/* Switch to the next conflict context */1451save = yypath;1452yypath = save->save;1453save->save = NULL;1454ctry = save->ctry;1455if (save->state != yystate) YYABORT;1456yyFreeState(save);14571458}1459else1460{14611462/* Unresolved conflict - start/continue trial parse */1463YYParseState *save;1464#if YYDEBUG1465if (yydebug)1466{1467fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate);1468if (yyps->save)1469fputs("ALREADY in conflict, continuing trial parse.\n", stderr);1470else1471fputs("Starting trial parse.\n", stderr);1472}1473#endif1474save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));1475if (save == NULL) goto yyenomem;1476save->save = yyps->save;1477save->state = yystate;1478save->errflag = yyerrflag;1479save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base);1480memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));1481save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base);1482memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));1483#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)1484save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base);1485memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));1486#endif1487ctry = yytable[yyn];1488if (yyctable[ctry] == -1)1489{1490#if YYDEBUG1491if (yydebug && yychar >= YYEOF)1492fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth);1493#endif1494ctry++;1495}1496save->ctry = ctry;1497if (yyps->save == NULL)1498{1499/* If this is a first conflict in the stack, start saving lexemes */1500if (!yylexemes)1501{1502yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));1503if (yylexemes == NULL) goto yyenomem;1504yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));1505if (yylvals == NULL) goto yyenomem;1506yylvlim = yylvals + YYLVQUEUEGROWTH;1507#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)1508yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE));1509if (yylpsns == NULL) goto yyenomem;1510yylplim = yylpsns + YYLVQUEUEGROWTH;1511#endif1512}1513if (yylvp == yylve)1514{1515yylvp = yylve = yylvals;1516#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)1517yylpp = yylpe = yylpsns;1518#endif1519yylexp = yylexemes;1520if (yychar >= YYEOF)1521{1522*yylve++ = yylval;1523#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)1524*yylpe++ = yylloc;1525#endif1526*yylexp = (YYINT) yychar;1527yychar = YYEMPTY;1528}1529}1530}1531if (yychar >= YYEOF)1532{1533yylvp--;1534#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)1535yylpp--;1536#endif1537yylexp--;1538yychar = YYEMPTY;1539}1540save->lexeme = (int) (yylvp - yylvals);1541yyps->save = save;1542}1543if (yytable[yyn] == ctry)1544{1545#if YYDEBUG1546if (yydebug)1547fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",1548YYDEBUGSTR, yydepth, yystate, yyctable[ctry]);1549#endif1550if (yychar < 0)1551{1552yylvp++;1553#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)1554yylpp++;1555#endif1556yylexp++;1557}1558if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)1559goto yyoverflow;1560yystate = yyctable[ctry];1561*++yystack.s_mark = (YYINT) yystate;1562*++yystack.l_mark = yylval;1563#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)1564*++yystack.p_mark = yylloc;1565#endif1566yychar = YYEMPTY;1567if (yyerrflag > 0) --yyerrflag;1568goto yyloop;1569}1570else1571{1572yyn = yyctable[ctry];1573goto yyreduce;1574}1575} /* End of code dealing with conflicts */1576#endif /* YYBTYACC */1577if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&1578yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)1579{1580#if YYDEBUG1581if (yydebug)1582fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",1583YYDEBUGSTR, yydepth, yystate, yytable[yyn]);1584#endif1585if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;1586yystate = yytable[yyn];1587*++yystack.s_mark = yytable[yyn];1588*++yystack.l_mark = yylval;1589#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)1590*++yystack.p_mark = yylloc;1591#endif1592yychar = YYEMPTY;1593if (yyerrflag > 0) --yyerrflag;1594goto yyloop;1595}1596if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&1597yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)1598{1599yyn = yytable[yyn];1600goto yyreduce;1601}1602if (yyerrflag != 0) goto yyinrecovery;1603#if YYBTYACC16041605yynewerrflag = 1;1606goto yyerrhandler;1607goto yyerrlab; /* redundant goto avoids 'unused label' warning */16081609yyerrlab:1610/* explicit YYERROR from an action -- pop the rhs of the rule reduced1611* before looking for error recovery */1612yystack.s_mark -= yym;1613yystate = *yystack.s_mark;1614yystack.l_mark -= yym;1615#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)1616yystack.p_mark -= yym;1617#endif16181619yynewerrflag = 0;1620yyerrhandler:1621while (yyps->save)1622{1623int ctry;1624YYParseState *save = yyps->save;1625#if YYDEBUG1626if (yydebug)1627fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n",1628YYDEBUGSTR, yydepth, yystate, yyps->save->state,1629(int)(yylvp - yylvals - yyps->save->lexeme));1630#endif1631/* Memorize most forward-looking error state in case it's really an error. */1632if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals)1633{1634/* Free old saved error context state */1635if (yyerrctx) yyFreeState(yyerrctx);1636/* Create and fill out new saved error context state */1637yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));1638if (yyerrctx == NULL) goto yyenomem;1639yyerrctx->save = yyps->save;1640yyerrctx->state = yystate;1641yyerrctx->errflag = yyerrflag;1642yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base);1643memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));1644yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base);1645memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));1646#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)1647yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base);1648memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));1649#endif1650yyerrctx->lexeme = (int) (yylvp - yylvals);1651}1652yylvp = yylvals + save->lexeme;1653#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)1654yylpp = yylpsns + save->lexeme;1655#endif1656yylexp = yylexemes + save->lexeme;1657yychar = YYEMPTY;1658yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base);1659memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));1660yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base);1661memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));1662#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)1663yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base);1664memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));1665#endif1666ctry = ++save->ctry;1667yystate = save->state;1668/* We tried shift, try reduce now */1669if ((yyn = yyctable[ctry]) >= 0) goto yyreduce;1670yyps->save = save->save;1671save->save = NULL;1672yyFreeState(save);16731674/* Nothing left on the stack -- error */1675if (!yyps->save)1676{1677#if YYDEBUG1678if (yydebug)1679fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n",1680YYPREFIX, yydepth);1681#endif1682/* Restore state as it was in the most forward-advanced error */1683yylvp = yylvals + yyerrctx->lexeme;1684#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)1685yylpp = yylpsns + yyerrctx->lexeme;1686#endif1687yylexp = yylexemes + yyerrctx->lexeme;1688yychar = yylexp[-1];1689yylval = yylvp[-1];1690#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)1691yylloc = yylpp[-1];1692#endif1693yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base);1694memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));1695yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base);1696memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));1697#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)1698yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base);1699memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));1700#endif1701yystate = yyerrctx->state;1702yyFreeState(yyerrctx);1703yyerrctx = NULL;1704}1705yynewerrflag = 1;1706}1707if (yynewerrflag == 0) goto yyinrecovery;1708#endif /* YYBTYACC */17091710YYERROR_CALL("syntax error");1711#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)1712yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */1713#endif17141715#if !YYBTYACC1716goto yyerrlab; /* redundant goto avoids 'unused label' warning */1717yyerrlab:1718#endif1719++yynerrs;17201721yyinrecovery:1722if (yyerrflag < 3)1723{1724yyerrflag = 3;1725for (;;)1726{1727if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&1728yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)1729{1730#if YYDEBUG1731if (yydebug)1732fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n",1733YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]);1734#endif1735if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;1736yystate = yytable[yyn];1737*++yystack.s_mark = yytable[yyn];1738*++yystack.l_mark = yylval;1739#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)1740/* lookahead position is error end position */1741yyerror_loc_range[2] = yylloc;1742YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */1743*++yystack.p_mark = yyloc;1744#endif1745goto yyloop;1746}1747else1748{1749#if YYDEBUG1750if (yydebug)1751fprintf(stderr, "%s[%d]: error recovery discarding state %d\n",1752YYDEBUGSTR, yydepth, *yystack.s_mark);1753#endif1754if (yystack.s_mark <= yystack.s_base) goto yyabort;1755#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)1756/* the current TOS position is the error start position */1757yyerror_loc_range[1] = *yystack.p_mark;1758#endif1759#if defined(YYDESTRUCT_CALL)1760#if YYBTYACC1761if (!yytrial)1762#endif /* YYBTYACC */1763#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)1764YYDESTRUCT_CALL("error: discarding state",1765yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark);1766#else1767YYDESTRUCT_CALL("error: discarding state",1768yystos[*yystack.s_mark], yystack.l_mark);1769#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */1770#endif /* defined(YYDESTRUCT_CALL) */1771--yystack.s_mark;1772--yystack.l_mark;1773#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)1774--yystack.p_mark;1775#endif1776}1777}1778}1779else1780{1781if (yychar == YYEOF) goto yyabort;1782#if YYDEBUG1783if (yydebug)1784{1785if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];1786fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n",1787YYDEBUGSTR, yydepth, yystate, yychar, yys);1788}1789#endif1790#if defined(YYDESTRUCT_CALL)1791#if YYBTYACC1792if (!yytrial)1793#endif /* YYBTYACC */1794#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)1795YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc);1796#else1797YYDESTRUCT_CALL("error: discarding token", yychar, &yylval);1798#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */1799#endif /* defined(YYDESTRUCT_CALL) */1800yychar = YYEMPTY;1801goto yyloop;1802}18031804yyreduce:1805yym = yylen[yyn];1806#if YYDEBUG1807if (yydebug)1808{1809fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)",1810YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]);1811#ifdef YYSTYPE_TOSTRING1812#if YYBTYACC1813if (!yytrial)1814#endif /* YYBTYACC */1815if (yym > 0)1816{1817int i;1818fputc('<', stderr);1819for (i = yym; i > 0; i--)1820{1821if (i != yym) fputs(", ", stderr);1822fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]],1823yystack.l_mark[1-i]), stderr);1824}1825fputc('>', stderr);1826}1827#endif1828fputc('\n', stderr);1829}1830#endif1831if (yym > 0)1832yyval = yystack.l_mark[1-yym];1833else1834memset(&yyval, 0, sizeof yyval);1835#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)18361837/* Perform position reduction */1838memset(&yyloc, 0, sizeof(yyloc));1839#if YYBTYACC1840if (!yytrial)1841#endif /* YYBTYACC */1842{1843YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym);1844/* just in case YYERROR is invoked within the action, save1845the start of the rhs as the error start position */1846yyerror_loc_range[1] = yystack.p_mark[1-yym];1847}1848#endif18491850switch (yyn)1851{1852case 1:1853#line 93 "btyacc_demo.y"1854{ yyval.scope = yystack.l_mark[0].scope; }1855#line 1857 "btyacc_demo.tab.c"1856break;1857case 2:1858#line 94 "btyacc_demo.y"1859{ yyval.scope = global_scope; }1860#line 1862 "btyacc_demo.tab.c"1861break;1862case 3:1863#line 95 "btyacc_demo.y"1864{ Decl *d = lookup(yystack.l_mark[-2].scope, yystack.l_mark[-1].id);1865if (!d || !d->scope) YYERROR;1866yyval.scope = d->scope; }1867#line 1869 "btyacc_demo.tab.c"1868break;1869case 4:1870#line 101 "btyacc_demo.y"1871{ Decl *d = lookup(yystack.l_mark[-1].scope, yystack.l_mark[0].id);1872if (d == NULL || d->istype() == 0) YYERROR;1873yyval.type = d->type; }1874#line 1876 "btyacc_demo.tab.c"1875break;1876case 5:1877#line 106 "btyacc_demo.y"1878yyval.scope = global_scope = new_scope(0);1879#line 1881 "btyacc_demo.tab.c"1880break;1881case 8:1882#line 107 "btyacc_demo.y"1883yyval.scope = yystack.l_mark[-1].scope;1884#line 1886 "btyacc_demo.tab.c"1885break;1886case 10:1887#line 109 "btyacc_demo.y"1888{YYVALID;}1889#line 1891 "btyacc_demo.tab.c"1890break;1891case 11:1892#line 110 "btyacc_demo.y"1893yyval.scope = start_fn_def(yystack.l_mark[-2].scope, yystack.l_mark[0].decl);1894#line 1896 "btyacc_demo.tab.c"1895break;1896case 12:1897if (!yytrial)1898#line 111 "btyacc_demo.y"1899{ /* demonstrate use of @$ & @N, although this is just the1900default computation and so is not necessary */1901yyloc.first_line = yystack.p_mark[-3].first_line;1902yyloc.first_column = yystack.p_mark[-3].first_column;1903yyloc.last_line = yystack.p_mark[0].last_line;1904yyloc.last_column = yystack.p_mark[0].last_column;1905finish_fn_def(yystack.l_mark[-2].decl, yystack.l_mark[0].code); }1906#line 1908 "btyacc_demo.tab.c"1907break;1908case 13:1909#line 121 "btyacc_demo.y"1910{ yyval.type = yystack.l_mark[0].type; }1911#line 1913 "btyacc_demo.tab.c"1912break;1913case 14:1914#line 122 "btyacc_demo.y"1915{ yyval.type = type_combine(yystack.l_mark[-2].type, yystack.l_mark[0].type); }1916#line 1918 "btyacc_demo.tab.c"1917break;1918case 15:1919#line 125 "btyacc_demo.y"1920{ yyval.type = 0; }1921#line 1923 "btyacc_demo.tab.c"1922break;1923case 16:1924#line 126 "btyacc_demo.y"1925{ yyval.type = type_combine(yystack.l_mark[-1].type, yystack.l_mark[0].type); }1926#line 1928 "btyacc_demo.tab.c"1927break;1928case 17:1929#line 130 "btyacc_demo.y"1930{ yyval.type = yystack.l_mark[0].type; }1931#line 1933 "btyacc_demo.tab.c"1932break;1933case 18:1934#line 131 "btyacc_demo.y"1935{ yyval.type = yystack.l_mark[0].type; }1936#line 1938 "btyacc_demo.tab.c"1937break;1938case 19:1939#line 132 "btyacc_demo.y"1940{ yyval.type = bare_extern(); }1941#line 1943 "btyacc_demo.tab.c"1942break;1943case 20:1944#line 133 "btyacc_demo.y"1945{ yyval.type = bare_register(); }1946#line 1948 "btyacc_demo.tab.c"1947break;1948case 21:1949#line 134 "btyacc_demo.y"1950{ yyval.type = bare_static(); }1951#line 1953 "btyacc_demo.tab.c"1952break;1953case 22:1954#line 138 "btyacc_demo.y"1955{ yyval.type = bare_const(); }1956#line 1958 "btyacc_demo.tab.c"1957break;1958case 23:1959#line 139 "btyacc_demo.y"1960{ yyval.type = bare_volatile(); }1961#line 1963 "btyacc_demo.tab.c"1962break;1963case 24:1964#line 143 "btyacc_demo.y"1965yyval.scope = yystack.l_mark[-3].scope;1966#line 1968 "btyacc_demo.tab.c"1967break;1968case 25:1969#line 143 "btyacc_demo.y"1970yyval.type = yystack.l_mark[-3].type;1971#line 1973 "btyacc_demo.tab.c"1972break;1973case 28:1974#line 148 "btyacc_demo.y"1975{ if (!yystack.l_mark[0].type) YYERROR; } if (!yytrial)1976#line 149 "btyacc_demo.y"1977{ yyval.decl = declare(yystack.l_mark[-1].scope, 0, yystack.l_mark[0].type); }1978#line 1980 "btyacc_demo.tab.c"1979break;1980case 29:1981if (!yytrial)1982#line 150 "btyacc_demo.y"1983{ yyval.decl = declare(yystack.l_mark[-2].scope, yystack.l_mark[0].id, yystack.l_mark[-1].type); }1984#line 1986 "btyacc_demo.tab.c"1985break;1986case 30:1987#line 151 "btyacc_demo.y"1988yyval.scope = yystack.l_mark[-2].scope;1989#line 1991 "btyacc_demo.tab.c"1990break;1991case 31:1992#line 151 "btyacc_demo.y"1993yyval.type = yystack.l_mark[-2].type;1994#line 1996 "btyacc_demo.tab.c"1995break;1996case 32:1997if (!yytrial)1998#line 151 "btyacc_demo.y"1999{ yyval.decl = yystack.l_mark[-1].decl; }2000#line 2002 "btyacc_demo.tab.c"2001break;2002case 33:2003if (!yytrial)2004#line 153 "btyacc_demo.y"2005{ yyval.decl = make_pointer(yystack.l_mark[0].decl, yystack.l_mark[-3].type); }2006#line 2008 "btyacc_demo.tab.c"2007break;2008case 34:2009if (!yytrial)2010#line 155 "btyacc_demo.y"2011{ yyval.decl = make_array(yystack.l_mark[-4].decl->type, yystack.l_mark[-1].expr); }2012#line 2014 "btyacc_demo.tab.c"2013break;2014case 35:2015if (!yytrial)2016#line 157 "btyacc_demo.y"2017{ yyval.decl = build_function(yystack.l_mark[-5].decl, yystack.l_mark[-2].dlist, yystack.l_mark[0].type); }2018#line 2020 "btyacc_demo.tab.c"2019break;2020case 36:2021if (!yytrial)2022#line 160 "btyacc_demo.y"2023{ yyval.dlist = 0; }2024#line 2026 "btyacc_demo.tab.c"2025break;2026case 37:2027if (!yytrial)2028#line 161 "btyacc_demo.y"2029{ yyval.dlist = yystack.l_mark[0].dlist; }2030#line 2032 "btyacc_demo.tab.c"2031break;2032case 38:2033if (!yytrial)2034#line 164 "btyacc_demo.y"2035{ yyval.dlist = append_dlist(yystack.l_mark[-3].dlist, yystack.l_mark[0].decl); }2036#line 2038 "btyacc_demo.tab.c"2037break;2038case 39:2039if (!yytrial)2040#line 165 "btyacc_demo.y"2041{ yyval.dlist = build_dlist(yystack.l_mark[0].decl); }2042#line 2044 "btyacc_demo.tab.c"2043break;2044case 40:2045if (!yytrial)2046#line 168 "btyacc_demo.y"2047{ yyval.decl = yystack.l_mark[0].decl; }2048#line 2050 "btyacc_demo.tab.c"2049break;2050case 41:2051if (!yytrial)2052#line 172 "btyacc_demo.y"2053{ yyval.expr = build_expr(yystack.l_mark[-3].expr, ADD, yystack.l_mark[0].expr); }2054#line 2056 "btyacc_demo.tab.c"2055break;2056case 42:2057if (!yytrial)2058#line 173 "btyacc_demo.y"2059{ yyval.expr = build_expr(yystack.l_mark[-3].expr, SUB, yystack.l_mark[0].expr); }2060#line 2062 "btyacc_demo.tab.c"2061break;2062case 43:2063if (!yytrial)2064#line 174 "btyacc_demo.y"2065{ yyval.expr = build_expr(yystack.l_mark[-3].expr, MUL, yystack.l_mark[0].expr); }2066#line 2068 "btyacc_demo.tab.c"2067break;2068case 44:2069if (!yytrial)2070#line 175 "btyacc_demo.y"2071{ yyval.expr = build_expr(yystack.l_mark[-3].expr, MOD, yystack.l_mark[0].expr); }2072#line 2074 "btyacc_demo.tab.c"2073break;2074case 45:2075if (!yytrial)2076#line 176 "btyacc_demo.y"2077{ yyval.expr = build_expr(yystack.l_mark[-3].expr, DIV, yystack.l_mark[0].expr); }2078#line 2080 "btyacc_demo.tab.c"2079break;2080case 46:2081if (!yytrial)2082#line 177 "btyacc_demo.y"2083{ yyval.expr = build_expr(0, DEREF, yystack.l_mark[0].expr); }2084#line 2086 "btyacc_demo.tab.c"2085break;2086case 47:2087if (!yytrial)2088#line 178 "btyacc_demo.y"2089{ yyval.expr = var_expr(yystack.l_mark[-1].scope, yystack.l_mark[0].id); }2090#line 2092 "btyacc_demo.tab.c"2091break;2092case 48:2093if (!yytrial)2094#line 179 "btyacc_demo.y"2095{ yyval.expr = yystack.l_mark[0].expr; }2096#line 2098 "btyacc_demo.tab.c"2097break;2098case 49:2099if (!yytrial)2100#line 183 "btyacc_demo.y"2101{ yyval.code = 0; }2102#line 2104 "btyacc_demo.tab.c"2103break;2104case 50:2105#line 184 "btyacc_demo.y"2106{YYVALID;} if (!yytrial)2107#line 184 "btyacc_demo.y"2108{ yyval.code = build_expr_code(yystack.l_mark[-1].expr); }2109#line 2111 "btyacc_demo.tab.c"2110break;2111case 51:2112#line 185 "btyacc_demo.y"2113yyval.scope = yystack.l_mark[-6].scope;2114#line 2116 "btyacc_demo.tab.c"2115break;2116case 52:2117#line 185 "btyacc_demo.y"2118yyval.scope = yystack.l_mark[-9].scope;2119#line 2121 "btyacc_demo.tab.c"2120break;2121case 53:2122#line 185 "btyacc_demo.y"2123{YYVALID;} if (!yytrial)2124#line 186 "btyacc_demo.y"2125{ yyval.code = build_if(yystack.l_mark[-7].expr, yystack.l_mark[-3].code, yystack.l_mark[0].code); }2126#line 2128 "btyacc_demo.tab.c"2127break;2128case 54:2129#line 187 "btyacc_demo.y"2130{YYVALID;} if (!yytrial)2131#line 188 "btyacc_demo.y"2132{ yyval.code = build_if(yystack.l_mark[-4].expr, yystack.l_mark[0].code, 0); }2133#line 2135 "btyacc_demo.tab.c"2134break;2135case 55:2136#line 189 "btyacc_demo.y"2137yyval.scope = new_scope(yystack.l_mark[0].scope);2138#line 2140 "btyacc_demo.tab.c"2139break;2140case 56:2141#line 189 "btyacc_demo.y"2142{YYVALID;} if (!yytrial)2143#line 189 "btyacc_demo.y"2144{ yyval.code = yystack.l_mark[0].code; }2145#line 2147 "btyacc_demo.tab.c"2146break;2147case 57:2148if (!yytrial)2149#line 192 "btyacc_demo.y"2150{ yyval.code = 0; }2151#line 2153 "btyacc_demo.tab.c"2152break;2153case 58:2154if (!yytrial)2155#line 193 "btyacc_demo.y"2156{ yyval.code = code_append(yystack.l_mark[-2].code, yystack.l_mark[0].code); }2157#line 2159 "btyacc_demo.tab.c"2158break;2159case 59:2160if (!yytrial)2161#line 197 "btyacc_demo.y"2162{ yyval.code = yystack.l_mark[-1].code; }2163#line 2165 "btyacc_demo.tab.c"2164break;2165#line 2167 "btyacc_demo.tab.c"2166default:2167break;2168}2169yystack.s_mark -= yym;2170yystate = *yystack.s_mark;2171yystack.l_mark -= yym;2172#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)2173yystack.p_mark -= yym;2174#endif2175yym = yylhs[yyn];2176if (yystate == 0 && yym == 0)2177{2178#if YYDEBUG2179if (yydebug)2180{2181fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);2182#ifdef YYSTYPE_TOSTRING2183#if YYBTYACC2184if (!yytrial)2185#endif /* YYBTYACC */2186fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval));2187#endif2188fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL);2189}2190#endif2191yystate = YYFINAL;2192*++yystack.s_mark = YYFINAL;2193*++yystack.l_mark = yyval;2194#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)2195*++yystack.p_mark = yyloc;2196#endif2197if (yychar < 0)2198{2199#if YYBTYACC2200do {2201if (yylvp < yylve)2202{2203/* we're currently re-reading tokens */2204yylval = *yylvp++;2205#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)2206yylloc = *yylpp++;2207#endif2208yychar = *yylexp++;2209break;2210}2211if (yyps->save)2212{2213/* in trial mode; save scanner results for future parse attempts */2214if (yylvp == yylvlim)2215{ /* Enlarge lexical value queue */2216size_t p = (size_t) (yylvp - yylvals);2217size_t s = (size_t) (yylvlim - yylvals);22182219s += YYLVQUEUEGROWTH;2220if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL)2221goto yyenomem;2222if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)2223goto yyenomem;2224#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)2225if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)2226goto yyenomem;2227#endif2228yylvp = yylve = yylvals + p;2229yylvlim = yylvals + s;2230#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)2231yylpp = yylpe = yylpsns + p;2232yylplim = yylpsns + s;2233#endif2234yylexp = yylexemes + p;2235}2236*yylexp = (YYINT) YYLEX;2237*yylvp++ = yylval;2238yylve++;2239#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)2240*yylpp++ = yylloc;2241yylpe++;2242#endif2243yychar = *yylexp++;2244break;2245}2246/* normal operation, no conflict encountered */2247#endif /* YYBTYACC */2248yychar = YYLEX;2249#if YYBTYACC2250} while (0);2251#endif /* YYBTYACC */2252if (yychar < 0) yychar = YYEOF;2253#if YYDEBUG2254if (yydebug)2255{2256if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];2257fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n",2258YYDEBUGSTR, yydepth, YYFINAL, yychar, yys);2259}2260#endif2261}2262if (yychar == YYEOF) goto yyaccept;2263goto yyloop;2264}2265if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&2266yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)2267yystate = yytable[yyn];2268else2269yystate = yydgoto[yym];2270#if YYDEBUG2271if (yydebug)2272{2273fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);2274#ifdef YYSTYPE_TOSTRING2275#if YYBTYACC2276if (!yytrial)2277#endif /* YYBTYACC */2278fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval));2279#endif2280fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate);2281}2282#endif2283if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;2284*++yystack.s_mark = (YYINT) yystate;2285*++yystack.l_mark = yyval;2286#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)2287*++yystack.p_mark = yyloc;2288#endif2289goto yyloop;2290#if YYBTYACC22912292/* Reduction declares that this path is valid. Set yypath and do a full parse */2293yyvalid:2294if (yypath) YYABORT;2295while (yyps->save)2296{2297YYParseState *save = yyps->save;2298yyps->save = save->save;2299save->save = yypath;2300yypath = save;2301}2302#if YYDEBUG2303if (yydebug)2304fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n",2305YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme));2306#endif2307if (yyerrctx)2308{2309yyFreeState(yyerrctx);2310yyerrctx = NULL;2311}2312yylvp = yylvals + yypath->lexeme;2313#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)2314yylpp = yylpsns + yypath->lexeme;2315#endif2316yylexp = yylexemes + yypath->lexeme;2317yychar = YYEMPTY;2318yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base);2319memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));2320yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base);2321memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));2322#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)2323yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base);2324memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));2325#endif2326yystate = yypath->state;2327goto yyloop;2328#endif /* YYBTYACC */23292330yyoverflow:2331YYERROR_CALL("yacc stack overflow");2332#if YYBTYACC2333goto yyabort_nomem;2334yyenomem:2335YYERROR_CALL("memory exhausted");2336yyabort_nomem:2337#endif /* YYBTYACC */2338yyresult = 2;2339goto yyreturn;23402341yyabort:2342yyresult = 1;2343goto yyreturn;23442345yyaccept:2346#if YYBTYACC2347if (yyps->save) goto yyvalid;2348#endif /* YYBTYACC */2349yyresult = 0;23502351yyreturn:2352#if defined(YYDESTRUCT_CALL)2353if (yychar != YYEOF && yychar != YYEMPTY)2354#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)2355YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc);2356#else2357YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval);2358#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */23592360{2361YYSTYPE *pv;2362#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)2363YYLTYPE *pp;23642365for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp)2366YYDESTRUCT_CALL("cleanup: discarding state",2367yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp);2368#else2369for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv)2370YYDESTRUCT_CALL("cleanup: discarding state",2371yystos[*(yystack.s_base + (pv - yystack.l_base))], pv);2372#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */2373}2374#endif /* defined(YYDESTRUCT_CALL) */23752376#if YYBTYACC2377if (yyerrctx)2378{2379yyFreeState(yyerrctx);2380yyerrctx = NULL;2381}2382while (yyps)2383{2384YYParseState *save = yyps;2385yyps = save->save;2386save->save = NULL;2387yyFreeState(save);2388}2389while (yypath)2390{2391YYParseState *save = yypath;2392yypath = save->save;2393save->save = NULL;2394yyFreeState(save);2395}2396#endif /* YYBTYACC */2397yyfreestack(&yystack);2398return (yyresult);2399}240024012402