diff --git a/contrib/byacc/test/btyacc/btyacc_calc1.tab.c b/contrib/byacc/test/btyacc/btyacc_calc1.tab.c index f2057aa37997..36765d09ec09 100644 --- a/contrib/byacc/test/btyacc/btyacc_calc1.tab.c +++ b/contrib/byacc/test/btyacc/btyacc_calc1.tab.c @@ -1,1803 +1,1803 @@ /* original parser id follows */ /* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ /* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ #define YYBYACC 1 #define YYMAJOR 2 #define YYMINOR 0 #define YYCHECK "yyyymmdd" #define YYEMPTY (-1) #define yyclearin (yychar = YYEMPTY) #define yyerrok (yyerrflag = 0) #define YYRECOVERING() (yyerrflag != 0) #define YYENOMEM (-2) #define YYEOF 0 #undef YYBTYACC #define YYBTYACC 1 #define YYDEBUGSTR (yytrial ? YYPREFIX "debug(trial)" : YYPREFIX "debug") #ifndef yyparse #define yyparse calc1_parse #endif /* yyparse */ #ifndef yylex #define yylex calc1_lex #endif /* yylex */ #ifndef yyerror #define yyerror calc1_error #endif /* yyerror */ #ifndef yychar #define yychar calc1_char #endif /* yychar */ #ifndef yyval #define yyval calc1_val #endif /* yyval */ #ifndef yylval #define yylval calc1_lval #endif /* yylval */ #ifndef yydebug #define yydebug calc1_debug #endif /* yydebug */ #ifndef yynerrs #define yynerrs calc1_nerrs #endif /* yynerrs */ #ifndef yyerrflag #define yyerrflag calc1_errflag #endif /* yyerrflag */ #ifndef yylhs #define yylhs calc1_lhs #endif /* yylhs */ #ifndef yylen #define yylen calc1_len #endif /* yylen */ #ifndef yydefred #define yydefred calc1_defred #endif /* yydefred */ #ifndef yystos #define yystos calc1_stos #endif /* yystos */ #ifndef yydgoto #define yydgoto calc1_dgoto #endif /* yydgoto */ #ifndef yysindex #define yysindex calc1_sindex #endif /* yysindex */ #ifndef yyrindex #define yyrindex calc1_rindex #endif /* yyrindex */ #ifndef yygindex #define yygindex calc1_gindex #endif /* yygindex */ #ifndef yytable #define yytable calc1_table #endif /* yytable */ #ifndef yycheck #define yycheck calc1_check #endif /* yycheck */ #ifndef yyname #define yyname calc1_name #endif /* yyname */ #ifndef yyrule #define yyrule calc1_rule #endif /* yyrule */ #if YYBTYACC #ifndef yycindex #define yycindex calc1_cindex #endif /* yycindex */ #ifndef yyctable #define yyctable calc1_ctable #endif /* yyctable */ #endif /* YYBTYACC */ #define YYPREFIX "calc1_" #define YYPURE 1 #line 3 "btyacc_calc1.y" /* http://dinosaur.compilertools.net/yacc/index.html */ #include #include #include #include typedef struct interval { double lo, hi; } INTERVAL; INTERVAL vmul(double, double, INTERVAL); INTERVAL vdiv(double, double, INTERVAL); int dcheck(INTERVAL); double dreg[26]; INTERVAL vreg[26]; #ifdef YYSTYPE #undef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 #endif #ifndef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 #line 29 "btyacc_calc1.y" -typedef union YYSTYPE +typedef union { int ival; double dval; INTERVAL vval; } YYSTYPE; #endif /* !YYSTYPE_IS_DECLARED */ #line 158 "btyacc_calc1.tab.c" /* compatibility with bison */ #ifdef YYPARSE_PARAM /* compatibility with FreeBSD */ # ifdef YYPARSE_PARAM_TYPE # define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) # else # define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) # endif #else # define YYPARSE_DECL() yyparse(void) #endif /* Parameters sent to lex. */ #ifdef YYLEX_PARAM # ifdef YYLEX_PARAM_TYPE # define YYLEX_DECL() yylex(YYSTYPE *yylval, YYLEX_PARAM_TYPE YYLEX_PARAM) # else # define YYLEX_DECL() yylex(YYSTYPE *yylval, void * YYLEX_PARAM) # endif # define YYLEX yylex(&yylval, YYLEX_PARAM) #else # define YYLEX_DECL() yylex(YYSTYPE *yylval) # define YYLEX yylex(&yylval) #endif /* Parameters sent to yyerror. */ #ifndef YYERROR_DECL #define YYERROR_DECL() yyerror(const char *s) #endif #ifndef YYERROR_CALL #define YYERROR_CALL(msg) yyerror(msg) #endif extern int YYPARSE_DECL(); #define DREG 257 #define VREG 258 #define CONST 259 #define UMINUS 260 #define YYERRCODE 256 typedef int YYINT; static const YYINT calc1_lhs[] = { -1, 0, 0, 0, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, }; static const YYINT calc1_len[] = { 2, 0, 3, 3, 1, 1, 3, 3, 1, 1, 3, 3, 3, 3, 2, 3, 1, 5, 1, 3, 3, 3, 3, 3, 3, 3, 3, 2, 3, }; static const YYINT calc1_defred[] = { 1, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 3, 0, 0, 9, 18, 0, 27, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 15, 0, 28, 0, 0, 0, 0, 0, 24, 0, 26, 0, 0, 23, 25, 14, 0, 0, 0, 0, 0, 0, 0, 0, 12, 13, 17, }; #if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) static const YYINT calc1_stos[] = { 0, 262, 256, 257, 258, 259, 45, 40, 263, 264, 265, 10, 61, 61, 257, 258, 263, 264, 263, 264, 43, 45, 42, 47, 43, 45, 42, 47, 10, 45, 40, 263, 263, 264, 41, 44, 41, 263, 264, 263, 264, 263, 264, 263, 264, 264, 264, 264, 264, 263, 263, 43, 45, 42, 47, 263, 263, 263, 263, 263, 41, }; #endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ static const YYINT calc1_dgoto[] = { 1, 32, 9, 10, }; static const YYINT calc1_sindex[] = { 0, -40, -9, -59, -54, 0, -37, -37, 0, 82, 4, 0, -34, -37, 0, 0, 0, 0, -31, -25, -37, -37, -37, -37, -37, -37, -37, -37, 0, -34, -34, 132, 0, 82, 0, -34, 0, 0, -12, 0, -12, 0, 0, 0, 0, -12, -12, 0, 0, 0, 112, -34, -34, -34, -34, 119, -11, -11, 0, 0, 0, }; static const YYINT calc1_rindex[] = { 0, 0, 0, 51, 58, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, -16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 9, 27, 0, 0, 0, -5, 41, -4, 77, -2, 0, 8, 0, 78, 85, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 99, 0, 0, 0, }; #if YYBTYACC static const YYINT calc1_cindex[] = { 0, 0, 0, 0, 0, 0, 0, 0, 65, 0, 0, 0, 0, 0, 0, 0, 2, 0, 126, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 138, 0, 0, 0, 0, 17, 0, 24, 0, 31, 0, 38, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; #endif static const YYINT calc1_gindex[] = { 0, 3, 125, 0, }; #define YYTABLESIZE 225 static const YYINT calc1_table[] = { 7, 11, 12, 7, 8, 6, 30, 13, 6, 16, 18, 29, 14, 35, 28, 31, 36, 26, 24, 16, 25, 5, 27, 37, 39, 41, 43, 20, 14, 6, 26, 53, 49, 50, 23, 27, 54, 7, 55, 10, 11, 26, 12, 14, 14, 14, 0, 14, 29, 14, 16, 20, 13, 0, 56, 57, 58, 59, 20, 6, 20, 9, 20, 0, 9, 23, 6, 23, 18, 23, 0, 9, 26, 26, 26, 11, 26, 0, 26, 29, 29, 29, 20, 29, 20, 29, 20, 22, 19, 0, 0, 0, 0, 9, 9, 21, 9, 0, 9, 0, 18, 18, 10, 18, 0, 18, 0, 6, 0, 11, 3, 0, 9, 0, 0, 0, 0, 0, 22, 19, 22, 19, 22, 19, 26, 24, 21, 25, 21, 27, 21, 17, 19, 10, 0, 10, 0, 10, 33, 0, 11, 0, 11, 0, 11, 38, 40, 42, 44, 45, 46, 47, 48, 34, 53, 51, 0, 52, 0, 54, 60, 53, 51, 0, 52, 0, 54, 18, 6, 0, 0, 3, 0, 9, 53, 51, 0, 52, 0, 54, 6, 0, 0, 3, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 4, 5, 14, 15, 5, 14, 0, 5, }; static const YYINT calc1_check[] = { 40, 10, 61, 40, 1, 45, 40, 61, 45, 6, 7, 45, 10, 44, 10, 12, 41, 42, 43, 10, 45, 10, 47, 20, 21, 22, 23, 10, 44, 10, 42, 42, 29, 30, 10, 47, 47, 10, 35, 44, 44, 10, 44, 41, 42, 43, -1, 45, 10, 47, 41, 10, 44, -1, 51, 52, 53, 54, 41, 42, 43, 10, 45, -1, 47, 41, 42, 43, 10, 45, -1, 47, 41, 42, 43, 10, 45, -1, 47, 41, 42, 43, 41, 45, 43, 47, 45, 10, 10, -1, -1, -1, -1, 42, 43, 10, 45, -1, 47, -1, 42, 43, 10, 45, -1, 47, -1, 42, 43, 10, 45, -1, 47, -1, -1, -1, -1, -1, 41, 41, 43, 43, 45, 45, 42, 43, 41, 45, 43, 47, 45, 6, 7, 41, -1, 43, -1, 45, 13, -1, 41, -1, 43, -1, 45, 20, 21, 22, 23, 24, 25, 26, 27, 41, 42, 43, -1, 45, -1, 47, 41, 42, 43, -1, 45, -1, 47, 41, 42, 43, -1, 45, -1, 47, 42, 43, -1, 45, -1, 47, 42, 43, -1, 45, -1, 47, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 256, 257, 258, 259, 257, 258, 259, 257, -1, 259, }; #if YYBTYACC static const YYINT calc1_ctable[] = { 20, 16, -1, 21, 16, -1, 22, 16, -1, 23, 16, -1, 4, 16, -1, 14, 16, -1, 34, 16, -1, 10, 16, -1, 11, 16, -1, 12, 16, -1, 13, 16, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, }; #endif #define YYFINAL 1 #ifndef YYDEBUG #define YYDEBUG 0 #endif #define YYMAXTOKEN 260 #define YYUNDFTOKEN 266 #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) #if YYDEBUG static const char *const calc1_name[] = { "$end",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,"'('","')'","'*'","'+'","','","'-'",0,"'/'",0,0,0,0,0,0,0,0,0,0,0,0, 0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, "error","DREG","VREG","CONST","UMINUS","$accept","lines","dexp","vexp","line", "illegal-symbol", }; static const char *const calc1_rule[] = { "$accept : lines", "lines :", "lines : lines line '\\n'", "lines : lines error '\\n'", "line : dexp", "line : vexp", "line : DREG '=' dexp", "line : VREG '=' vexp", "dexp : CONST", "dexp : DREG", "dexp : dexp '+' dexp", "dexp : dexp '-' dexp", "dexp : dexp '*' dexp", "dexp : dexp '/' dexp", "dexp : '-' dexp", "dexp : '(' dexp ')'", "vexp : dexp", "vexp : '(' dexp ',' dexp ')'", "vexp : VREG", "vexp : vexp '+' vexp", "vexp : dexp '+' vexp", "vexp : vexp '-' vexp", "vexp : dexp '-' vexp", "vexp : vexp '*' vexp", "vexp : dexp '*' vexp", "vexp : vexp '/' vexp", "vexp : dexp '/' vexp", "vexp : '-' vexp", "vexp : '(' vexp ')'", }; #endif #if YYDEBUG int yydebug; #endif #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) #ifndef YYLLOC_DEFAULT #define YYLLOC_DEFAULT(loc, rhs, n) \ do \ { \ if (n == 0) \ { \ (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ } \ else \ { \ (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ (loc).last_line = YYRHSLOC(rhs, n).last_line; \ (loc).last_column = YYRHSLOC(rhs, n).last_column; \ } \ } while (0) #endif /* YYLLOC_DEFAULT */ #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ #if YYBTYACC #ifndef YYLVQUEUEGROWTH #define YYLVQUEUEGROWTH 32 #endif #endif /* YYBTYACC */ /* define the initial stack-sizes */ #ifdef YYSTACKSIZE #undef YYMAXDEPTH #define YYMAXDEPTH YYSTACKSIZE #else #ifdef YYMAXDEPTH #define YYSTACKSIZE YYMAXDEPTH #else #define YYSTACKSIZE 10000 #define YYMAXDEPTH 10000 #endif #endif #ifndef YYINITSTACKSIZE #define YYINITSTACKSIZE 200 #endif typedef struct { unsigned stacksize; YYINT *s_base; YYINT *s_mark; YYINT *s_last; YYSTYPE *l_base; YYSTYPE *l_mark; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE *p_base; YYLTYPE *p_mark; #endif } YYSTACKDATA; #if YYBTYACC struct YYParseState_s { struct YYParseState_s *save; /* Previously saved parser state */ YYSTACKDATA yystack; /* saved parser stack */ int state; /* saved parser state */ int errflag; /* saved error recovery status */ int lexeme; /* saved index of the conflict lexeme in the lexical queue */ YYINT ctry; /* saved index in yyctable[] for this conflict */ }; typedef struct YYParseState_s YYParseState; #endif /* YYBTYACC */ #line 174 "btyacc_calc1.y" /* beginning of subroutines section */ int main (void) { while(!feof(stdin)) { yyparse(); } return 0; } #define BSZ 50 /* buffer size for floating point numbers */ static void YYERROR_DECL() { fprintf(stderr, "%s\n", s); } /* lexical analysis */ static int YYLEX_DECL() { int c; while ((c = getchar()) == ' ') { /* skip over blanks */ } if (isupper(c)) { #if YYPURE (*yylval).ival = c - 'A'; #else yylval.ival = c - 'A'; #endif return (VREG); } if (islower(c)) { #if YYPURE (*yylval).ival = c - 'a'; #else yylval.ival = c - 'a'; #endif return (DREG); } if (isdigit(c) || c == '.') { /* gobble up digits, points, exponents */ char buf[BSZ + 1], *cp = buf; int dot = 0, expr = 0; for (; (cp - buf) < BSZ; ++cp, c = getchar()) { *cp = (char) c; if (isdigit(c)) continue; if (c == '.') { if (dot++ || expr) return ('.'); /* will cause syntax error */ continue; } if (c == 'e') { if (expr++) return ('e'); /* will cause syntax error */ continue; } /* end of number */ break; } *cp = '\0'; if ((cp - buf) >= BSZ) printf("constant too long: truncated\n"); else ungetc(c, stdin); /* push back last char read */ #if YYPURE (*yylval).dval = atof(buf); #else yylval.dval = atof(buf); #endif return (CONST); } return (c); } static INTERVAL hilo(double a, double b, double c, double d) { /* returns the smallest interval containing a, b, c, and d */ /* used by *, / routines */ INTERVAL v; if (a > b) { v.hi = a; v.lo = b; } else { v.hi = b; v.lo = a; } if (c > d) { if (c > v.hi) v.hi = c; if (d < v.lo) v.lo = d; } else { if (d > v.hi) v.hi = d; if (c < v.lo) v.lo = c; } return (v); } INTERVAL vmul(double a, double b, INTERVAL v) { return (hilo(a * v.hi, a * v.lo, b * v.hi, b * v.lo)); } int dcheck(INTERVAL v) { if (v.hi >= 0. && v.lo <= 0.) { printf("divisor interval contains 0.\n"); return (1); } return (0); } INTERVAL vdiv(double a, double b, INTERVAL v) { return (hilo(a / v.hi, a / v.lo, b / v.hi, b / v.lo)); } #line 620 "btyacc_calc1.tab.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) #if YYBTYACC #define yytrial (yyps->save) #endif /* YYBTYACC */ #if YYDEBUG #include /* needed for printf */ #endif #include /* needed for malloc, etc */ #include /* needed for memset */ /* allocate initial stack or double stack size, up to YYMAXDEPTH */ static int yygrowstack(YYSTACKDATA *data) { int i; unsigned newsize; YYINT *newss; YYSTYPE *newvs; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE *newps; #endif if ((newsize = data->stacksize) == 0) newsize = YYINITSTACKSIZE; else if (newsize >= YYMAXDEPTH) return YYENOMEM; else if ((newsize *= 2) > YYMAXDEPTH) newsize = YYMAXDEPTH; i = (int) (data->s_mark - data->s_base); newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); if (newss == NULL) return YYENOMEM; data->s_base = newss; data->s_mark = newss + i; newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); if (newvs == NULL) return YYENOMEM; data->l_base = newvs; data->l_mark = newvs + i; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); if (newps == NULL) return YYENOMEM; data->p_base = newps; data->p_mark = newps + i; #endif data->stacksize = newsize; data->s_last = data->s_base + newsize - 1; #if YYDEBUG if (yydebug) fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); #endif return 0; } #if YYPURE || defined(YY_NO_LEAKS) static void yyfreestack(YYSTACKDATA *data) { free(data->s_base); free(data->l_base); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) free(data->p_base); #endif memset(data, 0, sizeof(*data)); } #else #define yyfreestack(data) /* nothing */ #endif /* YYPURE || defined(YY_NO_LEAKS) */ #if YYBTYACC static YYParseState * yyNewState(unsigned size) { YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); if (p == NULL) return NULL; p->yystack.stacksize = size; if (size == 0) { p->yystack.s_base = NULL; p->yystack.l_base = NULL; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) p->yystack.p_base = NULL; #endif return p; } p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); if (p->yystack.s_base == NULL) return NULL; p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); if (p->yystack.l_base == NULL) return NULL; memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); if (p->yystack.p_base == NULL) return NULL; memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); #endif return p; } static void yyFreeState(YYParseState *p) { yyfreestack(&p->yystack); free(p); } #endif /* YYBTYACC */ #define YYABORT goto yyabort #define YYREJECT goto yyabort #define YYACCEPT goto yyaccept #define YYERROR goto yyerrlab #if YYBTYACC #define YYVALID do { if (yyps->save) goto yyvalid; } while(0) #define YYVALID_NESTED do { if (yyps->save && \ yyps->save->save == 0) goto yyvalid; } while(0) #endif /* YYBTYACC */ int YYPARSE_DECL() { int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; int yynerrs; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyloc; /* position returned by actions */ YYLTYPE yylloc; /* position from the lexer */ #endif /* variables for the parser stack */ YYSTACKDATA yystack; #if YYBTYACC /* Current parser state */ static YYParseState *yyps = 0; /* yypath != NULL: do the full parse, starting at *yypath parser state. */ static YYParseState *yypath = 0; /* Base of the lexical value queue */ static YYSTYPE *yylvals = 0; /* Current position at lexical value queue */ static YYSTYPE *yylvp = 0; /* End position of lexical value queue */ static YYSTYPE *yylve = 0; /* The last allocated position at the lexical value queue */ static YYSTYPE *yylvlim = 0; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* Base of the lexical position queue */ static YYLTYPE *yylpsns = 0; /* Current position at lexical position queue */ static YYLTYPE *yylpp = 0; /* End position of lexical position queue */ static YYLTYPE *yylpe = 0; /* The last allocated position at the lexical position queue */ static YYLTYPE *yylplim = 0; #endif /* Current position at lexical token queue */ static YYINT *yylexp = 0; static YYINT *yylexemes = 0; #endif /* YYBTYACC */ int yym, yyn, yystate, yyresult; #if YYBTYACC int yynewerrflag; YYParseState *yyerrctx = NULL; #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ #endif #if YYDEBUG const char *yys; if ((yys = getenv("YYDEBUG")) != NULL) { yyn = *yys; if (yyn >= '0' && yyn <= '9') yydebug = yyn - '0'; } if (yydebug) fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); #endif #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); #endif yyerrflag = 0; yychar = 0; memset(&yyval, 0, sizeof(yyval)); memset(&yylval, 0, sizeof(yylval)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) memset(&yyloc, 0, sizeof(yyloc)); memset(&yylloc, 0, sizeof(yylloc)); #endif #if YYBTYACC yyps = yyNewState(0); if (yyps == 0) goto yyenomem; yyps->save = 0; #endif /* YYBTYACC */ yym = 0; /* yyn is set below */ yynerrs = 0; yyerrflag = 0; yychar = YYEMPTY; yystate = 0; #if YYPURE memset(&yystack, 0, sizeof(yystack)); #endif if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystack.s_mark = yystack.s_base; yystack.l_mark = yystack.l_base; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark = yystack.p_base; #endif yystate = 0; *yystack.s_mark = 0; yyloop: if ((yyn = yydefred[yystate]) != 0) goto yyreduce; if (yychar < 0) { #if YYBTYACC do { if (yylvp < yylve) { /* we're currently re-reading tokens */ yylval = *yylvp++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylloc = *yylpp++; #endif yychar = *yylexp++; break; } if (yyps->save) { /* in trial mode; save scanner results for future parse attempts */ if (yylvp == yylvlim) { /* Enlarge lexical value queue */ size_t p = (size_t) (yylvp - yylvals); size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpe = yylpsns + p; yylplim = yylpsns + s; #endif yylexp = yylexemes + p; } *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpp++ = yylloc; yylpe++; #endif yychar = *yylexp++; break; } /* normal operation, no conflict encountered */ #endif /* YYBTYACC */ yychar = YYLEX; #if YYBTYACC } while (0); #endif /* YYBTYACC */ if (yychar < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", YYDEBUGSTR, yydepth, yystate, yychar, yys); #ifdef YYSTYPE_TOSTRING #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); #endif fputc('\n', stderr); } #endif } #if YYBTYACC /* Do we have a conflict? */ if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) { YYINT ctry; if (yypath) { YYParseState *save; #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", YYDEBUGSTR, yydepth, yystate); #endif /* Switch to the next conflict context */ save = yypath; yypath = save->save; save->save = NULL; ctry = save->ctry; if (save->state != yystate) YYABORT; yyFreeState(save); } else { /* Unresolved conflict - start/continue trial parse */ YYParseState *save; #if YYDEBUG if (yydebug) { fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); if (yyps->save) fputs("ALREADY in conflict, continuing trial parse.\n", stderr); else fputs("Starting trial parse.\n", stderr); } #endif save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); if (save == NULL) goto yyenomem; save->save = yyps->save; save->state = yystate; save->errflag = yyerrflag; save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif ctry = yytable[yyn]; if (yyctable[ctry] == -1) { #if YYDEBUG if (yydebug && yychar >= YYEOF) fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); #endif ctry++; } save->ctry = ctry; if (yyps->save == NULL) { /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; yylvlim = yylvals + YYLVQUEUEGROWTH; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); if (yylpsns == NULL) goto yyenomem; yylplim = yylpsns + YYLVQUEUEGROWTH; #endif } if (yylvp == yylve) { yylvp = yylve = yylvals; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpe = yylpsns; #endif yylexp = yylexemes; if (yychar >= YYEOF) { *yylve++ = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpe++ = yylloc; #endif *yylexp = (YYINT) yychar; yychar = YYEMPTY; } } } if (yychar >= YYEOF) { yylvp--; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp--; #endif yylexp--; yychar = YYEMPTY; } save->lexeme = (int) (yylvp - yylvals); yyps->save = save; } if (yytable[yyn] == ctry) { #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); #endif if (yychar < 0) { yylvp++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp++; #endif yylexp++; } if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystate = yyctable[ctry]; *++yystack.s_mark = (YYINT) yystate; *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *++yystack.p_mark = yylloc; #endif yychar = YYEMPTY; if (yyerrflag > 0) --yyerrflag; goto yyloop; } else { yyn = yyctable[ctry]; goto yyreduce; } } /* End of code dealing with conflicts */ #endif /* YYBTYACC */ if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) { #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", YYDEBUGSTR, yydepth, yystate, yytable[yyn]); #endif if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystate = yytable[yyn]; *++yystack.s_mark = yytable[yyn]; *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *++yystack.p_mark = yylloc; #endif yychar = YYEMPTY; if (yyerrflag > 0) --yyerrflag; goto yyloop; } if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) { yyn = yytable[yyn]; goto yyreduce; } if (yyerrflag != 0) goto yyinrecovery; #if YYBTYACC yynewerrflag = 1; goto yyerrhandler; goto yyerrlab; /* redundant goto avoids 'unused label' warning */ yyerrlab: /* explicit YYERROR from an action -- pop the rhs of the rule reduced * before looking for error recovery */ yystack.s_mark -= yym; yystate = *yystack.s_mark; yystack.l_mark -= yym; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark -= yym; #endif yynewerrflag = 0; yyerrhandler: while (yyps->save) { int ctry; YYParseState *save = yyps->save; #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", YYDEBUGSTR, yydepth, yystate, yyps->save->state, (int)(yylvp - yylvals - yyps->save->lexeme)); #endif /* Memorize most forward-looking error state in case it's really an error. */ if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) { /* Free old saved error context state */ if (yyerrctx) yyFreeState(yyerrctx); /* Create and fill out new saved error context state */ yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); if (yyerrctx == NULL) goto yyenomem; yyerrctx->save = yyps->save; yyerrctx->state = yystate; yyerrctx->errflag = yyerrflag; yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif yyerrctx->lexeme = (int) (yylvp - yylvals); } yylvp = yylvals + save->lexeme; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpsns + save->lexeme; #endif yylexp = yylexemes + save->lexeme; yychar = YYEMPTY; yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif ctry = ++save->ctry; yystate = save->state; /* We tried shift, try reduce now */ if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; yyps->save = save->save; save->save = NULL; yyFreeState(save); /* Nothing left on the stack -- error */ if (!yyps->save) { #if YYDEBUG if (yydebug) fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", YYPREFIX, yydepth); #endif /* Restore state as it was in the most forward-advanced error */ yylvp = yylvals + yyerrctx->lexeme; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpsns + yyerrctx->lexeme; #endif yylexp = yylexemes + yyerrctx->lexeme; yychar = yylexp[-1]; yylval = yylvp[-1]; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylloc = yylpp[-1]; #endif yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif yystate = yyerrctx->state; yyFreeState(yyerrctx); yyerrctx = NULL; } yynewerrflag = 1; } if (yynewerrflag == 0) goto yyinrecovery; #endif /* YYBTYACC */ YYERROR_CALL("syntax error"); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ #endif #if !YYBTYACC goto yyerrlab; /* redundant goto avoids 'unused label' warning */ yyerrlab: #endif ++yynerrs; yyinrecovery: if (yyerrflag < 3) { yyerrflag = 3; for (;;) { if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) { #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); #endif if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystate = yytable[yyn]; *++yystack.s_mark = yytable[yyn]; *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* lookahead position is error end position */ yyerror_loc_range[2] = yylloc; YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ *++yystack.p_mark = yyloc; #endif goto yyloop; } else { #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", YYDEBUGSTR, yydepth, *yystack.s_mark); #endif if (yystack.s_mark <= yystack.s_base) goto yyabort; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* the current TOS position is the error start position */ yyerror_loc_range[1] = *yystack.p_mark; #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYDESTRUCT_CALL("error: discarding state", yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); #else YYDESTRUCT_CALL("error: discarding state", yystos[*yystack.s_mark], yystack.l_mark); #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ #endif /* defined(YYDESTRUCT_CALL) */ --yystack.s_mark; --yystack.l_mark; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) --yystack.p_mark; #endif } } } else { if (yychar == YYEOF) goto yyabort; #if YYDEBUG if (yydebug) { if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", YYDEBUGSTR, yydepth, yystate, yychar, yys); } #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); #else YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ #endif /* defined(YYDESTRUCT_CALL) */ yychar = YYEMPTY; goto yyloop; } yyreduce: yym = yylen[yyn]; #if YYDEBUG if (yydebug) { fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); #ifdef YYSTYPE_TOSTRING #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ if (yym > 0) { int i; fputc('<', stderr); for (i = yym; i > 0; i--) { if (i != yym) fputs(", ", stderr); fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], yystack.l_mark[1-i]), stderr); } fputc('>', stderr); } #endif fputc('\n', stderr); } #endif if (yym > 0) yyval = yystack.l_mark[1-yym]; else memset(&yyval, 0, sizeof yyval); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* Perform position reduction */ memset(&yyloc, 0, sizeof(yyloc)); #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ { YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); /* just in case YYERROR is invoked within the action, save the start of the rhs as the error start position */ yyerror_loc_range[1] = yystack.p_mark[1-yym]; } #endif switch (yyn) { case 2: #line 51 "btyacc_calc1.y" {YYVALID;} #line 1354 "btyacc_calc1.tab.c" break; case 3: #line 52 "btyacc_calc1.y" {YYVALID;} if (!yytrial) #line 53 "btyacc_calc1.y" { yyerrok; } #line 1363 "btyacc_calc1.tab.c" break; case 4: if (!yytrial) #line 59 "btyacc_calc1.y" { (void) printf("%15.8f\n", yystack.l_mark[0].dval); } #line 1371 "btyacc_calc1.tab.c" break; case 5: if (!yytrial) #line 63 "btyacc_calc1.y" { (void) printf("(%15.8f, %15.8f)\n", yystack.l_mark[0].vval.lo, yystack.l_mark[0].vval.hi); } #line 1379 "btyacc_calc1.tab.c" break; case 6: if (!yytrial) #line 67 "btyacc_calc1.y" { dreg[yystack.l_mark[-2].ival] = yystack.l_mark[0].dval; } #line 1387 "btyacc_calc1.tab.c" break; case 7: if (!yytrial) #line 71 "btyacc_calc1.y" { vreg[yystack.l_mark[-2].ival] = yystack.l_mark[0].vval; } #line 1395 "btyacc_calc1.tab.c" break; case 9: if (!yytrial) #line 78 "btyacc_calc1.y" { yyval.dval = dreg[yystack.l_mark[0].ival]; } #line 1403 "btyacc_calc1.tab.c" break; case 10: if (!yytrial) #line 82 "btyacc_calc1.y" { yyval.dval = yystack.l_mark[-2].dval + yystack.l_mark[0].dval; } #line 1411 "btyacc_calc1.tab.c" break; case 11: if (!yytrial) #line 86 "btyacc_calc1.y" { yyval.dval = yystack.l_mark[-2].dval - yystack.l_mark[0].dval; } #line 1419 "btyacc_calc1.tab.c" break; case 12: if (!yytrial) #line 90 "btyacc_calc1.y" { yyval.dval = yystack.l_mark[-2].dval * yystack.l_mark[0].dval; } #line 1427 "btyacc_calc1.tab.c" break; case 13: if (!yytrial) #line 94 "btyacc_calc1.y" { yyval.dval = yystack.l_mark[-2].dval / yystack.l_mark[0].dval; } #line 1435 "btyacc_calc1.tab.c" break; case 14: if (!yytrial) #line 98 "btyacc_calc1.y" { yyval.dval = -yystack.l_mark[0].dval; } #line 1443 "btyacc_calc1.tab.c" break; case 15: if (!yytrial) #line 102 "btyacc_calc1.y" { yyval.dval = yystack.l_mark[-1].dval; } #line 1451 "btyacc_calc1.tab.c" break; case 16: if (!yytrial) #line 108 "btyacc_calc1.y" { yyval.vval.hi = yyval.vval.lo = yystack.l_mark[0].dval; } #line 1459 "btyacc_calc1.tab.c" break; case 17: if (!yytrial) #line 112 "btyacc_calc1.y" { yyval.vval.lo = yystack.l_mark[-3].dval; yyval.vval.hi = yystack.l_mark[-1].dval; if ( yyval.vval.lo > yyval.vval.hi ) { (void) printf("interval out of order\n"); YYERROR; } } #line 1473 "btyacc_calc1.tab.c" break; case 18: if (!yytrial) #line 122 "btyacc_calc1.y" { yyval.vval = vreg[yystack.l_mark[0].ival]; } #line 1481 "btyacc_calc1.tab.c" break; case 19: if (!yytrial) #line 126 "btyacc_calc1.y" { yyval.vval.hi = yystack.l_mark[-2].vval.hi + yystack.l_mark[0].vval.hi; yyval.vval.lo = yystack.l_mark[-2].vval.lo + yystack.l_mark[0].vval.lo; } #line 1490 "btyacc_calc1.tab.c" break; case 20: if (!yytrial) #line 131 "btyacc_calc1.y" { yyval.vval.hi = yystack.l_mark[-2].dval + yystack.l_mark[0].vval.hi; yyval.vval.lo = yystack.l_mark[-2].dval + yystack.l_mark[0].vval.lo; } #line 1499 "btyacc_calc1.tab.c" break; case 21: if (!yytrial) #line 136 "btyacc_calc1.y" { yyval.vval.hi = yystack.l_mark[-2].vval.hi - yystack.l_mark[0].vval.lo; yyval.vval.lo = yystack.l_mark[-2].vval.lo - yystack.l_mark[0].vval.hi; } #line 1508 "btyacc_calc1.tab.c" break; case 22: if (!yytrial) #line 141 "btyacc_calc1.y" { yyval.vval.hi = yystack.l_mark[-2].dval - yystack.l_mark[0].vval.lo; yyval.vval.lo = yystack.l_mark[-2].dval - yystack.l_mark[0].vval.hi; } #line 1517 "btyacc_calc1.tab.c" break; case 23: if (!yytrial) #line 146 "btyacc_calc1.y" { yyval.vval = vmul( yystack.l_mark[-2].vval.lo, yystack.l_mark[-2].vval.hi, yystack.l_mark[0].vval ); } #line 1525 "btyacc_calc1.tab.c" break; case 24: if (!yytrial) #line 150 "btyacc_calc1.y" { yyval.vval = vmul (yystack.l_mark[-2].dval, yystack.l_mark[-2].dval, yystack.l_mark[0].vval ); } #line 1533 "btyacc_calc1.tab.c" break; case 25: if (!yytrial) #line 154 "btyacc_calc1.y" { if (dcheck(yystack.l_mark[0].vval)) YYERROR; yyval.vval = vdiv ( yystack.l_mark[-2].vval.lo, yystack.l_mark[-2].vval.hi, yystack.l_mark[0].vval ); } #line 1542 "btyacc_calc1.tab.c" break; case 26: if (!yytrial) #line 159 "btyacc_calc1.y" { if (dcheck ( yystack.l_mark[0].vval )) YYERROR; yyval.vval = vdiv (yystack.l_mark[-2].dval, yystack.l_mark[-2].dval, yystack.l_mark[0].vval ); } #line 1551 "btyacc_calc1.tab.c" break; case 27: if (!yytrial) #line 164 "btyacc_calc1.y" { yyval.vval.hi = -yystack.l_mark[0].vval.lo; yyval.vval.lo = -yystack.l_mark[0].vval.hi; } #line 1560 "btyacc_calc1.tab.c" break; case 28: if (!yytrial) #line 169 "btyacc_calc1.y" { yyval.vval = yystack.l_mark[-1].vval; } #line 1568 "btyacc_calc1.tab.c" break; #line 1570 "btyacc_calc1.tab.c" default: break; } yystack.s_mark -= yym; yystate = *yystack.s_mark; yystack.l_mark -= yym; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark -= yym; #endif yym = yylhs[yyn]; if (yystate == 0 && yym == 0) { #if YYDEBUG if (yydebug) { fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); #ifdef YYSTYPE_TOSTRING #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); #endif fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); } #endif yystate = YYFINAL; *++yystack.s_mark = YYFINAL; *++yystack.l_mark = yyval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *++yystack.p_mark = yyloc; #endif if (yychar < 0) { #if YYBTYACC do { if (yylvp < yylve) { /* we're currently re-reading tokens */ yylval = *yylvp++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylloc = *yylpp++; #endif yychar = *yylexp++; break; } if (yyps->save) { /* in trial mode; save scanner results for future parse attempts */ if (yylvp == yylvlim) { /* Enlarge lexical value queue */ size_t p = (size_t) (yylvp - yylvals); size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpe = yylpsns + p; yylplim = yylpsns + s; #endif yylexp = yylexemes + p; } *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpp++ = yylloc; yylpe++; #endif yychar = *yylexp++; break; } /* normal operation, no conflict encountered */ #endif /* YYBTYACC */ yychar = YYLEX; #if YYBTYACC } while (0); #endif /* YYBTYACC */ if (yychar < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); } #endif } if (yychar == YYEOF) goto yyaccept; goto yyloop; } if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) yystate = yytable[yyn]; else yystate = yydgoto[yym]; #if YYDEBUG if (yydebug) { fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); #ifdef YYSTYPE_TOSTRING #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); #endif fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); } #endif if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; *++yystack.s_mark = (YYINT) yystate; *++yystack.l_mark = yyval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *++yystack.p_mark = yyloc; #endif goto yyloop; #if YYBTYACC /* Reduction declares that this path is valid. Set yypath and do a full parse */ yyvalid: if (yypath) YYABORT; while (yyps->save) { YYParseState *save = yyps->save; yyps->save = save->save; save->save = yypath; yypath = save; } #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); #endif if (yyerrctx) { yyFreeState(yyerrctx); yyerrctx = NULL; } yylvp = yylvals + yypath->lexeme; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpsns + yypath->lexeme; #endif yylexp = yylexemes + yypath->lexeme; yychar = YYEMPTY; yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif yystate = yypath->state; goto yyloop; #endif /* YYBTYACC */ yyoverflow: YYERROR_CALL("yacc stack overflow"); #if YYBTYACC goto yyabort_nomem; yyenomem: YYERROR_CALL("memory exhausted"); yyabort_nomem: #endif /* YYBTYACC */ yyresult = 2; goto yyreturn; yyabort: yyresult = 1; goto yyreturn; yyaccept: #if YYBTYACC if (yyps->save) goto yyvalid; #endif /* YYBTYACC */ yyresult = 0; yyreturn: #if defined(YYDESTRUCT_CALL) if (yychar != YYEOF && yychar != YYEMPTY) #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); #else YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ { YYSTYPE *pv; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE *pp; for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) YYDESTRUCT_CALL("cleanup: discarding state", yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); #else for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) YYDESTRUCT_CALL("cleanup: discarding state", yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ } #endif /* defined(YYDESTRUCT_CALL) */ #if YYBTYACC if (yyerrctx) { yyFreeState(yyerrctx); yyerrctx = NULL; } while (yyps) { YYParseState *save = yyps; yyps = save->save; save->save = NULL; yyFreeState(save); } while (yypath) { YYParseState *save = yypath; yypath = save->save; save->save = NULL; yyFreeState(save); } #endif /* YYBTYACC */ yyfreestack(&yystack); return (yyresult); } diff --git a/contrib/byacc/test/btyacc/btyacc_calc1.tab.h b/contrib/byacc/test/btyacc/btyacc_calc1.tab.h index 114d213cd962..9cf4e75ba38a 100644 --- a/contrib/byacc/test/btyacc/btyacc_calc1.tab.h +++ b/contrib/byacc/test/btyacc/btyacc_calc1.tab.h @@ -1,22 +1,22 @@ #ifndef _calc1__defines_h_ #define _calc1__defines_h_ #define DREG 257 #define VREG 258 #define CONST 259 #define UMINUS 260 #ifdef YYSTYPE #undef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 #endif #ifndef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 -typedef union YYSTYPE +typedef union { int ival; double dval; INTERVAL vval; } YYSTYPE; #endif /* !YYSTYPE_IS_DECLARED */ #endif /* _calc1__defines_h_ */ diff --git a/contrib/byacc/test/btyacc/btyacc_demo.tab.c b/contrib/byacc/test/btyacc/btyacc_demo.tab.c index 04557cd2d356..73b7a1073127 100644 --- a/contrib/byacc/test/btyacc/btyacc_demo.tab.c +++ b/contrib/byacc/test/btyacc/btyacc_demo.tab.c @@ -1,2400 +1,2400 @@ /* original parser id follows */ /* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ /* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ #define YYBYACC 1 #define YYMAJOR 2 #define YYMINOR 0 #define YYCHECK "yyyymmdd" #define YYEMPTY (-1) #define yyclearin (yychar = YYEMPTY) #define yyerrok (yyerrflag = 0) #define YYRECOVERING() (yyerrflag != 0) #define YYENOMEM (-2) #define YYEOF 0 #undef YYBTYACC #define YYBTYACC 1 #define YYDEBUGSTR (yytrial ? YYPREFIX "debug(trial)" : YYPREFIX "debug") #ifndef yyparse #define yyparse demo_parse #endif /* yyparse */ #ifndef yylex #define yylex demo_lex #endif /* yylex */ #ifndef yyerror #define yyerror demo_error #endif /* yyerror */ #ifndef yychar #define yychar demo_char #endif /* yychar */ #ifndef yyval #define yyval demo_val #endif /* yyval */ #ifndef yylval #define yylval demo_lval #endif /* yylval */ #ifndef yydebug #define yydebug demo_debug #endif /* yydebug */ #ifndef yynerrs #define yynerrs demo_nerrs #endif /* yynerrs */ #ifndef yyerrflag #define yyerrflag demo_errflag #endif /* yyerrflag */ #ifndef yylhs #define yylhs demo_lhs #endif /* yylhs */ #ifndef yylen #define yylen demo_len #endif /* yylen */ #ifndef yydefred #define yydefred demo_defred #endif /* yydefred */ #ifndef yystos #define yystos demo_stos #endif /* yystos */ #ifndef yydgoto #define yydgoto demo_dgoto #endif /* yydgoto */ #ifndef yysindex #define yysindex demo_sindex #endif /* yysindex */ #ifndef yyrindex #define yyrindex demo_rindex #endif /* yyrindex */ #ifndef yygindex #define yygindex demo_gindex #endif /* yygindex */ #ifndef yytable #define yytable demo_table #endif /* yytable */ #ifndef yycheck #define yycheck demo_check #endif /* yycheck */ #ifndef yyname #define yyname demo_name #endif /* yyname */ #ifndef yyrule #define yyrule demo_rule #endif /* yyrule */ #ifndef yyloc #define yyloc demo_loc #endif /* yyloc */ #ifndef yylloc #define yylloc demo_lloc #endif /* yylloc */ #if YYBTYACC #ifndef yycindex #define yycindex demo_cindex #endif /* yycindex */ #ifndef yyctable #define yyctable demo_ctable #endif /* yyctable */ #endif /* YYBTYACC */ #define YYPREFIX "demo_" #define YYPURE 0 #line 15 "btyacc_demo.y" /* dummy types just for compile check */ typedef int Code; typedef int Decl_List; typedef int Expr; typedef int Expr_List; typedef int Scope; typedef int Type; enum Operator { ADD, SUB, MUL, MOD, DIV, DEREF }; typedef unsigned char bool; typedef struct Decl { Scope *scope; Type *type; bool (*istype)(void); } Decl; #include "btyacc_demo.tab.h" #include #include #ifdef YYSTYPE #undef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 #endif #ifndef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 #line 36 "btyacc_demo.y" -typedef union YYSTYPE { +typedef union { Scope *scope; Expr *expr; Expr_List *elist; Type *type; Decl *decl; Decl_List *dlist; Code *code; char *id; } YYSTYPE; #endif /* !YYSTYPE_IS_DECLARED */ #line 167 "btyacc_demo.tab.c" #if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED /* Default: YYLTYPE is the text position type. */ typedef struct YYLTYPE { int first_line; int first_column; int last_line; int last_column; unsigned source; } YYLTYPE; #define YYLTYPE_IS_DECLARED 1 #endif #define YYRHSLOC(rhs, k) ((rhs)[k]) /* compatibility with bison */ #ifdef YYPARSE_PARAM /* compatibility with FreeBSD */ # ifdef YYPARSE_PARAM_TYPE # define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) # else # define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) # endif #else # define YYPARSE_DECL() yyparse(void) #endif /* Parameters sent to lex. */ #ifdef YYLEX_PARAM # define YYLEX_DECL() yylex(void *YYLEX_PARAM) # define YYLEX yylex(YYLEX_PARAM) #else # define YYLEX_DECL() yylex(void) # define YYLEX yylex() #endif /* Parameters sent to yyerror. */ #ifndef YYERROR_DECL #define YYERROR_DECL() yyerror(YYLTYPE *loc, const char *s) #endif #ifndef YYERROR_CALL #define YYERROR_CALL(msg) yyerror(&yylloc, msg) #endif #ifndef YYDESTRUCT_DECL #define YYDESTRUCT_DECL() yydestruct(const char *msg, int psymb, YYSTYPE *val, YYLTYPE *loc) #endif #ifndef YYDESTRUCT_CALL #define YYDESTRUCT_CALL(msg, psymb, val, loc) yydestruct(msg, psymb, val, loc) #endif extern int YYPARSE_DECL(); #define PREFIX 257 #define POSTFIX 258 #define ID 259 #define CONSTANT 260 #define EXTERN 261 #define REGISTER 262 #define STATIC 263 #define CONST 264 #define VOLATILE 265 #define IF 266 #define THEN 267 #define ELSE 268 #define CLCL 269 #define YYERRCODE 256 typedef int YYINT; static const YYINT demo_lhs[] = { -1, 15, 15, 15, 12, 18, 0, 4, 19, 4, 2, 20, 2, 10, 10, 13, 13, 11, 11, 11, 11, 11, 14, 14, 21, 22, 3, 3, 8, 8, 23, 24, 8, 8, 8, 8, 16, 16, 17, 17, 9, 1, 1, 1, 1, 1, 1, 1, 1, 5, 5, 25, 26, 5, 5, 27, 5, 6, 6, 7, }; static const YYINT demo_len[] = { 2, 0, 1, 3, 2, 0, 2, 0, 0, 3, 3, 0, 4, 1, 3, 0, 2, 1, 1, 1, 1, 1, 1, 1, 0, 0, 5, 1, 0, 1, 0, 0, 5, 5, 5, 6, 0, 1, 4, 1, 2, 4, 4, 4, 4, 4, 3, 1, 1, 1, 2, 0, 0, 11, 8, 0, 2, 0, 3, 4, }; static const YYINT demo_defred[] = { 5, 0, 7, 0, 0, 19, 20, 21, 22, 23, 2, 9, 0, 13, 18, 17, 0, 15, 30, 29, 0, 0, 0, 0, 0, 31, 10, 24, 24, 24, 0, 14, 3, 16, 25, 0, 25, 0, 0, 8, 12, 0, 0, 0, 39, 0, 0, 0, 8, 47, 48, 0, 57, 0, 32, 0, 0, 15, 30, 0, 30, 30, 30, 30, 30, 34, 0, 0, 0, 46, 0, 0, 0, 0, 0, 59, 0, 38, 0, 0, 43, 45, 44, 0, 0, 49, 58, 0, 30, 50, 56, 0, 0, 0, 51, 0, 0, 52, 0, 53, }; #if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) static const YYINT demo_stos[] = { 0, 271, 289, 275, 290, 261, 262, 263, 264, 265, 269, 273, 281, 282, 283, 285, 286, 42, 40, 259, 274, 279, 290, 259, 284, 294, 59, 44, 40, 91, 291, 282, 269, 285, 292, 295, 292, 292, 292, 123, 278, 293, 279, 293, 280, 281, 287, 288, 42, 259, 260, 272, 290, 279, 41, 279, 279, 41, 44, 290, 43, 45, 42, 47, 37, 93, 277, 284, 294, 272, 294, 294, 294, 294, 294, 125, 290, 280, 272, 272, 272, 272, 272, 266, 272, 273, 276, 298, 40, 59, 278, 294, 272, 41, 267, 296, 276, 268, 297, 276, }; #endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ static const YYINT demo_dgoto[] = { 1, 84, 85, 20, 3, 86, 66, 40, 21, 44, 12, 13, 14, 24, 15, 16, 46, 47, 2, 22, 30, 34, 41, 25, 35, 95, 98, 87, }; static const YYINT demo_sindex[] = { 0, 0, 0, 0, -103, 0, 0, 0, 0, 0, 0, 0, -31, 0, 0, 0, -238, 0, 0, 0, 4, -36, -103, 0, -133, 0, 0, 0, 0, 0, -94, 0, 0, 0, 0, -40, 0, -103, -33, 0, 0, -40, -25, -40, 0, -31, 8, 15, 0, 0, 0, -2, 0, -36, 0, -36, -36, 0, 0, -33, 0, 0, 0, 0, 0, 0, -92, -133, -103, 0, -33, -33, -33, -33, -33, 0, -8, 0, 23, 23, 0, 0, 0, 11, 75, 0, 0, -94, 0, 0, 0, -33, 96, -194, 0, -8, 0, 0, -8, 0, }; static const YYINT demo_rindex[] = { 0, 0, 0, 1, -181, 0, 0, 0, 0, 0, 0, 0, 17, 0, 0, 0, 0, 0, 0, 0, 0, -39, -181, 12, -34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -5, 0, -11, 0, 0, 0, -17, 0, 28, 0, -41, 0, 47, 0, 0, 0, 0, 0, -13, 0, 18, 70, 0, 0, 0, 0, 0, 0, 0, 0, 0, -19, -27, -181, 0, 0, 0, 0, 0, 0, 0, -29, 0, 56, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -29, -30, 0, -29, 0, }; #if YYBTYACC static const YYINT demo_cindex[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -22, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -179, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 52, 0, 0, 0, 0, 0, 58, 0, 62, 0, -21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -146, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -143, -147, 0, -134, 0, }; #endif static const YYINT demo_gindex[] = { 0, 9, 143, 0, 0, 50, 0, 63, 101, 83, 7, 130, 0, 98, 2, 0, 0, 0, 0, 19, 0, 10, 117, 66, 0, 0, 0, 0, }; #define YYTABLESIZE 286 static const YYINT demo_table[] = { 28, 6, 17, 28, 28, 27, 24, 24, 24, 48, 24, 17, 54, 35, 35, 28, 54, 35, 0, 0, 27, 23, 4, 8, 28, 24, 33, 28, 33, 39, 36, 33, 35, 75, 48, 64, 28, 36, 37, 38, 62, 60, 28, 61, 45, 63, 33, 51, 27, 57, 28, 88, 4, 4, 4, 29, 4, 24, 52, 58, 64, 28, 26, 26, 35, 62, 29, 59, 69, 33, 63, 4, 28, 94, 28, 45, 28, 26, 1, 78, 79, 80, 81, 82, 11, 76, 28, 28, 37, 24, 6, 65, 0, 54, 55, 54, 35, 41, 0, 41, 92, 41, 0, 4, 8, 42, 28, 42, 28, 42, 33, 40, 64, 9, 40, 41, 9, 62, 60, 28, 61, 12, 63, 42, 68, 9, 70, 71, 72, 73, 74, 8, 9, 64, 89, 4, 42, 93, 62, 60, 28, 61, 53, 63, 55, 96, 56, 11, 99, 41, 90, 77, 31, 43, 91, 67, 0, 42, 5, 6, 7, 8, 9, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 8, 8, 8, 8, 8, 24, 49, 50, 8, 54, 54, 54, 54, 54, 54, 54, 54, 3, 3, 54, 8, 8, 8, 8, 8, 8, 8, 8, 1, 0, 8, 0, 50, 5, 6, 7, 8, 9, 83, 0, 8, 10, 8, 8, 8, 8, 8, 0, 0, 0, 8, 4, 0, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 0, 0, 0, 8, }; static const YYINT demo_check[] = { 41, 0, 42, 44, 40, 44, 40, 41, 42, 42, 44, 42, 42, 40, 41, 40, 41, 44, 40, 40, 59, 259, 3, 42, 41, 59, 24, 44, 41, 123, 41, 44, 59, 125, 42, 37, 41, 27, 28, 29, 42, 43, 59, 45, 37, 47, 59, 38, 44, 41, 91, 40, 40, 41, 42, 91, 44, 91, 39, 44, 37, 44, 44, 59, 91, 42, 91, 48, 59, 67, 47, 59, 44, 267, 91, 68, 59, 59, 259, 70, 71, 72, 73, 74, 123, 66, 91, 59, 41, 123, 269, 93, 40, 123, 123, 125, 123, 41, 40, 43, 91, 45, 40, 91, 123, 41, 123, 43, 91, 45, 123, 41, 37, 259, 44, 59, 259, 42, 43, 91, 45, 268, 47, 59, 58, 259, 60, 61, 62, 63, 64, 264, 265, 37, 59, 123, 35, 41, 42, 43, 123, 45, 41, 47, 43, 95, 45, 4, 98, 93, 87, 68, 22, 36, 88, 57, -1, 93, 261, 262, 263, 264, 265, -1, -1, -1, 269, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 259, 261, 262, 263, 264, 265, 259, 259, 260, 269, 259, 260, 261, 262, 263, 264, 265, 266, 259, 259, 269, 259, 260, 261, 262, 263, 264, 265, 266, 259, -1, 269, -1, 260, 261, 262, 263, 264, 265, 266, -1, 259, 269, 261, 262, 263, 264, 265, -1, -1, -1, 269, 259, -1, 261, 262, 263, 264, 265, 261, 262, 263, 264, 265, -1, -1, -1, 269, }; #if YYBTYACC static const YYINT demo_ctable[] = { 18, 28, -1, 19, 8, -1, 32, 4, -1, 49, 1, -1, 97, 54, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, }; #endif #define YYFINAL 1 #ifndef YYDEBUG #define YYDEBUG 0 #endif #define YYMAXTOKEN 269 #define YYUNDFTOKEN 299 #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) #if YYDEBUG static const char *const demo_name[] = { "$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, "'%'",0,0,"'('","')'","'*'","'+'","','","'-'","'.'","'/'",0,0,0,0,0,0,0,0,0,0,0, "';'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'['",0, "']'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'{'",0,"'}'",0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,"error","PREFIX","POSTFIX","ID","CONSTANT","EXTERN", "REGISTER","STATIC","CONST","VOLATILE","IF","THEN","ELSE","CLCL","$accept", "input","expr","decl","declarator_list","decl_list","statement", "statement_list","block_statement","declarator","formal_arg","decl_specs", "decl_spec","typename","cv_quals","cv_qual","opt_scope","formal_arg_list", "nonempty_formal_arg_list","$$1","$$2","$$3","$$4","$$5","$$6","$$7","$$8", "$$9","$$10","illegal-symbol", }; static const char *const demo_rule[] = { "$accept : input", "opt_scope :", "opt_scope : CLCL", "opt_scope : opt_scope ID CLCL", "typename : opt_scope ID", "$$1 :", "input : $$1 decl_list", "decl_list :", "$$2 :", "decl_list : decl_list $$2 decl", "decl : decl_specs declarator_list ';'", "$$3 :", "decl : decl_specs declarator $$3 block_statement", "decl_specs : decl_spec", "decl_specs : decl_specs $$2 decl_spec", "cv_quals :", "cv_quals : cv_quals cv_qual", "decl_spec : cv_qual", "decl_spec : typename", "decl_spec : EXTERN", "decl_spec : REGISTER", "decl_spec : STATIC", "cv_qual : CONST", "cv_qual : VOLATILE", "$$4 :", "$$5 :", "declarator_list : declarator_list ',' $$4 $$5 declarator", "declarator_list : declarator", "declarator :", "declarator : ID", "$$6 :", "$$7 :", "declarator : '(' $$6 $$7 declarator ')'", "declarator : '*' cv_quals $$4 $$5 declarator", "declarator : declarator '[' $$4 expr ']'", "declarator : declarator '(' $$4 formal_arg_list ')' cv_quals", "formal_arg_list :", "formal_arg_list : nonempty_formal_arg_list", "nonempty_formal_arg_list : nonempty_formal_arg_list ',' $$6 formal_arg", "nonempty_formal_arg_list : formal_arg", "formal_arg : decl_specs declarator", "expr : expr '+' $$6 expr", "expr : expr '-' $$6 expr", "expr : expr '*' $$6 expr", "expr : expr '%' $$6 expr", "expr : expr '/' $$6 expr", "expr : '*' $$2 expr", "expr : ID", "expr : CONSTANT", "statement : decl", "statement : expr ';'", "$$8 :", "$$9 :", "statement : IF '(' $$6 expr ')' THEN $$8 statement ELSE $$9 statement", "statement : IF '(' $$6 expr ')' THEN $$8 statement", "$$10 :", "statement : $$10 block_statement", "statement_list :", "statement_list : statement_list $$2 statement", "block_statement : '{' $$2 statement_list '}'", }; #endif #if YYDEBUG int yydebug; #endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; int yynerrs; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyloc; /* position returned by actions */ YYLTYPE yylloc; /* position from the lexer */ #endif #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) #ifndef YYLLOC_DEFAULT #define YYLLOC_DEFAULT(loc, rhs, n) \ do \ { \ if (n == 0) \ { \ (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ } \ else \ { \ (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ (loc).last_line = YYRHSLOC(rhs, n).last_line; \ (loc).last_column = YYRHSLOC(rhs, n).last_column; \ } \ } while (0) #endif /* YYLLOC_DEFAULT */ #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ #if YYBTYACC #ifndef YYLVQUEUEGROWTH #define YYLVQUEUEGROWTH 32 #endif #endif /* YYBTYACC */ /* define the initial stack-sizes */ #ifdef YYSTACKSIZE #undef YYMAXDEPTH #define YYMAXDEPTH YYSTACKSIZE #else #ifdef YYMAXDEPTH #define YYSTACKSIZE YYMAXDEPTH #else #define YYSTACKSIZE 10000 #define YYMAXDEPTH 10000 #endif #endif #ifndef YYINITSTACKSIZE #define YYINITSTACKSIZE 200 #endif typedef struct { unsigned stacksize; YYINT *s_base; YYINT *s_mark; YYINT *s_last; YYSTYPE *l_base; YYSTYPE *l_mark; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE *p_base; YYLTYPE *p_mark; #endif } YYSTACKDATA; #if YYBTYACC struct YYParseState_s { struct YYParseState_s *save; /* Previously saved parser state */ YYSTACKDATA yystack; /* saved parser stack */ int state; /* saved parser state */ int errflag; /* saved error recovery status */ int lexeme; /* saved index of the conflict lexeme in the lexical queue */ YYINT ctry; /* saved index in yyctable[] for this conflict */ }; typedef struct YYParseState_s YYParseState; #endif /* YYBTYACC */ /* variables for the parser stack */ static YYSTACKDATA yystack; #if YYBTYACC /* Current parser state */ static YYParseState *yyps = 0; /* yypath != NULL: do the full parse, starting at *yypath parser state. */ static YYParseState *yypath = 0; /* Base of the lexical value queue */ static YYSTYPE *yylvals = 0; /* Current position at lexical value queue */ static YYSTYPE *yylvp = 0; /* End position of lexical value queue */ static YYSTYPE *yylve = 0; /* The last allocated position at the lexical value queue */ static YYSTYPE *yylvlim = 0; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* Base of the lexical position queue */ static YYLTYPE *yylpsns = 0; /* Current position at lexical position queue */ static YYLTYPE *yylpp = 0; /* End position of lexical position queue */ static YYLTYPE *yylpe = 0; /* The last allocated position at the lexical position queue */ static YYLTYPE *yylplim = 0; #endif /* Current position at lexical token queue */ static YYINT *yylexp = 0; static YYINT *yylexemes = 0; #endif /* YYBTYACC */ #line 200 "btyacc_demo.y" extern int YYLEX_DECL(); extern void YYERROR_DECL(); extern Scope *global_scope; extern Decl * lookup(Scope *scope, char *id); extern Scope * new_scope(Scope *outer_scope); extern Scope * start_fn_def(Scope *scope, Decl *fn_decl); extern void finish_fn_def(Decl *fn_decl, Code *block); extern Type * type_combine(Type *specs, Type *spec); extern Type * bare_extern(void); extern Type * bare_register(void); extern Type * bare_static(void); extern Type * bare_const(void); extern Type * bare_volatile(void); extern Decl * declare(Scope *scope, char *id, Type *type); extern Decl * make_pointer(Decl *decl, Type *type); extern Decl * make_array(Type *type, Expr *expr); extern Decl * build_function(Decl *decl, Decl_List *dlist, Type *type); extern Decl_List * append_dlist(Decl_List *dlist, Decl *decl); extern Decl_List * build_dlist(Decl *decl); extern Expr * build_expr(Expr *left, enum Operator op, Expr *right); extern Expr * var_expr(Scope *scope, char *id); extern Code * build_expr_code(Expr *expr); extern Code * build_if(Expr *cond_expr, Code *then_stmt, Code *else_stmt); extern Code * code_append(Code *stmt_list, Code *stmt); #line 667 "btyacc_demo.tab.c" /* Release memory associated with symbol. */ #if ! defined YYDESTRUCT_IS_DECLARED static void YYDESTRUCT_DECL() { switch (psymb) { case 43: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", msg, (*loc).first_line, (*loc).first_column, (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } #line 683 "btyacc_demo.tab.c" break; case 45: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", msg, (*loc).first_line, (*loc).first_column, (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } #line 692 "btyacc_demo.tab.c" break; case 42: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", msg, (*loc).first_line, (*loc).first_column, (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } #line 701 "btyacc_demo.tab.c" break; case 47: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", msg, (*loc).first_line, (*loc).first_column, (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } #line 710 "btyacc_demo.tab.c" break; case 37: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", msg, (*loc).first_line, (*loc).first_column, (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } #line 719 "btyacc_demo.tab.c" break; case 257: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", msg, (*loc).first_line, (*loc).first_column, (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } #line 728 "btyacc_demo.tab.c" break; case 258: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", msg, (*loc).first_line, (*loc).first_column, (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } #line 737 "btyacc_demo.tab.c" break; case 40: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", msg, (*loc).first_line, (*loc).first_column, (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } #line 746 "btyacc_demo.tab.c" break; case 91: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", msg, (*loc).first_line, (*loc).first_column, (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } #line 755 "btyacc_demo.tab.c" break; case 46: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", msg, (*loc).first_line, (*loc).first_column, (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } #line 764 "btyacc_demo.tab.c" break; case 259: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", msg, (*loc).first_line, (*loc).first_column, (*loc).last_line, (*loc).last_column); free((*val).id); } #line 773 "btyacc_demo.tab.c" break; case 260: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", msg, (*loc).first_line, (*loc).first_column, (*loc).last_line, (*loc).last_column); free((*val).expr); } #line 782 "btyacc_demo.tab.c" break; case 261: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", msg, (*loc).first_line, (*loc).first_column, (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } #line 791 "btyacc_demo.tab.c" break; case 262: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", msg, (*loc).first_line, (*loc).first_column, (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } #line 800 "btyacc_demo.tab.c" break; case 263: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", msg, (*loc).first_line, (*loc).first_column, (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } #line 809 "btyacc_demo.tab.c" break; case 264: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", msg, (*loc).first_line, (*loc).first_column, (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } #line 818 "btyacc_demo.tab.c" break; case 265: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", msg, (*loc).first_line, (*loc).first_column, (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } #line 827 "btyacc_demo.tab.c" break; case 266: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", msg, (*loc).first_line, (*loc).first_column, (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } #line 836 "btyacc_demo.tab.c" break; case 267: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", msg, (*loc).first_line, (*loc).first_column, (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } #line 845 "btyacc_demo.tab.c" break; case 268: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", msg, (*loc).first_line, (*loc).first_column, (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } #line 854 "btyacc_demo.tab.c" break; case 269: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", msg, (*loc).first_line, (*loc).first_column, (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } #line 863 "btyacc_demo.tab.c" break; case 59: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", msg, (*loc).first_line, (*loc).first_column, (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } #line 872 "btyacc_demo.tab.c" break; case 44: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", msg, (*loc).first_line, (*loc).first_column, (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } #line 881 "btyacc_demo.tab.c" break; case 41: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", msg, (*loc).first_line, (*loc).first_column, (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } #line 890 "btyacc_demo.tab.c" break; case 93: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", msg, (*loc).first_line, (*loc).first_column, (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } #line 899 "btyacc_demo.tab.c" break; case 123: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", msg, (*loc).first_line, (*loc).first_column, (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } #line 908 "btyacc_demo.tab.c" break; case 125: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", msg, (*loc).first_line, (*loc).first_column, (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } #line 917 "btyacc_demo.tab.c" break; case 270: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", msg, (*loc).first_line, (*loc).first_column, (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } #line 926 "btyacc_demo.tab.c" break; case 271: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", msg, (*loc).first_line, (*loc).first_column, (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } #line 935 "btyacc_demo.tab.c" break; case 272: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", msg, (*loc).first_line, (*loc).first_column, (*loc).last_line, (*loc).last_column); free((*val).expr); } #line 944 "btyacc_demo.tab.c" break; case 273: #line 67 "btyacc_demo.y" { /* 'msg' is a 'char *' indicating the context of destructor invocation*/ printf("%s accessed by symbol \"decl\" (case s.b. 273) @ position[%d,%d..%d,%d]\n", msg, (*loc).first_line, (*loc).first_column, (*loc).last_line, (*loc).last_column); free((*val).decl->scope); free((*val).decl->type); } #line 954 "btyacc_demo.tab.c" break; case 274: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", msg, (*loc).first_line, (*loc).first_column, (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } #line 963 "btyacc_demo.tab.c" break; case 275: #line 83 "btyacc_demo.y" { printf("%s accessed by symbol with no type @ position[%d,%d..%d,%d]\n", msg, (*loc).first_line, (*loc).first_column, (*loc).last_line, (*loc).last_column); /* in this example, we don't know what to do here */ } #line 972 "btyacc_demo.tab.c" break; case 276: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", msg, (*loc).first_line, (*loc).first_column, (*loc).last_line, (*loc).last_column); free((*val).code); } #line 981 "btyacc_demo.tab.c" break; case 277: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", msg, (*loc).first_line, (*loc).first_column, (*loc).last_line, (*loc).last_column); free((*val).code); } #line 990 "btyacc_demo.tab.c" break; case 278: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", msg, (*loc).first_line, (*loc).first_column, (*loc).last_line, (*loc).last_column); free((*val).code); } #line 999 "btyacc_demo.tab.c" break; case 279: #line 73 "btyacc_demo.y" { printf("%s accessed by symbol with type (case s.b. 279 & 280) @ position[%d,%d..%d,%d]\n", msg, (*loc).first_line, (*loc).first_column, (*loc).last_line, (*loc).last_column); free((*val).decl); } #line 1008 "btyacc_demo.tab.c" break; case 280: #line 73 "btyacc_demo.y" { printf("%s accessed by symbol with type (case s.b. 279 & 280) @ position[%d,%d..%d,%d]\n", msg, (*loc).first_line, (*loc).first_column, (*loc).last_line, (*loc).last_column); free((*val).decl); } #line 1017 "btyacc_demo.tab.c" break; case 281: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", msg, (*loc).first_line, (*loc).first_column, (*loc).last_line, (*loc).last_column); free((*val).type); } #line 1026 "btyacc_demo.tab.c" break; case 282: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", msg, (*loc).first_line, (*loc).first_column, (*loc).last_line, (*loc).last_column); free((*val).type); } #line 1035 "btyacc_demo.tab.c" break; case 283: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", msg, (*loc).first_line, (*loc).first_column, (*loc).last_line, (*loc).last_column); free((*val).type); } #line 1044 "btyacc_demo.tab.c" break; case 284: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", msg, (*loc).first_line, (*loc).first_column, (*loc).last_line, (*loc).last_column); free((*val).type); } #line 1053 "btyacc_demo.tab.c" break; case 285: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", msg, (*loc).first_line, (*loc).first_column, (*loc).last_line, (*loc).last_column); free((*val).type); } #line 1062 "btyacc_demo.tab.c" break; case 286: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", msg, (*loc).first_line, (*loc).first_column, (*loc).last_line, (*loc).last_column); free((*val).scope); } #line 1071 "btyacc_demo.tab.c" break; case 287: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", msg, (*loc).first_line, (*loc).first_column, (*loc).last_line, (*loc).last_column); free((*val).dlist); } #line 1080 "btyacc_demo.tab.c" break; case 288: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", msg, (*loc).first_line, (*loc).first_column, (*loc).last_line, (*loc).last_column); free((*val).dlist); } #line 1089 "btyacc_demo.tab.c" break; case 289: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", msg, (*loc).first_line, (*loc).first_column, (*loc).last_line, (*loc).last_column); free((*val).scope); } #line 1098 "btyacc_demo.tab.c" break; case 290: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", msg, (*loc).first_line, (*loc).first_column, (*loc).last_line, (*loc).last_column); free((*val).scope); } #line 1107 "btyacc_demo.tab.c" break; case 291: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", msg, (*loc).first_line, (*loc).first_column, (*loc).last_line, (*loc).last_column); free((*val).scope); } #line 1116 "btyacc_demo.tab.c" break; case 292: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", msg, (*loc).first_line, (*loc).first_column, (*loc).last_line, (*loc).last_column); free((*val).scope); } #line 1125 "btyacc_demo.tab.c" break; case 293: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", msg, (*loc).first_line, (*loc).first_column, (*loc).last_line, (*loc).last_column); free((*val).type); } #line 1134 "btyacc_demo.tab.c" break; case 294: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", msg, (*loc).first_line, (*loc).first_column, (*loc).last_line, (*loc).last_column); free((*val).scope); } #line 1143 "btyacc_demo.tab.c" break; case 295: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", msg, (*loc).first_line, (*loc).first_column, (*loc).last_line, (*loc).last_column); free((*val).type); } #line 1152 "btyacc_demo.tab.c" break; case 296: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", msg, (*loc).first_line, (*loc).first_column, (*loc).last_line, (*loc).last_column); free((*val).scope); } #line 1161 "btyacc_demo.tab.c" break; case 297: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", msg, (*loc).first_line, (*loc).first_column, (*loc).last_line, (*loc).last_column); free((*val).scope); } #line 1170 "btyacc_demo.tab.c" break; case 298: #line 78 "btyacc_demo.y" { printf("%s accessed by symbol of any type other than @ position[%d,%d..%d,%d]\n", msg, (*loc).first_line, (*loc).first_column, (*loc).last_line, (*loc).last_column); free((*val).scope); } #line 1179 "btyacc_demo.tab.c" break; } } #define YYDESTRUCT_IS_DECLARED 1 #endif /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) #if YYBTYACC #define yytrial (yyps->save) #endif /* YYBTYACC */ #if YYDEBUG #include /* needed for printf */ #endif #include /* needed for malloc, etc */ #include /* needed for memset */ /* allocate initial stack or double stack size, up to YYMAXDEPTH */ static int yygrowstack(YYSTACKDATA *data) { int i; unsigned newsize; YYINT *newss; YYSTYPE *newvs; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE *newps; #endif if ((newsize = data->stacksize) == 0) newsize = YYINITSTACKSIZE; else if (newsize >= YYMAXDEPTH) return YYENOMEM; else if ((newsize *= 2) > YYMAXDEPTH) newsize = YYMAXDEPTH; i = (int) (data->s_mark - data->s_base); newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); if (newss == NULL) return YYENOMEM; data->s_base = newss; data->s_mark = newss + i; newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); if (newvs == NULL) return YYENOMEM; data->l_base = newvs; data->l_mark = newvs + i; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); if (newps == NULL) return YYENOMEM; data->p_base = newps; data->p_mark = newps + i; #endif data->stacksize = newsize; data->s_last = data->s_base + newsize - 1; #if YYDEBUG if (yydebug) fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); #endif return 0; } #if YYPURE || defined(YY_NO_LEAKS) static void yyfreestack(YYSTACKDATA *data) { free(data->s_base); free(data->l_base); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) free(data->p_base); #endif memset(data, 0, sizeof(*data)); } #else #define yyfreestack(data) /* nothing */ #endif /* YYPURE || defined(YY_NO_LEAKS) */ #if YYBTYACC static YYParseState * yyNewState(unsigned size) { YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); if (p == NULL) return NULL; p->yystack.stacksize = size; if (size == 0) { p->yystack.s_base = NULL; p->yystack.l_base = NULL; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) p->yystack.p_base = NULL; #endif return p; } p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); if (p->yystack.s_base == NULL) return NULL; p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); if (p->yystack.l_base == NULL) return NULL; memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); if (p->yystack.p_base == NULL) return NULL; memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); #endif return p; } static void yyFreeState(YYParseState *p) { yyfreestack(&p->yystack); free(p); } #endif /* YYBTYACC */ #define YYABORT goto yyabort #define YYREJECT goto yyabort #define YYACCEPT goto yyaccept #define YYERROR goto yyerrlab #if YYBTYACC #define YYVALID do { if (yyps->save) goto yyvalid; } while(0) #define YYVALID_NESTED do { if (yyps->save && \ yyps->save->save == 0) goto yyvalid; } while(0) #endif /* YYBTYACC */ int YYPARSE_DECL() { int yym, yyn, yystate, yyresult; #if YYBTYACC int yynewerrflag; YYParseState *yyerrctx = NULL; #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ #endif #if YYDEBUG const char *yys; if ((yys = getenv("YYDEBUG")) != NULL) { yyn = *yys; if (yyn >= '0' && yyn <= '9') yydebug = yyn - '0'; } if (yydebug) fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); #endif #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); #endif #if YYBTYACC yyps = yyNewState(0); if (yyps == 0) goto yyenomem; yyps->save = 0; #endif /* YYBTYACC */ yym = 0; /* yyn is set below */ yynerrs = 0; yyerrflag = 0; yychar = YYEMPTY; yystate = 0; #if YYPURE memset(&yystack, 0, sizeof(yystack)); #endif if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystack.s_mark = yystack.s_base; yystack.l_mark = yystack.l_base; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark = yystack.p_base; #endif yystate = 0; *yystack.s_mark = 0; yyloop: if ((yyn = yydefred[yystate]) != 0) goto yyreduce; if (yychar < 0) { #if YYBTYACC do { if (yylvp < yylve) { /* we're currently re-reading tokens */ yylval = *yylvp++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylloc = *yylpp++; #endif yychar = *yylexp++; break; } if (yyps->save) { /* in trial mode; save scanner results for future parse attempts */ if (yylvp == yylvlim) { /* Enlarge lexical value queue */ size_t p = (size_t) (yylvp - yylvals); size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpe = yylpsns + p; yylplim = yylpsns + s; #endif yylexp = yylexemes + p; } *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpp++ = yylloc; yylpe++; #endif yychar = *yylexp++; break; } /* normal operation, no conflict encountered */ #endif /* YYBTYACC */ yychar = YYLEX; #if YYBTYACC } while (0); #endif /* YYBTYACC */ if (yychar < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", YYDEBUGSTR, yydepth, yystate, yychar, yys); #ifdef YYSTYPE_TOSTRING #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); #endif fputc('\n', stderr); } #endif } #if YYBTYACC /* Do we have a conflict? */ if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) { YYINT ctry; if (yypath) { YYParseState *save; #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", YYDEBUGSTR, yydepth, yystate); #endif /* Switch to the next conflict context */ save = yypath; yypath = save->save; save->save = NULL; ctry = save->ctry; if (save->state != yystate) YYABORT; yyFreeState(save); } else { /* Unresolved conflict - start/continue trial parse */ YYParseState *save; #if YYDEBUG if (yydebug) { fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); if (yyps->save) fputs("ALREADY in conflict, continuing trial parse.\n", stderr); else fputs("Starting trial parse.\n", stderr); } #endif save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); if (save == NULL) goto yyenomem; save->save = yyps->save; save->state = yystate; save->errflag = yyerrflag; save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif ctry = yytable[yyn]; if (yyctable[ctry] == -1) { #if YYDEBUG if (yydebug && yychar >= YYEOF) fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); #endif ctry++; } save->ctry = ctry; if (yyps->save == NULL) { /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; yylvlim = yylvals + YYLVQUEUEGROWTH; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); if (yylpsns == NULL) goto yyenomem; yylplim = yylpsns + YYLVQUEUEGROWTH; #endif } if (yylvp == yylve) { yylvp = yylve = yylvals; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpe = yylpsns; #endif yylexp = yylexemes; if (yychar >= YYEOF) { *yylve++ = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpe++ = yylloc; #endif *yylexp = (YYINT) yychar; yychar = YYEMPTY; } } } if (yychar >= YYEOF) { yylvp--; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp--; #endif yylexp--; yychar = YYEMPTY; } save->lexeme = (int) (yylvp - yylvals); yyps->save = save; } if (yytable[yyn] == ctry) { #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); #endif if (yychar < 0) { yylvp++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp++; #endif yylexp++; } if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystate = yyctable[ctry]; *++yystack.s_mark = (YYINT) yystate; *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *++yystack.p_mark = yylloc; #endif yychar = YYEMPTY; if (yyerrflag > 0) --yyerrflag; goto yyloop; } else { yyn = yyctable[ctry]; goto yyreduce; } } /* End of code dealing with conflicts */ #endif /* YYBTYACC */ if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) { #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", YYDEBUGSTR, yydepth, yystate, yytable[yyn]); #endif if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystate = yytable[yyn]; *++yystack.s_mark = yytable[yyn]; *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *++yystack.p_mark = yylloc; #endif yychar = YYEMPTY; if (yyerrflag > 0) --yyerrflag; goto yyloop; } if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) { yyn = yytable[yyn]; goto yyreduce; } if (yyerrflag != 0) goto yyinrecovery; #if YYBTYACC yynewerrflag = 1; goto yyerrhandler; goto yyerrlab; /* redundant goto avoids 'unused label' warning */ yyerrlab: /* explicit YYERROR from an action -- pop the rhs of the rule reduced * before looking for error recovery */ yystack.s_mark -= yym; yystate = *yystack.s_mark; yystack.l_mark -= yym; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark -= yym; #endif yynewerrflag = 0; yyerrhandler: while (yyps->save) { int ctry; YYParseState *save = yyps->save; #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", YYDEBUGSTR, yydepth, yystate, yyps->save->state, (int)(yylvp - yylvals - yyps->save->lexeme)); #endif /* Memorize most forward-looking error state in case it's really an error. */ if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) { /* Free old saved error context state */ if (yyerrctx) yyFreeState(yyerrctx); /* Create and fill out new saved error context state */ yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); if (yyerrctx == NULL) goto yyenomem; yyerrctx->save = yyps->save; yyerrctx->state = yystate; yyerrctx->errflag = yyerrflag; yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif yyerrctx->lexeme = (int) (yylvp - yylvals); } yylvp = yylvals + save->lexeme; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpsns + save->lexeme; #endif yylexp = yylexemes + save->lexeme; yychar = YYEMPTY; yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif ctry = ++save->ctry; yystate = save->state; /* We tried shift, try reduce now */ if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; yyps->save = save->save; save->save = NULL; yyFreeState(save); /* Nothing left on the stack -- error */ if (!yyps->save) { #if YYDEBUG if (yydebug) fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", YYPREFIX, yydepth); #endif /* Restore state as it was in the most forward-advanced error */ yylvp = yylvals + yyerrctx->lexeme; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpsns + yyerrctx->lexeme; #endif yylexp = yylexemes + yyerrctx->lexeme; yychar = yylexp[-1]; yylval = yylvp[-1]; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylloc = yylpp[-1]; #endif yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif yystate = yyerrctx->state; yyFreeState(yyerrctx); yyerrctx = NULL; } yynewerrflag = 1; } if (yynewerrflag == 0) goto yyinrecovery; #endif /* YYBTYACC */ YYERROR_CALL("syntax error"); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ #endif #if !YYBTYACC goto yyerrlab; /* redundant goto avoids 'unused label' warning */ yyerrlab: #endif ++yynerrs; yyinrecovery: if (yyerrflag < 3) { yyerrflag = 3; for (;;) { if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) { #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); #endif if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystate = yytable[yyn]; *++yystack.s_mark = yytable[yyn]; *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* lookahead position is error end position */ yyerror_loc_range[2] = yylloc; YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ *++yystack.p_mark = yyloc; #endif goto yyloop; } else { #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", YYDEBUGSTR, yydepth, *yystack.s_mark); #endif if (yystack.s_mark <= yystack.s_base) goto yyabort; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* the current TOS position is the error start position */ yyerror_loc_range[1] = *yystack.p_mark; #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYDESTRUCT_CALL("error: discarding state", yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); #else YYDESTRUCT_CALL("error: discarding state", yystos[*yystack.s_mark], yystack.l_mark); #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ #endif /* defined(YYDESTRUCT_CALL) */ --yystack.s_mark; --yystack.l_mark; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) --yystack.p_mark; #endif } } } else { if (yychar == YYEOF) goto yyabort; #if YYDEBUG if (yydebug) { if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", YYDEBUGSTR, yydepth, yystate, yychar, yys); } #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); #else YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ #endif /* defined(YYDESTRUCT_CALL) */ yychar = YYEMPTY; goto yyloop; } yyreduce: yym = yylen[yyn]; #if YYDEBUG if (yydebug) { fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); #ifdef YYSTYPE_TOSTRING #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ if (yym > 0) { int i; fputc('<', stderr); for (i = yym; i > 0; i--) { if (i != yym) fputs(", ", stderr); fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], yystack.l_mark[1-i]), stderr); } fputc('>', stderr); } #endif fputc('\n', stderr); } #endif if (yym > 0) yyval = yystack.l_mark[1-yym]; else memset(&yyval, 0, sizeof yyval); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* Perform position reduction */ memset(&yyloc, 0, sizeof(yyloc)); #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ { YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); /* just in case YYERROR is invoked within the action, save the start of the rhs as the error start position */ yyerror_loc_range[1] = yystack.p_mark[1-yym]; } #endif switch (yyn) { case 1: #line 93 "btyacc_demo.y" { yyval.scope = yystack.l_mark[0].scope; } #line 1857 "btyacc_demo.tab.c" break; case 2: #line 94 "btyacc_demo.y" { yyval.scope = global_scope; } #line 1862 "btyacc_demo.tab.c" break; case 3: #line 95 "btyacc_demo.y" { Decl *d = lookup(yystack.l_mark[-2].scope, yystack.l_mark[-1].id); if (!d || !d->scope) YYERROR; yyval.scope = d->scope; } #line 1869 "btyacc_demo.tab.c" break; case 4: #line 101 "btyacc_demo.y" { Decl *d = lookup(yystack.l_mark[-1].scope, yystack.l_mark[0].id); if (d == NULL || d->istype() == 0) YYERROR; yyval.type = d->type; } #line 1876 "btyacc_demo.tab.c" break; case 5: #line 106 "btyacc_demo.y" yyval.scope = global_scope = new_scope(0); #line 1881 "btyacc_demo.tab.c" break; case 8: #line 107 "btyacc_demo.y" yyval.scope = yystack.l_mark[-1].scope; #line 1886 "btyacc_demo.tab.c" break; case 10: #line 109 "btyacc_demo.y" {YYVALID;} #line 1891 "btyacc_demo.tab.c" break; case 11: #line 110 "btyacc_demo.y" yyval.scope = start_fn_def(yystack.l_mark[-2].scope, yystack.l_mark[0].decl); #line 1896 "btyacc_demo.tab.c" break; case 12: if (!yytrial) #line 111 "btyacc_demo.y" { /* demonstrate use of @$ & @N, although this is just the default computation and so is not necessary */ yyloc.first_line = yystack.p_mark[-3].first_line; yyloc.first_column = yystack.p_mark[-3].first_column; yyloc.last_line = yystack.p_mark[0].last_line; yyloc.last_column = yystack.p_mark[0].last_column; finish_fn_def(yystack.l_mark[-2].decl, yystack.l_mark[0].code); } #line 1908 "btyacc_demo.tab.c" break; case 13: #line 121 "btyacc_demo.y" { yyval.type = yystack.l_mark[0].type; } #line 1913 "btyacc_demo.tab.c" break; case 14: #line 122 "btyacc_demo.y" { yyval.type = type_combine(yystack.l_mark[-2].type, yystack.l_mark[0].type); } #line 1918 "btyacc_demo.tab.c" break; case 15: #line 125 "btyacc_demo.y" { yyval.type = 0; } #line 1923 "btyacc_demo.tab.c" break; case 16: #line 126 "btyacc_demo.y" { yyval.type = type_combine(yystack.l_mark[-1].type, yystack.l_mark[0].type); } #line 1928 "btyacc_demo.tab.c" break; case 17: #line 130 "btyacc_demo.y" { yyval.type = yystack.l_mark[0].type; } #line 1933 "btyacc_demo.tab.c" break; case 18: #line 131 "btyacc_demo.y" { yyval.type = yystack.l_mark[0].type; } #line 1938 "btyacc_demo.tab.c" break; case 19: #line 132 "btyacc_demo.y" { yyval.type = bare_extern(); } #line 1943 "btyacc_demo.tab.c" break; case 20: #line 133 "btyacc_demo.y" { yyval.type = bare_register(); } #line 1948 "btyacc_demo.tab.c" break; case 21: #line 134 "btyacc_demo.y" { yyval.type = bare_static(); } #line 1953 "btyacc_demo.tab.c" break; case 22: #line 138 "btyacc_demo.y" { yyval.type = bare_const(); } #line 1958 "btyacc_demo.tab.c" break; case 23: #line 139 "btyacc_demo.y" { yyval.type = bare_volatile(); } #line 1963 "btyacc_demo.tab.c" break; case 24: #line 143 "btyacc_demo.y" yyval.scope = yystack.l_mark[-3].scope; #line 1968 "btyacc_demo.tab.c" break; case 25: #line 143 "btyacc_demo.y" yyval.type = yystack.l_mark[-3].type; #line 1973 "btyacc_demo.tab.c" break; case 28: #line 148 "btyacc_demo.y" { if (!yystack.l_mark[0].type) YYERROR; } if (!yytrial) #line 149 "btyacc_demo.y" { yyval.decl = declare(yystack.l_mark[-1].scope, 0, yystack.l_mark[0].type); } #line 1980 "btyacc_demo.tab.c" break; case 29: if (!yytrial) #line 150 "btyacc_demo.y" { yyval.decl = declare(yystack.l_mark[-2].scope, yystack.l_mark[0].id, yystack.l_mark[-1].type); } #line 1986 "btyacc_demo.tab.c" break; case 30: #line 151 "btyacc_demo.y" yyval.scope = yystack.l_mark[-2].scope; #line 1991 "btyacc_demo.tab.c" break; case 31: #line 151 "btyacc_demo.y" yyval.type = yystack.l_mark[-2].type; #line 1996 "btyacc_demo.tab.c" break; case 32: if (!yytrial) #line 151 "btyacc_demo.y" { yyval.decl = yystack.l_mark[-1].decl; } #line 2002 "btyacc_demo.tab.c" break; case 33: if (!yytrial) #line 153 "btyacc_demo.y" { yyval.decl = make_pointer(yystack.l_mark[0].decl, yystack.l_mark[-3].type); } #line 2008 "btyacc_demo.tab.c" break; case 34: if (!yytrial) #line 155 "btyacc_demo.y" { yyval.decl = make_array(yystack.l_mark[-4].decl->type, yystack.l_mark[-1].expr); } #line 2014 "btyacc_demo.tab.c" break; case 35: if (!yytrial) #line 157 "btyacc_demo.y" { yyval.decl = build_function(yystack.l_mark[-5].decl, yystack.l_mark[-2].dlist, yystack.l_mark[0].type); } #line 2020 "btyacc_demo.tab.c" break; case 36: if (!yytrial) #line 160 "btyacc_demo.y" { yyval.dlist = 0; } #line 2026 "btyacc_demo.tab.c" break; case 37: if (!yytrial) #line 161 "btyacc_demo.y" { yyval.dlist = yystack.l_mark[0].dlist; } #line 2032 "btyacc_demo.tab.c" break; case 38: if (!yytrial) #line 164 "btyacc_demo.y" { yyval.dlist = append_dlist(yystack.l_mark[-3].dlist, yystack.l_mark[0].decl); } #line 2038 "btyacc_demo.tab.c" break; case 39: if (!yytrial) #line 165 "btyacc_demo.y" { yyval.dlist = build_dlist(yystack.l_mark[0].decl); } #line 2044 "btyacc_demo.tab.c" break; case 40: if (!yytrial) #line 168 "btyacc_demo.y" { yyval.decl = yystack.l_mark[0].decl; } #line 2050 "btyacc_demo.tab.c" break; case 41: if (!yytrial) #line 172 "btyacc_demo.y" { yyval.expr = build_expr(yystack.l_mark[-3].expr, ADD, yystack.l_mark[0].expr); } #line 2056 "btyacc_demo.tab.c" break; case 42: if (!yytrial) #line 173 "btyacc_demo.y" { yyval.expr = build_expr(yystack.l_mark[-3].expr, SUB, yystack.l_mark[0].expr); } #line 2062 "btyacc_demo.tab.c" break; case 43: if (!yytrial) #line 174 "btyacc_demo.y" { yyval.expr = build_expr(yystack.l_mark[-3].expr, MUL, yystack.l_mark[0].expr); } #line 2068 "btyacc_demo.tab.c" break; case 44: if (!yytrial) #line 175 "btyacc_demo.y" { yyval.expr = build_expr(yystack.l_mark[-3].expr, MOD, yystack.l_mark[0].expr); } #line 2074 "btyacc_demo.tab.c" break; case 45: if (!yytrial) #line 176 "btyacc_demo.y" { yyval.expr = build_expr(yystack.l_mark[-3].expr, DIV, yystack.l_mark[0].expr); } #line 2080 "btyacc_demo.tab.c" break; case 46: if (!yytrial) #line 177 "btyacc_demo.y" { yyval.expr = build_expr(0, DEREF, yystack.l_mark[0].expr); } #line 2086 "btyacc_demo.tab.c" break; case 47: if (!yytrial) #line 178 "btyacc_demo.y" { yyval.expr = var_expr(yystack.l_mark[-1].scope, yystack.l_mark[0].id); } #line 2092 "btyacc_demo.tab.c" break; case 48: if (!yytrial) #line 179 "btyacc_demo.y" { yyval.expr = yystack.l_mark[0].expr; } #line 2098 "btyacc_demo.tab.c" break; case 49: if (!yytrial) #line 183 "btyacc_demo.y" { yyval.code = 0; } #line 2104 "btyacc_demo.tab.c" break; case 50: #line 184 "btyacc_demo.y" {YYVALID;} if (!yytrial) #line 184 "btyacc_demo.y" { yyval.code = build_expr_code(yystack.l_mark[-1].expr); } #line 2111 "btyacc_demo.tab.c" break; case 51: #line 185 "btyacc_demo.y" yyval.scope = yystack.l_mark[-6].scope; #line 2116 "btyacc_demo.tab.c" break; case 52: #line 185 "btyacc_demo.y" yyval.scope = yystack.l_mark[-9].scope; #line 2121 "btyacc_demo.tab.c" break; case 53: #line 185 "btyacc_demo.y" {YYVALID;} if (!yytrial) #line 186 "btyacc_demo.y" { yyval.code = build_if(yystack.l_mark[-7].expr, yystack.l_mark[-3].code, yystack.l_mark[0].code); } #line 2128 "btyacc_demo.tab.c" break; case 54: #line 187 "btyacc_demo.y" {YYVALID;} if (!yytrial) #line 188 "btyacc_demo.y" { yyval.code = build_if(yystack.l_mark[-4].expr, yystack.l_mark[0].code, 0); } #line 2135 "btyacc_demo.tab.c" break; case 55: #line 189 "btyacc_demo.y" yyval.scope = new_scope(yystack.l_mark[0].scope); #line 2140 "btyacc_demo.tab.c" break; case 56: #line 189 "btyacc_demo.y" {YYVALID;} if (!yytrial) #line 189 "btyacc_demo.y" { yyval.code = yystack.l_mark[0].code; } #line 2147 "btyacc_demo.tab.c" break; case 57: if (!yytrial) #line 192 "btyacc_demo.y" { yyval.code = 0; } #line 2153 "btyacc_demo.tab.c" break; case 58: if (!yytrial) #line 193 "btyacc_demo.y" { yyval.code = code_append(yystack.l_mark[-2].code, yystack.l_mark[0].code); } #line 2159 "btyacc_demo.tab.c" break; case 59: if (!yytrial) #line 197 "btyacc_demo.y" { yyval.code = yystack.l_mark[-1].code; } #line 2165 "btyacc_demo.tab.c" break; #line 2167 "btyacc_demo.tab.c" default: break; } yystack.s_mark -= yym; yystate = *yystack.s_mark; yystack.l_mark -= yym; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark -= yym; #endif yym = yylhs[yyn]; if (yystate == 0 && yym == 0) { #if YYDEBUG if (yydebug) { fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); #ifdef YYSTYPE_TOSTRING #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); #endif fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); } #endif yystate = YYFINAL; *++yystack.s_mark = YYFINAL; *++yystack.l_mark = yyval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *++yystack.p_mark = yyloc; #endif if (yychar < 0) { #if YYBTYACC do { if (yylvp < yylve) { /* we're currently re-reading tokens */ yylval = *yylvp++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylloc = *yylpp++; #endif yychar = *yylexp++; break; } if (yyps->save) { /* in trial mode; save scanner results for future parse attempts */ if (yylvp == yylvlim) { /* Enlarge lexical value queue */ size_t p = (size_t) (yylvp - yylvals); size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpe = yylpsns + p; yylplim = yylpsns + s; #endif yylexp = yylexemes + p; } *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpp++ = yylloc; yylpe++; #endif yychar = *yylexp++; break; } /* normal operation, no conflict encountered */ #endif /* YYBTYACC */ yychar = YYLEX; #if YYBTYACC } while (0); #endif /* YYBTYACC */ if (yychar < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); } #endif } if (yychar == YYEOF) goto yyaccept; goto yyloop; } if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) yystate = yytable[yyn]; else yystate = yydgoto[yym]; #if YYDEBUG if (yydebug) { fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); #ifdef YYSTYPE_TOSTRING #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); #endif fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); } #endif if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; *++yystack.s_mark = (YYINT) yystate; *++yystack.l_mark = yyval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *++yystack.p_mark = yyloc; #endif goto yyloop; #if YYBTYACC /* Reduction declares that this path is valid. Set yypath and do a full parse */ yyvalid: if (yypath) YYABORT; while (yyps->save) { YYParseState *save = yyps->save; yyps->save = save->save; save->save = yypath; yypath = save; } #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); #endif if (yyerrctx) { yyFreeState(yyerrctx); yyerrctx = NULL; } yylvp = yylvals + yypath->lexeme; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpsns + yypath->lexeme; #endif yylexp = yylexemes + yypath->lexeme; yychar = YYEMPTY; yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif yystate = yypath->state; goto yyloop; #endif /* YYBTYACC */ yyoverflow: YYERROR_CALL("yacc stack overflow"); #if YYBTYACC goto yyabort_nomem; yyenomem: YYERROR_CALL("memory exhausted"); yyabort_nomem: #endif /* YYBTYACC */ yyresult = 2; goto yyreturn; yyabort: yyresult = 1; goto yyreturn; yyaccept: #if YYBTYACC if (yyps->save) goto yyvalid; #endif /* YYBTYACC */ yyresult = 0; yyreturn: #if defined(YYDESTRUCT_CALL) if (yychar != YYEOF && yychar != YYEMPTY) #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); #else YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ { YYSTYPE *pv; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE *pp; for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) YYDESTRUCT_CALL("cleanup: discarding state", yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); #else for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) YYDESTRUCT_CALL("cleanup: discarding state", yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ } #endif /* defined(YYDESTRUCT_CALL) */ #if YYBTYACC if (yyerrctx) { yyFreeState(yyerrctx); yyerrctx = NULL; } while (yyps) { YYParseState *save = yyps; yyps = save->save; save->save = NULL; yyFreeState(save); } while (yypath) { YYParseState *save = yypath; yypath = save->save; save->save = NULL; yyFreeState(save); } #endif /* YYBTYACC */ yyfreestack(&yystack); return (yyresult); } diff --git a/contrib/byacc/test/btyacc/btyacc_demo.tab.h b/contrib/byacc/test/btyacc/btyacc_demo.tab.h index 082f5cdbfa96..5c2b96cf3310 100644 --- a/contrib/byacc/test/btyacc/btyacc_demo.tab.h +++ b/contrib/byacc/test/btyacc/btyacc_demo.tab.h @@ -1,51 +1,51 @@ #ifndef _demo__defines_h_ #define _demo__defines_h_ #define PREFIX 257 #define POSTFIX 258 #define ID 259 #define CONSTANT 260 #define EXTERN 261 #define REGISTER 262 #define STATIC 263 #define CONST 264 #define VOLATILE 265 #define IF 266 #define THEN 267 #define ELSE 268 #define CLCL 269 #ifdef YYSTYPE #undef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 #endif #ifndef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 -typedef union YYSTYPE { +typedef union { Scope *scope; Expr *expr; Expr_List *elist; Type *type; Decl *decl; Decl_List *dlist; Code *code; char *id; } YYSTYPE; #endif /* !YYSTYPE_IS_DECLARED */ extern YYSTYPE demo_lval; #if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED /* Default: YYLTYPE is the text position type. */ typedef struct YYLTYPE { int first_line; int first_column; int last_line; int last_column; unsigned source; } YYLTYPE; #define YYLTYPE_IS_DECLARED 1 #endif #define YYRHSLOC(rhs, k) ((rhs)[k]) extern YYLTYPE demo_lloc; #endif /* _demo__defines_h_ */ diff --git a/contrib/byacc/test/btyacc/btyacc_destroy1.tab.c b/contrib/byacc/test/btyacc/btyacc_destroy1.tab.c index a95e13341eee..ce8d58593d88 100644 --- a/contrib/byacc/test/btyacc/btyacc_destroy1.tab.c +++ b/contrib/byacc/test/btyacc/btyacc_destroy1.tab.c @@ -1,1477 +1,1477 @@ /* original parser id follows */ /* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ /* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ #define YYBYACC 1 #define YYMAJOR 2 #define YYMINOR 0 #define YYCHECK "yyyymmdd" #define YYEMPTY (-1) #define yyclearin (yychar = YYEMPTY) #define yyerrok (yyerrflag = 0) #define YYRECOVERING() (yyerrflag != 0) #define YYENOMEM (-2) #define YYEOF 0 #undef YYBTYACC #define YYBTYACC 1 #define YYDEBUGSTR (yytrial ? YYPREFIX "debug(trial)" : YYPREFIX "debug") #ifndef yyparse #define yyparse destroy1_parse #endif /* yyparse */ #ifndef yylex #define yylex destroy1_lex #endif /* yylex */ #ifndef yyerror #define yyerror destroy1_error #endif /* yyerror */ #ifndef yychar #define yychar destroy1_char #endif /* yychar */ #ifndef yyval #define yyval destroy1_val #endif /* yyval */ #ifndef yylval #define yylval destroy1_lval #endif /* yylval */ #ifndef yydebug #define yydebug destroy1_debug #endif /* yydebug */ #ifndef yynerrs #define yynerrs destroy1_nerrs #endif /* yynerrs */ #ifndef yyerrflag #define yyerrflag destroy1_errflag #endif /* yyerrflag */ #ifndef yylhs #define yylhs destroy1_lhs #endif /* yylhs */ #ifndef yylen #define yylen destroy1_len #endif /* yylen */ #ifndef yydefred #define yydefred destroy1_defred #endif /* yydefred */ #ifndef yystos #define yystos destroy1_stos #endif /* yystos */ #ifndef yydgoto #define yydgoto destroy1_dgoto #endif /* yydgoto */ #ifndef yysindex #define yysindex destroy1_sindex #endif /* yysindex */ #ifndef yyrindex #define yyrindex destroy1_rindex #endif /* yyrindex */ #ifndef yygindex #define yygindex destroy1_gindex #endif /* yygindex */ #ifndef yytable #define yytable destroy1_table #endif /* yytable */ #ifndef yycheck #define yycheck destroy1_check #endif /* yycheck */ #ifndef yyname #define yyname destroy1_name #endif /* yyname */ #ifndef yyrule #define yyrule destroy1_rule #endif /* yyrule */ #if YYBTYACC #ifndef yycindex #define yycindex destroy1_cindex #endif /* yycindex */ #ifndef yyctable #define yyctable destroy1_ctable #endif /* yyctable */ #endif /* YYBTYACC */ #define YYPREFIX "destroy1_" #define YYPURE 0 #line 4 "btyacc_destroy1.y" #include typedef enum {cGLOBAL, cLOCAL} class; typedef enum {tREAL, tINTEGER} type; typedef char * name; struct symbol { class c; type t; name id; }; typedef struct symbol symbol; struct namelist { symbol *s; struct namelist *next; }; typedef struct namelist namelist; struct parser_param { int *rtrn; symbol ss; }; extern symbol *mksymbol(type t, class c, name id); #ifdef YYBISON #define YYLEX_DECL() yylex(void) #define YYERROR_DECL() yyerror(const char *s) #endif #ifdef YYSTYPE #undef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 #endif #ifndef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 #line 50 "btyacc_destroy1.y" -typedef union YYSTYPE +typedef union { class cval; type tval; namelist * nlist; name id; } YYSTYPE; #endif /* !YYSTYPE_IS_DECLARED */ #line 160 "btyacc_destroy1.tab.c" /* compatibility with bison */ #ifdef YYPARSE_PARAM /* compatibility with FreeBSD */ # ifdef YYPARSE_PARAM_TYPE # define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) # else # define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) # endif #else # define YYPARSE_DECL() yyparse(struct parser_param *param, int flag) #endif /* Parameters sent to lex. */ #ifdef YYLEX_PARAM # define YYLEX_DECL() yylex(void *YYLEX_PARAM) # define YYLEX yylex(YYLEX_PARAM) #else # define YYLEX_DECL() yylex(void) # define YYLEX yylex() #endif /* Parameters sent to yyerror. */ #ifndef YYERROR_DECL #define YYERROR_DECL() yyerror(struct parser_param *param, int flag, const char *s) #endif #ifndef YYERROR_CALL #define YYERROR_CALL(msg) yyerror(param, flag, msg) #endif #ifndef YYDESTRUCT_DECL #define YYDESTRUCT_DECL() yydestruct(const char *msg, int psymb, YYSTYPE *val, struct parser_param *param, int flag) #endif #ifndef YYDESTRUCT_CALL #define YYDESTRUCT_CALL(msg, psymb, val) yydestruct(msg, psymb, val, param, flag) #endif extern int YYPARSE_DECL(); #define GLOBAL 257 #define LOCAL 258 #define REAL 259 #define INTEGER 260 #define NAME 261 #define YYERRCODE 256 typedef int YYINT; static const YYINT destroy1_lhs[] = { -1, 0, 0, 2, 2, 3, 3, 4, 4, 1, }; static const YYINT destroy1_len[] = { 2, 8, 5, 1, 1, 1, 1, 2, 1, 6, }; static const YYINT destroy1_defred[] = { 0, 3, 4, 5, 6, 0, 0, 0, 0, 8, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 9, 1, }; #if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) static const YYINT destroy1_stos[] = { 0, 257, 258, 259, 260, 263, 265, 266, 266, 261, 264, 267, 267, 40, 261, 40, 40, 265, 258, 265, 41, 44, 44, 266, 266, 41, 41, }; #endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ static const YYINT destroy1_dgoto[] = { 5, 10, 6, 7, 11, }; static const YYINT destroy1_sindex[] = { -254, 0, 0, 0, 0, 0, -251, -248, -248, 0, -26, -40, -39, -246, 0, -243, -246, -25, -24, -23, 0, -251, -251, -22, -19, 0, 0, }; static const YYINT destroy1_rindex[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; #if YYBTYACC static const YYINT destroy1_cindex[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; #endif static const YYINT destroy1_gindex[] = { 0, 0, -6, -4, 15, }; #define YYTABLESIZE 222 static const YYINT destroy1_table[] = { 15, 16, 8, 1, 2, 3, 4, 17, 3, 4, 19, 1, 2, 9, 13, 18, 20, 23, 24, 25, 21, 22, 26, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 14, }; static const YYINT destroy1_check[] = { 40, 40, 6, 257, 258, 259, 260, 13, 259, 260, 16, 257, 258, 261, 40, 258, 41, 21, 22, 41, 44, 44, 41, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 261, 261, }; #if YYBTYACC static const YYINT destroy1_ctable[] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, }; #endif #define YYFINAL 5 #ifndef YYDEBUG #define YYDEBUG 0 #endif #define YYMAXTOKEN 261 #define YYUNDFTOKEN 268 #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) #if YYDEBUG static const char *const destroy1_name[] = { "$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, 0,0,0,"'('","')'",0,0,"','",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"error","GLOBAL","LOCAL", "REAL","INTEGER","NAME","$accept","declaration","locnamelist","class","type", "namelist","illegal-symbol", }; static const char *const destroy1_rule[] = { "$accept : declaration", "declaration : class type namelist '(' class ',' type ')'", "declaration : type locnamelist '(' class ')'", "class : GLOBAL", "class : LOCAL", "type : REAL", "type : INTEGER", "namelist : namelist NAME", "namelist : NAME", "locnamelist : namelist '(' LOCAL ',' type ')'", }; #endif #if YYDEBUG int yydebug; #endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; int yynerrs; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyloc; /* position returned by actions */ YYLTYPE yylloc; /* position from the lexer */ #endif #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) #ifndef YYLLOC_DEFAULT #define YYLLOC_DEFAULT(loc, rhs, n) \ do \ { \ if (n == 0) \ { \ (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ } \ else \ { \ (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ (loc).last_line = YYRHSLOC(rhs, n).last_line; \ (loc).last_column = YYRHSLOC(rhs, n).last_column; \ } \ } while (0) #endif /* YYLLOC_DEFAULT */ #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ #if YYBTYACC #ifndef YYLVQUEUEGROWTH #define YYLVQUEUEGROWTH 32 #endif #endif /* YYBTYACC */ /* define the initial stack-sizes */ #ifdef YYSTACKSIZE #undef YYMAXDEPTH #define YYMAXDEPTH YYSTACKSIZE #else #ifdef YYMAXDEPTH #define YYSTACKSIZE YYMAXDEPTH #else #define YYSTACKSIZE 10000 #define YYMAXDEPTH 10000 #endif #endif #ifndef YYINITSTACKSIZE #define YYINITSTACKSIZE 200 #endif typedef struct { unsigned stacksize; YYINT *s_base; YYINT *s_mark; YYINT *s_last; YYSTYPE *l_base; YYSTYPE *l_mark; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE *p_base; YYLTYPE *p_mark; #endif } YYSTACKDATA; #if YYBTYACC struct YYParseState_s { struct YYParseState_s *save; /* Previously saved parser state */ YYSTACKDATA yystack; /* saved parser stack */ int state; /* saved parser state */ int errflag; /* saved error recovery status */ int lexeme; /* saved index of the conflict lexeme in the lexical queue */ YYINT ctry; /* saved index in yyctable[] for this conflict */ }; typedef struct YYParseState_s YYParseState; #endif /* YYBTYACC */ /* variables for the parser stack */ static YYSTACKDATA yystack; #if YYBTYACC /* Current parser state */ static YYParseState *yyps = 0; /* yypath != NULL: do the full parse, starting at *yypath parser state. */ static YYParseState *yypath = 0; /* Base of the lexical value queue */ static YYSTYPE *yylvals = 0; /* Current position at lexical value queue */ static YYSTYPE *yylvp = 0; /* End position of lexical value queue */ static YYSTYPE *yylve = 0; /* The last allocated position at the lexical value queue */ static YYSTYPE *yylvlim = 0; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* Base of the lexical position queue */ static YYLTYPE *yylpsns = 0; /* Current position at lexical position queue */ static YYLTYPE *yylpp = 0; /* End position of lexical position queue */ static YYLTYPE *yylpe = 0; /* The last allocated position at the lexical position queue */ static YYLTYPE *yylplim = 0; #endif /* Current position at lexical token queue */ static YYINT *yylexp = 0; static YYINT *yylexemes = 0; #endif /* YYBTYACC */ #line 89 "btyacc_destroy1.y" extern int YYLEX_DECL(); extern void YYERROR_DECL(); #line 492 "btyacc_destroy1.tab.c" /* Release memory associated with symbol. */ #if ! defined YYDESTRUCT_IS_DECLARED static void YYDESTRUCT_DECL() { switch (psymb) { case 263: #line 41 "btyacc_destroy1.y" { namelist *p = (*val).nlist; while (p != NULL) { namelist *pp = p; p = p->next; free(pp->s); free(pp); } } #line 511 "btyacc_destroy1.tab.c" break; } } #define YYDESTRUCT_IS_DECLARED 1 #endif /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) #if YYBTYACC #define yytrial (yyps->save) #endif /* YYBTYACC */ #if YYDEBUG #include /* needed for printf */ #endif #include /* needed for malloc, etc */ #include /* needed for memset */ /* allocate initial stack or double stack size, up to YYMAXDEPTH */ static int yygrowstack(YYSTACKDATA *data) { int i; unsigned newsize; YYINT *newss; YYSTYPE *newvs; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE *newps; #endif if ((newsize = data->stacksize) == 0) newsize = YYINITSTACKSIZE; else if (newsize >= YYMAXDEPTH) return YYENOMEM; else if ((newsize *= 2) > YYMAXDEPTH) newsize = YYMAXDEPTH; i = (int) (data->s_mark - data->s_base); newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); if (newss == NULL) return YYENOMEM; data->s_base = newss; data->s_mark = newss + i; newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); if (newvs == NULL) return YYENOMEM; data->l_base = newvs; data->l_mark = newvs + i; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); if (newps == NULL) return YYENOMEM; data->p_base = newps; data->p_mark = newps + i; #endif data->stacksize = newsize; data->s_last = data->s_base + newsize - 1; #if YYDEBUG if (yydebug) fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); #endif return 0; } #if YYPURE || defined(YY_NO_LEAKS) static void yyfreestack(YYSTACKDATA *data) { free(data->s_base); free(data->l_base); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) free(data->p_base); #endif memset(data, 0, sizeof(*data)); } #else #define yyfreestack(data) /* nothing */ #endif /* YYPURE || defined(YY_NO_LEAKS) */ #if YYBTYACC static YYParseState * yyNewState(unsigned size) { YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); if (p == NULL) return NULL; p->yystack.stacksize = size; if (size == 0) { p->yystack.s_base = NULL; p->yystack.l_base = NULL; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) p->yystack.p_base = NULL; #endif return p; } p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); if (p->yystack.s_base == NULL) return NULL; p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); if (p->yystack.l_base == NULL) return NULL; memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); if (p->yystack.p_base == NULL) return NULL; memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); #endif return p; } static void yyFreeState(YYParseState *p) { yyfreestack(&p->yystack); free(p); } #endif /* YYBTYACC */ #define YYABORT goto yyabort #define YYREJECT goto yyabort #define YYACCEPT goto yyaccept #define YYERROR goto yyerrlab #if YYBTYACC #define YYVALID do { if (yyps->save) goto yyvalid; } while(0) #define YYVALID_NESTED do { if (yyps->save && \ yyps->save->save == 0) goto yyvalid; } while(0) #endif /* YYBTYACC */ int YYPARSE_DECL() { int yym, yyn, yystate, yyresult; #if YYBTYACC int yynewerrflag; YYParseState *yyerrctx = NULL; #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ #endif #if YYDEBUG const char *yys; if ((yys = getenv("YYDEBUG")) != NULL) { yyn = *yys; if (yyn >= '0' && yyn <= '9') yydebug = yyn - '0'; } if (yydebug) fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); #endif #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); #endif #if YYBTYACC yyps = yyNewState(0); if (yyps == 0) goto yyenomem; yyps->save = 0; #endif /* YYBTYACC */ yym = 0; /* yyn is set below */ yynerrs = 0; yyerrflag = 0; yychar = YYEMPTY; yystate = 0; #if YYPURE memset(&yystack, 0, sizeof(yystack)); #endif if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystack.s_mark = yystack.s_base; yystack.l_mark = yystack.l_base; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark = yystack.p_base; #endif yystate = 0; *yystack.s_mark = 0; yyloop: if ((yyn = yydefred[yystate]) != 0) goto yyreduce; if (yychar < 0) { #if YYBTYACC do { if (yylvp < yylve) { /* we're currently re-reading tokens */ yylval = *yylvp++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylloc = *yylpp++; #endif yychar = *yylexp++; break; } if (yyps->save) { /* in trial mode; save scanner results for future parse attempts */ if (yylvp == yylvlim) { /* Enlarge lexical value queue */ size_t p = (size_t) (yylvp - yylvals); size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpe = yylpsns + p; yylplim = yylpsns + s; #endif yylexp = yylexemes + p; } *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpp++ = yylloc; yylpe++; #endif yychar = *yylexp++; break; } /* normal operation, no conflict encountered */ #endif /* YYBTYACC */ yychar = YYLEX; #if YYBTYACC } while (0); #endif /* YYBTYACC */ if (yychar < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", YYDEBUGSTR, yydepth, yystate, yychar, yys); #ifdef YYSTYPE_TOSTRING #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); #endif fputc('\n', stderr); } #endif } #if YYBTYACC /* Do we have a conflict? */ if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) { YYINT ctry; if (yypath) { YYParseState *save; #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", YYDEBUGSTR, yydepth, yystate); #endif /* Switch to the next conflict context */ save = yypath; yypath = save->save; save->save = NULL; ctry = save->ctry; if (save->state != yystate) YYABORT; yyFreeState(save); } else { /* Unresolved conflict - start/continue trial parse */ YYParseState *save; #if YYDEBUG if (yydebug) { fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); if (yyps->save) fputs("ALREADY in conflict, continuing trial parse.\n", stderr); else fputs("Starting trial parse.\n", stderr); } #endif save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); if (save == NULL) goto yyenomem; save->save = yyps->save; save->state = yystate; save->errflag = yyerrflag; save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif ctry = yytable[yyn]; if (yyctable[ctry] == -1) { #if YYDEBUG if (yydebug && yychar >= YYEOF) fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); #endif ctry++; } save->ctry = ctry; if (yyps->save == NULL) { /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; yylvlim = yylvals + YYLVQUEUEGROWTH; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); if (yylpsns == NULL) goto yyenomem; yylplim = yylpsns + YYLVQUEUEGROWTH; #endif } if (yylvp == yylve) { yylvp = yylve = yylvals; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpe = yylpsns; #endif yylexp = yylexemes; if (yychar >= YYEOF) { *yylve++ = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpe++ = yylloc; #endif *yylexp = (YYINT) yychar; yychar = YYEMPTY; } } } if (yychar >= YYEOF) { yylvp--; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp--; #endif yylexp--; yychar = YYEMPTY; } save->lexeme = (int) (yylvp - yylvals); yyps->save = save; } if (yytable[yyn] == ctry) { #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); #endif if (yychar < 0) { yylvp++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp++; #endif yylexp++; } if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystate = yyctable[ctry]; *++yystack.s_mark = (YYINT) yystate; *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *++yystack.p_mark = yylloc; #endif yychar = YYEMPTY; if (yyerrflag > 0) --yyerrflag; goto yyloop; } else { yyn = yyctable[ctry]; goto yyreduce; } } /* End of code dealing with conflicts */ #endif /* YYBTYACC */ if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) { #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", YYDEBUGSTR, yydepth, yystate, yytable[yyn]); #endif if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystate = yytable[yyn]; *++yystack.s_mark = yytable[yyn]; *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *++yystack.p_mark = yylloc; #endif yychar = YYEMPTY; if (yyerrflag > 0) --yyerrflag; goto yyloop; } if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) { yyn = yytable[yyn]; goto yyreduce; } if (yyerrflag != 0) goto yyinrecovery; #if YYBTYACC yynewerrflag = 1; goto yyerrhandler; goto yyerrlab; /* redundant goto avoids 'unused label' warning */ yyerrlab: /* explicit YYERROR from an action -- pop the rhs of the rule reduced * before looking for error recovery */ yystack.s_mark -= yym; yystate = *yystack.s_mark; yystack.l_mark -= yym; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark -= yym; #endif yynewerrflag = 0; yyerrhandler: while (yyps->save) { int ctry; YYParseState *save = yyps->save; #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", YYDEBUGSTR, yydepth, yystate, yyps->save->state, (int)(yylvp - yylvals - yyps->save->lexeme)); #endif /* Memorize most forward-looking error state in case it's really an error. */ if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) { /* Free old saved error context state */ if (yyerrctx) yyFreeState(yyerrctx); /* Create and fill out new saved error context state */ yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); if (yyerrctx == NULL) goto yyenomem; yyerrctx->save = yyps->save; yyerrctx->state = yystate; yyerrctx->errflag = yyerrflag; yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif yyerrctx->lexeme = (int) (yylvp - yylvals); } yylvp = yylvals + save->lexeme; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpsns + save->lexeme; #endif yylexp = yylexemes + save->lexeme; yychar = YYEMPTY; yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif ctry = ++save->ctry; yystate = save->state; /* We tried shift, try reduce now */ if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; yyps->save = save->save; save->save = NULL; yyFreeState(save); /* Nothing left on the stack -- error */ if (!yyps->save) { #if YYDEBUG if (yydebug) fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", YYPREFIX, yydepth); #endif /* Restore state as it was in the most forward-advanced error */ yylvp = yylvals + yyerrctx->lexeme; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpsns + yyerrctx->lexeme; #endif yylexp = yylexemes + yyerrctx->lexeme; yychar = yylexp[-1]; yylval = yylvp[-1]; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylloc = yylpp[-1]; #endif yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif yystate = yyerrctx->state; yyFreeState(yyerrctx); yyerrctx = NULL; } yynewerrflag = 1; } if (yynewerrflag == 0) goto yyinrecovery; #endif /* YYBTYACC */ YYERROR_CALL("syntax error"); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ #endif #if !YYBTYACC goto yyerrlab; /* redundant goto avoids 'unused label' warning */ yyerrlab: #endif ++yynerrs; yyinrecovery: if (yyerrflag < 3) { yyerrflag = 3; for (;;) { if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) { #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); #endif if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystate = yytable[yyn]; *++yystack.s_mark = yytable[yyn]; *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* lookahead position is error end position */ yyerror_loc_range[2] = yylloc; YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ *++yystack.p_mark = yyloc; #endif goto yyloop; } else { #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", YYDEBUGSTR, yydepth, *yystack.s_mark); #endif if (yystack.s_mark <= yystack.s_base) goto yyabort; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* the current TOS position is the error start position */ yyerror_loc_range[1] = *yystack.p_mark; #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYDESTRUCT_CALL("error: discarding state", yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); #else YYDESTRUCT_CALL("error: discarding state", yystos[*yystack.s_mark], yystack.l_mark); #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ #endif /* defined(YYDESTRUCT_CALL) */ --yystack.s_mark; --yystack.l_mark; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) --yystack.p_mark; #endif } } } else { if (yychar == YYEOF) goto yyabort; #if YYDEBUG if (yydebug) { if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", YYDEBUGSTR, yydepth, yystate, yychar, yys); } #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); #else YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ #endif /* defined(YYDESTRUCT_CALL) */ yychar = YYEMPTY; goto yyloop; } yyreduce: yym = yylen[yyn]; #if YYDEBUG if (yydebug) { fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); #ifdef YYSTYPE_TOSTRING #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ if (yym > 0) { int i; fputc('<', stderr); for (i = yym; i > 0; i--) { if (i != yym) fputs(", ", stderr); fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], yystack.l_mark[1-i]), stderr); } fputc('>', stderr); } #endif fputc('\n', stderr); } #endif if (yym > 0) yyval = yystack.l_mark[1-yym]; else memset(&yyval, 0, sizeof yyval); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* Perform position reduction */ memset(&yyloc, 0, sizeof(yyloc)); #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ { YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); /* just in case YYERROR is invoked within the action, save the start of the rhs as the error start position */ yyerror_loc_range[1] = yystack.p_mark[1-yym]; } #endif switch (yyn) { case 1: if (!yytrial) #line 62 "btyacc_destroy1.y" { yyval.nlist = yystack.l_mark[-5].nlist; } #line 1190 "btyacc_destroy1.tab.c" break; case 2: if (!yytrial) #line 64 "btyacc_destroy1.y" { yyval.nlist = yystack.l_mark[-3].nlist; } #line 1196 "btyacc_destroy1.tab.c" break; case 3: if (!yytrial) #line 67 "btyacc_destroy1.y" { yyval.cval = cGLOBAL; } #line 1202 "btyacc_destroy1.tab.c" break; case 4: if (!yytrial) #line 68 "btyacc_destroy1.y" { yyval.cval = cLOCAL; } #line 1208 "btyacc_destroy1.tab.c" break; case 5: if (!yytrial) #line 71 "btyacc_destroy1.y" { yyval.tval = tREAL; } #line 1214 "btyacc_destroy1.tab.c" break; case 6: if (!yytrial) #line 72 "btyacc_destroy1.y" { yyval.tval = tINTEGER; } #line 1220 "btyacc_destroy1.tab.c" break; case 7: if (!yytrial) #line 76 "btyacc_destroy1.y" { yyval.nlist->s = mksymbol(yystack.l_mark[-2].tval, yystack.l_mark[-2].cval, yystack.l_mark[0].id); yyval.nlist->next = yystack.l_mark[-1].nlist; } #line 1228 "btyacc_destroy1.tab.c" break; case 8: if (!yytrial) #line 80 "btyacc_destroy1.y" { yyval.nlist->s = mksymbol(0, 0, yystack.l_mark[0].id); yyval.nlist->next = NULL; } #line 1236 "btyacc_destroy1.tab.c" break; case 9: if (!yytrial) #line 86 "btyacc_destroy1.y" { yyval.nlist = yystack.l_mark[-5].nlist; } #line 1242 "btyacc_destroy1.tab.c" break; #line 1244 "btyacc_destroy1.tab.c" default: break; } yystack.s_mark -= yym; yystate = *yystack.s_mark; yystack.l_mark -= yym; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark -= yym; #endif yym = yylhs[yyn]; if (yystate == 0 && yym == 0) { #if YYDEBUG if (yydebug) { fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); #ifdef YYSTYPE_TOSTRING #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); #endif fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); } #endif yystate = YYFINAL; *++yystack.s_mark = YYFINAL; *++yystack.l_mark = yyval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *++yystack.p_mark = yyloc; #endif if (yychar < 0) { #if YYBTYACC do { if (yylvp < yylve) { /* we're currently re-reading tokens */ yylval = *yylvp++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylloc = *yylpp++; #endif yychar = *yylexp++; break; } if (yyps->save) { /* in trial mode; save scanner results for future parse attempts */ if (yylvp == yylvlim) { /* Enlarge lexical value queue */ size_t p = (size_t) (yylvp - yylvals); size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpe = yylpsns + p; yylplim = yylpsns + s; #endif yylexp = yylexemes + p; } *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpp++ = yylloc; yylpe++; #endif yychar = *yylexp++; break; } /* normal operation, no conflict encountered */ #endif /* YYBTYACC */ yychar = YYLEX; #if YYBTYACC } while (0); #endif /* YYBTYACC */ if (yychar < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); } #endif } if (yychar == YYEOF) goto yyaccept; goto yyloop; } if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) yystate = yytable[yyn]; else yystate = yydgoto[yym]; #if YYDEBUG if (yydebug) { fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); #ifdef YYSTYPE_TOSTRING #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); #endif fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); } #endif if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; *++yystack.s_mark = (YYINT) yystate; *++yystack.l_mark = yyval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *++yystack.p_mark = yyloc; #endif goto yyloop; #if YYBTYACC /* Reduction declares that this path is valid. Set yypath and do a full parse */ yyvalid: if (yypath) YYABORT; while (yyps->save) { YYParseState *save = yyps->save; yyps->save = save->save; save->save = yypath; yypath = save; } #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); #endif if (yyerrctx) { yyFreeState(yyerrctx); yyerrctx = NULL; } yylvp = yylvals + yypath->lexeme; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpsns + yypath->lexeme; #endif yylexp = yylexemes + yypath->lexeme; yychar = YYEMPTY; yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif yystate = yypath->state; goto yyloop; #endif /* YYBTYACC */ yyoverflow: YYERROR_CALL("yacc stack overflow"); #if YYBTYACC goto yyabort_nomem; yyenomem: YYERROR_CALL("memory exhausted"); yyabort_nomem: #endif /* YYBTYACC */ yyresult = 2; goto yyreturn; yyabort: yyresult = 1; goto yyreturn; yyaccept: #if YYBTYACC if (yyps->save) goto yyvalid; #endif /* YYBTYACC */ yyresult = 0; yyreturn: #if defined(YYDESTRUCT_CALL) if (yychar != YYEOF && yychar != YYEMPTY) #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); #else YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ { YYSTYPE *pv; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE *pp; for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) YYDESTRUCT_CALL("cleanup: discarding state", yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); #else for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) YYDESTRUCT_CALL("cleanup: discarding state", yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ } #endif /* defined(YYDESTRUCT_CALL) */ #if YYBTYACC if (yyerrctx) { yyFreeState(yyerrctx); yyerrctx = NULL; } while (yyps) { YYParseState *save = yyps; yyps = save->save; save->save = NULL; yyFreeState(save); } while (yypath) { YYParseState *save = yypath; yypath = save->save; save->save = NULL; yyFreeState(save); } #endif /* YYBTYACC */ yyfreestack(&yystack); return (yyresult); } diff --git a/contrib/byacc/test/btyacc/btyacc_destroy1.tab.h b/contrib/byacc/test/btyacc/btyacc_destroy1.tab.h index fd25e13b0019..21b0bc21fe86 100644 --- a/contrib/byacc/test/btyacc/btyacc_destroy1.tab.h +++ b/contrib/byacc/test/btyacc/btyacc_destroy1.tab.h @@ -1,25 +1,25 @@ #ifndef _destroy1__defines_h_ #define _destroy1__defines_h_ #define GLOBAL 257 #define LOCAL 258 #define REAL 259 #define INTEGER 260 #define NAME 261 #ifdef YYSTYPE #undef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 #endif #ifndef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 -typedef union YYSTYPE +typedef union { class cval; type tval; namelist * nlist; name id; } YYSTYPE; #endif /* !YYSTYPE_IS_DECLARED */ extern YYSTYPE destroy1_lval; #endif /* _destroy1__defines_h_ */ diff --git a/contrib/byacc/test/btyacc/btyacc_destroy2.tab.c b/contrib/byacc/test/btyacc/btyacc_destroy2.tab.c index 1c7ac86fc24f..8f0dd0975fe2 100644 --- a/contrib/byacc/test/btyacc/btyacc_destroy2.tab.c +++ b/contrib/byacc/test/btyacc/btyacc_destroy2.tab.c @@ -1,1477 +1,1477 @@ /* original parser id follows */ /* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ /* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ #define YYBYACC 1 #define YYMAJOR 2 #define YYMINOR 0 #define YYCHECK "yyyymmdd" #define YYEMPTY (-1) #define yyclearin (yychar = YYEMPTY) #define yyerrok (yyerrflag = 0) #define YYRECOVERING() (yyerrflag != 0) #define YYENOMEM (-2) #define YYEOF 0 #undef YYBTYACC #define YYBTYACC 1 #define YYDEBUGSTR (yytrial ? YYPREFIX "debug(trial)" : YYPREFIX "debug") #ifndef yyparse #define yyparse destroy2_parse #endif /* yyparse */ #ifndef yylex #define yylex destroy2_lex #endif /* yylex */ #ifndef yyerror #define yyerror destroy2_error #endif /* yyerror */ #ifndef yychar #define yychar destroy2_char #endif /* yychar */ #ifndef yyval #define yyval destroy2_val #endif /* yyval */ #ifndef yylval #define yylval destroy2_lval #endif /* yylval */ #ifndef yydebug #define yydebug destroy2_debug #endif /* yydebug */ #ifndef yynerrs #define yynerrs destroy2_nerrs #endif /* yynerrs */ #ifndef yyerrflag #define yyerrflag destroy2_errflag #endif /* yyerrflag */ #ifndef yylhs #define yylhs destroy2_lhs #endif /* yylhs */ #ifndef yylen #define yylen destroy2_len #endif /* yylen */ #ifndef yydefred #define yydefred destroy2_defred #endif /* yydefred */ #ifndef yystos #define yystos destroy2_stos #endif /* yystos */ #ifndef yydgoto #define yydgoto destroy2_dgoto #endif /* yydgoto */ #ifndef yysindex #define yysindex destroy2_sindex #endif /* yysindex */ #ifndef yyrindex #define yyrindex destroy2_rindex #endif /* yyrindex */ #ifndef yygindex #define yygindex destroy2_gindex #endif /* yygindex */ #ifndef yytable #define yytable destroy2_table #endif /* yytable */ #ifndef yycheck #define yycheck destroy2_check #endif /* yycheck */ #ifndef yyname #define yyname destroy2_name #endif /* yyname */ #ifndef yyrule #define yyrule destroy2_rule #endif /* yyrule */ #if YYBTYACC #ifndef yycindex #define yycindex destroy2_cindex #endif /* yycindex */ #ifndef yyctable #define yyctable destroy2_ctable #endif /* yyctable */ #endif /* YYBTYACC */ #define YYPREFIX "destroy2_" #define YYPURE 0 #line 4 "btyacc_destroy2.y" #include typedef enum {cGLOBAL, cLOCAL} class; typedef enum {tREAL, tINTEGER} type; typedef char * name; struct symbol { class c; type t; name id; }; typedef struct symbol symbol; struct namelist { symbol *s; struct namelist *next; }; typedef struct namelist namelist; struct parser_param { int *rtrn; symbol ss; }; extern symbol *mksymbol(type t, class c, name id); #ifdef YYBISON #define YYLEX_DECL() yylex(void) #define YYERROR_DECL() yyerror(const char *s) #endif #ifdef YYSTYPE #undef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 #endif #ifndef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 #line 50 "btyacc_destroy2.y" -typedef union YYSTYPE +typedef union { class cval; type tval; namelist * nlist; name id; } YYSTYPE; #endif /* !YYSTYPE_IS_DECLARED */ #line 160 "btyacc_destroy2.tab.c" /* compatibility with bison */ #ifdef YYPARSE_PARAM /* compatibility with FreeBSD */ # ifdef YYPARSE_PARAM_TYPE # define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) # else # define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) # endif #else # define YYPARSE_DECL() yyparse(struct parser_param *param, int flag) #endif /* Parameters sent to lex. */ #ifdef YYLEX_PARAM # define YYLEX_DECL() yylex(void *YYLEX_PARAM) # define YYLEX yylex(YYLEX_PARAM) #else # define YYLEX_DECL() yylex(void) # define YYLEX yylex() #endif /* Parameters sent to yyerror. */ #ifndef YYERROR_DECL #define YYERROR_DECL() yyerror(struct parser_param *param, int flag, const char *s) #endif #ifndef YYERROR_CALL #define YYERROR_CALL(msg) yyerror(param, flag, msg) #endif #ifndef YYDESTRUCT_DECL #define YYDESTRUCT_DECL() yydestruct(const char *msg, int psymb, YYSTYPE *val, struct parser_param *param, int flag) #endif #ifndef YYDESTRUCT_CALL #define YYDESTRUCT_CALL(msg, psymb, val) yydestruct(msg, psymb, val, param, flag) #endif extern int YYPARSE_DECL(); #define GLOBAL 257 #define LOCAL 258 #define REAL 259 #define INTEGER 260 #define NAME 261 #define YYERRCODE 256 typedef int YYINT; static const YYINT destroy2_lhs[] = { -1, 0, 0, 2, 2, 3, 3, 4, 4, 1, }; static const YYINT destroy2_len[] = { 2, 8, 5, 1, 1, 1, 1, 2, 1, 6, }; static const YYINT destroy2_defred[] = { 0, 3, 4, 5, 6, 0, 0, 0, 0, 8, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 9, 1, }; #if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) static const YYINT destroy2_stos[] = { 0, 257, 258, 259, 260, 263, 265, 266, 266, 261, 264, 267, 267, 40, 261, 40, 40, 265, 258, 265, 41, 44, 44, 266, 266, 41, 41, }; #endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ static const YYINT destroy2_dgoto[] = { 5, 10, 6, 7, 11, }; static const YYINT destroy2_sindex[] = { -254, 0, 0, 0, 0, 0, -251, -248, -248, 0, -26, -40, -39, -246, 0, -243, -246, -25, -24, -23, 0, -251, -251, -22, -19, 0, 0, }; static const YYINT destroy2_rindex[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; #if YYBTYACC static const YYINT destroy2_cindex[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; #endif static const YYINT destroy2_gindex[] = { 0, 0, -6, -4, 15, }; #define YYTABLESIZE 222 static const YYINT destroy2_table[] = { 15, 16, 8, 1, 2, 3, 4, 17, 3, 4, 19, 1, 2, 9, 13, 18, 20, 23, 24, 25, 21, 22, 26, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 14, }; static const YYINT destroy2_check[] = { 40, 40, 6, 257, 258, 259, 260, 13, 259, 260, 16, 257, 258, 261, 40, 258, 41, 21, 22, 41, 44, 44, 41, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 261, 261, }; #if YYBTYACC static const YYINT destroy2_ctable[] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, }; #endif #define YYFINAL 5 #ifndef YYDEBUG #define YYDEBUG 0 #endif #define YYMAXTOKEN 261 #define YYUNDFTOKEN 268 #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) #if YYDEBUG static const char *const destroy2_name[] = { "$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, 0,0,0,"'('","')'",0,0,"','",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"error","GLOBAL","LOCAL", "REAL","INTEGER","NAME","$accept","declaration","locnamelist","class","type", "namelist","illegal-symbol", }; static const char *const destroy2_rule[] = { "$accept : declaration", "declaration : class type namelist '(' class ',' type ')'", "declaration : type locnamelist '(' class ')'", "class : GLOBAL", "class : LOCAL", "type : REAL", "type : INTEGER", "namelist : namelist NAME", "namelist : NAME", "locnamelist : namelist '(' LOCAL ',' type ')'", }; #endif #if YYDEBUG int yydebug; #endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; int yynerrs; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyloc; /* position returned by actions */ YYLTYPE yylloc; /* position from the lexer */ #endif #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) #ifndef YYLLOC_DEFAULT #define YYLLOC_DEFAULT(loc, rhs, n) \ do \ { \ if (n == 0) \ { \ (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ } \ else \ { \ (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ (loc).last_line = YYRHSLOC(rhs, n).last_line; \ (loc).last_column = YYRHSLOC(rhs, n).last_column; \ } \ } while (0) #endif /* YYLLOC_DEFAULT */ #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ #if YYBTYACC #ifndef YYLVQUEUEGROWTH #define YYLVQUEUEGROWTH 32 #endif #endif /* YYBTYACC */ /* define the initial stack-sizes */ #ifdef YYSTACKSIZE #undef YYMAXDEPTH #define YYMAXDEPTH YYSTACKSIZE #else #ifdef YYMAXDEPTH #define YYSTACKSIZE YYMAXDEPTH #else #define YYSTACKSIZE 10000 #define YYMAXDEPTH 10000 #endif #endif #ifndef YYINITSTACKSIZE #define YYINITSTACKSIZE 200 #endif typedef struct { unsigned stacksize; YYINT *s_base; YYINT *s_mark; YYINT *s_last; YYSTYPE *l_base; YYSTYPE *l_mark; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE *p_base; YYLTYPE *p_mark; #endif } YYSTACKDATA; #if YYBTYACC struct YYParseState_s { struct YYParseState_s *save; /* Previously saved parser state */ YYSTACKDATA yystack; /* saved parser stack */ int state; /* saved parser state */ int errflag; /* saved error recovery status */ int lexeme; /* saved index of the conflict lexeme in the lexical queue */ YYINT ctry; /* saved index in yyctable[] for this conflict */ }; typedef struct YYParseState_s YYParseState; #endif /* YYBTYACC */ /* variables for the parser stack */ static YYSTACKDATA yystack; #if YYBTYACC /* Current parser state */ static YYParseState *yyps = 0; /* yypath != NULL: do the full parse, starting at *yypath parser state. */ static YYParseState *yypath = 0; /* Base of the lexical value queue */ static YYSTYPE *yylvals = 0; /* Current position at lexical value queue */ static YYSTYPE *yylvp = 0; /* End position of lexical value queue */ static YYSTYPE *yylve = 0; /* The last allocated position at the lexical value queue */ static YYSTYPE *yylvlim = 0; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* Base of the lexical position queue */ static YYLTYPE *yylpsns = 0; /* Current position at lexical position queue */ static YYLTYPE *yylpp = 0; /* End position of lexical position queue */ static YYLTYPE *yylpe = 0; /* The last allocated position at the lexical position queue */ static YYLTYPE *yylplim = 0; #endif /* Current position at lexical token queue */ static YYINT *yylexp = 0; static YYINT *yylexemes = 0; #endif /* YYBTYACC */ #line 89 "btyacc_destroy2.y" extern int YYLEX_DECL(); extern void YYERROR_DECL(); #line 492 "btyacc_destroy2.tab.c" /* Release memory associated with symbol. */ #if ! defined YYDESTRUCT_IS_DECLARED static void YYDESTRUCT_DECL() { switch (psymb) { case 263: #line 41 "btyacc_destroy2.y" { namelist *p = (*val).nlist; while (p != NULL) { namelist *pp = p; p = p->next; free(pp->s); free(pp); } } #line 511 "btyacc_destroy2.tab.c" break; } } #define YYDESTRUCT_IS_DECLARED 1 #endif /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) #if YYBTYACC #define yytrial (yyps->save) #endif /* YYBTYACC */ #if YYDEBUG #include /* needed for printf */ #endif #include /* needed for malloc, etc */ #include /* needed for memset */ /* allocate initial stack or double stack size, up to YYMAXDEPTH */ static int yygrowstack(YYSTACKDATA *data) { int i; unsigned newsize; YYINT *newss; YYSTYPE *newvs; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE *newps; #endif if ((newsize = data->stacksize) == 0) newsize = YYINITSTACKSIZE; else if (newsize >= YYMAXDEPTH) return YYENOMEM; else if ((newsize *= 2) > YYMAXDEPTH) newsize = YYMAXDEPTH; i = (int) (data->s_mark - data->s_base); newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); if (newss == NULL) return YYENOMEM; data->s_base = newss; data->s_mark = newss + i; newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); if (newvs == NULL) return YYENOMEM; data->l_base = newvs; data->l_mark = newvs + i; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); if (newps == NULL) return YYENOMEM; data->p_base = newps; data->p_mark = newps + i; #endif data->stacksize = newsize; data->s_last = data->s_base + newsize - 1; #if YYDEBUG if (yydebug) fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); #endif return 0; } #if YYPURE || defined(YY_NO_LEAKS) static void yyfreestack(YYSTACKDATA *data) { free(data->s_base); free(data->l_base); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) free(data->p_base); #endif memset(data, 0, sizeof(*data)); } #else #define yyfreestack(data) /* nothing */ #endif /* YYPURE || defined(YY_NO_LEAKS) */ #if YYBTYACC static YYParseState * yyNewState(unsigned size) { YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); if (p == NULL) return NULL; p->yystack.stacksize = size; if (size == 0) { p->yystack.s_base = NULL; p->yystack.l_base = NULL; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) p->yystack.p_base = NULL; #endif return p; } p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); if (p->yystack.s_base == NULL) return NULL; p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); if (p->yystack.l_base == NULL) return NULL; memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); if (p->yystack.p_base == NULL) return NULL; memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); #endif return p; } static void yyFreeState(YYParseState *p) { yyfreestack(&p->yystack); free(p); } #endif /* YYBTYACC */ #define YYABORT goto yyabort #define YYREJECT goto yyabort #define YYACCEPT goto yyaccept #define YYERROR goto yyerrlab #if YYBTYACC #define YYVALID do { if (yyps->save) goto yyvalid; } while(0) #define YYVALID_NESTED do { if (yyps->save && \ yyps->save->save == 0) goto yyvalid; } while(0) #endif /* YYBTYACC */ int YYPARSE_DECL() { int yym, yyn, yystate, yyresult; #if YYBTYACC int yynewerrflag; YYParseState *yyerrctx = NULL; #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ #endif #if YYDEBUG const char *yys; if ((yys = getenv("YYDEBUG")) != NULL) { yyn = *yys; if (yyn >= '0' && yyn <= '9') yydebug = yyn - '0'; } if (yydebug) fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); #endif #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); #endif #if YYBTYACC yyps = yyNewState(0); if (yyps == 0) goto yyenomem; yyps->save = 0; #endif /* YYBTYACC */ yym = 0; /* yyn is set below */ yynerrs = 0; yyerrflag = 0; yychar = YYEMPTY; yystate = 0; #if YYPURE memset(&yystack, 0, sizeof(yystack)); #endif if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystack.s_mark = yystack.s_base; yystack.l_mark = yystack.l_base; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark = yystack.p_base; #endif yystate = 0; *yystack.s_mark = 0; yyloop: if ((yyn = yydefred[yystate]) != 0) goto yyreduce; if (yychar < 0) { #if YYBTYACC do { if (yylvp < yylve) { /* we're currently re-reading tokens */ yylval = *yylvp++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylloc = *yylpp++; #endif yychar = *yylexp++; break; } if (yyps->save) { /* in trial mode; save scanner results for future parse attempts */ if (yylvp == yylvlim) { /* Enlarge lexical value queue */ size_t p = (size_t) (yylvp - yylvals); size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpe = yylpsns + p; yylplim = yylpsns + s; #endif yylexp = yylexemes + p; } *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpp++ = yylloc; yylpe++; #endif yychar = *yylexp++; break; } /* normal operation, no conflict encountered */ #endif /* YYBTYACC */ yychar = YYLEX; #if YYBTYACC } while (0); #endif /* YYBTYACC */ if (yychar < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", YYDEBUGSTR, yydepth, yystate, yychar, yys); #ifdef YYSTYPE_TOSTRING #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); #endif fputc('\n', stderr); } #endif } #if YYBTYACC /* Do we have a conflict? */ if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) { YYINT ctry; if (yypath) { YYParseState *save; #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", YYDEBUGSTR, yydepth, yystate); #endif /* Switch to the next conflict context */ save = yypath; yypath = save->save; save->save = NULL; ctry = save->ctry; if (save->state != yystate) YYABORT; yyFreeState(save); } else { /* Unresolved conflict - start/continue trial parse */ YYParseState *save; #if YYDEBUG if (yydebug) { fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); if (yyps->save) fputs("ALREADY in conflict, continuing trial parse.\n", stderr); else fputs("Starting trial parse.\n", stderr); } #endif save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); if (save == NULL) goto yyenomem; save->save = yyps->save; save->state = yystate; save->errflag = yyerrflag; save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif ctry = yytable[yyn]; if (yyctable[ctry] == -1) { #if YYDEBUG if (yydebug && yychar >= YYEOF) fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); #endif ctry++; } save->ctry = ctry; if (yyps->save == NULL) { /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; yylvlim = yylvals + YYLVQUEUEGROWTH; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); if (yylpsns == NULL) goto yyenomem; yylplim = yylpsns + YYLVQUEUEGROWTH; #endif } if (yylvp == yylve) { yylvp = yylve = yylvals; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpe = yylpsns; #endif yylexp = yylexemes; if (yychar >= YYEOF) { *yylve++ = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpe++ = yylloc; #endif *yylexp = (YYINT) yychar; yychar = YYEMPTY; } } } if (yychar >= YYEOF) { yylvp--; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp--; #endif yylexp--; yychar = YYEMPTY; } save->lexeme = (int) (yylvp - yylvals); yyps->save = save; } if (yytable[yyn] == ctry) { #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); #endif if (yychar < 0) { yylvp++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp++; #endif yylexp++; } if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystate = yyctable[ctry]; *++yystack.s_mark = (YYINT) yystate; *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *++yystack.p_mark = yylloc; #endif yychar = YYEMPTY; if (yyerrflag > 0) --yyerrflag; goto yyloop; } else { yyn = yyctable[ctry]; goto yyreduce; } } /* End of code dealing with conflicts */ #endif /* YYBTYACC */ if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) { #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", YYDEBUGSTR, yydepth, yystate, yytable[yyn]); #endif if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystate = yytable[yyn]; *++yystack.s_mark = yytable[yyn]; *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *++yystack.p_mark = yylloc; #endif yychar = YYEMPTY; if (yyerrflag > 0) --yyerrflag; goto yyloop; } if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) { yyn = yytable[yyn]; goto yyreduce; } if (yyerrflag != 0) goto yyinrecovery; #if YYBTYACC yynewerrflag = 1; goto yyerrhandler; goto yyerrlab; /* redundant goto avoids 'unused label' warning */ yyerrlab: /* explicit YYERROR from an action -- pop the rhs of the rule reduced * before looking for error recovery */ yystack.s_mark -= yym; yystate = *yystack.s_mark; yystack.l_mark -= yym; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark -= yym; #endif yynewerrflag = 0; yyerrhandler: while (yyps->save) { int ctry; YYParseState *save = yyps->save; #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", YYDEBUGSTR, yydepth, yystate, yyps->save->state, (int)(yylvp - yylvals - yyps->save->lexeme)); #endif /* Memorize most forward-looking error state in case it's really an error. */ if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) { /* Free old saved error context state */ if (yyerrctx) yyFreeState(yyerrctx); /* Create and fill out new saved error context state */ yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); if (yyerrctx == NULL) goto yyenomem; yyerrctx->save = yyps->save; yyerrctx->state = yystate; yyerrctx->errflag = yyerrflag; yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif yyerrctx->lexeme = (int) (yylvp - yylvals); } yylvp = yylvals + save->lexeme; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpsns + save->lexeme; #endif yylexp = yylexemes + save->lexeme; yychar = YYEMPTY; yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif ctry = ++save->ctry; yystate = save->state; /* We tried shift, try reduce now */ if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; yyps->save = save->save; save->save = NULL; yyFreeState(save); /* Nothing left on the stack -- error */ if (!yyps->save) { #if YYDEBUG if (yydebug) fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", YYPREFIX, yydepth); #endif /* Restore state as it was in the most forward-advanced error */ yylvp = yylvals + yyerrctx->lexeme; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpsns + yyerrctx->lexeme; #endif yylexp = yylexemes + yyerrctx->lexeme; yychar = yylexp[-1]; yylval = yylvp[-1]; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylloc = yylpp[-1]; #endif yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif yystate = yyerrctx->state; yyFreeState(yyerrctx); yyerrctx = NULL; } yynewerrflag = 1; } if (yynewerrflag == 0) goto yyinrecovery; #endif /* YYBTYACC */ YYERROR_CALL("syntax error"); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ #endif #if !YYBTYACC goto yyerrlab; /* redundant goto avoids 'unused label' warning */ yyerrlab: #endif ++yynerrs; yyinrecovery: if (yyerrflag < 3) { yyerrflag = 3; for (;;) { if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) { #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); #endif if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystate = yytable[yyn]; *++yystack.s_mark = yytable[yyn]; *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* lookahead position is error end position */ yyerror_loc_range[2] = yylloc; YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ *++yystack.p_mark = yyloc; #endif goto yyloop; } else { #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", YYDEBUGSTR, yydepth, *yystack.s_mark); #endif if (yystack.s_mark <= yystack.s_base) goto yyabort; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* the current TOS position is the error start position */ yyerror_loc_range[1] = *yystack.p_mark; #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYDESTRUCT_CALL("error: discarding state", yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); #else YYDESTRUCT_CALL("error: discarding state", yystos[*yystack.s_mark], yystack.l_mark); #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ #endif /* defined(YYDESTRUCT_CALL) */ --yystack.s_mark; --yystack.l_mark; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) --yystack.p_mark; #endif } } } else { if (yychar == YYEOF) goto yyabort; #if YYDEBUG if (yydebug) { if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", YYDEBUGSTR, yydepth, yystate, yychar, yys); } #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); #else YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ #endif /* defined(YYDESTRUCT_CALL) */ yychar = YYEMPTY; goto yyloop; } yyreduce: yym = yylen[yyn]; #if YYDEBUG if (yydebug) { fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); #ifdef YYSTYPE_TOSTRING #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ if (yym > 0) { int i; fputc('<', stderr); for (i = yym; i > 0; i--) { if (i != yym) fputs(", ", stderr); fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], yystack.l_mark[1-i]), stderr); } fputc('>', stderr); } #endif fputc('\n', stderr); } #endif if (yym > 0) yyval = yystack.l_mark[1-yym]; else memset(&yyval, 0, sizeof yyval); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* Perform position reduction */ memset(&yyloc, 0, sizeof(yyloc)); #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ { YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); /* just in case YYERROR is invoked within the action, save the start of the rhs as the error start position */ yyerror_loc_range[1] = yystack.p_mark[1-yym]; } #endif switch (yyn) { case 1: if (!yytrial) #line 62 "btyacc_destroy2.y" { yyval.nlist = yystack.l_mark[-5].nlist; } #line 1190 "btyacc_destroy2.tab.c" break; case 2: if (!yytrial) #line 64 "btyacc_destroy2.y" { yyval.nlist = yystack.l_mark[-3].nlist; } #line 1196 "btyacc_destroy2.tab.c" break; case 3: if (!yytrial) #line 67 "btyacc_destroy2.y" { yyval.cval = cGLOBAL; } #line 1202 "btyacc_destroy2.tab.c" break; case 4: if (!yytrial) #line 68 "btyacc_destroy2.y" { yyval.cval = cLOCAL; } #line 1208 "btyacc_destroy2.tab.c" break; case 5: if (!yytrial) #line 71 "btyacc_destroy2.y" { yyval.tval = tREAL; } #line 1214 "btyacc_destroy2.tab.c" break; case 6: if (!yytrial) #line 72 "btyacc_destroy2.y" { yyval.tval = tINTEGER; } #line 1220 "btyacc_destroy2.tab.c" break; case 7: if (!yytrial) #line 76 "btyacc_destroy2.y" { yyval.nlist->s = mksymbol(yystack.l_mark[-2].tval, yystack.l_mark[-2].cval, yystack.l_mark[0].id); yyval.nlist->next = yystack.l_mark[-1].nlist; } #line 1228 "btyacc_destroy2.tab.c" break; case 8: if (!yytrial) #line 80 "btyacc_destroy2.y" { yyval.nlist->s = mksymbol(0, 0, yystack.l_mark[0].id); yyval.nlist->next = NULL; } #line 1236 "btyacc_destroy2.tab.c" break; case 9: if (!yytrial) #line 86 "btyacc_destroy2.y" { yyval.nlist = yystack.l_mark[-5].nlist; } #line 1242 "btyacc_destroy2.tab.c" break; #line 1244 "btyacc_destroy2.tab.c" default: break; } yystack.s_mark -= yym; yystate = *yystack.s_mark; yystack.l_mark -= yym; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark -= yym; #endif yym = yylhs[yyn]; if (yystate == 0 && yym == 0) { #if YYDEBUG if (yydebug) { fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); #ifdef YYSTYPE_TOSTRING #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); #endif fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); } #endif yystate = YYFINAL; *++yystack.s_mark = YYFINAL; *++yystack.l_mark = yyval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *++yystack.p_mark = yyloc; #endif if (yychar < 0) { #if YYBTYACC do { if (yylvp < yylve) { /* we're currently re-reading tokens */ yylval = *yylvp++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylloc = *yylpp++; #endif yychar = *yylexp++; break; } if (yyps->save) { /* in trial mode; save scanner results for future parse attempts */ if (yylvp == yylvlim) { /* Enlarge lexical value queue */ size_t p = (size_t) (yylvp - yylvals); size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpe = yylpsns + p; yylplim = yylpsns + s; #endif yylexp = yylexemes + p; } *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpp++ = yylloc; yylpe++; #endif yychar = *yylexp++; break; } /* normal operation, no conflict encountered */ #endif /* YYBTYACC */ yychar = YYLEX; #if YYBTYACC } while (0); #endif /* YYBTYACC */ if (yychar < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); } #endif } if (yychar == YYEOF) goto yyaccept; goto yyloop; } if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) yystate = yytable[yyn]; else yystate = yydgoto[yym]; #if YYDEBUG if (yydebug) { fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); #ifdef YYSTYPE_TOSTRING #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); #endif fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); } #endif if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; *++yystack.s_mark = (YYINT) yystate; *++yystack.l_mark = yyval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *++yystack.p_mark = yyloc; #endif goto yyloop; #if YYBTYACC /* Reduction declares that this path is valid. Set yypath and do a full parse */ yyvalid: if (yypath) YYABORT; while (yyps->save) { YYParseState *save = yyps->save; yyps->save = save->save; save->save = yypath; yypath = save; } #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); #endif if (yyerrctx) { yyFreeState(yyerrctx); yyerrctx = NULL; } yylvp = yylvals + yypath->lexeme; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpsns + yypath->lexeme; #endif yylexp = yylexemes + yypath->lexeme; yychar = YYEMPTY; yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif yystate = yypath->state; goto yyloop; #endif /* YYBTYACC */ yyoverflow: YYERROR_CALL("yacc stack overflow"); #if YYBTYACC goto yyabort_nomem; yyenomem: YYERROR_CALL("memory exhausted"); yyabort_nomem: #endif /* YYBTYACC */ yyresult = 2; goto yyreturn; yyabort: yyresult = 1; goto yyreturn; yyaccept: #if YYBTYACC if (yyps->save) goto yyvalid; #endif /* YYBTYACC */ yyresult = 0; yyreturn: #if defined(YYDESTRUCT_CALL) if (yychar != YYEOF && yychar != YYEMPTY) #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); #else YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ { YYSTYPE *pv; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE *pp; for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) YYDESTRUCT_CALL("cleanup: discarding state", yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); #else for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) YYDESTRUCT_CALL("cleanup: discarding state", yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ } #endif /* defined(YYDESTRUCT_CALL) */ #if YYBTYACC if (yyerrctx) { yyFreeState(yyerrctx); yyerrctx = NULL; } while (yyps) { YYParseState *save = yyps; yyps = save->save; save->save = NULL; yyFreeState(save); } while (yypath) { YYParseState *save = yypath; yypath = save->save; save->save = NULL; yyFreeState(save); } #endif /* YYBTYACC */ yyfreestack(&yystack); return (yyresult); } diff --git a/contrib/byacc/test/btyacc/btyacc_destroy2.tab.h b/contrib/byacc/test/btyacc/btyacc_destroy2.tab.h index 5f59abdea129..6f8c2b029b4d 100644 --- a/contrib/byacc/test/btyacc/btyacc_destroy2.tab.h +++ b/contrib/byacc/test/btyacc/btyacc_destroy2.tab.h @@ -1,25 +1,25 @@ #ifndef _destroy2__defines_h_ #define _destroy2__defines_h_ #define GLOBAL 257 #define LOCAL 258 #define REAL 259 #define INTEGER 260 #define NAME 261 #ifdef YYSTYPE #undef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 #endif #ifndef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 -typedef union YYSTYPE +typedef union { class cval; type tval; namelist * nlist; name id; } YYSTYPE; #endif /* !YYSTYPE_IS_DECLARED */ extern YYSTYPE destroy2_lval; #endif /* _destroy2__defines_h_ */ diff --git a/contrib/byacc/test/btyacc/btyacc_destroy3.tab.c b/contrib/byacc/test/btyacc/btyacc_destroy3.tab.c index c0f897891d4e..dc93094e6116 100644 --- a/contrib/byacc/test/btyacc/btyacc_destroy3.tab.c +++ b/contrib/byacc/test/btyacc/btyacc_destroy3.tab.c @@ -1,1477 +1,1477 @@ /* original parser id follows */ /* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ /* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ #define YYBYACC 1 #define YYMAJOR 2 #define YYMINOR 0 #define YYCHECK "yyyymmdd" #define YYEMPTY (-1) #define yyclearin (yychar = YYEMPTY) #define yyerrok (yyerrflag = 0) #define YYRECOVERING() (yyerrflag != 0) #define YYENOMEM (-2) #define YYEOF 0 #undef YYBTYACC #define YYBTYACC 1 #define YYDEBUGSTR (yytrial ? YYPREFIX "debug(trial)" : YYPREFIX "debug") #ifndef yyparse #define yyparse destroy3_parse #endif /* yyparse */ #ifndef yylex #define yylex destroy3_lex #endif /* yylex */ #ifndef yyerror #define yyerror destroy3_error #endif /* yyerror */ #ifndef yychar #define yychar destroy3_char #endif /* yychar */ #ifndef yyval #define yyval destroy3_val #endif /* yyval */ #ifndef yylval #define yylval destroy3_lval #endif /* yylval */ #ifndef yydebug #define yydebug destroy3_debug #endif /* yydebug */ #ifndef yynerrs #define yynerrs destroy3_nerrs #endif /* yynerrs */ #ifndef yyerrflag #define yyerrflag destroy3_errflag #endif /* yyerrflag */ #ifndef yylhs #define yylhs destroy3_lhs #endif /* yylhs */ #ifndef yylen #define yylen destroy3_len #endif /* yylen */ #ifndef yydefred #define yydefred destroy3_defred #endif /* yydefred */ #ifndef yystos #define yystos destroy3_stos #endif /* yystos */ #ifndef yydgoto #define yydgoto destroy3_dgoto #endif /* yydgoto */ #ifndef yysindex #define yysindex destroy3_sindex #endif /* yysindex */ #ifndef yyrindex #define yyrindex destroy3_rindex #endif /* yyrindex */ #ifndef yygindex #define yygindex destroy3_gindex #endif /* yygindex */ #ifndef yytable #define yytable destroy3_table #endif /* yytable */ #ifndef yycheck #define yycheck destroy3_check #endif /* yycheck */ #ifndef yyname #define yyname destroy3_name #endif /* yyname */ #ifndef yyrule #define yyrule destroy3_rule #endif /* yyrule */ #if YYBTYACC #ifndef yycindex #define yycindex destroy3_cindex #endif /* yycindex */ #ifndef yyctable #define yyctable destroy3_ctable #endif /* yyctable */ #endif /* YYBTYACC */ #define YYPREFIX "destroy3_" #define YYPURE 0 #line 7 "btyacc_destroy3.y" #include typedef enum {cGLOBAL, cLOCAL} class; typedef enum {tREAL, tINTEGER} type; typedef char * name; struct symbol { class c; type t; name id; }; typedef struct symbol symbol; struct namelist { symbol *s; struct namelist *next; }; typedef struct namelist namelist; struct parser_param { int *rtrn; symbol ss; }; extern symbol *mksymbol(type t, class c, name id); #ifdef YYBISON #define YYLEX_DECL() yylex(void) #define YYERROR_DECL() yyerror(const char *s) #endif #ifdef YYSTYPE #undef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 #endif #ifndef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 #line 53 "btyacc_destroy3.y" -typedef union YYSTYPE +typedef union { class cval; type tval; namelist * nlist; name id; } YYSTYPE; #endif /* !YYSTYPE_IS_DECLARED */ #line 160 "btyacc_destroy3.tab.c" /* compatibility with bison */ #ifdef YYPARSE_PARAM /* compatibility with FreeBSD */ # ifdef YYPARSE_PARAM_TYPE # define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) # else # define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) # endif #else # define YYPARSE_DECL() yyparse(struct parser_param *param, int flag) #endif /* Parameters sent to lex. */ #ifdef YYLEX_PARAM # define YYLEX_DECL() yylex(void *YYLEX_PARAM) # define YYLEX yylex(YYLEX_PARAM) #else # define YYLEX_DECL() yylex(void) # define YYLEX yylex() #endif /* Parameters sent to yyerror. */ #ifndef YYERROR_DECL #define YYERROR_DECL() yyerror(struct parser_param *param, int flag, const char *s) #endif #ifndef YYERROR_CALL #define YYERROR_CALL(msg) yyerror(param, flag, msg) #endif #ifndef YYDESTRUCT_DECL #define YYDESTRUCT_DECL() yydestruct(const char *msg, int psymb, YYSTYPE *val, struct parser_param *param, int flag) #endif #ifndef YYDESTRUCT_CALL #define YYDESTRUCT_CALL(msg, psymb, val) yydestruct(msg, psymb, val, param, flag) #endif extern int YYPARSE_DECL(); #define GLOBAL 257 #define LOCAL 258 #define REAL 259 #define INTEGER 260 #define NAME 261 #define YYERRCODE 256 typedef int YYINT; static const YYINT destroy3_lhs[] = { -1, 0, 0, 2, 2, 3, 3, 4, 4, 1, }; static const YYINT destroy3_len[] = { 2, 8, 5, 1, 1, 1, 1, 2, 1, 6, }; static const YYINT destroy3_defred[] = { 0, 3, 4, 5, 6, 0, 0, 0, 0, 8, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 9, 1, }; #if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) static const YYINT destroy3_stos[] = { 0, 257, 258, 259, 260, 263, 265, 266, 266, 261, 264, 267, 267, 40, 261, 40, 40, 265, 258, 265, 41, 44, 44, 266, 266, 41, 41, }; #endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ static const YYINT destroy3_dgoto[] = { 5, 10, 6, 7, 11, }; static const YYINT destroy3_sindex[] = { -254, 0, 0, 0, 0, 0, -251, -248, -248, 0, -26, -40, -39, -246, 0, -243, -246, -25, -24, -23, 0, -251, -251, -22, -19, 0, 0, }; static const YYINT destroy3_rindex[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; #if YYBTYACC static const YYINT destroy3_cindex[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; #endif static const YYINT destroy3_gindex[] = { 0, 0, -6, -4, 15, }; #define YYTABLESIZE 222 static const YYINT destroy3_table[] = { 15, 16, 8, 1, 2, 3, 4, 17, 3, 4, 19, 1, 2, 9, 13, 18, 20, 23, 24, 25, 21, 22, 26, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 14, }; static const YYINT destroy3_check[] = { 40, 40, 6, 257, 258, 259, 260, 13, 259, 260, 16, 257, 258, 261, 40, 258, 41, 21, 22, 41, 44, 44, 41, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 261, 261, }; #if YYBTYACC static const YYINT destroy3_ctable[] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, }; #endif #define YYFINAL 5 #ifndef YYDEBUG #define YYDEBUG 0 #endif #define YYMAXTOKEN 261 #define YYUNDFTOKEN 268 #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) #if YYDEBUG static const char *const destroy3_name[] = { "$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, 0,0,0,"'('","')'",0,0,"','",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"error","GLOBAL","LOCAL", "REAL","INTEGER","NAME","$accept","declaration","locnamelist","class","type", "namelist","illegal-symbol", }; static const char *const destroy3_rule[] = { "$accept : declaration", "declaration : class type namelist '(' class ',' type ')'", "declaration : type locnamelist '(' class ')'", "class : GLOBAL", "class : LOCAL", "type : REAL", "type : INTEGER", "namelist : namelist NAME", "namelist : NAME", "locnamelist : namelist '(' LOCAL ',' type ')'", }; #endif #if YYDEBUG int yydebug; #endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; int yynerrs; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyloc; /* position returned by actions */ YYLTYPE yylloc; /* position from the lexer */ #endif #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) #ifndef YYLLOC_DEFAULT #define YYLLOC_DEFAULT(loc, rhs, n) \ do \ { \ if (n == 0) \ { \ (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ } \ else \ { \ (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ (loc).last_line = YYRHSLOC(rhs, n).last_line; \ (loc).last_column = YYRHSLOC(rhs, n).last_column; \ } \ } while (0) #endif /* YYLLOC_DEFAULT */ #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ #if YYBTYACC #ifndef YYLVQUEUEGROWTH #define YYLVQUEUEGROWTH 32 #endif #endif /* YYBTYACC */ /* define the initial stack-sizes */ #ifdef YYSTACKSIZE #undef YYMAXDEPTH #define YYMAXDEPTH YYSTACKSIZE #else #ifdef YYMAXDEPTH #define YYSTACKSIZE YYMAXDEPTH #else #define YYSTACKSIZE 10000 #define YYMAXDEPTH 10000 #endif #endif #ifndef YYINITSTACKSIZE #define YYINITSTACKSIZE 200 #endif typedef struct { unsigned stacksize; YYINT *s_base; YYINT *s_mark; YYINT *s_last; YYSTYPE *l_base; YYSTYPE *l_mark; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE *p_base; YYLTYPE *p_mark; #endif } YYSTACKDATA; #if YYBTYACC struct YYParseState_s { struct YYParseState_s *save; /* Previously saved parser state */ YYSTACKDATA yystack; /* saved parser stack */ int state; /* saved parser state */ int errflag; /* saved error recovery status */ int lexeme; /* saved index of the conflict lexeme in the lexical queue */ YYINT ctry; /* saved index in yyctable[] for this conflict */ }; typedef struct YYParseState_s YYParseState; #endif /* YYBTYACC */ /* variables for the parser stack */ static YYSTACKDATA yystack; #if YYBTYACC /* Current parser state */ static YYParseState *yyps = 0; /* yypath != NULL: do the full parse, starting at *yypath parser state. */ static YYParseState *yypath = 0; /* Base of the lexical value queue */ static YYSTYPE *yylvals = 0; /* Current position at lexical value queue */ static YYSTYPE *yylvp = 0; /* End position of lexical value queue */ static YYSTYPE *yylve = 0; /* The last allocated position at the lexical value queue */ static YYSTYPE *yylvlim = 0; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* Base of the lexical position queue */ static YYLTYPE *yylpsns = 0; /* Current position at lexical position queue */ static YYLTYPE *yylpp = 0; /* End position of lexical position queue */ static YYLTYPE *yylpe = 0; /* The last allocated position at the lexical position queue */ static YYLTYPE *yylplim = 0; #endif /* Current position at lexical token queue */ static YYINT *yylexp = 0; static YYINT *yylexemes = 0; #endif /* YYBTYACC */ #line 92 "btyacc_destroy3.y" extern int YYLEX_DECL(); extern void YYERROR_DECL(); #line 492 "btyacc_destroy3.tab.c" /* Release memory associated with symbol. */ #if ! defined YYDESTRUCT_IS_DECLARED static void YYDESTRUCT_DECL() { switch (psymb) { case 263: #line 44 "btyacc_destroy3.y" { namelist *p = (*val).nlist; while (p != NULL) { namelist *pp = p; p = p->next; free(pp->s); free(pp); } } #line 511 "btyacc_destroy3.tab.c" break; } } #define YYDESTRUCT_IS_DECLARED 1 #endif /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) #if YYBTYACC #define yytrial (yyps->save) #endif /* YYBTYACC */ #if YYDEBUG #include /* needed for printf */ #endif #include /* needed for malloc, etc */ #include /* needed for memset */ /* allocate initial stack or double stack size, up to YYMAXDEPTH */ static int yygrowstack(YYSTACKDATA *data) { int i; unsigned newsize; YYINT *newss; YYSTYPE *newvs; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE *newps; #endif if ((newsize = data->stacksize) == 0) newsize = YYINITSTACKSIZE; else if (newsize >= YYMAXDEPTH) return YYENOMEM; else if ((newsize *= 2) > YYMAXDEPTH) newsize = YYMAXDEPTH; i = (int) (data->s_mark - data->s_base); newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); if (newss == NULL) return YYENOMEM; data->s_base = newss; data->s_mark = newss + i; newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); if (newvs == NULL) return YYENOMEM; data->l_base = newvs; data->l_mark = newvs + i; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); if (newps == NULL) return YYENOMEM; data->p_base = newps; data->p_mark = newps + i; #endif data->stacksize = newsize; data->s_last = data->s_base + newsize - 1; #if YYDEBUG if (yydebug) fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); #endif return 0; } #if YYPURE || defined(YY_NO_LEAKS) static void yyfreestack(YYSTACKDATA *data) { free(data->s_base); free(data->l_base); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) free(data->p_base); #endif memset(data, 0, sizeof(*data)); } #else #define yyfreestack(data) /* nothing */ #endif /* YYPURE || defined(YY_NO_LEAKS) */ #if YYBTYACC static YYParseState * yyNewState(unsigned size) { YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); if (p == NULL) return NULL; p->yystack.stacksize = size; if (size == 0) { p->yystack.s_base = NULL; p->yystack.l_base = NULL; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) p->yystack.p_base = NULL; #endif return p; } p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); if (p->yystack.s_base == NULL) return NULL; p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); if (p->yystack.l_base == NULL) return NULL; memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); if (p->yystack.p_base == NULL) return NULL; memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); #endif return p; } static void yyFreeState(YYParseState *p) { yyfreestack(&p->yystack); free(p); } #endif /* YYBTYACC */ #define YYABORT goto yyabort #define YYREJECT goto yyabort #define YYACCEPT goto yyaccept #define YYERROR goto yyerrlab #if YYBTYACC #define YYVALID do { if (yyps->save) goto yyvalid; } while(0) #define YYVALID_NESTED do { if (yyps->save && \ yyps->save->save == 0) goto yyvalid; } while(0) #endif /* YYBTYACC */ int YYPARSE_DECL() { int yym, yyn, yystate, yyresult; #if YYBTYACC int yynewerrflag; YYParseState *yyerrctx = NULL; #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ #endif #if YYDEBUG const char *yys; if ((yys = getenv("YYDEBUG")) != NULL) { yyn = *yys; if (yyn >= '0' && yyn <= '9') yydebug = yyn - '0'; } if (yydebug) fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); #endif #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); #endif #if YYBTYACC yyps = yyNewState(0); if (yyps == 0) goto yyenomem; yyps->save = 0; #endif /* YYBTYACC */ yym = 0; /* yyn is set below */ yynerrs = 0; yyerrflag = 0; yychar = YYEMPTY; yystate = 0; #if YYPURE memset(&yystack, 0, sizeof(yystack)); #endif if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystack.s_mark = yystack.s_base; yystack.l_mark = yystack.l_base; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark = yystack.p_base; #endif yystate = 0; *yystack.s_mark = 0; yyloop: if ((yyn = yydefred[yystate]) != 0) goto yyreduce; if (yychar < 0) { #if YYBTYACC do { if (yylvp < yylve) { /* we're currently re-reading tokens */ yylval = *yylvp++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylloc = *yylpp++; #endif yychar = *yylexp++; break; } if (yyps->save) { /* in trial mode; save scanner results for future parse attempts */ if (yylvp == yylvlim) { /* Enlarge lexical value queue */ size_t p = (size_t) (yylvp - yylvals); size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpe = yylpsns + p; yylplim = yylpsns + s; #endif yylexp = yylexemes + p; } *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpp++ = yylloc; yylpe++; #endif yychar = *yylexp++; break; } /* normal operation, no conflict encountered */ #endif /* YYBTYACC */ yychar = YYLEX; #if YYBTYACC } while (0); #endif /* YYBTYACC */ if (yychar < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", YYDEBUGSTR, yydepth, yystate, yychar, yys); #ifdef YYSTYPE_TOSTRING #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); #endif fputc('\n', stderr); } #endif } #if YYBTYACC /* Do we have a conflict? */ if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) { YYINT ctry; if (yypath) { YYParseState *save; #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", YYDEBUGSTR, yydepth, yystate); #endif /* Switch to the next conflict context */ save = yypath; yypath = save->save; save->save = NULL; ctry = save->ctry; if (save->state != yystate) YYABORT; yyFreeState(save); } else { /* Unresolved conflict - start/continue trial parse */ YYParseState *save; #if YYDEBUG if (yydebug) { fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); if (yyps->save) fputs("ALREADY in conflict, continuing trial parse.\n", stderr); else fputs("Starting trial parse.\n", stderr); } #endif save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); if (save == NULL) goto yyenomem; save->save = yyps->save; save->state = yystate; save->errflag = yyerrflag; save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif ctry = yytable[yyn]; if (yyctable[ctry] == -1) { #if YYDEBUG if (yydebug && yychar >= YYEOF) fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); #endif ctry++; } save->ctry = ctry; if (yyps->save == NULL) { /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; yylvlim = yylvals + YYLVQUEUEGROWTH; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); if (yylpsns == NULL) goto yyenomem; yylplim = yylpsns + YYLVQUEUEGROWTH; #endif } if (yylvp == yylve) { yylvp = yylve = yylvals; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpe = yylpsns; #endif yylexp = yylexemes; if (yychar >= YYEOF) { *yylve++ = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpe++ = yylloc; #endif *yylexp = (YYINT) yychar; yychar = YYEMPTY; } } } if (yychar >= YYEOF) { yylvp--; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp--; #endif yylexp--; yychar = YYEMPTY; } save->lexeme = (int) (yylvp - yylvals); yyps->save = save; } if (yytable[yyn] == ctry) { #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); #endif if (yychar < 0) { yylvp++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp++; #endif yylexp++; } if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystate = yyctable[ctry]; *++yystack.s_mark = (YYINT) yystate; *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *++yystack.p_mark = yylloc; #endif yychar = YYEMPTY; if (yyerrflag > 0) --yyerrflag; goto yyloop; } else { yyn = yyctable[ctry]; goto yyreduce; } } /* End of code dealing with conflicts */ #endif /* YYBTYACC */ if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) { #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", YYDEBUGSTR, yydepth, yystate, yytable[yyn]); #endif if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystate = yytable[yyn]; *++yystack.s_mark = yytable[yyn]; *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *++yystack.p_mark = yylloc; #endif yychar = YYEMPTY; if (yyerrflag > 0) --yyerrflag; goto yyloop; } if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) { yyn = yytable[yyn]; goto yyreduce; } if (yyerrflag != 0) goto yyinrecovery; #if YYBTYACC yynewerrflag = 1; goto yyerrhandler; goto yyerrlab; /* redundant goto avoids 'unused label' warning */ yyerrlab: /* explicit YYERROR from an action -- pop the rhs of the rule reduced * before looking for error recovery */ yystack.s_mark -= yym; yystate = *yystack.s_mark; yystack.l_mark -= yym; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark -= yym; #endif yynewerrflag = 0; yyerrhandler: while (yyps->save) { int ctry; YYParseState *save = yyps->save; #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", YYDEBUGSTR, yydepth, yystate, yyps->save->state, (int)(yylvp - yylvals - yyps->save->lexeme)); #endif /* Memorize most forward-looking error state in case it's really an error. */ if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) { /* Free old saved error context state */ if (yyerrctx) yyFreeState(yyerrctx); /* Create and fill out new saved error context state */ yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); if (yyerrctx == NULL) goto yyenomem; yyerrctx->save = yyps->save; yyerrctx->state = yystate; yyerrctx->errflag = yyerrflag; yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif yyerrctx->lexeme = (int) (yylvp - yylvals); } yylvp = yylvals + save->lexeme; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpsns + save->lexeme; #endif yylexp = yylexemes + save->lexeme; yychar = YYEMPTY; yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif ctry = ++save->ctry; yystate = save->state; /* We tried shift, try reduce now */ if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; yyps->save = save->save; save->save = NULL; yyFreeState(save); /* Nothing left on the stack -- error */ if (!yyps->save) { #if YYDEBUG if (yydebug) fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", YYPREFIX, yydepth); #endif /* Restore state as it was in the most forward-advanced error */ yylvp = yylvals + yyerrctx->lexeme; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpsns + yyerrctx->lexeme; #endif yylexp = yylexemes + yyerrctx->lexeme; yychar = yylexp[-1]; yylval = yylvp[-1]; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylloc = yylpp[-1]; #endif yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif yystate = yyerrctx->state; yyFreeState(yyerrctx); yyerrctx = NULL; } yynewerrflag = 1; } if (yynewerrflag == 0) goto yyinrecovery; #endif /* YYBTYACC */ YYERROR_CALL("syntax error"); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ #endif #if !YYBTYACC goto yyerrlab; /* redundant goto avoids 'unused label' warning */ yyerrlab: #endif ++yynerrs; yyinrecovery: if (yyerrflag < 3) { yyerrflag = 3; for (;;) { if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) { #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); #endif if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystate = yytable[yyn]; *++yystack.s_mark = yytable[yyn]; *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* lookahead position is error end position */ yyerror_loc_range[2] = yylloc; YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ *++yystack.p_mark = yyloc; #endif goto yyloop; } else { #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", YYDEBUGSTR, yydepth, *yystack.s_mark); #endif if (yystack.s_mark <= yystack.s_base) goto yyabort; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* the current TOS position is the error start position */ yyerror_loc_range[1] = *yystack.p_mark; #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYDESTRUCT_CALL("error: discarding state", yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); #else YYDESTRUCT_CALL("error: discarding state", yystos[*yystack.s_mark], yystack.l_mark); #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ #endif /* defined(YYDESTRUCT_CALL) */ --yystack.s_mark; --yystack.l_mark; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) --yystack.p_mark; #endif } } } else { if (yychar == YYEOF) goto yyabort; #if YYDEBUG if (yydebug) { if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", YYDEBUGSTR, yydepth, yystate, yychar, yys); } #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); #else YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ #endif /* defined(YYDESTRUCT_CALL) */ yychar = YYEMPTY; goto yyloop; } yyreduce: yym = yylen[yyn]; #if YYDEBUG if (yydebug) { fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); #ifdef YYSTYPE_TOSTRING #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ if (yym > 0) { int i; fputc('<', stderr); for (i = yym; i > 0; i--) { if (i != yym) fputs(", ", stderr); fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], yystack.l_mark[1-i]), stderr); } fputc('>', stderr); } #endif fputc('\n', stderr); } #endif if (yym > 0) yyval = yystack.l_mark[1-yym]; else memset(&yyval, 0, sizeof yyval); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* Perform position reduction */ memset(&yyloc, 0, sizeof(yyloc)); #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ { YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); /* just in case YYERROR is invoked within the action, save the start of the rhs as the error start position */ yyerror_loc_range[1] = yystack.p_mark[1-yym]; } #endif switch (yyn) { case 1: if (!yytrial) #line 65 "btyacc_destroy3.y" { yyval.nlist = yystack.l_mark[-5].nlist; } #line 1190 "btyacc_destroy3.tab.c" break; case 2: if (!yytrial) #line 67 "btyacc_destroy3.y" { yyval.nlist = yystack.l_mark[-3].nlist; } #line 1196 "btyacc_destroy3.tab.c" break; case 3: if (!yytrial) #line 70 "btyacc_destroy3.y" { yyval.cval = cGLOBAL; } #line 1202 "btyacc_destroy3.tab.c" break; case 4: if (!yytrial) #line 71 "btyacc_destroy3.y" { yyval.cval = cLOCAL; } #line 1208 "btyacc_destroy3.tab.c" break; case 5: if (!yytrial) #line 74 "btyacc_destroy3.y" { yyval.tval = tREAL; } #line 1214 "btyacc_destroy3.tab.c" break; case 6: if (!yytrial) #line 75 "btyacc_destroy3.y" { yyval.tval = tINTEGER; } #line 1220 "btyacc_destroy3.tab.c" break; case 7: if (!yytrial) #line 79 "btyacc_destroy3.y" { yyval.nlist->s = mksymbol(yystack.l_mark[-2].tval, yystack.l_mark[-2].cval, yystack.l_mark[0].id); yyval.nlist->next = yystack.l_mark[-1].nlist; } #line 1228 "btyacc_destroy3.tab.c" break; case 8: if (!yytrial) #line 83 "btyacc_destroy3.y" { yyval.nlist->s = mksymbol(0, 0, yystack.l_mark[0].id); yyval.nlist->next = NULL; } #line 1236 "btyacc_destroy3.tab.c" break; case 9: if (!yytrial) #line 89 "btyacc_destroy3.y" { yyval.nlist = yystack.l_mark[-5].nlist; } #line 1242 "btyacc_destroy3.tab.c" break; #line 1244 "btyacc_destroy3.tab.c" default: break; } yystack.s_mark -= yym; yystate = *yystack.s_mark; yystack.l_mark -= yym; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark -= yym; #endif yym = yylhs[yyn]; if (yystate == 0 && yym == 0) { #if YYDEBUG if (yydebug) { fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); #ifdef YYSTYPE_TOSTRING #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); #endif fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); } #endif yystate = YYFINAL; *++yystack.s_mark = YYFINAL; *++yystack.l_mark = yyval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *++yystack.p_mark = yyloc; #endif if (yychar < 0) { #if YYBTYACC do { if (yylvp < yylve) { /* we're currently re-reading tokens */ yylval = *yylvp++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylloc = *yylpp++; #endif yychar = *yylexp++; break; } if (yyps->save) { /* in trial mode; save scanner results for future parse attempts */ if (yylvp == yylvlim) { /* Enlarge lexical value queue */ size_t p = (size_t) (yylvp - yylvals); size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpe = yylpsns + p; yylplim = yylpsns + s; #endif yylexp = yylexemes + p; } *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpp++ = yylloc; yylpe++; #endif yychar = *yylexp++; break; } /* normal operation, no conflict encountered */ #endif /* YYBTYACC */ yychar = YYLEX; #if YYBTYACC } while (0); #endif /* YYBTYACC */ if (yychar < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); } #endif } if (yychar == YYEOF) goto yyaccept; goto yyloop; } if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) yystate = yytable[yyn]; else yystate = yydgoto[yym]; #if YYDEBUG if (yydebug) { fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); #ifdef YYSTYPE_TOSTRING #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); #endif fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); } #endif if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; *++yystack.s_mark = (YYINT) yystate; *++yystack.l_mark = yyval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *++yystack.p_mark = yyloc; #endif goto yyloop; #if YYBTYACC /* Reduction declares that this path is valid. Set yypath and do a full parse */ yyvalid: if (yypath) YYABORT; while (yyps->save) { YYParseState *save = yyps->save; yyps->save = save->save; save->save = yypath; yypath = save; } #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); #endif if (yyerrctx) { yyFreeState(yyerrctx); yyerrctx = NULL; } yylvp = yylvals + yypath->lexeme; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpsns + yypath->lexeme; #endif yylexp = yylexemes + yypath->lexeme; yychar = YYEMPTY; yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif yystate = yypath->state; goto yyloop; #endif /* YYBTYACC */ yyoverflow: YYERROR_CALL("yacc stack overflow"); #if YYBTYACC goto yyabort_nomem; yyenomem: YYERROR_CALL("memory exhausted"); yyabort_nomem: #endif /* YYBTYACC */ yyresult = 2; goto yyreturn; yyabort: yyresult = 1; goto yyreturn; yyaccept: #if YYBTYACC if (yyps->save) goto yyvalid; #endif /* YYBTYACC */ yyresult = 0; yyreturn: #if defined(YYDESTRUCT_CALL) if (yychar != YYEOF && yychar != YYEMPTY) #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); #else YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ { YYSTYPE *pv; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE *pp; for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) YYDESTRUCT_CALL("cleanup: discarding state", yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); #else for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) YYDESTRUCT_CALL("cleanup: discarding state", yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ } #endif /* defined(YYDESTRUCT_CALL) */ #if YYBTYACC if (yyerrctx) { yyFreeState(yyerrctx); yyerrctx = NULL; } while (yyps) { YYParseState *save = yyps; yyps = save->save; save->save = NULL; yyFreeState(save); } while (yypath) { YYParseState *save = yypath; yypath = save->save; save->save = NULL; yyFreeState(save); } #endif /* YYBTYACC */ yyfreestack(&yystack); return (yyresult); } diff --git a/contrib/byacc/test/btyacc/btyacc_destroy3.tab.h b/contrib/byacc/test/btyacc/btyacc_destroy3.tab.h index 5a84568a6c04..1ef7d6b370f0 100644 --- a/contrib/byacc/test/btyacc/btyacc_destroy3.tab.h +++ b/contrib/byacc/test/btyacc/btyacc_destroy3.tab.h @@ -1,25 +1,25 @@ #ifndef _destroy3__defines_h_ #define _destroy3__defines_h_ #define GLOBAL 257 #define LOCAL 258 #define REAL 259 #define INTEGER 260 #define NAME 261 #ifdef YYSTYPE #undef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 #endif #ifndef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 -typedef union YYSTYPE +typedef union { class cval; type tval; namelist * nlist; name id; } YYSTYPE; #endif /* !YYSTYPE_IS_DECLARED */ extern YYSTYPE destroy3_lval; #endif /* _destroy3__defines_h_ */ diff --git a/contrib/byacc/test/btyacc/calc1.tab.c b/contrib/byacc/test/btyacc/calc1.tab.c index 54d7014a4b27..cc40060143b9 100644 --- a/contrib/byacc/test/btyacc/calc1.tab.c +++ b/contrib/byacc/test/btyacc/calc1.tab.c @@ -1,1746 +1,1746 @@ /* original parser id follows */ /* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ /* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ #define YYBYACC 1 #define YYMAJOR 2 #define YYMINOR 0 #define YYCHECK "yyyymmdd" #define YYEMPTY (-1) #define yyclearin (yychar = YYEMPTY) #define yyerrok (yyerrflag = 0) #define YYRECOVERING() (yyerrflag != 0) #define YYENOMEM (-2) #define YYEOF 0 #undef YYBTYACC #define YYBTYACC 0 #define YYDEBUGSTR YYPREFIX "debug" #ifndef yyparse #define yyparse calc1_parse #endif /* yyparse */ #ifndef yylex #define yylex calc1_lex #endif /* yylex */ #ifndef yyerror #define yyerror calc1_error #endif /* yyerror */ #ifndef yychar #define yychar calc1_char #endif /* yychar */ #ifndef yyval #define yyval calc1_val #endif /* yyval */ #ifndef yylval #define yylval calc1_lval #endif /* yylval */ #ifndef yydebug #define yydebug calc1_debug #endif /* yydebug */ #ifndef yynerrs #define yynerrs calc1_nerrs #endif /* yynerrs */ #ifndef yyerrflag #define yyerrflag calc1_errflag #endif /* yyerrflag */ #ifndef yylhs #define yylhs calc1_lhs #endif /* yylhs */ #ifndef yylen #define yylen calc1_len #endif /* yylen */ #ifndef yydefred #define yydefred calc1_defred #endif /* yydefred */ #ifndef yystos #define yystos calc1_stos #endif /* yystos */ #ifndef yydgoto #define yydgoto calc1_dgoto #endif /* yydgoto */ #ifndef yysindex #define yysindex calc1_sindex #endif /* yysindex */ #ifndef yyrindex #define yyrindex calc1_rindex #endif /* yyrindex */ #ifndef yygindex #define yygindex calc1_gindex #endif /* yygindex */ #ifndef yytable #define yytable calc1_table #endif /* yytable */ #ifndef yycheck #define yycheck calc1_check #endif /* yycheck */ #ifndef yyname #define yyname calc1_name #endif /* yyname */ #ifndef yyrule #define yyrule calc1_rule #endif /* yyrule */ #if YYBTYACC #ifndef yycindex #define yycindex calc1_cindex #endif /* yycindex */ #ifndef yyctable #define yyctable calc1_ctable #endif /* yyctable */ #endif /* YYBTYACC */ #define YYPREFIX "calc1_" #define YYPURE 0 #line 2 "calc1.y" /* http://dinosaur.compilertools.net/yacc/index.html */ #include #include #include #include typedef struct interval { double lo, hi; } INTERVAL; INTERVAL vmul(double, double, INTERVAL); INTERVAL vdiv(double, double, INTERVAL); extern int yylex(void); static void yyerror(const char *s); int dcheck(INTERVAL); double dreg[26]; INTERVAL vreg[26]; #ifdef YYSTYPE #undef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 #endif #ifndef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 #line 31 "calc1.y" -typedef union YYSTYPE +typedef union { int ival; double dval; INTERVAL vval; } YYSTYPE; #endif /* !YYSTYPE_IS_DECLARED */ #line 161 "calc1.tab.c" /* compatibility with bison */ #ifdef YYPARSE_PARAM /* compatibility with FreeBSD */ # ifdef YYPARSE_PARAM_TYPE # define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) # else # define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) # endif #else # define YYPARSE_DECL() yyparse(void) #endif /* Parameters sent to lex. */ #ifdef YYLEX_PARAM # define YYLEX_DECL() yylex(void *YYLEX_PARAM) # define YYLEX yylex(YYLEX_PARAM) #else # define YYLEX_DECL() yylex(void) # define YYLEX yylex() #endif /* Parameters sent to yyerror. */ #ifndef YYERROR_DECL #define YYERROR_DECL() yyerror(const char *s) #endif #ifndef YYERROR_CALL #define YYERROR_CALL(msg) yyerror(msg) #endif extern int YYPARSE_DECL(); #define DREG 257 #define VREG 258 #define CONST 259 #define UMINUS 260 #define YYERRCODE 256 typedef int YYINT; static const YYINT calc1_lhs[] = { -1, 3, 3, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, }; static const YYINT calc1_len[] = { 2, 0, 2, 2, 2, 4, 4, 2, 1, 1, 3, 3, 3, 3, 2, 3, 1, 5, 1, 3, 3, 3, 3, 3, 3, 3, 3, 2, 3, }; static const YYINT calc1_defred[] = { 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 7, 0, 0, 9, 18, 14, 27, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 15, 0, 28, 0, 0, 0, 0, 12, 24, 13, 26, 0, 0, 23, 25, 14, 0, 0, 0, 0, 0, 5, 6, 0, 0, 0, 12, 13, 17, }; #if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) static const YYINT calc1_stos[] = { 0, 256, 257, 258, 259, 45, 40, 262, 263, 264, 10, 61, 61, 257, 258, 263, 264, 263, 264, 43, 45, 42, 47, 10, 43, 45, 42, 47, 10, 45, 40, 263, 263, 264, 41, 44, 41, 263, 264, 263, 264, 263, 264, 263, 264, 264, 264, 264, 264, 263, 263, 43, 45, 42, 47, 10, 10, 263, 263, 263, 263, 263, 41, }; #endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ static const YYINT calc1_dgoto[] = { 7, 32, 9, 0, }; static const YYINT calc1_sindex[] = { -40, -8, -48, -47, 0, -37, -37, 0, 2, 17, 0, -34, -37, 0, 0, 0, 0, -25, 90, -37, -37, -37, -37, 0, -37, -37, -37, -37, 0, -34, -34, 25, 125, 31, 0, -34, 0, -11, 37, -11, 37, 0, 0, 0, 0, 37, 37, 0, 0, 0, 111, -34, -34, -34, -34, 0, 0, 118, 69, 69, 0, 0, 0, }; static const YYINT calc1_rindex[] = { 0, 0, 38, 44, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -9, 0, 0, 0, 0, 51, -3, 56, 61, 0, 0, 0, 0, 67, 72, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 78, 83, 0, 0, 0, }; #if YYBTYACC static const YYINT calc1_cindex[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; #endif static const YYINT calc1_gindex[] = { 0, 4, 124, 0, }; #define YYTABLESIZE 225 static const YYINT calc1_table[] = { 6, 16, 10, 6, 8, 5, 30, 20, 5, 15, 17, 29, 23, 11, 12, 31, 34, 21, 19, 35, 20, 0, 22, 37, 39, 41, 43, 28, 0, 0, 0, 21, 16, 49, 50, 55, 22, 0, 20, 57, 20, 56, 20, 0, 21, 19, 0, 20, 9, 22, 0, 0, 0, 0, 18, 58, 59, 60, 61, 26, 24, 10, 25, 0, 27, 0, 11, 53, 51, 0, 52, 22, 54, 26, 24, 0, 25, 19, 27, 26, 9, 9, 21, 9, 27, 9, 18, 18, 10, 18, 0, 18, 10, 11, 10, 10, 10, 11, 0, 11, 11, 11, 22, 0, 22, 0, 22, 0, 19, 0, 19, 53, 19, 21, 0, 21, 54, 21, 0, 10, 0, 10, 0, 10, 11, 0, 11, 0, 11, 16, 18, 36, 26, 24, 0, 25, 33, 27, 0, 0, 0, 0, 0, 38, 40, 42, 44, 0, 45, 46, 47, 48, 34, 53, 51, 0, 52, 0, 54, 62, 53, 51, 0, 52, 0, 54, 0, 21, 19, 0, 20, 0, 22, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 13, 14, 4, 13, 0, 4, }; static const YYINT calc1_check[] = { 40, 10, 10, 40, 0, 45, 40, 10, 45, 5, 6, 45, 10, 61, 61, 11, 41, 42, 43, 44, 45, -1, 47, 19, 20, 21, 22, 10, -1, -1, -1, 42, 41, 29, 30, 10, 47, -1, 41, 35, 43, 10, 45, -1, 42, 43, -1, 45, 10, 47, -1, -1, -1, -1, 10, 51, 52, 53, 54, 42, 43, 10, 45, -1, 47, -1, 10, 42, 43, -1, 45, 10, 47, 42, 43, -1, 45, 10, 47, 42, 42, 43, 10, 45, 47, 47, 42, 43, 10, 45, -1, 47, 41, 10, 43, 44, 45, 41, -1, 43, 44, 45, 41, -1, 43, -1, 45, -1, 41, -1, 43, 42, 45, 41, -1, 43, 47, 45, -1, 41, -1, 43, -1, 45, 41, -1, 43, -1, 45, 5, 6, 41, 42, 43, -1, 45, 12, 47, -1, -1, -1, -1, -1, 19, 20, 21, 22, -1, 24, 25, 26, 27, 41, 42, 43, -1, 45, -1, 47, 41, 42, 43, -1, 45, -1, 47, -1, 42, 43, -1, 45, -1, 47, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 256, 257, 258, 259, 257, 258, 259, 257, -1, 259, }; #if YYBTYACC static const YYINT calc1_ctable[] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, }; #endif #define YYFINAL 7 #ifndef YYDEBUG #define YYDEBUG 0 #endif #define YYMAXTOKEN 260 #define YYUNDFTOKEN 266 #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) #if YYDEBUG static const char *const calc1_name[] = { "$end",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,"'('","')'","'*'","'+'","','","'-'",0,"'/'",0,0,0,0,0,0,0,0,0,0,0,0, 0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, "error","DREG","VREG","CONST","UMINUS","$accept","line","dexp","vexp","lines", "illegal-symbol", }; static const char *const calc1_rule[] = { "$accept : line", "lines :", "lines : lines line", "line : dexp '\\n'", "line : vexp '\\n'", "line : DREG '=' dexp '\\n'", "line : VREG '=' vexp '\\n'", "line : error '\\n'", "dexp : CONST", "dexp : DREG", "dexp : dexp '+' dexp", "dexp : dexp '-' dexp", "dexp : dexp '*' dexp", "dexp : dexp '/' dexp", "dexp : '-' dexp", "dexp : '(' dexp ')'", "vexp : dexp", "vexp : '(' dexp ',' dexp ')'", "vexp : VREG", "vexp : vexp '+' vexp", "vexp : dexp '+' vexp", "vexp : vexp '-' vexp", "vexp : dexp '-' vexp", "vexp : vexp '*' vexp", "vexp : dexp '*' vexp", "vexp : vexp '/' vexp", "vexp : dexp '/' vexp", "vexp : '-' vexp", "vexp : '(' vexp ')'", }; #endif #if YYDEBUG int yydebug; #endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; int yynerrs; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyloc; /* position returned by actions */ YYLTYPE yylloc; /* position from the lexer */ #endif #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) #ifndef YYLLOC_DEFAULT #define YYLLOC_DEFAULT(loc, rhs, n) \ do \ { \ if (n == 0) \ { \ (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ } \ else \ { \ (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ (loc).last_line = YYRHSLOC(rhs, n).last_line; \ (loc).last_column = YYRHSLOC(rhs, n).last_column; \ } \ } while (0) #endif /* YYLLOC_DEFAULT */ #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ #if YYBTYACC #ifndef YYLVQUEUEGROWTH #define YYLVQUEUEGROWTH 32 #endif #endif /* YYBTYACC */ /* define the initial stack-sizes */ #ifdef YYSTACKSIZE #undef YYMAXDEPTH #define YYMAXDEPTH YYSTACKSIZE #else #ifdef YYMAXDEPTH #define YYSTACKSIZE YYMAXDEPTH #else #define YYSTACKSIZE 10000 #define YYMAXDEPTH 10000 #endif #endif #ifndef YYINITSTACKSIZE #define YYINITSTACKSIZE 200 #endif typedef struct { unsigned stacksize; YYINT *s_base; YYINT *s_mark; YYINT *s_last; YYSTYPE *l_base; YYSTYPE *l_mark; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE *p_base; YYLTYPE *p_mark; #endif } YYSTACKDATA; #if YYBTYACC struct YYParseState_s { struct YYParseState_s *save; /* Previously saved parser state */ YYSTACKDATA yystack; /* saved parser stack */ int state; /* saved parser state */ int errflag; /* saved error recovery status */ int lexeme; /* saved index of the conflict lexeme in the lexical queue */ YYINT ctry; /* saved index in yyctable[] for this conflict */ }; typedef struct YYParseState_s YYParseState; #endif /* YYBTYACC */ /* variables for the parser stack */ static YYSTACKDATA yystack; #if YYBTYACC /* Current parser state */ static YYParseState *yyps = 0; /* yypath != NULL: do the full parse, starting at *yypath parser state. */ static YYParseState *yypath = 0; /* Base of the lexical value queue */ static YYSTYPE *yylvals = 0; /* Current position at lexical value queue */ static YYSTYPE *yylvp = 0; /* End position of lexical value queue */ static YYSTYPE *yylve = 0; /* The last allocated position at the lexical value queue */ static YYSTYPE *yylvlim = 0; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* Base of the lexical position queue */ static YYLTYPE *yylpsns = 0; /* Current position at lexical position queue */ static YYLTYPE *yylpp = 0; /* End position of lexical position queue */ static YYLTYPE *yylpe = 0; /* The last allocated position at the lexical position queue */ static YYLTYPE *yylplim = 0; #endif /* Current position at lexical token queue */ static YYINT *yylexp = 0; static YYINT *yylexemes = 0; #endif /* YYBTYACC */ #line 176 "calc1.y" /* beginning of subroutines section */ #define BSZ 50 /* buffer size for floating point numbers */ /* lexical analysis */ static void yyerror(const char *s) { fprintf(stderr, "%s\n", s); } int yylex(void) { int c; while ((c = getchar()) == ' ') { /* skip over blanks */ } if (isupper(c)) { yylval.ival = c - 'A'; return (VREG); } if (islower(c)) { yylval.ival = c - 'a'; return (DREG); } if (isdigit(c) || c == '.') { /* gobble up digits, points, exponents */ char buf[BSZ + 1], *cp = buf; int dot = 0, expr = 0; for (; (cp - buf) < BSZ; ++cp, c = getchar()) { *cp = (char) c; if (isdigit(c)) continue; if (c == '.') { if (dot++ || expr) return ('.'); /* will cause syntax error */ continue; } if (c == 'e') { if (expr++) return ('e'); /* will cause syntax error */ continue; } /* end of number */ break; } *cp = '\0'; if ((cp - buf) >= BSZ) printf("constant too long: truncated\n"); else ungetc(c, stdin); /* push back last char read */ yylval.dval = atof(buf); return (CONST); } return (c); } static INTERVAL hilo(double a, double b, double c, double d) { /* returns the smallest interval containing a, b, c, and d */ /* used by *, / routines */ INTERVAL v; if (a > b) { v.hi = a; v.lo = b; } else { v.hi = b; v.lo = a; } if (c > d) { if (c > v.hi) v.hi = c; if (d < v.lo) v.lo = d; } else { if (d > v.hi) v.hi = d; if (c < v.lo) v.lo = c; } return (v); } INTERVAL vmul(double a, double b, INTERVAL v) { return (hilo(a * v.hi, a * v.lo, b * v.hi, b * v.lo)); } int dcheck(INTERVAL v) { if (v.hi >= 0. && v.lo <= 0.) { printf("divisor interval contains 0.\n"); return (1); } return (0); } INTERVAL vdiv(double a, double b, INTERVAL v) { return (hilo(a / v.hi, a / v.lo, b / v.hi, b / v.lo)); } #line 655 "calc1.tab.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) #if YYBTYACC #define yytrial (yyps->save) #endif /* YYBTYACC */ #if YYDEBUG #include /* needed for printf */ #endif #include /* needed for malloc, etc */ #include /* needed for memset */ /* allocate initial stack or double stack size, up to YYMAXDEPTH */ static int yygrowstack(YYSTACKDATA *data) { int i; unsigned newsize; YYINT *newss; YYSTYPE *newvs; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE *newps; #endif if ((newsize = data->stacksize) == 0) newsize = YYINITSTACKSIZE; else if (newsize >= YYMAXDEPTH) return YYENOMEM; else if ((newsize *= 2) > YYMAXDEPTH) newsize = YYMAXDEPTH; i = (int) (data->s_mark - data->s_base); newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); if (newss == NULL) return YYENOMEM; data->s_base = newss; data->s_mark = newss + i; newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); if (newvs == NULL) return YYENOMEM; data->l_base = newvs; data->l_mark = newvs + i; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); if (newps == NULL) return YYENOMEM; data->p_base = newps; data->p_mark = newps + i; #endif data->stacksize = newsize; data->s_last = data->s_base + newsize - 1; #if YYDEBUG if (yydebug) fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); #endif return 0; } #if YYPURE || defined(YY_NO_LEAKS) static void yyfreestack(YYSTACKDATA *data) { free(data->s_base); free(data->l_base); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) free(data->p_base); #endif memset(data, 0, sizeof(*data)); } #else #define yyfreestack(data) /* nothing */ #endif /* YYPURE || defined(YY_NO_LEAKS) */ #if YYBTYACC static YYParseState * yyNewState(unsigned size) { YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); if (p == NULL) return NULL; p->yystack.stacksize = size; if (size == 0) { p->yystack.s_base = NULL; p->yystack.l_base = NULL; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) p->yystack.p_base = NULL; #endif return p; } p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); if (p->yystack.s_base == NULL) return NULL; p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); if (p->yystack.l_base == NULL) return NULL; memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); if (p->yystack.p_base == NULL) return NULL; memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); #endif return p; } static void yyFreeState(YYParseState *p) { yyfreestack(&p->yystack); free(p); } #endif /* YYBTYACC */ #define YYABORT goto yyabort #define YYREJECT goto yyabort #define YYACCEPT goto yyaccept #define YYERROR goto yyerrlab #if YYBTYACC #define YYVALID do { if (yyps->save) goto yyvalid; } while(0) #define YYVALID_NESTED do { if (yyps->save && \ yyps->save->save == 0) goto yyvalid; } while(0) #endif /* YYBTYACC */ int YYPARSE_DECL() { int yym, yyn, yystate, yyresult; #if YYBTYACC int yynewerrflag; YYParseState *yyerrctx = NULL; #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ #endif #if YYDEBUG const char *yys; if ((yys = getenv("YYDEBUG")) != NULL) { yyn = *yys; if (yyn >= '0' && yyn <= '9') yydebug = yyn - '0'; } if (yydebug) fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); #endif #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); #endif #if YYBTYACC yyps = yyNewState(0); if (yyps == 0) goto yyenomem; yyps->save = 0; #endif /* YYBTYACC */ yym = 0; /* yyn is set below */ yynerrs = 0; yyerrflag = 0; yychar = YYEMPTY; yystate = 0; #if YYPURE memset(&yystack, 0, sizeof(yystack)); #endif if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystack.s_mark = yystack.s_base; yystack.l_mark = yystack.l_base; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark = yystack.p_base; #endif yystate = 0; *yystack.s_mark = 0; yyloop: if ((yyn = yydefred[yystate]) != 0) goto yyreduce; if (yychar < 0) { #if YYBTYACC do { if (yylvp < yylve) { /* we're currently re-reading tokens */ yylval = *yylvp++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylloc = *yylpp++; #endif yychar = *yylexp++; break; } if (yyps->save) { /* in trial mode; save scanner results for future parse attempts */ if (yylvp == yylvlim) { /* Enlarge lexical value queue */ size_t p = (size_t) (yylvp - yylvals); size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpe = yylpsns + p; yylplim = yylpsns + s; #endif yylexp = yylexemes + p; } *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpp++ = yylloc; yylpe++; #endif yychar = *yylexp++; break; } /* normal operation, no conflict encountered */ #endif /* YYBTYACC */ yychar = YYLEX; #if YYBTYACC } while (0); #endif /* YYBTYACC */ if (yychar < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", YYDEBUGSTR, yydepth, yystate, yychar, yys); #ifdef YYSTYPE_TOSTRING #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); #endif fputc('\n', stderr); } #endif } #if YYBTYACC /* Do we have a conflict? */ if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) { YYINT ctry; if (yypath) { YYParseState *save; #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", YYDEBUGSTR, yydepth, yystate); #endif /* Switch to the next conflict context */ save = yypath; yypath = save->save; save->save = NULL; ctry = save->ctry; if (save->state != yystate) YYABORT; yyFreeState(save); } else { /* Unresolved conflict - start/continue trial parse */ YYParseState *save; #if YYDEBUG if (yydebug) { fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); if (yyps->save) fputs("ALREADY in conflict, continuing trial parse.\n", stderr); else fputs("Starting trial parse.\n", stderr); } #endif save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); if (save == NULL) goto yyenomem; save->save = yyps->save; save->state = yystate; save->errflag = yyerrflag; save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif ctry = yytable[yyn]; if (yyctable[ctry] == -1) { #if YYDEBUG if (yydebug && yychar >= YYEOF) fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); #endif ctry++; } save->ctry = ctry; if (yyps->save == NULL) { /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; yylvlim = yylvals + YYLVQUEUEGROWTH; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); if (yylpsns == NULL) goto yyenomem; yylplim = yylpsns + YYLVQUEUEGROWTH; #endif } if (yylvp == yylve) { yylvp = yylve = yylvals; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpe = yylpsns; #endif yylexp = yylexemes; if (yychar >= YYEOF) { *yylve++ = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpe++ = yylloc; #endif *yylexp = (YYINT) yychar; yychar = YYEMPTY; } } } if (yychar >= YYEOF) { yylvp--; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp--; #endif yylexp--; yychar = YYEMPTY; } save->lexeme = (int) (yylvp - yylvals); yyps->save = save; } if (yytable[yyn] == ctry) { #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); #endif if (yychar < 0) { yylvp++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp++; #endif yylexp++; } if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystate = yyctable[ctry]; *++yystack.s_mark = (YYINT) yystate; *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *++yystack.p_mark = yylloc; #endif yychar = YYEMPTY; if (yyerrflag > 0) --yyerrflag; goto yyloop; } else { yyn = yyctable[ctry]; goto yyreduce; } } /* End of code dealing with conflicts */ #endif /* YYBTYACC */ if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) { #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", YYDEBUGSTR, yydepth, yystate, yytable[yyn]); #endif if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystate = yytable[yyn]; *++yystack.s_mark = yytable[yyn]; *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *++yystack.p_mark = yylloc; #endif yychar = YYEMPTY; if (yyerrflag > 0) --yyerrflag; goto yyloop; } if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) { yyn = yytable[yyn]; goto yyreduce; } if (yyerrflag != 0) goto yyinrecovery; #if YYBTYACC yynewerrflag = 1; goto yyerrhandler; goto yyerrlab; /* redundant goto avoids 'unused label' warning */ yyerrlab: /* explicit YYERROR from an action -- pop the rhs of the rule reduced * before looking for error recovery */ yystack.s_mark -= yym; yystate = *yystack.s_mark; yystack.l_mark -= yym; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark -= yym; #endif yynewerrflag = 0; yyerrhandler: while (yyps->save) { int ctry; YYParseState *save = yyps->save; #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", YYDEBUGSTR, yydepth, yystate, yyps->save->state, (int)(yylvp - yylvals - yyps->save->lexeme)); #endif /* Memorize most forward-looking error state in case it's really an error. */ if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) { /* Free old saved error context state */ if (yyerrctx) yyFreeState(yyerrctx); /* Create and fill out new saved error context state */ yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); if (yyerrctx == NULL) goto yyenomem; yyerrctx->save = yyps->save; yyerrctx->state = yystate; yyerrctx->errflag = yyerrflag; yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif yyerrctx->lexeme = (int) (yylvp - yylvals); } yylvp = yylvals + save->lexeme; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpsns + save->lexeme; #endif yylexp = yylexemes + save->lexeme; yychar = YYEMPTY; yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif ctry = ++save->ctry; yystate = save->state; /* We tried shift, try reduce now */ if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; yyps->save = save->save; save->save = NULL; yyFreeState(save); /* Nothing left on the stack -- error */ if (!yyps->save) { #if YYDEBUG if (yydebug) fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", YYPREFIX, yydepth); #endif /* Restore state as it was in the most forward-advanced error */ yylvp = yylvals + yyerrctx->lexeme; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpsns + yyerrctx->lexeme; #endif yylexp = yylexemes + yyerrctx->lexeme; yychar = yylexp[-1]; yylval = yylvp[-1]; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylloc = yylpp[-1]; #endif yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif yystate = yyerrctx->state; yyFreeState(yyerrctx); yyerrctx = NULL; } yynewerrflag = 1; } if (yynewerrflag == 0) goto yyinrecovery; #endif /* YYBTYACC */ YYERROR_CALL("syntax error"); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ #endif #if !YYBTYACC goto yyerrlab; /* redundant goto avoids 'unused label' warning */ yyerrlab: #endif ++yynerrs; yyinrecovery: if (yyerrflag < 3) { yyerrflag = 3; for (;;) { if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) { #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); #endif if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystate = yytable[yyn]; *++yystack.s_mark = yytable[yyn]; *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* lookahead position is error end position */ yyerror_loc_range[2] = yylloc; YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ *++yystack.p_mark = yyloc; #endif goto yyloop; } else { #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", YYDEBUGSTR, yydepth, *yystack.s_mark); #endif if (yystack.s_mark <= yystack.s_base) goto yyabort; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* the current TOS position is the error start position */ yyerror_loc_range[1] = *yystack.p_mark; #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYDESTRUCT_CALL("error: discarding state", yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); #else YYDESTRUCT_CALL("error: discarding state", yystos[*yystack.s_mark], yystack.l_mark); #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ #endif /* defined(YYDESTRUCT_CALL) */ --yystack.s_mark; --yystack.l_mark; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) --yystack.p_mark; #endif } } } else { if (yychar == YYEOF) goto yyabort; #if YYDEBUG if (yydebug) { if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", YYDEBUGSTR, yydepth, yystate, yychar, yys); } #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); #else YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ #endif /* defined(YYDESTRUCT_CALL) */ yychar = YYEMPTY; goto yyloop; } yyreduce: yym = yylen[yyn]; #if YYDEBUG if (yydebug) { fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); #ifdef YYSTYPE_TOSTRING #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ if (yym > 0) { int i; fputc('<', stderr); for (i = yym; i > 0; i--) { if (i != yym) fputs(", ", stderr); fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], yystack.l_mark[1-i]), stderr); } fputc('>', stderr); } #endif fputc('\n', stderr); } #endif if (yym > 0) yyval = yystack.l_mark[1-yym]; else memset(&yyval, 0, sizeof yyval); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* Perform position reduction */ memset(&yyloc, 0, sizeof(yyloc)); #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ { YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); /* just in case YYERROR is invoked within the action, save the start of the rhs as the error start position */ yyerror_loc_range[1] = yystack.p_mark[1-yym]; } #endif switch (yyn) { case 3: #line 57 "calc1.y" { (void) printf("%15.8f\n", yystack.l_mark[-1].dval); } #line 1330 "calc1.tab.c" break; case 4: #line 61 "calc1.y" { (void) printf("(%15.8f, %15.8f)\n", yystack.l_mark[-1].vval.lo, yystack.l_mark[-1].vval.hi); } #line 1337 "calc1.tab.c" break; case 5: #line 65 "calc1.y" { dreg[yystack.l_mark[-3].ival] = yystack.l_mark[-1].dval; } #line 1344 "calc1.tab.c" break; case 6: #line 69 "calc1.y" { vreg[yystack.l_mark[-3].ival] = yystack.l_mark[-1].vval; } #line 1351 "calc1.tab.c" break; case 7: #line 73 "calc1.y" { yyerrok; } #line 1358 "calc1.tab.c" break; case 9: #line 80 "calc1.y" { yyval.dval = dreg[yystack.l_mark[0].ival]; } #line 1365 "calc1.tab.c" break; case 10: #line 84 "calc1.y" { yyval.dval = yystack.l_mark[-2].dval + yystack.l_mark[0].dval; } #line 1372 "calc1.tab.c" break; case 11: #line 88 "calc1.y" { yyval.dval = yystack.l_mark[-2].dval - yystack.l_mark[0].dval; } #line 1379 "calc1.tab.c" break; case 12: #line 92 "calc1.y" { yyval.dval = yystack.l_mark[-2].dval * yystack.l_mark[0].dval; } #line 1386 "calc1.tab.c" break; case 13: #line 96 "calc1.y" { yyval.dval = yystack.l_mark[-2].dval / yystack.l_mark[0].dval; } #line 1393 "calc1.tab.c" break; case 14: #line 100 "calc1.y" { yyval.dval = -yystack.l_mark[0].dval; } #line 1400 "calc1.tab.c" break; case 15: #line 104 "calc1.y" { yyval.dval = yystack.l_mark[-1].dval; } #line 1407 "calc1.tab.c" break; case 16: #line 110 "calc1.y" { yyval.vval.hi = yyval.vval.lo = yystack.l_mark[0].dval; } #line 1414 "calc1.tab.c" break; case 17: #line 114 "calc1.y" { yyval.vval.lo = yystack.l_mark[-3].dval; yyval.vval.hi = yystack.l_mark[-1].dval; if ( yyval.vval.lo > yyval.vval.hi ) { (void) printf("interval out of order\n"); YYERROR; } } #line 1427 "calc1.tab.c" break; case 18: #line 124 "calc1.y" { yyval.vval = vreg[yystack.l_mark[0].ival]; } #line 1434 "calc1.tab.c" break; case 19: #line 128 "calc1.y" { yyval.vval.hi = yystack.l_mark[-2].vval.hi + yystack.l_mark[0].vval.hi; yyval.vval.lo = yystack.l_mark[-2].vval.lo + yystack.l_mark[0].vval.lo; } #line 1442 "calc1.tab.c" break; case 20: #line 133 "calc1.y" { yyval.vval.hi = yystack.l_mark[-2].dval + yystack.l_mark[0].vval.hi; yyval.vval.lo = yystack.l_mark[-2].dval + yystack.l_mark[0].vval.lo; } #line 1450 "calc1.tab.c" break; case 21: #line 138 "calc1.y" { yyval.vval.hi = yystack.l_mark[-2].vval.hi - yystack.l_mark[0].vval.lo; yyval.vval.lo = yystack.l_mark[-2].vval.lo - yystack.l_mark[0].vval.hi; } #line 1458 "calc1.tab.c" break; case 22: #line 143 "calc1.y" { yyval.vval.hi = yystack.l_mark[-2].dval - yystack.l_mark[0].vval.lo; yyval.vval.lo = yystack.l_mark[-2].dval - yystack.l_mark[0].vval.hi; } #line 1466 "calc1.tab.c" break; case 23: #line 148 "calc1.y" { yyval.vval = vmul( yystack.l_mark[-2].vval.lo, yystack.l_mark[-2].vval.hi, yystack.l_mark[0].vval ); } #line 1473 "calc1.tab.c" break; case 24: #line 152 "calc1.y" { yyval.vval = vmul (yystack.l_mark[-2].dval, yystack.l_mark[-2].dval, yystack.l_mark[0].vval ); } #line 1480 "calc1.tab.c" break; case 25: #line 156 "calc1.y" { if (dcheck(yystack.l_mark[0].vval)) YYERROR; yyval.vval = vdiv ( yystack.l_mark[-2].vval.lo, yystack.l_mark[-2].vval.hi, yystack.l_mark[0].vval ); } #line 1488 "calc1.tab.c" break; case 26: #line 161 "calc1.y" { if (dcheck ( yystack.l_mark[0].vval )) YYERROR; yyval.vval = vdiv (yystack.l_mark[-2].dval, yystack.l_mark[-2].dval, yystack.l_mark[0].vval ); } #line 1496 "calc1.tab.c" break; case 27: #line 166 "calc1.y" { yyval.vval.hi = -yystack.l_mark[0].vval.lo; yyval.vval.lo = -yystack.l_mark[0].vval.hi; } #line 1504 "calc1.tab.c" break; case 28: #line 171 "calc1.y" { yyval.vval = yystack.l_mark[-1].vval; } #line 1511 "calc1.tab.c" break; #line 1513 "calc1.tab.c" default: break; } yystack.s_mark -= yym; yystate = *yystack.s_mark; yystack.l_mark -= yym; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark -= yym; #endif yym = yylhs[yyn]; if (yystate == 0 && yym == 0) { #if YYDEBUG if (yydebug) { fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); #ifdef YYSTYPE_TOSTRING #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); #endif fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); } #endif yystate = YYFINAL; *++yystack.s_mark = YYFINAL; *++yystack.l_mark = yyval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *++yystack.p_mark = yyloc; #endif if (yychar < 0) { #if YYBTYACC do { if (yylvp < yylve) { /* we're currently re-reading tokens */ yylval = *yylvp++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylloc = *yylpp++; #endif yychar = *yylexp++; break; } if (yyps->save) { /* in trial mode; save scanner results for future parse attempts */ if (yylvp == yylvlim) { /* Enlarge lexical value queue */ size_t p = (size_t) (yylvp - yylvals); size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpe = yylpsns + p; yylplim = yylpsns + s; #endif yylexp = yylexemes + p; } *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpp++ = yylloc; yylpe++; #endif yychar = *yylexp++; break; } /* normal operation, no conflict encountered */ #endif /* YYBTYACC */ yychar = YYLEX; #if YYBTYACC } while (0); #endif /* YYBTYACC */ if (yychar < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); } #endif } if (yychar == YYEOF) goto yyaccept; goto yyloop; } if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) yystate = yytable[yyn]; else yystate = yydgoto[yym]; #if YYDEBUG if (yydebug) { fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); #ifdef YYSTYPE_TOSTRING #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); #endif fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); } #endif if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; *++yystack.s_mark = (YYINT) yystate; *++yystack.l_mark = yyval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *++yystack.p_mark = yyloc; #endif goto yyloop; #if YYBTYACC /* Reduction declares that this path is valid. Set yypath and do a full parse */ yyvalid: if (yypath) YYABORT; while (yyps->save) { YYParseState *save = yyps->save; yyps->save = save->save; save->save = yypath; yypath = save; } #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); #endif if (yyerrctx) { yyFreeState(yyerrctx); yyerrctx = NULL; } yylvp = yylvals + yypath->lexeme; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpsns + yypath->lexeme; #endif yylexp = yylexemes + yypath->lexeme; yychar = YYEMPTY; yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif yystate = yypath->state; goto yyloop; #endif /* YYBTYACC */ yyoverflow: YYERROR_CALL("yacc stack overflow"); #if YYBTYACC goto yyabort_nomem; yyenomem: YYERROR_CALL("memory exhausted"); yyabort_nomem: #endif /* YYBTYACC */ yyresult = 2; goto yyreturn; yyabort: yyresult = 1; goto yyreturn; yyaccept: #if YYBTYACC if (yyps->save) goto yyvalid; #endif /* YYBTYACC */ yyresult = 0; yyreturn: #if defined(YYDESTRUCT_CALL) if (yychar != YYEOF && yychar != YYEMPTY) #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); #else YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ { YYSTYPE *pv; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE *pp; for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) YYDESTRUCT_CALL("cleanup: discarding state", yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); #else for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) YYDESTRUCT_CALL("cleanup: discarding state", yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ } #endif /* defined(YYDESTRUCT_CALL) */ #if YYBTYACC if (yyerrctx) { yyFreeState(yyerrctx); yyerrctx = NULL; } while (yyps) { YYParseState *save = yyps; yyps = save->save; save->save = NULL; yyFreeState(save); } while (yypath) { YYParseState *save = yypath; yypath = save->save; save->save = NULL; yyFreeState(save); } #endif /* YYBTYACC */ yyfreestack(&yystack); return (yyresult); } diff --git a/contrib/byacc/test/btyacc/calc1.tab.h b/contrib/byacc/test/btyacc/calc1.tab.h index 0162b2107474..1802350b0d2a 100644 --- a/contrib/byacc/test/btyacc/calc1.tab.h +++ b/contrib/byacc/test/btyacc/calc1.tab.h @@ -1,23 +1,23 @@ #ifndef _calc1__defines_h_ #define _calc1__defines_h_ #define DREG 257 #define VREG 258 #define CONST 259 #define UMINUS 260 #ifdef YYSTYPE #undef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 #endif #ifndef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 -typedef union YYSTYPE +typedef union { int ival; double dval; INTERVAL vval; } YYSTYPE; #endif /* !YYSTYPE_IS_DECLARED */ extern YYSTYPE calc1_lval; #endif /* _calc1__defines_h_ */ diff --git a/contrib/byacc/test/btyacc/err_inherit3.tab.c b/contrib/byacc/test/btyacc/err_inherit3.tab.c index 072d23b59cbb..2a2bde418a5d 100644 --- a/contrib/byacc/test/btyacc/err_inherit3.tab.c +++ b/contrib/byacc/test/btyacc/err_inherit3.tab.c @@ -1,1445 +1,1445 @@ /* original parser id follows */ /* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ /* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ #define YYBYACC 1 #define YYMAJOR 2 #define YYMINOR 0 #define YYCHECK "yyyymmdd" #define YYEMPTY (-1) #define yyclearin (yychar = YYEMPTY) #define yyerrok (yyerrflag = 0) #define YYRECOVERING() (yyerrflag != 0) #define YYENOMEM (-2) #define YYEOF 0 #undef YYBTYACC #define YYBTYACC 0 #define YYDEBUGSTR YYPREFIX "debug" #ifndef yyparse #define yyparse err_inherit3_parse #endif /* yyparse */ #ifndef yylex #define yylex err_inherit3_lex #endif /* yylex */ #ifndef yyerror #define yyerror err_inherit3_error #endif /* yyerror */ #ifndef yychar #define yychar err_inherit3_char #endif /* yychar */ #ifndef yyval #define yyval err_inherit3_val #endif /* yyval */ #ifndef yylval #define yylval err_inherit3_lval #endif /* yylval */ #ifndef yydebug #define yydebug err_inherit3_debug #endif /* yydebug */ #ifndef yynerrs #define yynerrs err_inherit3_nerrs #endif /* yynerrs */ #ifndef yyerrflag #define yyerrflag err_inherit3_errflag #endif /* yyerrflag */ #ifndef yylhs #define yylhs err_inherit3_lhs #endif /* yylhs */ #ifndef yylen #define yylen err_inherit3_len #endif /* yylen */ #ifndef yydefred #define yydefred err_inherit3_defred #endif /* yydefred */ #ifndef yystos #define yystos err_inherit3_stos #endif /* yystos */ #ifndef yydgoto #define yydgoto err_inherit3_dgoto #endif /* yydgoto */ #ifndef yysindex #define yysindex err_inherit3_sindex #endif /* yysindex */ #ifndef yyrindex #define yyrindex err_inherit3_rindex #endif /* yyrindex */ #ifndef yygindex #define yygindex err_inherit3_gindex #endif /* yygindex */ #ifndef yytable #define yytable err_inherit3_table #endif /* yytable */ #ifndef yycheck #define yycheck err_inherit3_check #endif /* yycheck */ #ifndef yyname #define yyname err_inherit3_name #endif /* yyname */ #ifndef yyrule #define yyrule err_inherit3_rule #endif /* yyrule */ #if YYBTYACC #ifndef yycindex #define yycindex err_inherit3_cindex #endif /* yycindex */ #ifndef yyctable #define yyctable err_inherit3_ctable #endif /* yyctable */ #endif /* YYBTYACC */ #define YYPREFIX "err_inherit3_" #define YYPURE 0 #line 2 "err_inherit3.y" #include typedef enum {cGLOBAL, cLOCAL} class; typedef enum {tREAL, tINTEGER} type; typedef char * name; struct symbol { class c; type t; name id; }; typedef struct symbol symbol; struct namelist { symbol *s; struct namelist *next; }; typedef struct namelist namelist; extern symbol *mksymbol(type t, class c, name id); #ifdef YYBISON #define YYLEX_DECL() yylex(void) #define YYERROR_DECL() yyerror(const char *s) #endif #ifdef YYSTYPE #undef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 #endif #ifndef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 #line 39 "err_inherit3.y" -typedef union YYSTYPE +typedef union { class cval; type tval; namelist * nlist; name id; } YYSTYPE; #endif /* !YYSTYPE_IS_DECLARED */ #line 155 "err_inherit3.tab.c" /* compatibility with bison */ #ifdef YYPARSE_PARAM /* compatibility with FreeBSD */ # ifdef YYPARSE_PARAM_TYPE # define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) # else # define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) # endif #else # define YYPARSE_DECL() yyparse(void) #endif /* Parameters sent to lex. */ #ifdef YYLEX_PARAM # define YYLEX_DECL() yylex(void *YYLEX_PARAM) # define YYLEX yylex(YYLEX_PARAM) #else # define YYLEX_DECL() yylex(void) # define YYLEX yylex() #endif /* Parameters sent to yyerror. */ #ifndef YYERROR_DECL #define YYERROR_DECL() yyerror(const char *s) #endif #ifndef YYERROR_CALL #define YYERROR_CALL(msg) yyerror(msg) #endif #ifndef YYDESTRUCT_DECL #define YYDESTRUCT_DECL() yydestruct(const char *msg, int psymb, YYSTYPE *val) #endif #ifndef YYDESTRUCT_CALL #define YYDESTRUCT_CALL(msg, psymb, val) yydestruct(msg, psymb, val) #endif extern int YYPARSE_DECL(); #define GLOBAL 257 #define LOCAL 258 #define REAL 259 #define INTEGER 260 #define NAME 261 #define YYERRCODE 256 typedef int YYINT; static const YYINT err_inherit3_lhs[] = { -1, 5, 6, 0, 0, 3, 3, 4, 4, 7, 1, 1, 8, 2, }; static const YYINT err_inherit3_len[] = { 2, 0, 0, 5, 2, 1, 1, 1, 1, 0, 3, 1, 0, 3, }; static const YYINT err_inherit3_defred[] = { 0, 5, 6, 7, 8, 0, 0, 12, 1, 4, 2, 2, 0, 0, 11, 13, 0, 3, 0, 10, }; #if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) static const YYINT err_inherit3_stos[] = { 0, 257, 258, 259, 260, 263, 266, 267, 267, 265, 271, 268, 269, 269, 261, 264, 270, 264, 264, 261, }; #endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ static const YYINT err_inherit3_dgoto[] = { 5, 15, 9, 6, 7, 11, 12, 16, 10, }; static const YYINT err_inherit3_sindex[] = { -257, 0, 0, 0, 0, 0, -254, 0, 0, 0, 0, 0, -253, -253, 0, 0, -253, 0, -252, 0, }; static const YYINT err_inherit3_rindex[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; #if YYBTYACC static const YYINT err_inherit3_cindex[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; #endif static const YYINT err_inherit3_gindex[] = { 0, -9, 0, 0, 4, 0, 1, 0, 0, }; #define YYTABLESIZE 12 static const YYINT err_inherit3_table[] = { 1, 2, 3, 4, 17, 3, 4, 18, 14, 19, 8, 0, 13, }; static const YYINT err_inherit3_check[] = { 257, 258, 259, 260, 13, 259, 260, 16, 261, 261, 6, -1, 11, }; #if YYBTYACC static const YYINT err_inherit3_ctable[] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, }; #endif #define YYFINAL 5 #ifndef YYDEBUG #define YYDEBUG 0 #endif #define YYMAXTOKEN 261 #define YYUNDFTOKEN 272 #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) #if YYDEBUG static const char *const err_inherit3_name[] = { "$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, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"error","GLOBAL","LOCAL","REAL","INTEGER", "NAME","$accept","declaration","namelist","locnamelist","class","type","$$1", "$$2","$$3","$$4","illegal-symbol", }; static const char *const err_inherit3_rule[] = { "$accept : declaration", "$$1 :", "$$2 :", "declaration : class type $$1 $$2 namelist", "declaration : type locnamelist", "class : GLOBAL", "class : LOCAL", "type : REAL", "type : INTEGER", "$$3 :", "namelist : $$3 namelist NAME", "namelist : NAME", "$$4 :", "locnamelist : $$4 $$2 namelist", }; #endif #if YYDEBUG int yydebug; #endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; int yynerrs; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyloc; /* position returned by actions */ YYLTYPE yylloc; /* position from the lexer */ #endif #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) #ifndef YYLLOC_DEFAULT #define YYLLOC_DEFAULT(loc, rhs, n) \ do \ { \ if (n == 0) \ { \ (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ } \ else \ { \ (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ (loc).last_line = YYRHSLOC(rhs, n).last_line; \ (loc).last_column = YYRHSLOC(rhs, n).last_column; \ } \ } while (0) #endif /* YYLLOC_DEFAULT */ #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ #if YYBTYACC #ifndef YYLVQUEUEGROWTH #define YYLVQUEUEGROWTH 32 #endif #endif /* YYBTYACC */ /* define the initial stack-sizes */ #ifdef YYSTACKSIZE #undef YYMAXDEPTH #define YYMAXDEPTH YYSTACKSIZE #else #ifdef YYMAXDEPTH #define YYSTACKSIZE YYMAXDEPTH #else #define YYSTACKSIZE 10000 #define YYMAXDEPTH 10000 #endif #endif #ifndef YYINITSTACKSIZE #define YYINITSTACKSIZE 200 #endif typedef struct { unsigned stacksize; YYINT *s_base; YYINT *s_mark; YYINT *s_last; YYSTYPE *l_base; YYSTYPE *l_mark; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE *p_base; YYLTYPE *p_mark; #endif } YYSTACKDATA; #if YYBTYACC struct YYParseState_s { struct YYParseState_s *save; /* Previously saved parser state */ YYSTACKDATA yystack; /* saved parser stack */ int state; /* saved parser state */ int errflag; /* saved error recovery status */ int lexeme; /* saved index of the conflict lexeme in the lexical queue */ YYINT ctry; /* saved index in yyctable[] for this conflict */ }; typedef struct YYParseState_s YYParseState; #endif /* YYBTYACC */ /* variables for the parser stack */ static YYSTACKDATA yystack; #if YYBTYACC /* Current parser state */ static YYParseState *yyps = 0; /* yypath != NULL: do the full parse, starting at *yypath parser state. */ static YYParseState *yypath = 0; /* Base of the lexical value queue */ static YYSTYPE *yylvals = 0; /* Current position at lexical value queue */ static YYSTYPE *yylvp = 0; /* End position of lexical value queue */ static YYSTYPE *yylve = 0; /* The last allocated position at the lexical value queue */ static YYSTYPE *yylvlim = 0; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* Base of the lexical position queue */ static YYLTYPE *yylpsns = 0; /* Current position at lexical position queue */ static YYLTYPE *yylpp = 0; /* End position of lexical position queue */ static YYLTYPE *yylpe = 0; /* The last allocated position at the lexical position queue */ static YYLTYPE *yylplim = 0; #endif /* Current position at lexical token queue */ static YYINT *yylexp = 0; static YYINT *yylexemes = 0; #endif /* YYBTYACC */ #line 78 "err_inherit3.y" extern int YYLEX_DECL(); extern void YYERROR_DECL(); #line 425 "err_inherit3.tab.c" /* Release memory associated with symbol. */ #if ! defined YYDESTRUCT_IS_DECLARED static void YYDESTRUCT_DECL() { switch (psymb) { case 263: #line 30 "err_inherit3.y" { namelist *p = (*val).nlist; while (p != NULL) { namelist *pp = p; p = p->next; free(pp->s); free(pp); } } #line 444 "err_inherit3.tab.c" break; case 264: #line 30 "err_inherit3.y" { namelist *p = (*val).nlist; while (p != NULL) { namelist *pp = p; p = p->next; free(pp->s); free(pp); } } #line 456 "err_inherit3.tab.c" break; case 265: #line 30 "err_inherit3.y" { namelist *p = (*val).nlist; while (p != NULL) { namelist *pp = p; p = p->next; free(pp->s); free(pp); } } #line 468 "err_inherit3.tab.c" break; } } #define YYDESTRUCT_IS_DECLARED 1 #endif /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) #if YYBTYACC #define yytrial (yyps->save) #endif /* YYBTYACC */ #if YYDEBUG #include /* needed for printf */ #endif #include /* needed for malloc, etc */ #include /* needed for memset */ /* allocate initial stack or double stack size, up to YYMAXDEPTH */ static int yygrowstack(YYSTACKDATA *data) { int i; unsigned newsize; YYINT *newss; YYSTYPE *newvs; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE *newps; #endif if ((newsize = data->stacksize) == 0) newsize = YYINITSTACKSIZE; else if (newsize >= YYMAXDEPTH) return YYENOMEM; else if ((newsize *= 2) > YYMAXDEPTH) newsize = YYMAXDEPTH; i = (int) (data->s_mark - data->s_base); newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); if (newss == NULL) return YYENOMEM; data->s_base = newss; data->s_mark = newss + i; newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); if (newvs == NULL) return YYENOMEM; data->l_base = newvs; data->l_mark = newvs + i; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); if (newps == NULL) return YYENOMEM; data->p_base = newps; data->p_mark = newps + i; #endif data->stacksize = newsize; data->s_last = data->s_base + newsize - 1; #if YYDEBUG if (yydebug) fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); #endif return 0; } #if YYPURE || defined(YY_NO_LEAKS) static void yyfreestack(YYSTACKDATA *data) { free(data->s_base); free(data->l_base); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) free(data->p_base); #endif memset(data, 0, sizeof(*data)); } #else #define yyfreestack(data) /* nothing */ #endif /* YYPURE || defined(YY_NO_LEAKS) */ #if YYBTYACC static YYParseState * yyNewState(unsigned size) { YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); if (p == NULL) return NULL; p->yystack.stacksize = size; if (size == 0) { p->yystack.s_base = NULL; p->yystack.l_base = NULL; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) p->yystack.p_base = NULL; #endif return p; } p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); if (p->yystack.s_base == NULL) return NULL; p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); if (p->yystack.l_base == NULL) return NULL; memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); if (p->yystack.p_base == NULL) return NULL; memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); #endif return p; } static void yyFreeState(YYParseState *p) { yyfreestack(&p->yystack); free(p); } #endif /* YYBTYACC */ #define YYABORT goto yyabort #define YYREJECT goto yyabort #define YYACCEPT goto yyaccept #define YYERROR goto yyerrlab #if YYBTYACC #define YYVALID do { if (yyps->save) goto yyvalid; } while(0) #define YYVALID_NESTED do { if (yyps->save && \ yyps->save->save == 0) goto yyvalid; } while(0) #endif /* YYBTYACC */ int YYPARSE_DECL() { int yym, yyn, yystate, yyresult; #if YYBTYACC int yynewerrflag; YYParseState *yyerrctx = NULL; #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ #endif #if YYDEBUG const char *yys; if ((yys = getenv("YYDEBUG")) != NULL) { yyn = *yys; if (yyn >= '0' && yyn <= '9') yydebug = yyn - '0'; } if (yydebug) fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); #endif #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); #endif #if YYBTYACC yyps = yyNewState(0); if (yyps == 0) goto yyenomem; yyps->save = 0; #endif /* YYBTYACC */ yym = 0; /* yyn is set below */ yynerrs = 0; yyerrflag = 0; yychar = YYEMPTY; yystate = 0; #if YYPURE memset(&yystack, 0, sizeof(yystack)); #endif if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystack.s_mark = yystack.s_base; yystack.l_mark = yystack.l_base; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark = yystack.p_base; #endif yystate = 0; *yystack.s_mark = 0; yyloop: if ((yyn = yydefred[yystate]) != 0) goto yyreduce; if (yychar < 0) { #if YYBTYACC do { if (yylvp < yylve) { /* we're currently re-reading tokens */ yylval = *yylvp++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylloc = *yylpp++; #endif yychar = *yylexp++; break; } if (yyps->save) { /* in trial mode; save scanner results for future parse attempts */ if (yylvp == yylvlim) { /* Enlarge lexical value queue */ size_t p = (size_t) (yylvp - yylvals); size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpe = yylpsns + p; yylplim = yylpsns + s; #endif yylexp = yylexemes + p; } *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpp++ = yylloc; yylpe++; #endif yychar = *yylexp++; break; } /* normal operation, no conflict encountered */ #endif /* YYBTYACC */ yychar = YYLEX; #if YYBTYACC } while (0); #endif /* YYBTYACC */ if (yychar < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", YYDEBUGSTR, yydepth, yystate, yychar, yys); #ifdef YYSTYPE_TOSTRING #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); #endif fputc('\n', stderr); } #endif } #if YYBTYACC /* Do we have a conflict? */ if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) { YYINT ctry; if (yypath) { YYParseState *save; #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", YYDEBUGSTR, yydepth, yystate); #endif /* Switch to the next conflict context */ save = yypath; yypath = save->save; save->save = NULL; ctry = save->ctry; if (save->state != yystate) YYABORT; yyFreeState(save); } else { /* Unresolved conflict - start/continue trial parse */ YYParseState *save; #if YYDEBUG if (yydebug) { fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); if (yyps->save) fputs("ALREADY in conflict, continuing trial parse.\n", stderr); else fputs("Starting trial parse.\n", stderr); } #endif save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); if (save == NULL) goto yyenomem; save->save = yyps->save; save->state = yystate; save->errflag = yyerrflag; save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif ctry = yytable[yyn]; if (yyctable[ctry] == -1) { #if YYDEBUG if (yydebug && yychar >= YYEOF) fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); #endif ctry++; } save->ctry = ctry; if (yyps->save == NULL) { /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; yylvlim = yylvals + YYLVQUEUEGROWTH; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); if (yylpsns == NULL) goto yyenomem; yylplim = yylpsns + YYLVQUEUEGROWTH; #endif } if (yylvp == yylve) { yylvp = yylve = yylvals; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpe = yylpsns; #endif yylexp = yylexemes; if (yychar >= YYEOF) { *yylve++ = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpe++ = yylloc; #endif *yylexp = (YYINT) yychar; yychar = YYEMPTY; } } } if (yychar >= YYEOF) { yylvp--; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp--; #endif yylexp--; yychar = YYEMPTY; } save->lexeme = (int) (yylvp - yylvals); yyps->save = save; } if (yytable[yyn] == ctry) { #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); #endif if (yychar < 0) { yylvp++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp++; #endif yylexp++; } if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystate = yyctable[ctry]; *++yystack.s_mark = (YYINT) yystate; *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *++yystack.p_mark = yylloc; #endif yychar = YYEMPTY; if (yyerrflag > 0) --yyerrflag; goto yyloop; } else { yyn = yyctable[ctry]; goto yyreduce; } } /* End of code dealing with conflicts */ #endif /* YYBTYACC */ if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) { #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", YYDEBUGSTR, yydepth, yystate, yytable[yyn]); #endif if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystate = yytable[yyn]; *++yystack.s_mark = yytable[yyn]; *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *++yystack.p_mark = yylloc; #endif yychar = YYEMPTY; if (yyerrflag > 0) --yyerrflag; goto yyloop; } if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) { yyn = yytable[yyn]; goto yyreduce; } if (yyerrflag != 0) goto yyinrecovery; #if YYBTYACC yynewerrflag = 1; goto yyerrhandler; goto yyerrlab; /* redundant goto avoids 'unused label' warning */ yyerrlab: /* explicit YYERROR from an action -- pop the rhs of the rule reduced * before looking for error recovery */ yystack.s_mark -= yym; yystate = *yystack.s_mark; yystack.l_mark -= yym; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark -= yym; #endif yynewerrflag = 0; yyerrhandler: while (yyps->save) { int ctry; YYParseState *save = yyps->save; #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", YYDEBUGSTR, yydepth, yystate, yyps->save->state, (int)(yylvp - yylvals - yyps->save->lexeme)); #endif /* Memorize most forward-looking error state in case it's really an error. */ if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) { /* Free old saved error context state */ if (yyerrctx) yyFreeState(yyerrctx); /* Create and fill out new saved error context state */ yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); if (yyerrctx == NULL) goto yyenomem; yyerrctx->save = yyps->save; yyerrctx->state = yystate; yyerrctx->errflag = yyerrflag; yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif yyerrctx->lexeme = (int) (yylvp - yylvals); } yylvp = yylvals + save->lexeme; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpsns + save->lexeme; #endif yylexp = yylexemes + save->lexeme; yychar = YYEMPTY; yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif ctry = ++save->ctry; yystate = save->state; /* We tried shift, try reduce now */ if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; yyps->save = save->save; save->save = NULL; yyFreeState(save); /* Nothing left on the stack -- error */ if (!yyps->save) { #if YYDEBUG if (yydebug) fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", YYPREFIX, yydepth); #endif /* Restore state as it was in the most forward-advanced error */ yylvp = yylvals + yyerrctx->lexeme; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpsns + yyerrctx->lexeme; #endif yylexp = yylexemes + yyerrctx->lexeme; yychar = yylexp[-1]; yylval = yylvp[-1]; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylloc = yylpp[-1]; #endif yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif yystate = yyerrctx->state; yyFreeState(yyerrctx); yyerrctx = NULL; } yynewerrflag = 1; } if (yynewerrflag == 0) goto yyinrecovery; #endif /* YYBTYACC */ YYERROR_CALL("syntax error"); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ #endif #if !YYBTYACC goto yyerrlab; /* redundant goto avoids 'unused label' warning */ yyerrlab: #endif ++yynerrs; yyinrecovery: if (yyerrflag < 3) { yyerrflag = 3; for (;;) { if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) { #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); #endif if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystate = yytable[yyn]; *++yystack.s_mark = yytable[yyn]; *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* lookahead position is error end position */ yyerror_loc_range[2] = yylloc; YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ *++yystack.p_mark = yyloc; #endif goto yyloop; } else { #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", YYDEBUGSTR, yydepth, *yystack.s_mark); #endif if (yystack.s_mark <= yystack.s_base) goto yyabort; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* the current TOS position is the error start position */ yyerror_loc_range[1] = *yystack.p_mark; #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYDESTRUCT_CALL("error: discarding state", yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); #else YYDESTRUCT_CALL("error: discarding state", yystos[*yystack.s_mark], yystack.l_mark); #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ #endif /* defined(YYDESTRUCT_CALL) */ --yystack.s_mark; --yystack.l_mark; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) --yystack.p_mark; #endif } } } else { if (yychar == YYEOF) goto yyabort; #if YYDEBUG if (yydebug) { if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", YYDEBUGSTR, yydepth, yystate, yychar, yys); } #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); #else YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ #endif /* defined(YYDESTRUCT_CALL) */ yychar = YYEMPTY; goto yyloop; } yyreduce: yym = yylen[yyn]; #if YYDEBUG if (yydebug) { fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); #ifdef YYSTYPE_TOSTRING #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ if (yym > 0) { int i; fputc('<', stderr); for (i = yym; i > 0; i--) { if (i != yym) fputs(", ", stderr); fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], yystack.l_mark[1-i]), stderr); } fputc('>', stderr); } #endif fputc('\n', stderr); } #endif if (yym > 0) yyval = yystack.l_mark[1-yym]; else memset(&yyval, 0, sizeof yyval); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* Perform position reduction */ memset(&yyloc, 0, sizeof(yyloc)); #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ { YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); /* just in case YYERROR is invoked within the action, save the start of the rhs as the error start position */ yyerror_loc_range[1] = yystack.p_mark[1-yym]; } #endif switch (yyn) { case 1: #line 50 "err_inherit3.y" yyval.cval = yystack.l_mark[-1].cval; #line 1146 "err_inherit3.tab.c" break; case 2: #line 50 "err_inherit3.y" yyval.tval = yystack.l_mark[-1].tval; #line 1151 "err_inherit3.tab.c" break; case 3: #line 51 "err_inherit3.y" { yyval.nlist = yystack.l_mark[0].nlist; } #line 1156 "err_inherit3.tab.c" break; case 4: #line 53 "err_inherit3.y" { yyval.nlist = yystack.l_mark[0].nlist; } #line 1161 "err_inherit3.tab.c" break; case 5: #line 56 "err_inherit3.y" { yyval.cval = cGLOBAL; } #line 1166 "err_inherit3.tab.c" break; case 6: #line 57 "err_inherit3.y" { yyval.cval = cLOCAL; } #line 1171 "err_inherit3.tab.c" break; case 7: #line 60 "err_inherit3.y" { yyval.tval = tREAL; } #line 1176 "err_inherit3.tab.c" break; case 8: #line 61 "err_inherit3.y" { yyval.tval = tINTEGER; } #line 1181 "err_inherit3.tab.c" break; case 9: #line 64 "err_inherit3.y" yyval.cval = yystack.l_mark[-2]; #line 1186 "err_inherit3.tab.c" break; case 10: #line 65 "err_inherit3.y" { yyval.nlist->s = mksymbol(yystack.l_mark[-5].tval, yystack.l_mark[-5].cval, yystack.l_mark[0].id); yyval.nlist->next = yystack.l_mark[-1].nlist; } #line 1193 "err_inherit3.tab.c" break; case 11: #line 69 "err_inherit3.y" { yyval.nlist->s = mksymbol(yystack.l_mark[-3], yystack.l_mark[-3], yystack.l_mark[0].id); yyval.nlist->next = NULL; } #line 1200 "err_inherit3.tab.c" break; case 12: #line 74 "err_inherit3.y" yyval.cval = cLOCAL; #line 1205 "err_inherit3.tab.c" break; case 13: #line 75 "err_inherit3.y" { yyval.nlist = yystack.l_mark[0].nlist; } #line 1210 "err_inherit3.tab.c" break; #line 1212 "err_inherit3.tab.c" default: break; } yystack.s_mark -= yym; yystate = *yystack.s_mark; yystack.l_mark -= yym; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark -= yym; #endif yym = yylhs[yyn]; if (yystate == 0 && yym == 0) { #if YYDEBUG if (yydebug) { fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); #ifdef YYSTYPE_TOSTRING #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); #endif fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); } #endif yystate = YYFINAL; *++yystack.s_mark = YYFINAL; *++yystack.l_mark = yyval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *++yystack.p_mark = yyloc; #endif if (yychar < 0) { #if YYBTYACC do { if (yylvp < yylve) { /* we're currently re-reading tokens */ yylval = *yylvp++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylloc = *yylpp++; #endif yychar = *yylexp++; break; } if (yyps->save) { /* in trial mode; save scanner results for future parse attempts */ if (yylvp == yylvlim) { /* Enlarge lexical value queue */ size_t p = (size_t) (yylvp - yylvals); size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpe = yylpsns + p; yylplim = yylpsns + s; #endif yylexp = yylexemes + p; } *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpp++ = yylloc; yylpe++; #endif yychar = *yylexp++; break; } /* normal operation, no conflict encountered */ #endif /* YYBTYACC */ yychar = YYLEX; #if YYBTYACC } while (0); #endif /* YYBTYACC */ if (yychar < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); } #endif } if (yychar == YYEOF) goto yyaccept; goto yyloop; } if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) yystate = yytable[yyn]; else yystate = yydgoto[yym]; #if YYDEBUG if (yydebug) { fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); #ifdef YYSTYPE_TOSTRING #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); #endif fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); } #endif if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; *++yystack.s_mark = (YYINT) yystate; *++yystack.l_mark = yyval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *++yystack.p_mark = yyloc; #endif goto yyloop; #if YYBTYACC /* Reduction declares that this path is valid. Set yypath and do a full parse */ yyvalid: if (yypath) YYABORT; while (yyps->save) { YYParseState *save = yyps->save; yyps->save = save->save; save->save = yypath; yypath = save; } #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); #endif if (yyerrctx) { yyFreeState(yyerrctx); yyerrctx = NULL; } yylvp = yylvals + yypath->lexeme; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpsns + yypath->lexeme; #endif yylexp = yylexemes + yypath->lexeme; yychar = YYEMPTY; yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif yystate = yypath->state; goto yyloop; #endif /* YYBTYACC */ yyoverflow: YYERROR_CALL("yacc stack overflow"); #if YYBTYACC goto yyabort_nomem; yyenomem: YYERROR_CALL("memory exhausted"); yyabort_nomem: #endif /* YYBTYACC */ yyresult = 2; goto yyreturn; yyabort: yyresult = 1; goto yyreturn; yyaccept: #if YYBTYACC if (yyps->save) goto yyvalid; #endif /* YYBTYACC */ yyresult = 0; yyreturn: #if defined(YYDESTRUCT_CALL) if (yychar != YYEOF && yychar != YYEMPTY) #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); #else YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ { YYSTYPE *pv; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE *pp; for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) YYDESTRUCT_CALL("cleanup: discarding state", yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); #else for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) YYDESTRUCT_CALL("cleanup: discarding state", yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ } #endif /* defined(YYDESTRUCT_CALL) */ #if YYBTYACC if (yyerrctx) { yyFreeState(yyerrctx); yyerrctx = NULL; } while (yyps) { YYParseState *save = yyps; yyps = save->save; save->save = NULL; yyFreeState(save); } while (yypath) { YYParseState *save = yypath; yypath = save->save; save->save = NULL; yyFreeState(save); } #endif /* YYBTYACC */ yyfreestack(&yystack); return (yyresult); } diff --git a/contrib/byacc/test/btyacc/err_inherit3.tab.h b/contrib/byacc/test/btyacc/err_inherit3.tab.h index 1018167b685a..5fa781de315b 100644 --- a/contrib/byacc/test/btyacc/err_inherit3.tab.h +++ b/contrib/byacc/test/btyacc/err_inherit3.tab.h @@ -1,25 +1,25 @@ #ifndef _err_inherit3__defines_h_ #define _err_inherit3__defines_h_ #define GLOBAL 257 #define LOCAL 258 #define REAL 259 #define INTEGER 260 #define NAME 261 #ifdef YYSTYPE #undef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 #endif #ifndef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 -typedef union YYSTYPE +typedef union { class cval; type tval; namelist * nlist; name id; } YYSTYPE; #endif /* !YYSTYPE_IS_DECLARED */ extern YYSTYPE err_inherit3_lval; #endif /* _err_inherit3__defines_h_ */ diff --git a/contrib/byacc/test/btyacc/err_inherit4.tab.c b/contrib/byacc/test/btyacc/err_inherit4.tab.c index 4d84c3abf220..71a460d6c606 100644 --- a/contrib/byacc/test/btyacc/err_inherit4.tab.c +++ b/contrib/byacc/test/btyacc/err_inherit4.tab.c @@ -1,1433 +1,1433 @@ /* original parser id follows */ /* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ /* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ #define YYBYACC 1 #define YYMAJOR 2 #define YYMINOR 0 #define YYCHECK "yyyymmdd" #define YYEMPTY (-1) #define yyclearin (yychar = YYEMPTY) #define yyerrok (yyerrflag = 0) #define YYRECOVERING() (yyerrflag != 0) #define YYENOMEM (-2) #define YYEOF 0 #undef YYBTYACC #define YYBTYACC 0 #define YYDEBUGSTR YYPREFIX "debug" #ifndef yyparse #define yyparse err_inherit4_parse #endif /* yyparse */ #ifndef yylex #define yylex err_inherit4_lex #endif /* yylex */ #ifndef yyerror #define yyerror err_inherit4_error #endif /* yyerror */ #ifndef yychar #define yychar err_inherit4_char #endif /* yychar */ #ifndef yyval #define yyval err_inherit4_val #endif /* yyval */ #ifndef yylval #define yylval err_inherit4_lval #endif /* yylval */ #ifndef yydebug #define yydebug err_inherit4_debug #endif /* yydebug */ #ifndef yynerrs #define yynerrs err_inherit4_nerrs #endif /* yynerrs */ #ifndef yyerrflag #define yyerrflag err_inherit4_errflag #endif /* yyerrflag */ #ifndef yylhs #define yylhs err_inherit4_lhs #endif /* yylhs */ #ifndef yylen #define yylen err_inherit4_len #endif /* yylen */ #ifndef yydefred #define yydefred err_inherit4_defred #endif /* yydefred */ #ifndef yystos #define yystos err_inherit4_stos #endif /* yystos */ #ifndef yydgoto #define yydgoto err_inherit4_dgoto #endif /* yydgoto */ #ifndef yysindex #define yysindex err_inherit4_sindex #endif /* yysindex */ #ifndef yyrindex #define yyrindex err_inherit4_rindex #endif /* yyrindex */ #ifndef yygindex #define yygindex err_inherit4_gindex #endif /* yygindex */ #ifndef yytable #define yytable err_inherit4_table #endif /* yytable */ #ifndef yycheck #define yycheck err_inherit4_check #endif /* yycheck */ #ifndef yyname #define yyname err_inherit4_name #endif /* yyname */ #ifndef yyrule #define yyrule err_inherit4_rule #endif /* yyrule */ #ifndef yyloc #define yyloc err_inherit4_loc #endif /* yyloc */ #ifndef yylloc #define yylloc err_inherit4_lloc #endif /* yylloc */ #if YYBTYACC #ifndef yycindex #define yycindex err_inherit4_cindex #endif /* yycindex */ #ifndef yyctable #define yyctable err_inherit4_ctable #endif /* yyctable */ #endif /* YYBTYACC */ #define YYPREFIX "err_inherit4_" #define YYPURE 0 #line 3 "err_inherit4.y" #include typedef enum {cGLOBAL, cLOCAL} class; typedef enum {tREAL, tINTEGER} type; typedef char * name; struct symbol { class c; type t; name id; }; typedef struct symbol symbol; struct namelist { symbol *s; struct namelist *next; }; typedef struct namelist namelist; extern symbol *mksymbol(type t, class c, name id); #ifdef YYBISON #define YYLEX_DECL() yylex(void) #define YYERROR_DECL() yyerror(const char *s) #endif #ifdef YYSTYPE #undef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 #endif #ifndef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 #line 41 "err_inherit4.y" -typedef union YYSTYPE +typedef union { class cval; type tval; namelist * nlist; name id; } YYSTYPE; #endif /* !YYSTYPE_IS_DECLARED */ #line 163 "err_inherit4.tab.c" #if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED /* Default: YYLTYPE is the text position type. */ typedef struct YYLTYPE { int first_line; int first_column; int last_line; int last_column; unsigned source; } YYLTYPE; #define YYLTYPE_IS_DECLARED 1 #endif #define YYRHSLOC(rhs, k) ((rhs)[k]) /* compatibility with bison */ #ifdef YYPARSE_PARAM /* compatibility with FreeBSD */ # ifdef YYPARSE_PARAM_TYPE # define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) # else # define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) # endif #else # define YYPARSE_DECL() yyparse(void) #endif /* Parameters sent to lex. */ #ifdef YYLEX_PARAM # define YYLEX_DECL() yylex(void *YYLEX_PARAM) # define YYLEX yylex(YYLEX_PARAM) #else # define YYLEX_DECL() yylex(void) # define YYLEX yylex() #endif /* Parameters sent to yyerror. */ #ifndef YYERROR_DECL #define YYERROR_DECL() yyerror(YYLTYPE *loc, const char *s) #endif #ifndef YYERROR_CALL #define YYERROR_CALL(msg) yyerror(&yylloc, msg) #endif #ifndef YYDESTRUCT_DECL #define YYDESTRUCT_DECL() yydestruct(const char *msg, int psymb, YYSTYPE *val, YYLTYPE *loc) #endif #ifndef YYDESTRUCT_CALL #define YYDESTRUCT_CALL(msg, psymb, val, loc) yydestruct(msg, psymb, val, loc) #endif extern int YYPARSE_DECL(); #define GLOBAL 257 #define LOCAL 258 #define REAL 259 #define INTEGER 260 #define NAME 261 #define YYERRCODE 256 typedef int YYINT; static const YYINT err_inherit4_lhs[] = { -1, 5, 6, 0, 0, 3, 3, 4, 4, 1, 1, 2, }; static const YYINT err_inherit4_len[] = { 2, 0, 0, 5, 2, 1, 1, 1, 1, 2, 1, 1, }; static const YYINT err_inherit4_defred[] = { 0, 5, 6, 7, 8, 0, 0, 0, 1, 10, 0, 4, 2, 9, 0, 0, }; #if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) static const YYINT err_inherit4_stos[] = { 0, 257, 258, 259, 260, 263, 266, 267, 267, 261, 264, 265, 268, 261, 269, 264, }; #endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ static const YYINT err_inherit4_dgoto[] = { 5, 10, 11, 6, 7, 12, 14, }; static const YYINT err_inherit4_sindex[] = { -257, 0, 0, 0, 0, 0, -255, -254, 0, 0, -253, 0, 0, 0, -254, -253, }; static const YYINT err_inherit4_rindex[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 9, }; #if YYBTYACC static const YYINT err_inherit4_cindex[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; #endif static const YYINT err_inherit4_gindex[] = { 0, -4, 0, 0, 5, 0, 0, }; #define YYTABLESIZE 11 static const YYINT err_inherit4_table[] = { 1, 2, 3, 4, 3, 4, 11, 9, 13, 3, 15, 8, }; static const YYINT err_inherit4_check[] = { 257, 258, 259, 260, 259, 260, 0, 261, 261, 0, 14, 6, }; #if YYBTYACC static const YYINT err_inherit4_ctable[] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, }; #endif #define YYFINAL 5 #ifndef YYDEBUG #define YYDEBUG 0 #endif #define YYMAXTOKEN 261 #define YYUNDFTOKEN 270 #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) #if YYDEBUG static const char *const err_inherit4_name[] = { "$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, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"error","GLOBAL","LOCAL","REAL","INTEGER", "NAME","$accept","declaration","namelist","locnamelist","class","type","$$1", "$$2","illegal-symbol", }; static const char *const err_inherit4_rule[] = { "$accept : declaration", "$$1 :", "$$2 :", "declaration : class type $$1 $$2 namelist", "declaration : type locnamelist", "class : GLOBAL", "class : LOCAL", "type : REAL", "type : INTEGER", "namelist : namelist NAME", "namelist : NAME", "locnamelist : namelist", }; #endif #if YYDEBUG int yydebug; #endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; int yynerrs; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyloc; /* position returned by actions */ YYLTYPE yylloc; /* position from the lexer */ #endif #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) #ifndef YYLLOC_DEFAULT #define YYLLOC_DEFAULT(loc, rhs, n) \ do \ { \ if (n == 0) \ { \ (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ } \ else \ { \ (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ (loc).last_line = YYRHSLOC(rhs, n).last_line; \ (loc).last_column = YYRHSLOC(rhs, n).last_column; \ } \ } while (0) #endif /* YYLLOC_DEFAULT */ #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ #if YYBTYACC #ifndef YYLVQUEUEGROWTH #define YYLVQUEUEGROWTH 32 #endif #endif /* YYBTYACC */ /* define the initial stack-sizes */ #ifdef YYSTACKSIZE #undef YYMAXDEPTH #define YYMAXDEPTH YYSTACKSIZE #else #ifdef YYMAXDEPTH #define YYSTACKSIZE YYMAXDEPTH #else #define YYSTACKSIZE 10000 #define YYMAXDEPTH 10000 #endif #endif #ifndef YYINITSTACKSIZE #define YYINITSTACKSIZE 200 #endif typedef struct { unsigned stacksize; YYINT *s_base; YYINT *s_mark; YYINT *s_last; YYSTYPE *l_base; YYSTYPE *l_mark; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE *p_base; YYLTYPE *p_mark; #endif } YYSTACKDATA; #if YYBTYACC struct YYParseState_s { struct YYParseState_s *save; /* Previously saved parser state */ YYSTACKDATA yystack; /* saved parser stack */ int state; /* saved parser state */ int errflag; /* saved error recovery status */ int lexeme; /* saved index of the conflict lexeme in the lexical queue */ YYINT ctry; /* saved index in yyctable[] for this conflict */ }; typedef struct YYParseState_s YYParseState; #endif /* YYBTYACC */ /* variables for the parser stack */ static YYSTACKDATA yystack; #if YYBTYACC /* Current parser state */ static YYParseState *yyps = 0; /* yypath != NULL: do the full parse, starting at *yypath parser state. */ static YYParseState *yypath = 0; /* Base of the lexical value queue */ static YYSTYPE *yylvals = 0; /* Current position at lexical value queue */ static YYSTYPE *yylvp = 0; /* End position of lexical value queue */ static YYSTYPE *yylve = 0; /* The last allocated position at the lexical value queue */ static YYSTYPE *yylvlim = 0; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* Base of the lexical position queue */ static YYLTYPE *yylpsns = 0; /* Current position at lexical position queue */ static YYLTYPE *yylpp = 0; /* End position of lexical position queue */ static YYLTYPE *yylpe = 0; /* The last allocated position at the lexical position queue */ static YYLTYPE *yylplim = 0; #endif /* Current position at lexical token queue */ static YYINT *yylexp = 0; static YYINT *yylexemes = 0; #endif /* YYBTYACC */ #line 80 "err_inherit4.y" extern int YYLEX_DECL(); extern void YYERROR_DECL(); #line 444 "err_inherit4.tab.c" /* Release memory associated with symbol. */ #if ! defined YYDESTRUCT_IS_DECLARED static void YYDESTRUCT_DECL() { switch (psymb) { case 263: #line 28 "err_inherit4.y" { } #line 456 "err_inherit4.tab.c" break; case 264: #line 28 "err_inherit4.y" { } #line 461 "err_inherit4.tab.c" break; case 265: #line 28 "err_inherit4.y" { } #line 466 "err_inherit4.tab.c" break; } } #define YYDESTRUCT_IS_DECLARED 1 #endif /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) #if YYBTYACC #define yytrial (yyps->save) #endif /* YYBTYACC */ #if YYDEBUG #include /* needed for printf */ #endif #include /* needed for malloc, etc */ #include /* needed for memset */ /* allocate initial stack or double stack size, up to YYMAXDEPTH */ static int yygrowstack(YYSTACKDATA *data) { int i; unsigned newsize; YYINT *newss; YYSTYPE *newvs; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE *newps; #endif if ((newsize = data->stacksize) == 0) newsize = YYINITSTACKSIZE; else if (newsize >= YYMAXDEPTH) return YYENOMEM; else if ((newsize *= 2) > YYMAXDEPTH) newsize = YYMAXDEPTH; i = (int) (data->s_mark - data->s_base); newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); if (newss == NULL) return YYENOMEM; data->s_base = newss; data->s_mark = newss + i; newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); if (newvs == NULL) return YYENOMEM; data->l_base = newvs; data->l_mark = newvs + i; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); if (newps == NULL) return YYENOMEM; data->p_base = newps; data->p_mark = newps + i; #endif data->stacksize = newsize; data->s_last = data->s_base + newsize - 1; #if YYDEBUG if (yydebug) fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); #endif return 0; } #if YYPURE || defined(YY_NO_LEAKS) static void yyfreestack(YYSTACKDATA *data) { free(data->s_base); free(data->l_base); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) free(data->p_base); #endif memset(data, 0, sizeof(*data)); } #else #define yyfreestack(data) /* nothing */ #endif /* YYPURE || defined(YY_NO_LEAKS) */ #if YYBTYACC static YYParseState * yyNewState(unsigned size) { YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); if (p == NULL) return NULL; p->yystack.stacksize = size; if (size == 0) { p->yystack.s_base = NULL; p->yystack.l_base = NULL; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) p->yystack.p_base = NULL; #endif return p; } p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); if (p->yystack.s_base == NULL) return NULL; p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); if (p->yystack.l_base == NULL) return NULL; memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); if (p->yystack.p_base == NULL) return NULL; memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); #endif return p; } static void yyFreeState(YYParseState *p) { yyfreestack(&p->yystack); free(p); } #endif /* YYBTYACC */ #define YYABORT goto yyabort #define YYREJECT goto yyabort #define YYACCEPT goto yyaccept #define YYERROR goto yyerrlab #if YYBTYACC #define YYVALID do { if (yyps->save) goto yyvalid; } while(0) #define YYVALID_NESTED do { if (yyps->save && \ yyps->save->save == 0) goto yyvalid; } while(0) #endif /* YYBTYACC */ int YYPARSE_DECL() { int yym, yyn, yystate, yyresult; #if YYBTYACC int yynewerrflag; YYParseState *yyerrctx = NULL; #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ #endif #if YYDEBUG const char *yys; if ((yys = getenv("YYDEBUG")) != NULL) { yyn = *yys; if (yyn >= '0' && yyn <= '9') yydebug = yyn - '0'; } if (yydebug) fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); #endif #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); #endif #if YYBTYACC yyps = yyNewState(0); if (yyps == 0) goto yyenomem; yyps->save = 0; #endif /* YYBTYACC */ yym = 0; /* yyn is set below */ yynerrs = 0; yyerrflag = 0; yychar = YYEMPTY; yystate = 0; #if YYPURE memset(&yystack, 0, sizeof(yystack)); #endif if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystack.s_mark = yystack.s_base; yystack.l_mark = yystack.l_base; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark = yystack.p_base; #endif yystate = 0; *yystack.s_mark = 0; yyloop: if ((yyn = yydefred[yystate]) != 0) goto yyreduce; if (yychar < 0) { #if YYBTYACC do { if (yylvp < yylve) { /* we're currently re-reading tokens */ yylval = *yylvp++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylloc = *yylpp++; #endif yychar = *yylexp++; break; } if (yyps->save) { /* in trial mode; save scanner results for future parse attempts */ if (yylvp == yylvlim) { /* Enlarge lexical value queue */ size_t p = (size_t) (yylvp - yylvals); size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpe = yylpsns + p; yylplim = yylpsns + s; #endif yylexp = yylexemes + p; } *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpp++ = yylloc; yylpe++; #endif yychar = *yylexp++; break; } /* normal operation, no conflict encountered */ #endif /* YYBTYACC */ yychar = YYLEX; #if YYBTYACC } while (0); #endif /* YYBTYACC */ if (yychar < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", YYDEBUGSTR, yydepth, yystate, yychar, yys); #ifdef YYSTYPE_TOSTRING #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); #endif fputc('\n', stderr); } #endif } #if YYBTYACC /* Do we have a conflict? */ if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) { YYINT ctry; if (yypath) { YYParseState *save; #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", YYDEBUGSTR, yydepth, yystate); #endif /* Switch to the next conflict context */ save = yypath; yypath = save->save; save->save = NULL; ctry = save->ctry; if (save->state != yystate) YYABORT; yyFreeState(save); } else { /* Unresolved conflict - start/continue trial parse */ YYParseState *save; #if YYDEBUG if (yydebug) { fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); if (yyps->save) fputs("ALREADY in conflict, continuing trial parse.\n", stderr); else fputs("Starting trial parse.\n", stderr); } #endif save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); if (save == NULL) goto yyenomem; save->save = yyps->save; save->state = yystate; save->errflag = yyerrflag; save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif ctry = yytable[yyn]; if (yyctable[ctry] == -1) { #if YYDEBUG if (yydebug && yychar >= YYEOF) fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); #endif ctry++; } save->ctry = ctry; if (yyps->save == NULL) { /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; yylvlim = yylvals + YYLVQUEUEGROWTH; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); if (yylpsns == NULL) goto yyenomem; yylplim = yylpsns + YYLVQUEUEGROWTH; #endif } if (yylvp == yylve) { yylvp = yylve = yylvals; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpe = yylpsns; #endif yylexp = yylexemes; if (yychar >= YYEOF) { *yylve++ = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpe++ = yylloc; #endif *yylexp = (YYINT) yychar; yychar = YYEMPTY; } } } if (yychar >= YYEOF) { yylvp--; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp--; #endif yylexp--; yychar = YYEMPTY; } save->lexeme = (int) (yylvp - yylvals); yyps->save = save; } if (yytable[yyn] == ctry) { #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); #endif if (yychar < 0) { yylvp++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp++; #endif yylexp++; } if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystate = yyctable[ctry]; *++yystack.s_mark = (YYINT) yystate; *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *++yystack.p_mark = yylloc; #endif yychar = YYEMPTY; if (yyerrflag > 0) --yyerrflag; goto yyloop; } else { yyn = yyctable[ctry]; goto yyreduce; } } /* End of code dealing with conflicts */ #endif /* YYBTYACC */ if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) { #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", YYDEBUGSTR, yydepth, yystate, yytable[yyn]); #endif if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystate = yytable[yyn]; *++yystack.s_mark = yytable[yyn]; *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *++yystack.p_mark = yylloc; #endif yychar = YYEMPTY; if (yyerrflag > 0) --yyerrflag; goto yyloop; } if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) { yyn = yytable[yyn]; goto yyreduce; } if (yyerrflag != 0) goto yyinrecovery; #if YYBTYACC yynewerrflag = 1; goto yyerrhandler; goto yyerrlab; /* redundant goto avoids 'unused label' warning */ yyerrlab: /* explicit YYERROR from an action -- pop the rhs of the rule reduced * before looking for error recovery */ yystack.s_mark -= yym; yystate = *yystack.s_mark; yystack.l_mark -= yym; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark -= yym; #endif yynewerrflag = 0; yyerrhandler: while (yyps->save) { int ctry; YYParseState *save = yyps->save; #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", YYDEBUGSTR, yydepth, yystate, yyps->save->state, (int)(yylvp - yylvals - yyps->save->lexeme)); #endif /* Memorize most forward-looking error state in case it's really an error. */ if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) { /* Free old saved error context state */ if (yyerrctx) yyFreeState(yyerrctx); /* Create and fill out new saved error context state */ yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); if (yyerrctx == NULL) goto yyenomem; yyerrctx->save = yyps->save; yyerrctx->state = yystate; yyerrctx->errflag = yyerrflag; yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif yyerrctx->lexeme = (int) (yylvp - yylvals); } yylvp = yylvals + save->lexeme; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpsns + save->lexeme; #endif yylexp = yylexemes + save->lexeme; yychar = YYEMPTY; yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif ctry = ++save->ctry; yystate = save->state; /* We tried shift, try reduce now */ if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; yyps->save = save->save; save->save = NULL; yyFreeState(save); /* Nothing left on the stack -- error */ if (!yyps->save) { #if YYDEBUG if (yydebug) fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", YYPREFIX, yydepth); #endif /* Restore state as it was in the most forward-advanced error */ yylvp = yylvals + yyerrctx->lexeme; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpsns + yyerrctx->lexeme; #endif yylexp = yylexemes + yyerrctx->lexeme; yychar = yylexp[-1]; yylval = yylvp[-1]; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylloc = yylpp[-1]; #endif yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif yystate = yyerrctx->state; yyFreeState(yyerrctx); yyerrctx = NULL; } yynewerrflag = 1; } if (yynewerrflag == 0) goto yyinrecovery; #endif /* YYBTYACC */ YYERROR_CALL("syntax error"); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ #endif #if !YYBTYACC goto yyerrlab; /* redundant goto avoids 'unused label' warning */ yyerrlab: #endif ++yynerrs; yyinrecovery: if (yyerrflag < 3) { yyerrflag = 3; for (;;) { if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) { #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); #endif if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystate = yytable[yyn]; *++yystack.s_mark = yytable[yyn]; *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* lookahead position is error end position */ yyerror_loc_range[2] = yylloc; YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ *++yystack.p_mark = yyloc; #endif goto yyloop; } else { #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", YYDEBUGSTR, yydepth, *yystack.s_mark); #endif if (yystack.s_mark <= yystack.s_base) goto yyabort; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* the current TOS position is the error start position */ yyerror_loc_range[1] = *yystack.p_mark; #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYDESTRUCT_CALL("error: discarding state", yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); #else YYDESTRUCT_CALL("error: discarding state", yystos[*yystack.s_mark], yystack.l_mark); #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ #endif /* defined(YYDESTRUCT_CALL) */ --yystack.s_mark; --yystack.l_mark; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) --yystack.p_mark; #endif } } } else { if (yychar == YYEOF) goto yyabort; #if YYDEBUG if (yydebug) { if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", YYDEBUGSTR, yydepth, yystate, yychar, yys); } #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); #else YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ #endif /* defined(YYDESTRUCT_CALL) */ yychar = YYEMPTY; goto yyloop; } yyreduce: yym = yylen[yyn]; #if YYDEBUG if (yydebug) { fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); #ifdef YYSTYPE_TOSTRING #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ if (yym > 0) { int i; fputc('<', stderr); for (i = yym; i > 0; i--) { if (i != yym) fputs(", ", stderr); fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], yystack.l_mark[1-i]), stderr); } fputc('>', stderr); } #endif fputc('\n', stderr); } #endif if (yym > 0) yyval = yystack.l_mark[1-yym]; else memset(&yyval, 0, sizeof yyval); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* Perform position reduction */ memset(&yyloc, 0, sizeof(yyloc)); #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ { YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); /* just in case YYERROR is invoked within the action, save the start of the rhs as the error start position */ yyerror_loc_range[1] = yystack.p_mark[1-yym]; } #endif switch (yyn) { case 1: #line 52 "err_inherit4.y" yyval.cval = yystack.l_mark[-1].cval; #line 1144 "err_inherit4.tab.c" break; case 2: #line 52 "err_inherit4.y" yyval.tval = yystack.l_mark[-1].tval; #line 1149 "err_inherit4.tab.c" break; case 3: #line 53 "err_inherit4.y" { yyval.nlist = yystack.l_mark[0].nlist; yyloc = yystack.p_mark[0]; } #line 1154 "err_inherit4.tab.c" break; case 4: #line 55 "err_inherit4.y" { yyval.nlist = yystack.l_mark[0].nlist; yyloc = yystack.p_mark[-3]; } #line 1159 "err_inherit4.tab.c" break; case 5: #line 58 "err_inherit4.y" { yyval.cval = cGLOBAL; } #line 1164 "err_inherit4.tab.c" break; case 6: #line 59 "err_inherit4.y" { yyval.cval = cLOCAL; } #line 1169 "err_inherit4.tab.c" break; case 7: #line 62 "err_inherit4.y" { yyval.tval = tREAL; } #line 1174 "err_inherit4.tab.c" break; case 8: #line 63 "err_inherit4.y" { yyval.tval = tINTEGER; } #line 1179 "err_inherit4.tab.c" break; case 9: #line 67 "err_inherit4.y" { yyval.nlist->s = mksymbol(yystack.l_mark[-2].tval, yystack.l_mark[-3].cval, yystack.l_mark[0].id); yyval.nlist->next = yystack.l_mark[-1].nlist; } #line 1186 "err_inherit4.tab.c" break; case 10: #line 71 "err_inherit4.y" { yyval.nlist->s = mksymbol(yystack.l_mark[-1].tval, yystack.l_mark[-2].cval, yystack.l_mark[0].id); yyval.nlist->next = NULL; } #line 1193 "err_inherit4.tab.c" break; case 11: #line 77 "err_inherit4.y" { yyval.nlist = yystack.l_mark[0].nlist; yyloc = yystack.p_mark[1]; } #line 1198 "err_inherit4.tab.c" break; #line 1200 "err_inherit4.tab.c" default: break; } yystack.s_mark -= yym; yystate = *yystack.s_mark; yystack.l_mark -= yym; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark -= yym; #endif yym = yylhs[yyn]; if (yystate == 0 && yym == 0) { #if YYDEBUG if (yydebug) { fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); #ifdef YYSTYPE_TOSTRING #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); #endif fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); } #endif yystate = YYFINAL; *++yystack.s_mark = YYFINAL; *++yystack.l_mark = yyval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *++yystack.p_mark = yyloc; #endif if (yychar < 0) { #if YYBTYACC do { if (yylvp < yylve) { /* we're currently re-reading tokens */ yylval = *yylvp++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylloc = *yylpp++; #endif yychar = *yylexp++; break; } if (yyps->save) { /* in trial mode; save scanner results for future parse attempts */ if (yylvp == yylvlim) { /* Enlarge lexical value queue */ size_t p = (size_t) (yylvp - yylvals); size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpe = yylpsns + p; yylplim = yylpsns + s; #endif yylexp = yylexemes + p; } *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpp++ = yylloc; yylpe++; #endif yychar = *yylexp++; break; } /* normal operation, no conflict encountered */ #endif /* YYBTYACC */ yychar = YYLEX; #if YYBTYACC } while (0); #endif /* YYBTYACC */ if (yychar < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); } #endif } if (yychar == YYEOF) goto yyaccept; goto yyloop; } if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) yystate = yytable[yyn]; else yystate = yydgoto[yym]; #if YYDEBUG if (yydebug) { fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); #ifdef YYSTYPE_TOSTRING #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); #endif fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); } #endif if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; *++yystack.s_mark = (YYINT) yystate; *++yystack.l_mark = yyval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *++yystack.p_mark = yyloc; #endif goto yyloop; #if YYBTYACC /* Reduction declares that this path is valid. Set yypath and do a full parse */ yyvalid: if (yypath) YYABORT; while (yyps->save) { YYParseState *save = yyps->save; yyps->save = save->save; save->save = yypath; yypath = save; } #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); #endif if (yyerrctx) { yyFreeState(yyerrctx); yyerrctx = NULL; } yylvp = yylvals + yypath->lexeme; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpsns + yypath->lexeme; #endif yylexp = yylexemes + yypath->lexeme; yychar = YYEMPTY; yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif yystate = yypath->state; goto yyloop; #endif /* YYBTYACC */ yyoverflow: YYERROR_CALL("yacc stack overflow"); #if YYBTYACC goto yyabort_nomem; yyenomem: YYERROR_CALL("memory exhausted"); yyabort_nomem: #endif /* YYBTYACC */ yyresult = 2; goto yyreturn; yyabort: yyresult = 1; goto yyreturn; yyaccept: #if YYBTYACC if (yyps->save) goto yyvalid; #endif /* YYBTYACC */ yyresult = 0; yyreturn: #if defined(YYDESTRUCT_CALL) if (yychar != YYEOF && yychar != YYEMPTY) #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); #else YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ { YYSTYPE *pv; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE *pp; for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) YYDESTRUCT_CALL("cleanup: discarding state", yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); #else for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) YYDESTRUCT_CALL("cleanup: discarding state", yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ } #endif /* defined(YYDESTRUCT_CALL) */ #if YYBTYACC if (yyerrctx) { yyFreeState(yyerrctx); yyerrctx = NULL; } while (yyps) { YYParseState *save = yyps; yyps = save->save; save->save = NULL; yyFreeState(save); } while (yypath) { YYParseState *save = yypath; yypath = save->save; save->save = NULL; yyFreeState(save); } #endif /* YYBTYACC */ yyfreestack(&yystack); return (yyresult); } diff --git a/contrib/byacc/test/btyacc/err_inherit4.tab.h b/contrib/byacc/test/btyacc/err_inherit4.tab.h index b8c5c281761e..657f87f078fa 100644 --- a/contrib/byacc/test/btyacc/err_inherit4.tab.h +++ b/contrib/byacc/test/btyacc/err_inherit4.tab.h @@ -1,40 +1,40 @@ #ifndef _err_inherit4__defines_h_ #define _err_inherit4__defines_h_ #define GLOBAL 257 #define LOCAL 258 #define REAL 259 #define INTEGER 260 #define NAME 261 #ifdef YYSTYPE #undef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 #endif #ifndef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 -typedef union YYSTYPE +typedef union { class cval; type tval; namelist * nlist; name id; } YYSTYPE; #endif /* !YYSTYPE_IS_DECLARED */ extern YYSTYPE err_inherit4_lval; #if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED /* Default: YYLTYPE is the text position type. */ typedef struct YYLTYPE { int first_line; int first_column; int last_line; int last_column; unsigned source; } YYLTYPE; #define YYLTYPE_IS_DECLARED 1 #endif #define YYRHSLOC(rhs, k) ((rhs)[k]) extern YYLTYPE err_inherit4_lloc; #endif /* _err_inherit4__defines_h_ */ diff --git a/contrib/byacc/test/btyacc/expr.oxout.tab.c b/contrib/byacc/test/btyacc/expr.oxout.tab.c index f83485d97710..9c16860461f0 100644 --- a/contrib/byacc/test/btyacc/expr.oxout.tab.c +++ b/contrib/byacc/test/btyacc/expr.oxout.tab.c @@ -1,2768 +1,2768 @@ /* original parser id follows */ /* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ /* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ #define YYBYACC 1 #define YYMAJOR 2 #define YYMINOR 0 #define YYCHECK "yyyymmdd" #define YYEMPTY (-1) #define yyclearin (yychar = YYEMPTY) #define yyerrok (yyerrflag = 0) #define YYRECOVERING() (yyerrflag != 0) #define YYENOMEM (-2) #define YYEOF 0 #undef YYBTYACC #define YYBTYACC 0 #define YYDEBUGSTR YYPREFIX "debug" #ifndef yyparse #define yyparse expr_oxout_parse #endif /* yyparse */ #ifndef yylex #define yylex expr_oxout_lex #endif /* yylex */ #ifndef yyerror #define yyerror expr_oxout_error #endif /* yyerror */ #ifndef yychar #define yychar expr_oxout_char #endif /* yychar */ #ifndef yyval #define yyval expr_oxout_val #endif /* yyval */ #ifndef yylval #define yylval expr_oxout_lval #endif /* yylval */ #ifndef yydebug #define yydebug expr_oxout_debug #endif /* yydebug */ #ifndef yynerrs #define yynerrs expr_oxout_nerrs #endif /* yynerrs */ #ifndef yyerrflag #define yyerrflag expr_oxout_errflag #endif /* yyerrflag */ #ifndef yylhs #define yylhs expr_oxout_lhs #endif /* yylhs */ #ifndef yylen #define yylen expr_oxout_len #endif /* yylen */ #ifndef yydefred #define yydefred expr_oxout_defred #endif /* yydefred */ #ifndef yystos #define yystos expr_oxout_stos #endif /* yystos */ #ifndef yydgoto #define yydgoto expr_oxout_dgoto #endif /* yydgoto */ #ifndef yysindex #define yysindex expr_oxout_sindex #endif /* yysindex */ #ifndef yyrindex #define yyrindex expr_oxout_rindex #endif /* yyrindex */ #ifndef yygindex #define yygindex expr_oxout_gindex #endif /* yygindex */ #ifndef yytable #define yytable expr_oxout_table #endif /* yytable */ #ifndef yycheck #define yycheck expr_oxout_check #endif /* yycheck */ #ifndef yyname #define yyname expr_oxout_name #endif /* yyname */ #ifndef yyrule #define yyrule expr_oxout_rule #endif /* yyrule */ #if YYBTYACC #ifndef yycindex #define yycindex expr_oxout_cindex #endif /* yycindex */ #ifndef yyctable #define yyctable expr_oxout_ctable #endif /* yyctable */ #endif /* YYBTYACC */ #define YYPREFIX "expr_oxout_" #define YYPURE 0 #line 5 "expr.oxout.y" #include #include #line 8 "expr.Y" #include "expr.oxout.h" #include extern int yylex(void); extern void yyerror(const char *); #line 27 "expr.oxout.y" #include #define yyyR USHRT_MAX #ifdef YYSTYPE #undef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 #endif #ifndef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 #line 31 "expr.oxout.y" -typedef union YYSTYPE { +typedef union { struct yyyOxAttrbs { struct yyyStackItem *yyyOxStackItem; } yyyOxAttrbs; } YYSTYPE; #endif /* !YYSTYPE_IS_DECLARED */ #line 38 "expr.oxout.y" #include #include static int yyyYok = 1; extern yyyFT yyyRCIL[]; void yyyExecuteRRsection(yyyGNT *rootNode); void yyyYoxInit(void); void yyyDecorate(void); struct yyyOxAttrbs; /* hack required to compensate for 'msta' behavior */ void yyyGenIntNode(long yyyProdNum, int yyyRHSlength, int yyyNattrbs, struct yyyOxAttrbs *yyval_OxAttrbs, ...); void yyyAdjustINRC(long yyyProdNum, int yyyRHSlength, long startP, long stopP, struct yyyOxAttrbs *yyval_OxAttrbs, ...); void yyyCheckUnsolvedInstTrav(yyyGNT *rootNode,long *nNZrc,long *cycleSum); void yyyUnsolvedInstSearchTrav(yyyGNT *pNode); void yyyUnsolvedInstSearchTravAux(yyyGNT *pNode); void yyyabort(void); #line 166 "expr.oxout.tab.c" /* compatibility with bison */ #ifdef YYPARSE_PARAM /* compatibility with FreeBSD */ # ifdef YYPARSE_PARAM_TYPE # define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) # else # define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) # endif #else # define YYPARSE_DECL() yyparse(void) #endif /* Parameters sent to lex. */ #ifdef YYLEX_PARAM # define YYLEX_DECL() yylex(void *YYLEX_PARAM) # define YYLEX yylex(YYLEX_PARAM) #else # define YYLEX_DECL() yylex(void) # define YYLEX yylex() #endif /* Parameters sent to yyerror. */ #ifndef YYERROR_DECL #define YYERROR_DECL() yyerror(const char *s) #endif #ifndef YYERROR_CALL #define YYERROR_CALL(msg) yyerror(msg) #endif extern int YYPARSE_DECL(); #define ID 257 #define CONST 258 #define YYERRCODE 256 typedef int YYINT; static const YYINT expr_oxout_lhs[] = { -1, 2, 0, 1, 3, 3, 3, 3, 3, 3, 3, }; static const YYINT expr_oxout_len[] = { 2, 0, 2, 1, 3, 3, 3, 3, 3, 1, 1, }; static const YYINT expr_oxout_defred[] = { 1, 0, 0, 9, 10, 0, 2, 0, 0, 0, 0, 0, 0, 8, 0, 0, 4, 0, }; #if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) static const YYINT expr_oxout_stos[] = { 0, 260, 262, 257, 258, 40, 261, 263, 263, 43, 45, 42, 47, 41, 263, 263, 263, 263, }; #endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ static const YYINT expr_oxout_dgoto[] = { 1, 6, 2, 7, }; static const YYINT expr_oxout_sindex[] = { 0, 0, -40, 0, 0, -40, 0, -18, -24, -40, -40, -40, -40, 0, -37, -37, 0, -39, }; static const YYINT expr_oxout_rindex[] = { 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 2, 8, 0, 1, }; #if YYBTYACC static const YYINT expr_oxout_cindex[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; #endif static const YYINT expr_oxout_gindex[] = { 0, 0, 0, 4, }; #define YYTABLESIZE 218 static const YYINT expr_oxout_table[] = { 5, 6, 5, 11, 0, 11, 3, 0, 7, 8, 12, 0, 0, 14, 15, 16, 17, 13, 11, 9, 0, 10, 0, 12, 11, 9, 0, 10, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 5, 6, 5, 6, 5, 6, 7, 0, 7, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 4, }; static const YYINT expr_oxout_check[] = { 40, 0, 0, 42, -1, 42, 0, -1, 0, 5, 47, -1, -1, 9, 10, 11, 12, 41, 42, 43, -1, 45, -1, 47, 42, 43, -1, 45, -1, 47, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 41, 41, 43, 43, 45, 45, 47, 41, -1, 43, -1, 45, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 257, 258, }; #if YYBTYACC static const YYINT expr_oxout_ctable[] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, }; #endif #define YYFINAL 1 #ifndef YYDEBUG #define YYDEBUG 0 #endif #define YYMAXTOKEN 258 #define YYUNDFTOKEN 264 #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) #if YYDEBUG static const char *const expr_oxout_name[] = { "$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, 0,0,0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"error","ID", "CONST","$accept","yyyAugNonterm","s","$$1","expr","illegal-symbol", }; static const char *const expr_oxout_rule[] = { "$accept : yyyAugNonterm", "$$1 :", "yyyAugNonterm : $$1 s", "s : expr", "expr : expr '*' expr", "expr : expr '+' expr", "expr : expr '/' expr", "expr : expr '-' expr", "expr : '(' expr ')'", "expr : ID", "expr : CONST", }; #endif #if YYDEBUG int yydebug; #endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; int yynerrs; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyloc; /* position returned by actions */ YYLTYPE yylloc; /* position from the lexer */ #endif #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) #ifndef YYLLOC_DEFAULT #define YYLLOC_DEFAULT(loc, rhs, n) \ do \ { \ if (n == 0) \ { \ (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ } \ else \ { \ (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ (loc).last_line = YYRHSLOC(rhs, n).last_line; \ (loc).last_column = YYRHSLOC(rhs, n).last_column; \ } \ } while (0) #endif /* YYLLOC_DEFAULT */ #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ #if YYBTYACC #ifndef YYLVQUEUEGROWTH #define YYLVQUEUEGROWTH 32 #endif #endif /* YYBTYACC */ /* define the initial stack-sizes */ #ifdef YYSTACKSIZE #undef YYMAXDEPTH #define YYMAXDEPTH YYSTACKSIZE #else #ifdef YYMAXDEPTH #define YYSTACKSIZE YYMAXDEPTH #else #define YYSTACKSIZE 10000 #define YYMAXDEPTH 10000 #endif #endif #ifndef YYINITSTACKSIZE #define YYINITSTACKSIZE 200 #endif typedef struct { unsigned stacksize; YYINT *s_base; YYINT *s_mark; YYINT *s_last; YYSTYPE *l_base; YYSTYPE *l_mark; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE *p_base; YYLTYPE *p_mark; #endif } YYSTACKDATA; #if YYBTYACC struct YYParseState_s { struct YYParseState_s *save; /* Previously saved parser state */ YYSTACKDATA yystack; /* saved parser stack */ int state; /* saved parser state */ int errflag; /* saved error recovery status */ int lexeme; /* saved index of the conflict lexeme in the lexical queue */ YYINT ctry; /* saved index in yyctable[] for this conflict */ }; typedef struct YYParseState_s YYParseState; #endif /* YYBTYACC */ /* variables for the parser stack */ static YYSTACKDATA yystack; #if YYBTYACC /* Current parser state */ static YYParseState *yyps = 0; /* yypath != NULL: do the full parse, starting at *yypath parser state. */ static YYParseState *yypath = 0; /* Base of the lexical value queue */ static YYSTYPE *yylvals = 0; /* Current position at lexical value queue */ static YYSTYPE *yylvp = 0; /* End position of lexical value queue */ static YYSTYPE *yylve = 0; /* The last allocated position at the lexical value queue */ static YYSTYPE *yylvlim = 0; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* Base of the lexical position queue */ static YYLTYPE *yylpsns = 0; /* Current position at lexical position queue */ static YYLTYPE *yylpp = 0; /* End position of lexical position queue */ static YYLTYPE *yylpe = 0; /* The last allocated position at the lexical position queue */ static YYLTYPE *yylplim = 0; #endif /* Current position at lexical token queue */ static YYINT *yylexp = 0; static YYINT *yylexemes = 0; #endif /* YYBTYACC */ #line 53 "expr.Y" int yyparse(void); int main() {yyparse(); } #line 138 "expr.oxout.y" long yyySSALspaceSize = 20000; long yyyRSmaxSize = 1000; long yyyTravStackMaxSize = 2000; struct yyySolvedSAlistCell {yyyWAT attrbNum; long next; }; #define yyyLambdaSSAL 0 long yyySSALCfreeList = yyyLambdaSSAL; long yyyNewSSALC = 1; struct yyySolvedSAlistCell *yyySSALspace; long yyyNbytesStackStg; yyyFT yyyRCIL[1]; short yyyIIIEL[] = {0, 0,2,6,10,14,18,22,24, }; long yyyIIEL[] = { 0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0, 1,1, }; long yyyIEL[] = { 0,0,0, }; yyyFT yyyEntL[1]; void yyyfatal(char *msg) {fputs(msg,stderr);exit(-1);} #define yyySSALof 'S' #define yyyRSof 'q' #define yyyTSof 't' void yyyHandleOverflow(char which) {char *msg1 = "?", *msg2; long oldSize = 0, newSize; switch(which) { case yyySSALof : msg1 = "SSAL overflow: "; oldSize = yyySSALspaceSize; break; case yyyRSof : msg1 = "ready set overflow: "; oldSize = yyyRSmaxSize; break; case yyyTSof : msg1 = "traversal stack overflow: "; oldSize = yyyTravStackMaxSize; break; default :; } newSize = (3*oldSize)/2; if (newSize < 100) newSize = 100; fputs(msg1,stderr); fprintf(stderr,"size was %ld.\n",oldSize); msg2 = " Have to modify evaluator: -Y%c%ld.\n"; fprintf(stderr,msg2,which,newSize); exit(-1); } void yyySignalEnts(yyyGNT *node,long startP,long stopP) {yyyGNT *dumNode; while (startP < stopP) { if (!yyyEntL[startP]) dumNode = node; else dumNode = (node->cL)[yyyEntL[startP]-1]; if (!(--((dumNode->refCountList)[yyyEntL[startP+1]] ) ) ) { if (++yyyRSTop == yyyAfterRS) {yyyHandleOverflow(yyyRSof); break; } yyyRSTop->node = dumNode; yyyRSTop->whichSym = yyyEntL[startP]; yyyRSTop->wa = yyyEntL[startP+1]; } startP += 2; } } void yyySolveAndSignal() { long yyyiDum,*yyypL; int yyyws,yyywa; yyyGNT *yyyRSTopN,*yyyRefN; yyyParent yyyRSTopNp; yyyRSTopNp = (yyyRSTopN = yyyRSTop->node)->parent; yyyRefN= (yyyws = (yyyRSTop->whichSym))?yyyRSTopNp.noderef:yyyRSTopN; yyywa = yyyRSTop->wa; yyyRSTop--; switch(yyyRefN->prodNum) { case 1: /***yacc rule 1***/ switch (yyyws) { } break; case 2: /***yacc rule 2***/ switch (yyyws) { } break; case 3: /***yacc rule 3***/ switch (yyyws) { } break; case 4: /***yacc rule 4***/ switch (yyyws) { } break; case 5: /***yacc rule 5***/ switch (yyyws) { } break; case 6: /***yacc rule 6***/ switch (yyyws) { } break; case 7: /***yacc rule 7***/ switch (yyyws) { case 1: /**/ switch (yyywa) { } break; } break; case 8: /***yacc rule 8***/ switch (yyyws) { case 1: /**/ switch (yyywa) { } break; } break; } /* switch */ if (yyyws) /* the just-solved instance was inherited. */ {if (yyyRSTopN->prodNum) {yyyiDum = yyyIIEL[yyyIIIEL[yyyRSTopN->prodNum]] + yyywa; yyySignalEnts(yyyRSTopN,yyyIEL[yyyiDum], yyyIEL[yyyiDum+1] ); } } else /* the just-solved instance was synthesized. */ {if (!(yyyRSTopN->parentIsStack)) /* node has a parent. */ {yyyiDum = yyyIIEL[yyyIIIEL[yyyRSTopNp.noderef->prodNum] + yyyRSTopN->whichSym ] + yyywa; yyySignalEnts(yyyRSTopNp.noderef, yyyIEL[yyyiDum], yyyIEL[yyyiDum+1] ); } else /* node is still on the stack--it has no parent yet. */ {yyypL = &(yyyRSTopNp.stackref->solvedSAlist); if (yyySSALCfreeList == yyyLambdaSSAL) {yyySSALspace[yyyNewSSALC].next = *yyypL; if ((*yyypL = yyyNewSSALC++) == yyySSALspaceSize) yyyHandleOverflow(yyySSALof); } else {yyyiDum = yyySSALCfreeList; yyySSALCfreeList = yyySSALspace[yyySSALCfreeList].next; yyySSALspace[yyyiDum].next = *yyypL; *yyypL = yyyiDum; } yyySSALspace[*yyypL].attrbNum = yyywa; } } } /* yyySolveAndSignal */ #define condStg unsigned int conds; #define yyyClearConds {yyyTST->conds = 0;} #define yyySetCond(n) {yyyTST->conds += (1<<(n));} #define yyyCond(n) ((yyyTST->conds & (1<<(n)))?1:0) struct yyyTravStackItem {yyyGNT *node; char isReady; condStg }; void yyyDoTraversals(yyyGNT *rootNode) {struct yyyTravStackItem *yyyTravStack,*yyyTST,*yyyAfterTravStack; yyyGNT *yyyTSTn,**yyyCLptr2; int yyyi,yyyRL,yyyPass; int i; if (!yyyYok) return; if ((yyyTravStack = ((struct yyyTravStackItem *) calloc((size_t)yyyTravStackMaxSize, (size_t)sizeof(struct yyyTravStackItem) ) ) ) == (struct yyyTravStackItem *)NULL ) {fputs("malloc error in traversal stack allocation\n",stderr); exit(-1); } yyyAfterTravStack = yyyTravStack + yyyTravStackMaxSize; yyyTravStack++; for (yyyi=0; yyyi<2; yyyi++) { yyyTST = yyyTravStack; yyyTST->node = rootNode; yyyTST->isReady = 0; yyyClearConds while(yyyTST >= yyyTravStack) {yyyTSTn = yyyTST->node; if (yyyTST->isReady) {yyyPass = 1; goto yyyTravSwitch; yyyTpop: yyyTST--; } else {yyyPass = 0; goto yyyTravSwitch; yyyTpush: yyyTST->isReady = 1; if (yyyTSTn->prodNum) {if (yyyRL) {yyyCLptr2 = yyyTSTn->cL; i = yyyTSTn->cLlen; while (i--) {if (++yyyTST == yyyAfterTravStack) yyyHandleOverflow(yyyTSof); else {yyyTST->node = *yyyCLptr2; yyyTST->isReady = 0; yyyClearConds } yyyCLptr2++; } } /* right to left */ else /* left to right */ {i = yyyTSTn->cLlen; yyyCLptr2 = yyyTSTn->cL + i; while (i--) {yyyCLptr2--; if (++yyyTST == yyyAfterTravStack) yyyHandleOverflow(yyyTSof); else {yyyTST->node = *yyyCLptr2; yyyTST->isReady = 0; yyyClearConds } } } /* left to right */ } } /* else */ continue; yyyTravSwitch: switch(yyyTSTn->prodNum) { case 1: switch(yyyi) { case 0: switch(yyyPass) { case 0: yyyRL = 0;yyySetCond(0) if (! #line 24 "expr.Y" (1) #line 444 "expr.oxout.y" ) yyySetCond(1) yyySetCond(2) case 1: if (yyyCond(0) != yyyPass) { #line 24 "expr.Y" #line 453 "expr.oxout.y" } if (yyyCond(1) != yyyPass) { #line 24 "expr.Y" printf("\n"); #line 459 "expr.oxout.y" } if (yyyCond(2) != yyyPass) { #line 25 "expr.Y" printf("prefix: "); #line 465 "expr.oxout.y" } break; } break; case 1: switch(yyyPass) { case 0: yyyRL = 0; if ( #line 23 "expr.Y" (1) #line 477 "expr.oxout.y" ) yyySetCond(2) case 1: if (yyyCond(0) != yyyPass) { #line 22 "expr.Y" printf("\n"); #line 486 "expr.oxout.y" } if (yyyCond(1) != yyyPass) { #line 23 "expr.Y" #line 491 "expr.oxout.y" } if (yyyCond(2) != yyyPass) { #line 23 "expr.Y" printf("postfix: "); #line 497 "expr.oxout.y" } break; } break; } break; case 2: switch(yyyi) { case 0: switch(yyyPass) { case 0: yyyRL = 0;yyySetCond(0) case 1: if (yyyCond(0) != yyyPass) { #line 29 "expr.Y" printf(" * "); #line 518 "expr.oxout.y" } break; } break; case 1: switch(yyyPass) { case 0: yyyRL = 0; case 1: if (yyyCond(0) != yyyPass) { #line 28 "expr.Y" printf(" * "); #line 533 "expr.oxout.y" } break; } break; } break; case 3: switch(yyyi) { case 0: switch(yyyPass) { case 0: yyyRL = 0;yyySetCond(0) case 1: if (yyyCond(0) != yyyPass) { #line 32 "expr.Y" printf(" + "); #line 554 "expr.oxout.y" } break; } break; case 1: switch(yyyPass) { case 0: yyyRL = 0; case 1: if (yyyCond(0) != yyyPass) { #line 33 "expr.Y" printf(" + "); #line 569 "expr.oxout.y" } break; } break; } break; case 4: switch(yyyi) { case 0: switch(yyyPass) { case 0: yyyRL = 0;yyySetCond(0) case 1: if (yyyCond(0) != yyyPass) { #line 37 "expr.Y" printf(" / "); #line 590 "expr.oxout.y" } break; } break; case 1: switch(yyyPass) { case 0: yyyRL = 0; case 1: if (yyyCond(0) != yyyPass) { #line 36 "expr.Y" printf(" / "); #line 605 "expr.oxout.y" } break; } break; } break; case 5: switch(yyyi) { case 0: switch(yyyPass) { case 0: yyyRL = 0;yyySetCond(0) case 1: if (yyyCond(0) != yyyPass) { #line 41 "expr.Y" printf(" - "); #line 626 "expr.oxout.y" } break; } break; case 1: switch(yyyPass) { case 0: yyyRL = 0; case 1: if (yyyCond(0) != yyyPass) { #line 40 "expr.Y" printf(" - "); #line 641 "expr.oxout.y" } break; } break; } break; case 6: switch(yyyi) { case 0: switch(yyyPass) { case 0: yyyRL = 0; case 1: break; } break; case 1: switch(yyyPass) { case 0: yyyRL = 0; case 1: break; } break; } break; case 7: switch(yyyi) { case 0: switch(yyyPass) { case 0: yyyRL = 0;yyySetCond(0) case 1: if (yyyCond(0) != yyyPass) { #line 46 "expr.Y" printf(" %s ",yyyTSTn->cL[0]->yyyAttrbs.yyyAttrb1.lexeme); #line 685 "expr.oxout.y" } break; } break; case 1: switch(yyyPass) { case 0: yyyRL = 0; case 1: if (yyyCond(0) != yyyPass) { #line 45 "expr.Y" printf(" %s ",yyyTSTn->cL[0]->yyyAttrbs.yyyAttrb1.lexeme); #line 700 "expr.oxout.y" } break; } break; } break; case 8: switch(yyyi) { case 0: switch(yyyPass) { case 0: yyyRL = 0;yyySetCond(0) case 1: if (yyyCond(0) != yyyPass) { #line 50 "expr.Y" printf(" %s ",yyyTSTn->cL[0]->yyyAttrbs.yyyAttrb1.lexeme); #line 721 "expr.oxout.y" } break; } break; case 1: switch(yyyPass) { case 0: yyyRL = 0; case 1: if (yyyCond(0) != yyyPass) { #line 49 "expr.Y" printf(" %s ",yyyTSTn->cL[0]->yyyAttrbs.yyyAttrb1.lexeme); #line 736 "expr.oxout.y" } break; } break; } break; } /* switch */ if (yyyPass) goto yyyTpop; else goto yyyTpush; } /* while */ } /* for */ } /* yyyDoTraversals */ void yyyExecuteRRsection(yyyGNT *rootNode) { int yyyi; long cycleSum = 0; long nNZrc = 0; if (!yyyYok) return; yyyCheckUnsolvedInstTrav(rootNode,&nNZrc,&cycleSum); if (nNZrc) { fputs("\n\n\n**********\n",stderr); fputs("cycle detected in completed parse tree",stderr); fputs(" after decoration.\n",stderr); #if CYCLE_VERBOSE fprintf(stderr, "number of unsolved attribute instances == %ld.\n", nNZrc ); fprintf(stderr, "total number of remaining dependencies == %ld.\n", cycleSum ); fputs("average number of remaining dependencies\n",stderr); fprintf(stderr," per unsolved instance == %f.\n", ((float)(cycleSum)/(float)(nNZrc)) ); #endif fprintf(stderr, "searching parse tree for %ld unsolved instances:\n", nNZrc ); yyyUnsolvedInstSearchTravAux(rootNode); } yyyDoTraversals(rootNode); } /* yyyExecuteRRsection */ yyyWAT yyyLRCIL[2] = {0,0, }; void yyyYoxInit(void) { static int yyyInitDone = 0; if (yyyInitDone) return; if ((yyyRS = (yyyRSitem *) calloc((size_t)(yyyRSmaxSize+1), (size_t)sizeof(yyyRSitem)) ) == ((yyyRSitem *) NULL) ) yyyfatal("malloc error in ox ready set space allocation\n"); yyyRS++; yyyAfterRS = yyyRS + yyyRSmaxSize; if ((yyySSALspace = (struct yyySolvedSAlistCell *) calloc((size_t)(yyySSALspaceSize+1), (size_t)sizeof(struct yyySolvedSAlistCell)) ) == ((struct yyySolvedSAlistCell *) NULL) ) yyyfatal("malloc error in stack solved list space allocation\n"); yyyInitDone = 1; yyyRSTop = yyyRS - 1; } /* yyyYoxInit */ void yyyDecorate(void) { while (yyyRSTop >= yyyRS) yyySolveAndSignal(); } void yyyGenIntNode(long yyyProdNum, int yyyRHSlength, int yyyNattrbs, struct yyyOxAttrbs *yyval_OxAttrbs, ...) {yyyWST i; yyySIT **yyyOxStackItem = &yyval_OxAttrbs->yyyOxStackItem; yyyGNT *gnpDum; va_list ap; *yyyOxStackItem = (yyySIT *) malloc((size_t)sizeof(yyySIT)); if (*yyyOxStackItem == (yyySIT *) NULL) yyyfatal("malloc error in ox yacc semantic stack space allocation\n"); (*yyyOxStackItem)->node = (yyyGNT *) malloc((size_t)sizeof(yyyGNT)); if ((*yyyOxStackItem)->node == (yyyGNT *) NULL) yyyfatal("malloc error in ox node space allocation\n"); (*yyyOxStackItem)->solvedSAlist = yyyLambdaSSAL; (*yyyOxStackItem)->node->parent.stackref = *yyyOxStackItem; (*yyyOxStackItem)->node->parentIsStack = 1; (*yyyOxStackItem)->node->cLlen = yyyRHSlength; (*yyyOxStackItem)->node->cL = (yyyGNT **) calloc((size_t)yyyRHSlength, (size_t)sizeof(yyyGNT *)); if ((*yyyOxStackItem)->node->cL == (yyyGNT **) NULL) yyyfatal("malloc error in ox child list space allocation\n"); (*yyyOxStackItem)->node->refCountListLen = yyyNattrbs; (*yyyOxStackItem)->node->refCountList = (yyyRCT *) calloc((size_t)yyyNattrbs, (size_t)sizeof(yyyRCT)); if ((*yyyOxStackItem)->node->refCountList == (yyyRCT *) NULL) yyyfatal("malloc error in ox reference count list space allocation\n"); (*yyyOxStackItem)->node->prodNum = (int) yyyProdNum; va_start(ap, yyval_OxAttrbs); for (i=1;i<=yyyRHSlength;i++) {yyySIT *yaccStDum = va_arg(ap,struct yyyOxAttrbs *)->yyyOxStackItem; gnpDum = (*yyyOxStackItem)->node->cL[i-1] = yaccStDum->node; gnpDum->whichSym = i; gnpDum->parent.noderef = (*yyyOxStackItem)->node; gnpDum->parentIsStack = 0; } va_end(ap); } #define yyyDECORfREQ 50 void yyyAdjustINRC(long yyyProdNum, int yyyRHSlength, long startP, long stopP, struct yyyOxAttrbs *yyval_OxAttrbs, ...) {yyyWST i; yyySIT *yyyOxStackItem = yyval_OxAttrbs->yyyOxStackItem; long SSALptr,SSALptrHead,*cPtrPtr; long *pL; yyyGNT *gnpDum; long iTemp; long nextP; static unsigned short intNodeCount = yyyDECORfREQ; va_list ap; nextP = startP; while (nextP < stopP) {if (yyyRCIL[nextP] == yyyR) {(yyyOxStackItem->node->refCountList)[yyyRCIL[nextP+1]] = yyyRCIL[nextP+2]; } else {(((yyyOxStackItem->node->cL)[yyyRCIL[nextP]])->refCountList)[yyyRCIL[nextP+1]] = yyyRCIL[nextP+2]; } nextP += 3; } pL = yyyIIEL + yyyIIIEL[yyyProdNum]; va_start(ap, yyval_OxAttrbs); for (i=1;i<=yyyRHSlength;i++) {yyySIT *yaccStDum = va_arg(ap,struct yyyOxAttrbs *)->yyyOxStackItem; pL++; SSALptrHead = SSALptr = *(cPtrPtr = &(yaccStDum->solvedSAlist)); if (SSALptr != yyyLambdaSSAL) {*cPtrPtr = yyyLambdaSSAL; do { iTemp = (*pL+yyySSALspace[SSALptr].attrbNum); yyySignalEnts(yyyOxStackItem->node, yyyIEL[iTemp], yyyIEL[iTemp+1] ); SSALptr = *(cPtrPtr = &(yyySSALspace[SSALptr].next)); } while (SSALptr != yyyLambdaSSAL); *cPtrPtr = yyySSALCfreeList; yyySSALCfreeList = SSALptrHead; } } va_end(ap); nextP = startP + 2; while (nextP < stopP) {if (!yyyRCIL[nextP]) {if (yyyRCIL[nextP-2] == yyyR) {pL = &(yyyOxStackItem->solvedSAlist); if (yyySSALCfreeList == yyyLambdaSSAL) {yyySSALspace[yyyNewSSALC].next = *pL; if ((*pL = yyyNewSSALC++) == yyySSALspaceSize) yyyHandleOverflow(yyySSALof); } else {iTemp = yyySSALCfreeList; yyySSALCfreeList = yyySSALspace[yyySSALCfreeList].next; yyySSALspace[iTemp].next = *pL; *pL = iTemp; } yyySSALspace[*pL].attrbNum = yyyRCIL[nextP-1]; } else {if ((gnpDum = (yyyOxStackItem->node->cL)[yyyRCIL[nextP-2]])->prodNum != 0) { iTemp = yyyIIEL[yyyIIIEL[gnpDum->prodNum]] + yyyRCIL[nextP-1]; yyySignalEnts(gnpDum, yyyIEL[iTemp], yyyIEL[iTemp+1] ); } } } nextP += 3; } if (!--intNodeCount) {intNodeCount = yyyDECORfREQ; yyyDecorate(); } } void yyyGenLeaf(int nAttrbs,int typeNum,long startP,long stopP,YYSTYPE *mylval) {yyyRCT *rcPdum; yyySIT **yyyOxStackItem = &mylval->yyyOxAttrbs.yyyOxStackItem; (*yyyOxStackItem) = (yyySIT *) malloc((size_t)sizeof(yyySIT)); if ((*yyyOxStackItem) == (yyySIT *) NULL) yyyfatal("malloc error in ox yacc semantic stack space allocation\n"); (*yyyOxStackItem)->node = (yyyGNT *) malloc((size_t)sizeof(yyyGNT)) ; if ((*yyyOxStackItem)->node == (yyyGNT *) NULL) yyyfatal("malloc error in ox node space allocation\n"); (*yyyOxStackItem)->solvedSAlist = yyyLambdaSSAL; (*yyyOxStackItem)->node->parent.stackref = *yyyOxStackItem; (*yyyOxStackItem)->node->parentIsStack = 1; (*yyyOxStackItem)->node->cLlen = 0; (*yyyOxStackItem)->node->cL = (yyyGNT **)NULL; (*yyyOxStackItem)->node->refCountListLen = nAttrbs; rcPdum = (*yyyOxStackItem)->node->refCountList = (yyyRCT *) calloc((size_t)nAttrbs, (size_t)sizeof(yyyRCT)); if (rcPdum == (yyyRCT *) NULL) yyyfatal("malloc error in ox reference count list space allocation\n"); while (startP < stopP) rcPdum[yyyLRCIL[startP++]] = 0; (*yyyOxStackItem)->node->prodNum = 0; (*yyyOxStackItem)->node->whichSym = 0; } void yyyabort(void) {yyyYok = 0; } #define yyyLastProdNum 8 #define yyyNsorts 1 int yyyProdsInd[] = { 0, 0, 2, 6, 10, 14, 18, 22, 24, 26, }; int yyyProds[][2] = { { 116, 0},{ 462, 0},{ 462, 0},{ 462, 0},{ 412, 0}, { 462, 0},{ 462, 0},{ 462, 0},{ 420, 0},{ 462, 0}, { 462, 0},{ 462, 0},{ 452, 0},{ 462, 0},{ 462, 0}, { 462, 0},{ 436, 0},{ 462, 0},{ 462, 0},{ 396, 0}, { 462, 0},{ 404, 0},{ 462, 0},{ 619, 1},{ 462, 0}, { 567, 1}, }; int yyySortsInd[] = { 0, 0, 1, }; int yyySorts[] = { 413, }; char *yyyStringTab[] = { 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,"s",0,0,0, 0,0,"y",0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,"LRpre",0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,"'('",0,0,0, 0,0,0,0,"')'", 0,0,0,0,0, 0,0,"'*'","lexeme",0, 0,0,0,0,0, "'+'",0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,"'-'",0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,"'/'",0,0, 0,0,0,0,0, 0,0,"expr",0,0, 0,0,0,0,0, 0,0,0,0,0, 0,"printf",0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,"CONST","LRpost",0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,"ID", 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0, }; #define yyySizeofProd(num) (yyyProdsInd[(num)+1] - yyyProdsInd[(num)]) #define yyyGSoccurStr(prodNum,symPos) \ (yyyStringTab[yyyProds[yyyProdsInd[(prodNum)] + (symPos)][0]]) #define yyySizeofSort(num) (yyySortsInd[(num)+1] - yyySortsInd[(num)]) #define yyySortOf(prodNum,symPos) \ (yyyProds[yyyProdsInd[(prodNum)] + (symPos)][1]) #define yyyAttrbStr(prodNum,symPos,attrbNum) \ (yyyStringTab[yyySorts[yyySortsInd[yyySortOf(prodNum,symPos)] + \ (attrbNum) \ ] \ ] \ ) void yyyShowProd(int i) {int j,nSyms; nSyms = yyySizeofProd(i); for (j=0; j\n",stderr); else putc('\n',stderr); } } } void yyyCheckNodeInstancesSolved(yyyGNT *np) {int mysort,sortSize,i,prodNum,symPos,inTerminalNode; int nUnsolvedInsts = 0; if (np->prodNum != 0) {inTerminalNode = 0; prodNum = np->prodNum; symPos = 0; } else {inTerminalNode = 1; prodNum = np->parent.noderef->prodNum; symPos = np->whichSym; } mysort = yyySortOf(prodNum,symPos); sortSize = yyySizeofSort(mysort); for (i=0; irefCountList)[i] != 0) nUnsolvedInsts += 1; if (nUnsolvedInsts) {fprintf(stderr, "\nFound node that has %d unsolved attribute instance(s).\n", nUnsolvedInsts ); fprintf(stderr,"Node is labeled \"%s\".\n", yyyGSoccurStr(prodNum,symPos)); if (inTerminalNode) {fputs("Node is terminal. Its parent production is:\n ",stderr); yyyShowProd(prodNum); } else {fputs("Node is nonterminal. ",stderr); if (!(np->parentIsStack)) {fprintf(stderr, "Node is %dth child in its parent production:\n ", np->whichSym ); yyyShowProd(np->parent.noderef->prodNum); } fputs("Node is on left hand side of this production:\n ",stderr); yyyShowProd(np->prodNum); } fputs("The following instances are unsolved:\n",stderr); for (i=0; irefCountList)[i] != 0) fprintf(stderr," %-16s still has %1d dependencies.\n", yyyAttrbStr(prodNum,symPos,i),(np->refCountList)[i]); } } void yyyCheckUnsolvedInstTrav(yyyGNT *pNode,long *nNZrc,long *cycleSum) {yyyGNT **yyyCLpdum; yyyRCT *rcp; int i; /* visit the refCountList of each node in the tree, and sum the non-zero refCounts */ rcp = pNode->refCountList; i = pNode->refCountListLen; while (i--) if (*rcp++) {*cycleSum += *(rcp - 1); (*nNZrc)++;} yyyCLpdum = pNode->cL; i = pNode->cLlen; while (i--) { yyyCheckUnsolvedInstTrav(*yyyCLpdum,nNZrc,cycleSum); yyyCLpdum++; } } void yyyUnsolvedInstSearchTravAux(yyyGNT *pNode) {yyyGNT **yyyCLpdum; int i; yyyCheckNodeInstancesSolved(pNode); yyyCLpdum = pNode->cL; i = pNode->cLlen; while (i--) { yyyUnsolvedInstSearchTravAux(*yyyCLpdum); yyyCLpdum++; } } void yyyUnsolvedInstSearchTrav(yyyGNT *pNode) {yyyGNT **yyyCLpdum; int i; yyyCLpdum = pNode->cL; i = pNode->cLlen; while (i--) { yyyUnsolvedInstSearchTravAux(*yyyCLpdum); yyyCLpdum++; } } #line 1797 "expr.oxout.tab.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) #if YYBTYACC #define yytrial (yyps->save) #endif /* YYBTYACC */ #if YYDEBUG #include /* needed for printf */ #endif #include /* needed for malloc, etc */ #include /* needed for memset */ /* allocate initial stack or double stack size, up to YYMAXDEPTH */ static int yygrowstack(YYSTACKDATA *data) { int i; unsigned newsize; YYINT *newss; YYSTYPE *newvs; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE *newps; #endif if ((newsize = data->stacksize) == 0) newsize = YYINITSTACKSIZE; else if (newsize >= YYMAXDEPTH) return YYENOMEM; else if ((newsize *= 2) > YYMAXDEPTH) newsize = YYMAXDEPTH; i = (int) (data->s_mark - data->s_base); newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); if (newss == NULL) return YYENOMEM; data->s_base = newss; data->s_mark = newss + i; newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); if (newvs == NULL) return YYENOMEM; data->l_base = newvs; data->l_mark = newvs + i; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); if (newps == NULL) return YYENOMEM; data->p_base = newps; data->p_mark = newps + i; #endif data->stacksize = newsize; data->s_last = data->s_base + newsize - 1; #if YYDEBUG if (yydebug) fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); #endif return 0; } #if YYPURE || defined(YY_NO_LEAKS) static void yyfreestack(YYSTACKDATA *data) { free(data->s_base); free(data->l_base); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) free(data->p_base); #endif memset(data, 0, sizeof(*data)); } #else #define yyfreestack(data) /* nothing */ #endif /* YYPURE || defined(YY_NO_LEAKS) */ #if YYBTYACC static YYParseState * yyNewState(unsigned size) { YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); if (p == NULL) return NULL; p->yystack.stacksize = size; if (size == 0) { p->yystack.s_base = NULL; p->yystack.l_base = NULL; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) p->yystack.p_base = NULL; #endif return p; } p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); if (p->yystack.s_base == NULL) return NULL; p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); if (p->yystack.l_base == NULL) return NULL; memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); if (p->yystack.p_base == NULL) return NULL; memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); #endif return p; } static void yyFreeState(YYParseState *p) { yyfreestack(&p->yystack); free(p); } #endif /* YYBTYACC */ #define YYABORT goto yyabort #define YYREJECT goto yyabort #define YYACCEPT goto yyaccept #define YYERROR goto yyerrlab #if YYBTYACC #define YYVALID do { if (yyps->save) goto yyvalid; } while(0) #define YYVALID_NESTED do { if (yyps->save && \ yyps->save->save == 0) goto yyvalid; } while(0) #endif /* YYBTYACC */ int YYPARSE_DECL() { int yym, yyn, yystate, yyresult; #if YYBTYACC int yynewerrflag; YYParseState *yyerrctx = NULL; #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ #endif #if YYDEBUG const char *yys; if ((yys = getenv("YYDEBUG")) != NULL) { yyn = *yys; if (yyn >= '0' && yyn <= '9') yydebug = yyn - '0'; } if (yydebug) fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); #endif #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); #endif #if YYBTYACC yyps = yyNewState(0); if (yyps == 0) goto yyenomem; yyps->save = 0; #endif /* YYBTYACC */ yym = 0; /* yyn is set below */ yynerrs = 0; yyerrflag = 0; yychar = YYEMPTY; yystate = 0; #if YYPURE memset(&yystack, 0, sizeof(yystack)); #endif if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystack.s_mark = yystack.s_base; yystack.l_mark = yystack.l_base; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark = yystack.p_base; #endif yystate = 0; *yystack.s_mark = 0; yyloop: if ((yyn = yydefred[yystate]) != 0) goto yyreduce; if (yychar < 0) { #if YYBTYACC do { if (yylvp < yylve) { /* we're currently re-reading tokens */ yylval = *yylvp++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylloc = *yylpp++; #endif yychar = *yylexp++; break; } if (yyps->save) { /* in trial mode; save scanner results for future parse attempts */ if (yylvp == yylvlim) { /* Enlarge lexical value queue */ size_t p = (size_t) (yylvp - yylvals); size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpe = yylpsns + p; yylplim = yylpsns + s; #endif yylexp = yylexemes + p; } *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpp++ = yylloc; yylpe++; #endif yychar = *yylexp++; break; } /* normal operation, no conflict encountered */ #endif /* YYBTYACC */ yychar = YYLEX; #if YYBTYACC } while (0); #endif /* YYBTYACC */ if (yychar < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", YYDEBUGSTR, yydepth, yystate, yychar, yys); #ifdef YYSTYPE_TOSTRING #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); #endif fputc('\n', stderr); } #endif } #if YYBTYACC /* Do we have a conflict? */ if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) { YYINT ctry; if (yypath) { YYParseState *save; #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", YYDEBUGSTR, yydepth, yystate); #endif /* Switch to the next conflict context */ save = yypath; yypath = save->save; save->save = NULL; ctry = save->ctry; if (save->state != yystate) YYABORT; yyFreeState(save); } else { /* Unresolved conflict - start/continue trial parse */ YYParseState *save; #if YYDEBUG if (yydebug) { fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); if (yyps->save) fputs("ALREADY in conflict, continuing trial parse.\n", stderr); else fputs("Starting trial parse.\n", stderr); } #endif save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); if (save == NULL) goto yyenomem; save->save = yyps->save; save->state = yystate; save->errflag = yyerrflag; save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif ctry = yytable[yyn]; if (yyctable[ctry] == -1) { #if YYDEBUG if (yydebug && yychar >= YYEOF) fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); #endif ctry++; } save->ctry = ctry; if (yyps->save == NULL) { /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; yylvlim = yylvals + YYLVQUEUEGROWTH; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); if (yylpsns == NULL) goto yyenomem; yylplim = yylpsns + YYLVQUEUEGROWTH; #endif } if (yylvp == yylve) { yylvp = yylve = yylvals; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpe = yylpsns; #endif yylexp = yylexemes; if (yychar >= YYEOF) { *yylve++ = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpe++ = yylloc; #endif *yylexp = (YYINT) yychar; yychar = YYEMPTY; } } } if (yychar >= YYEOF) { yylvp--; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp--; #endif yylexp--; yychar = YYEMPTY; } save->lexeme = (int) (yylvp - yylvals); yyps->save = save; } if (yytable[yyn] == ctry) { #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); #endif if (yychar < 0) { yylvp++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp++; #endif yylexp++; } if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystate = yyctable[ctry]; *++yystack.s_mark = (YYINT) yystate; *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *++yystack.p_mark = yylloc; #endif yychar = YYEMPTY; if (yyerrflag > 0) --yyerrflag; goto yyloop; } else { yyn = yyctable[ctry]; goto yyreduce; } } /* End of code dealing with conflicts */ #endif /* YYBTYACC */ if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) { #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", YYDEBUGSTR, yydepth, yystate, yytable[yyn]); #endif if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystate = yytable[yyn]; *++yystack.s_mark = yytable[yyn]; *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *++yystack.p_mark = yylloc; #endif yychar = YYEMPTY; if (yyerrflag > 0) --yyerrflag; goto yyloop; } if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) { yyn = yytable[yyn]; goto yyreduce; } if (yyerrflag != 0) goto yyinrecovery; #if YYBTYACC yynewerrflag = 1; goto yyerrhandler; goto yyerrlab; /* redundant goto avoids 'unused label' warning */ yyerrlab: /* explicit YYERROR from an action -- pop the rhs of the rule reduced * before looking for error recovery */ yystack.s_mark -= yym; yystate = *yystack.s_mark; yystack.l_mark -= yym; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark -= yym; #endif yynewerrflag = 0; yyerrhandler: while (yyps->save) { int ctry; YYParseState *save = yyps->save; #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", YYDEBUGSTR, yydepth, yystate, yyps->save->state, (int)(yylvp - yylvals - yyps->save->lexeme)); #endif /* Memorize most forward-looking error state in case it's really an error. */ if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) { /* Free old saved error context state */ if (yyerrctx) yyFreeState(yyerrctx); /* Create and fill out new saved error context state */ yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); if (yyerrctx == NULL) goto yyenomem; yyerrctx->save = yyps->save; yyerrctx->state = yystate; yyerrctx->errflag = yyerrflag; yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif yyerrctx->lexeme = (int) (yylvp - yylvals); } yylvp = yylvals + save->lexeme; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpsns + save->lexeme; #endif yylexp = yylexemes + save->lexeme; yychar = YYEMPTY; yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif ctry = ++save->ctry; yystate = save->state; /* We tried shift, try reduce now */ if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; yyps->save = save->save; save->save = NULL; yyFreeState(save); /* Nothing left on the stack -- error */ if (!yyps->save) { #if YYDEBUG if (yydebug) fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", YYPREFIX, yydepth); #endif /* Restore state as it was in the most forward-advanced error */ yylvp = yylvals + yyerrctx->lexeme; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpsns + yyerrctx->lexeme; #endif yylexp = yylexemes + yyerrctx->lexeme; yychar = yylexp[-1]; yylval = yylvp[-1]; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylloc = yylpp[-1]; #endif yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif yystate = yyerrctx->state; yyFreeState(yyerrctx); yyerrctx = NULL; } yynewerrflag = 1; } if (yynewerrflag == 0) goto yyinrecovery; #endif /* YYBTYACC */ YYERROR_CALL("syntax error"); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ #endif #if !YYBTYACC goto yyerrlab; /* redundant goto avoids 'unused label' warning */ yyerrlab: #endif ++yynerrs; yyinrecovery: if (yyerrflag < 3) { yyerrflag = 3; for (;;) { if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) { #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); #endif if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystate = yytable[yyn]; *++yystack.s_mark = yytable[yyn]; *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* lookahead position is error end position */ yyerror_loc_range[2] = yylloc; YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ *++yystack.p_mark = yyloc; #endif goto yyloop; } else { #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", YYDEBUGSTR, yydepth, *yystack.s_mark); #endif if (yystack.s_mark <= yystack.s_base) goto yyabort; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* the current TOS position is the error start position */ yyerror_loc_range[1] = *yystack.p_mark; #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYDESTRUCT_CALL("error: discarding state", yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); #else YYDESTRUCT_CALL("error: discarding state", yystos[*yystack.s_mark], yystack.l_mark); #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ #endif /* defined(YYDESTRUCT_CALL) */ --yystack.s_mark; --yystack.l_mark; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) --yystack.p_mark; #endif } } } else { if (yychar == YYEOF) goto yyabort; #if YYDEBUG if (yydebug) { if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", YYDEBUGSTR, yydepth, yystate, yychar, yys); } #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); #else YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ #endif /* defined(YYDESTRUCT_CALL) */ yychar = YYEMPTY; goto yyloop; } yyreduce: yym = yylen[yyn]; #if YYDEBUG if (yydebug) { fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); #ifdef YYSTYPE_TOSTRING #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ if (yym > 0) { int i; fputc('<', stderr); for (i = yym; i > 0; i--) { if (i != yym) fputs(", ", stderr); fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], yystack.l_mark[1-i]), stderr); } fputc('>', stderr); } #endif fputc('\n', stderr); } #endif if (yym > 0) yyval = yystack.l_mark[1-yym]; else memset(&yyval, 0, sizeof yyval); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* Perform position reduction */ memset(&yyloc, 0, sizeof(yyloc)); #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ { YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); /* just in case YYERROR is invoked within the action, save the start of the rhs as the error start position */ yyerror_loc_range[1] = yystack.p_mark[1-yym]; } #endif switch (yyn) { case 1: #line 64 "expr.oxout.y" {yyyYoxInit();} #line 2470 "expr.oxout.tab.c" break; case 2: #line 66 "expr.oxout.y" { yyyDecorate(); yyyExecuteRRsection(yystack.l_mark[0].yyyOxAttrbs.yyyOxStackItem->node); } #line 2477 "expr.oxout.tab.c" break; case 3: #line 73 "expr.oxout.y" {if(yyyYok){ yyyGenIntNode(1,1,0,&yyval.yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); yyyAdjustINRC(1,1,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} #line 2484 "expr.oxout.tab.c" break; case 4: #line 80 "expr.oxout.y" {if(yyyYok){ yyyGenIntNode(2,3,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); yyyAdjustINRC(2,3,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} #line 2491 "expr.oxout.tab.c" break; case 5: #line 87 "expr.oxout.y" {if(yyyYok){ yyyGenIntNode(3,3,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); yyyAdjustINRC(3,3,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} #line 2498 "expr.oxout.tab.c" break; case 6: #line 94 "expr.oxout.y" {if(yyyYok){ yyyGenIntNode(4,3,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); yyyAdjustINRC(4,3,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} #line 2505 "expr.oxout.tab.c" break; case 7: #line 101 "expr.oxout.y" {if(yyyYok){ yyyGenIntNode(5,3,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); yyyAdjustINRC(5,3,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} #line 2512 "expr.oxout.tab.c" break; case 8: #line 108 "expr.oxout.y" {if(yyyYok){ yyyGenIntNode(6,3,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); yyyAdjustINRC(6,3,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} #line 2519 "expr.oxout.tab.c" break; case 9: #line 114 "expr.oxout.y" {if(yyyYok){ yyyGenIntNode(7,1,0,&yyval.yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); yyyAdjustINRC(7,1,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} #line 2526 "expr.oxout.tab.c" break; case 10: #line 121 "expr.oxout.y" {if(yyyYok){ yyyGenIntNode(8,1,0,&yyval.yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); yyyAdjustINRC(8,1,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} #line 2533 "expr.oxout.tab.c" break; #line 2535 "expr.oxout.tab.c" default: break; } yystack.s_mark -= yym; yystate = *yystack.s_mark; yystack.l_mark -= yym; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark -= yym; #endif yym = yylhs[yyn]; if (yystate == 0 && yym == 0) { #if YYDEBUG if (yydebug) { fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); #ifdef YYSTYPE_TOSTRING #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); #endif fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); } #endif yystate = YYFINAL; *++yystack.s_mark = YYFINAL; *++yystack.l_mark = yyval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *++yystack.p_mark = yyloc; #endif if (yychar < 0) { #if YYBTYACC do { if (yylvp < yylve) { /* we're currently re-reading tokens */ yylval = *yylvp++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylloc = *yylpp++; #endif yychar = *yylexp++; break; } if (yyps->save) { /* in trial mode; save scanner results for future parse attempts */ if (yylvp == yylvlim) { /* Enlarge lexical value queue */ size_t p = (size_t) (yylvp - yylvals); size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpe = yylpsns + p; yylplim = yylpsns + s; #endif yylexp = yylexemes + p; } *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpp++ = yylloc; yylpe++; #endif yychar = *yylexp++; break; } /* normal operation, no conflict encountered */ #endif /* YYBTYACC */ yychar = YYLEX; #if YYBTYACC } while (0); #endif /* YYBTYACC */ if (yychar < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); } #endif } if (yychar == YYEOF) goto yyaccept; goto yyloop; } if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) yystate = yytable[yyn]; else yystate = yydgoto[yym]; #if YYDEBUG if (yydebug) { fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); #ifdef YYSTYPE_TOSTRING #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); #endif fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); } #endif if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; *++yystack.s_mark = (YYINT) yystate; *++yystack.l_mark = yyval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *++yystack.p_mark = yyloc; #endif goto yyloop; #if YYBTYACC /* Reduction declares that this path is valid. Set yypath and do a full parse */ yyvalid: if (yypath) YYABORT; while (yyps->save) { YYParseState *save = yyps->save; yyps->save = save->save; save->save = yypath; yypath = save; } #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); #endif if (yyerrctx) { yyFreeState(yyerrctx); yyerrctx = NULL; } yylvp = yylvals + yypath->lexeme; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpsns + yypath->lexeme; #endif yylexp = yylexemes + yypath->lexeme; yychar = YYEMPTY; yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif yystate = yypath->state; goto yyloop; #endif /* YYBTYACC */ yyoverflow: YYERROR_CALL("yacc stack overflow"); #if YYBTYACC goto yyabort_nomem; yyenomem: YYERROR_CALL("memory exhausted"); yyabort_nomem: #endif /* YYBTYACC */ yyresult = 2; goto yyreturn; yyabort: yyresult = 1; goto yyreturn; yyaccept: #if YYBTYACC if (yyps->save) goto yyvalid; #endif /* YYBTYACC */ yyresult = 0; yyreturn: #if defined(YYDESTRUCT_CALL) if (yychar != YYEOF && yychar != YYEMPTY) #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); #else YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ { YYSTYPE *pv; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE *pp; for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) YYDESTRUCT_CALL("cleanup: discarding state", yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); #else for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) YYDESTRUCT_CALL("cleanup: discarding state", yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ } #endif /* defined(YYDESTRUCT_CALL) */ #if YYBTYACC if (yyerrctx) { yyFreeState(yyerrctx); yyerrctx = NULL; } while (yyps) { YYParseState *save = yyps; yyps = save->save; save->save = NULL; yyFreeState(save); } while (yypath) { YYParseState *save = yypath; yypath = save->save; save->save = NULL; yyFreeState(save); } #endif /* YYBTYACC */ yyfreestack(&yystack); return (yyresult); } diff --git a/contrib/byacc/test/btyacc/expr.oxout.tab.h b/contrib/byacc/test/btyacc/expr.oxout.tab.h index cafc41cae56e..eb8596306bdc 100644 --- a/contrib/byacc/test/btyacc/expr.oxout.tab.h +++ b/contrib/byacc/test/btyacc/expr.oxout.tab.h @@ -1,20 +1,20 @@ #ifndef _expr_oxout__defines_h_ #define _expr_oxout__defines_h_ #define ID 257 #define CONST 258 #ifdef YYSTYPE #undef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 #endif #ifndef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 -typedef union YYSTYPE { +typedef union { struct yyyOxAttrbs { struct yyyStackItem *yyyOxStackItem; } yyyOxAttrbs; } YYSTYPE; #endif /* !YYSTYPE_IS_DECLARED */ extern YYSTYPE expr_oxout_lval; #endif /* _expr_oxout__defines_h_ */ diff --git a/contrib/byacc/test/btyacc/inherit1.tab.c b/contrib/byacc/test/btyacc/inherit1.tab.c index 60af07cb10f1..b8e7c5a7935b 100644 --- a/contrib/byacc/test/btyacc/inherit1.tab.c +++ b/contrib/byacc/test/btyacc/inherit1.tab.c @@ -1,1379 +1,1379 @@ /* original parser id follows */ /* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ /* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ #define YYBYACC 1 #define YYMAJOR 2 #define YYMINOR 0 #define YYCHECK "yyyymmdd" #define YYEMPTY (-1) #define yyclearin (yychar = YYEMPTY) #define yyerrok (yyerrflag = 0) #define YYRECOVERING() (yyerrflag != 0) #define YYENOMEM (-2) #define YYEOF 0 #undef YYBTYACC #define YYBTYACC 0 #define YYDEBUGSTR YYPREFIX "debug" #ifndef yyparse #define yyparse inherit1_parse #endif /* yyparse */ #ifndef yylex #define yylex inherit1_lex #endif /* yylex */ #ifndef yyerror #define yyerror inherit1_error #endif /* yyerror */ #ifndef yychar #define yychar inherit1_char #endif /* yychar */ #ifndef yyval #define yyval inherit1_val #endif /* yyval */ #ifndef yylval #define yylval inherit1_lval #endif /* yylval */ #ifndef yydebug #define yydebug inherit1_debug #endif /* yydebug */ #ifndef yynerrs #define yynerrs inherit1_nerrs #endif /* yynerrs */ #ifndef yyerrflag #define yyerrflag inherit1_errflag #endif /* yyerrflag */ #ifndef yylhs #define yylhs inherit1_lhs #endif /* yylhs */ #ifndef yylen #define yylen inherit1_len #endif /* yylen */ #ifndef yydefred #define yydefred inherit1_defred #endif /* yydefred */ #ifndef yystos #define yystos inherit1_stos #endif /* yystos */ #ifndef yydgoto #define yydgoto inherit1_dgoto #endif /* yydgoto */ #ifndef yysindex #define yysindex inherit1_sindex #endif /* yysindex */ #ifndef yyrindex #define yyrindex inherit1_rindex #endif /* yyrindex */ #ifndef yygindex #define yygindex inherit1_gindex #endif /* yygindex */ #ifndef yytable #define yytable inherit1_table #endif /* yytable */ #ifndef yycheck #define yycheck inherit1_check #endif /* yycheck */ #ifndef yyname #define yyname inherit1_name #endif /* yyname */ #ifndef yyrule #define yyrule inherit1_rule #endif /* yyrule */ #if YYBTYACC #ifndef yycindex #define yycindex inherit1_cindex #endif /* yycindex */ #ifndef yyctable #define yyctable inherit1_ctable #endif /* yyctable */ #endif /* YYBTYACC */ #define YYPREFIX "inherit1_" #define YYPURE 0 #line 2 "inherit1.y" #include typedef enum {cGLOBAL, cLOCAL} class; typedef enum {tREAL, tINTEGER} type; typedef char * name; struct symbol { class c; type t; name id; }; typedef struct symbol symbol; struct namelist { symbol *s; struct namelist *next; }; typedef struct namelist namelist; extern symbol *mksymbol(type t, class c, name id); #ifdef YYBISON #define YYLEX_DECL() yylex(void) #define YYERROR_DECL() yyerror(const char *s) extern int YYLEX_DECL(); extern void YYERROR_DECL(); #endif #ifdef YYSTYPE #undef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 #endif #ifndef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 #line 32 "inherit1.y" -typedef union YYSTYPE +typedef union { class cval; type tval; namelist * nlist; name id; } YYSTYPE; #endif /* !YYSTYPE_IS_DECLARED */ #line 157 "inherit1.tab.c" /* compatibility with bison */ #ifdef YYPARSE_PARAM /* compatibility with FreeBSD */ # ifdef YYPARSE_PARAM_TYPE # define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) # else # define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) # endif #else # define YYPARSE_DECL() yyparse(void) #endif /* Parameters sent to lex. */ #ifdef YYLEX_PARAM # define YYLEX_DECL() yylex(void *YYLEX_PARAM) # define YYLEX yylex(YYLEX_PARAM) #else # define YYLEX_DECL() yylex(void) # define YYLEX yylex() #endif /* Parameters sent to yyerror. */ #ifndef YYERROR_DECL #define YYERROR_DECL() yyerror(const char *s) #endif #ifndef YYERROR_CALL #define YYERROR_CALL(msg) yyerror(msg) #endif extern int YYPARSE_DECL(); #define GLOBAL 257 #define LOCAL 258 #define REAL 259 #define INTEGER 260 #define NAME 261 #define YYERRCODE 256 typedef int YYINT; static const YYINT inherit1_lhs[] = { -1, 0, 0, 3, 3, 4, 4, 1, 1, 5, 6, 2, }; static const YYINT inherit1_len[] = { 2, 3, 2, 1, 1, 1, 1, 2, 1, 0, 0, 3, }; static const YYINT inherit1_defred[] = { 0, 3, 4, 5, 6, 0, 0, 9, 0, 2, 10, 8, 0, 0, 7, 0, }; #if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) static const YYINT inherit1_stos[] = { 0, 257, 258, 259, 260, 263, 266, 267, 267, 265, 268, 261, 264, 269, 261, 264, }; #endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ static const YYINT inherit1_dgoto[] = { 5, 12, 9, 6, 7, 10, 13, }; static const YYINT inherit1_sindex[] = { -257, 0, 0, 0, 0, 0, -255, 0, -254, 0, 0, 0, -253, -254, 0, -253, }; static const YYINT inherit1_rindex[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 9, }; #if YYBTYACC static const YYINT inherit1_cindex[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; #endif static const YYINT inherit1_gindex[] = { 0, -3, 0, 0, 5, 0, 0, }; #define YYTABLESIZE 11 static const YYINT inherit1_table[] = { 1, 2, 3, 4, 3, 4, 1, 11, 14, 11, 15, 8, }; static const YYINT inherit1_check[] = { 257, 258, 259, 260, 259, 260, 0, 261, 261, 0, 13, 6, }; #if YYBTYACC static const YYINT inherit1_ctable[] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, }; #endif #define YYFINAL 5 #ifndef YYDEBUG #define YYDEBUG 0 #endif #define YYMAXTOKEN 261 #define YYUNDFTOKEN 270 #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) #if YYDEBUG static const char *const inherit1_name[] = { "$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, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"error","GLOBAL","LOCAL","REAL","INTEGER", "NAME","$accept","declaration","namelist","locnamelist","class","type","$$1", "$$2","illegal-symbol", }; static const char *const inherit1_rule[] = { "$accept : declaration", "declaration : class type namelist", "declaration : type locnamelist", "class : GLOBAL", "class : LOCAL", "type : REAL", "type : INTEGER", "namelist : namelist NAME", "namelist : NAME", "$$1 :", "$$2 :", "locnamelist : $$1 $$2 namelist", }; #endif #if YYDEBUG int yydebug; #endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; int yynerrs; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyloc; /* position returned by actions */ YYLTYPE yylloc; /* position from the lexer */ #endif #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) #ifndef YYLLOC_DEFAULT #define YYLLOC_DEFAULT(loc, rhs, n) \ do \ { \ if (n == 0) \ { \ (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ } \ else \ { \ (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ (loc).last_line = YYRHSLOC(rhs, n).last_line; \ (loc).last_column = YYRHSLOC(rhs, n).last_column; \ } \ } while (0) #endif /* YYLLOC_DEFAULT */ #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ #if YYBTYACC #ifndef YYLVQUEUEGROWTH #define YYLVQUEUEGROWTH 32 #endif #endif /* YYBTYACC */ /* define the initial stack-sizes */ #ifdef YYSTACKSIZE #undef YYMAXDEPTH #define YYMAXDEPTH YYSTACKSIZE #else #ifdef YYMAXDEPTH #define YYSTACKSIZE YYMAXDEPTH #else #define YYSTACKSIZE 10000 #define YYMAXDEPTH 10000 #endif #endif #ifndef YYINITSTACKSIZE #define YYINITSTACKSIZE 200 #endif typedef struct { unsigned stacksize; YYINT *s_base; YYINT *s_mark; YYINT *s_last; YYSTYPE *l_base; YYSTYPE *l_mark; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE *p_base; YYLTYPE *p_mark; #endif } YYSTACKDATA; #if YYBTYACC struct YYParseState_s { struct YYParseState_s *save; /* Previously saved parser state */ YYSTACKDATA yystack; /* saved parser stack */ int state; /* saved parser state */ int errflag; /* saved error recovery status */ int lexeme; /* saved index of the conflict lexeme in the lexical queue */ YYINT ctry; /* saved index in yyctable[] for this conflict */ }; typedef struct YYParseState_s YYParseState; #endif /* YYBTYACC */ /* variables for the parser stack */ static YYSTACKDATA yystack; #if YYBTYACC /* Current parser state */ static YYParseState *yyps = 0; /* yypath != NULL: do the full parse, starting at *yypath parser state. */ static YYParseState *yypath = 0; /* Base of the lexical value queue */ static YYSTYPE *yylvals = 0; /* Current position at lexical value queue */ static YYSTYPE *yylvp = 0; /* End position of lexical value queue */ static YYSTYPE *yylve = 0; /* The last allocated position at the lexical value queue */ static YYSTYPE *yylvlim = 0; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* Base of the lexical position queue */ static YYLTYPE *yylpsns = 0; /* Current position at lexical position queue */ static YYLTYPE *yylpp = 0; /* End position of lexical position queue */ static YYLTYPE *yylpe = 0; /* The last allocated position at the lexical position queue */ static YYLTYPE *yylplim = 0; #endif /* Current position at lexical token queue */ static YYINT *yylexp = 0; static YYINT *yylexemes = 0; #endif /* YYBTYACC */ #line 74 "inherit1.y" extern int YYLEX_DECL(); extern void YYERROR_DECL(); #line 417 "inherit1.tab.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) #if YYBTYACC #define yytrial (yyps->save) #endif /* YYBTYACC */ #if YYDEBUG #include /* needed for printf */ #endif #include /* needed for malloc, etc */ #include /* needed for memset */ /* allocate initial stack or double stack size, up to YYMAXDEPTH */ static int yygrowstack(YYSTACKDATA *data) { int i; unsigned newsize; YYINT *newss; YYSTYPE *newvs; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE *newps; #endif if ((newsize = data->stacksize) == 0) newsize = YYINITSTACKSIZE; else if (newsize >= YYMAXDEPTH) return YYENOMEM; else if ((newsize *= 2) > YYMAXDEPTH) newsize = YYMAXDEPTH; i = (int) (data->s_mark - data->s_base); newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); if (newss == NULL) return YYENOMEM; data->s_base = newss; data->s_mark = newss + i; newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); if (newvs == NULL) return YYENOMEM; data->l_base = newvs; data->l_mark = newvs + i; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); if (newps == NULL) return YYENOMEM; data->p_base = newps; data->p_mark = newps + i; #endif data->stacksize = newsize; data->s_last = data->s_base + newsize - 1; #if YYDEBUG if (yydebug) fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); #endif return 0; } #if YYPURE || defined(YY_NO_LEAKS) static void yyfreestack(YYSTACKDATA *data) { free(data->s_base); free(data->l_base); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) free(data->p_base); #endif memset(data, 0, sizeof(*data)); } #else #define yyfreestack(data) /* nothing */ #endif /* YYPURE || defined(YY_NO_LEAKS) */ #if YYBTYACC static YYParseState * yyNewState(unsigned size) { YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); if (p == NULL) return NULL; p->yystack.stacksize = size; if (size == 0) { p->yystack.s_base = NULL; p->yystack.l_base = NULL; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) p->yystack.p_base = NULL; #endif return p; } p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); if (p->yystack.s_base == NULL) return NULL; p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); if (p->yystack.l_base == NULL) return NULL; memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); if (p->yystack.p_base == NULL) return NULL; memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); #endif return p; } static void yyFreeState(YYParseState *p) { yyfreestack(&p->yystack); free(p); } #endif /* YYBTYACC */ #define YYABORT goto yyabort #define YYREJECT goto yyabort #define YYACCEPT goto yyaccept #define YYERROR goto yyerrlab #if YYBTYACC #define YYVALID do { if (yyps->save) goto yyvalid; } while(0) #define YYVALID_NESTED do { if (yyps->save && \ yyps->save->save == 0) goto yyvalid; } while(0) #endif /* YYBTYACC */ int YYPARSE_DECL() { int yym, yyn, yystate, yyresult; #if YYBTYACC int yynewerrflag; YYParseState *yyerrctx = NULL; #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ #endif #if YYDEBUG const char *yys; if ((yys = getenv("YYDEBUG")) != NULL) { yyn = *yys; if (yyn >= '0' && yyn <= '9') yydebug = yyn - '0'; } if (yydebug) fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); #endif #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); #endif #if YYBTYACC yyps = yyNewState(0); if (yyps == 0) goto yyenomem; yyps->save = 0; #endif /* YYBTYACC */ yym = 0; /* yyn is set below */ yynerrs = 0; yyerrflag = 0; yychar = YYEMPTY; yystate = 0; #if YYPURE memset(&yystack, 0, sizeof(yystack)); #endif if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystack.s_mark = yystack.s_base; yystack.l_mark = yystack.l_base; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark = yystack.p_base; #endif yystate = 0; *yystack.s_mark = 0; yyloop: if ((yyn = yydefred[yystate]) != 0) goto yyreduce; if (yychar < 0) { #if YYBTYACC do { if (yylvp < yylve) { /* we're currently re-reading tokens */ yylval = *yylvp++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylloc = *yylpp++; #endif yychar = *yylexp++; break; } if (yyps->save) { /* in trial mode; save scanner results for future parse attempts */ if (yylvp == yylvlim) { /* Enlarge lexical value queue */ size_t p = (size_t) (yylvp - yylvals); size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpe = yylpsns + p; yylplim = yylpsns + s; #endif yylexp = yylexemes + p; } *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpp++ = yylloc; yylpe++; #endif yychar = *yylexp++; break; } /* normal operation, no conflict encountered */ #endif /* YYBTYACC */ yychar = YYLEX; #if YYBTYACC } while (0); #endif /* YYBTYACC */ if (yychar < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", YYDEBUGSTR, yydepth, yystate, yychar, yys); #ifdef YYSTYPE_TOSTRING #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); #endif fputc('\n', stderr); } #endif } #if YYBTYACC /* Do we have a conflict? */ if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) { YYINT ctry; if (yypath) { YYParseState *save; #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", YYDEBUGSTR, yydepth, yystate); #endif /* Switch to the next conflict context */ save = yypath; yypath = save->save; save->save = NULL; ctry = save->ctry; if (save->state != yystate) YYABORT; yyFreeState(save); } else { /* Unresolved conflict - start/continue trial parse */ YYParseState *save; #if YYDEBUG if (yydebug) { fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); if (yyps->save) fputs("ALREADY in conflict, continuing trial parse.\n", stderr); else fputs("Starting trial parse.\n", stderr); } #endif save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); if (save == NULL) goto yyenomem; save->save = yyps->save; save->state = yystate; save->errflag = yyerrflag; save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif ctry = yytable[yyn]; if (yyctable[ctry] == -1) { #if YYDEBUG if (yydebug && yychar >= YYEOF) fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); #endif ctry++; } save->ctry = ctry; if (yyps->save == NULL) { /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; yylvlim = yylvals + YYLVQUEUEGROWTH; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); if (yylpsns == NULL) goto yyenomem; yylplim = yylpsns + YYLVQUEUEGROWTH; #endif } if (yylvp == yylve) { yylvp = yylve = yylvals; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpe = yylpsns; #endif yylexp = yylexemes; if (yychar >= YYEOF) { *yylve++ = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpe++ = yylloc; #endif *yylexp = (YYINT) yychar; yychar = YYEMPTY; } } } if (yychar >= YYEOF) { yylvp--; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp--; #endif yylexp--; yychar = YYEMPTY; } save->lexeme = (int) (yylvp - yylvals); yyps->save = save; } if (yytable[yyn] == ctry) { #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); #endif if (yychar < 0) { yylvp++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp++; #endif yylexp++; } if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystate = yyctable[ctry]; *++yystack.s_mark = (YYINT) yystate; *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *++yystack.p_mark = yylloc; #endif yychar = YYEMPTY; if (yyerrflag > 0) --yyerrflag; goto yyloop; } else { yyn = yyctable[ctry]; goto yyreduce; } } /* End of code dealing with conflicts */ #endif /* YYBTYACC */ if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) { #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", YYDEBUGSTR, yydepth, yystate, yytable[yyn]); #endif if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystate = yytable[yyn]; *++yystack.s_mark = yytable[yyn]; *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *++yystack.p_mark = yylloc; #endif yychar = YYEMPTY; if (yyerrflag > 0) --yyerrflag; goto yyloop; } if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) { yyn = yytable[yyn]; goto yyreduce; } if (yyerrflag != 0) goto yyinrecovery; #if YYBTYACC yynewerrflag = 1; goto yyerrhandler; goto yyerrlab; /* redundant goto avoids 'unused label' warning */ yyerrlab: /* explicit YYERROR from an action -- pop the rhs of the rule reduced * before looking for error recovery */ yystack.s_mark -= yym; yystate = *yystack.s_mark; yystack.l_mark -= yym; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark -= yym; #endif yynewerrflag = 0; yyerrhandler: while (yyps->save) { int ctry; YYParseState *save = yyps->save; #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", YYDEBUGSTR, yydepth, yystate, yyps->save->state, (int)(yylvp - yylvals - yyps->save->lexeme)); #endif /* Memorize most forward-looking error state in case it's really an error. */ if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) { /* Free old saved error context state */ if (yyerrctx) yyFreeState(yyerrctx); /* Create and fill out new saved error context state */ yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); if (yyerrctx == NULL) goto yyenomem; yyerrctx->save = yyps->save; yyerrctx->state = yystate; yyerrctx->errflag = yyerrflag; yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif yyerrctx->lexeme = (int) (yylvp - yylvals); } yylvp = yylvals + save->lexeme; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpsns + save->lexeme; #endif yylexp = yylexemes + save->lexeme; yychar = YYEMPTY; yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif ctry = ++save->ctry; yystate = save->state; /* We tried shift, try reduce now */ if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; yyps->save = save->save; save->save = NULL; yyFreeState(save); /* Nothing left on the stack -- error */ if (!yyps->save) { #if YYDEBUG if (yydebug) fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", YYPREFIX, yydepth); #endif /* Restore state as it was in the most forward-advanced error */ yylvp = yylvals + yyerrctx->lexeme; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpsns + yyerrctx->lexeme; #endif yylexp = yylexemes + yyerrctx->lexeme; yychar = yylexp[-1]; yylval = yylvp[-1]; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylloc = yylpp[-1]; #endif yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif yystate = yyerrctx->state; yyFreeState(yyerrctx); yyerrctx = NULL; } yynewerrflag = 1; } if (yynewerrflag == 0) goto yyinrecovery; #endif /* YYBTYACC */ YYERROR_CALL("syntax error"); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ #endif #if !YYBTYACC goto yyerrlab; /* redundant goto avoids 'unused label' warning */ yyerrlab: #endif ++yynerrs; yyinrecovery: if (yyerrflag < 3) { yyerrflag = 3; for (;;) { if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) { #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); #endif if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystate = yytable[yyn]; *++yystack.s_mark = yytable[yyn]; *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* lookahead position is error end position */ yyerror_loc_range[2] = yylloc; YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ *++yystack.p_mark = yyloc; #endif goto yyloop; } else { #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", YYDEBUGSTR, yydepth, *yystack.s_mark); #endif if (yystack.s_mark <= yystack.s_base) goto yyabort; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* the current TOS position is the error start position */ yyerror_loc_range[1] = *yystack.p_mark; #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYDESTRUCT_CALL("error: discarding state", yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); #else YYDESTRUCT_CALL("error: discarding state", yystos[*yystack.s_mark], yystack.l_mark); #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ #endif /* defined(YYDESTRUCT_CALL) */ --yystack.s_mark; --yystack.l_mark; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) --yystack.p_mark; #endif } } } else { if (yychar == YYEOF) goto yyabort; #if YYDEBUG if (yydebug) { if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", YYDEBUGSTR, yydepth, yystate, yychar, yys); } #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); #else YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ #endif /* defined(YYDESTRUCT_CALL) */ yychar = YYEMPTY; goto yyloop; } yyreduce: yym = yylen[yyn]; #if YYDEBUG if (yydebug) { fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); #ifdef YYSTYPE_TOSTRING #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ if (yym > 0) { int i; fputc('<', stderr); for (i = yym; i > 0; i--) { if (i != yym) fputs(", ", stderr); fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], yystack.l_mark[1-i]), stderr); } fputc('>', stderr); } #endif fputc('\n', stderr); } #endif if (yym > 0) yyval = yystack.l_mark[1-yym]; else memset(&yyval, 0, sizeof yyval); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* Perform position reduction */ memset(&yyloc, 0, sizeof(yyloc)); #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ { YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); /* just in case YYERROR is invoked within the action, save the start of the rhs as the error start position */ yyerror_loc_range[1] = yystack.p_mark[1-yym]; } #endif switch (yyn) { case 1: #line 44 "inherit1.y" { yyval.nlist = yystack.l_mark[0].nlist; } #line 1090 "inherit1.tab.c" break; case 2: #line 46 "inherit1.y" { yyval.nlist = yystack.l_mark[0].nlist; } #line 1095 "inherit1.tab.c" break; case 3: #line 49 "inherit1.y" { yyval.cval = cGLOBAL; } #line 1100 "inherit1.tab.c" break; case 4: #line 50 "inherit1.y" { yyval.cval = cLOCAL; } #line 1105 "inherit1.tab.c" break; case 5: #line 53 "inherit1.y" { yyval.tval = tREAL; } #line 1110 "inherit1.tab.c" break; case 6: #line 54 "inherit1.y" { yyval.tval = tINTEGER; } #line 1115 "inherit1.tab.c" break; case 7: #line 58 "inherit1.y" { yyval.nlist->s = mksymbol(yystack.l_mark[-2].tval, yystack.l_mark[-3].cval, yystack.l_mark[0].id); yyval.nlist->next = yystack.l_mark[-1].nlist; } #line 1122 "inherit1.tab.c" break; case 8: #line 62 "inherit1.y" { yyval.nlist->s = mksymbol(yystack.l_mark[-1].tval, yystack.l_mark[-2].cval, yystack.l_mark[0].id); yyval.nlist->next = NULL; } #line 1129 "inherit1.tab.c" break; case 9: #line 68 "inherit1.y" { yyval.cval = cLOCAL; } #line 1134 "inherit1.tab.c" break; case 10: #line 69 "inherit1.y" { yyval.tval = yystack.l_mark[-2].tval; } #line 1139 "inherit1.tab.c" break; case 11: #line 71 "inherit1.y" { yyval.nlist = yystack.l_mark[0].nlist; } #line 1144 "inherit1.tab.c" break; #line 1146 "inherit1.tab.c" default: break; } yystack.s_mark -= yym; yystate = *yystack.s_mark; yystack.l_mark -= yym; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark -= yym; #endif yym = yylhs[yyn]; if (yystate == 0 && yym == 0) { #if YYDEBUG if (yydebug) { fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); #ifdef YYSTYPE_TOSTRING #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); #endif fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); } #endif yystate = YYFINAL; *++yystack.s_mark = YYFINAL; *++yystack.l_mark = yyval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *++yystack.p_mark = yyloc; #endif if (yychar < 0) { #if YYBTYACC do { if (yylvp < yylve) { /* we're currently re-reading tokens */ yylval = *yylvp++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylloc = *yylpp++; #endif yychar = *yylexp++; break; } if (yyps->save) { /* in trial mode; save scanner results for future parse attempts */ if (yylvp == yylvlim) { /* Enlarge lexical value queue */ size_t p = (size_t) (yylvp - yylvals); size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpe = yylpsns + p; yylplim = yylpsns + s; #endif yylexp = yylexemes + p; } *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpp++ = yylloc; yylpe++; #endif yychar = *yylexp++; break; } /* normal operation, no conflict encountered */ #endif /* YYBTYACC */ yychar = YYLEX; #if YYBTYACC } while (0); #endif /* YYBTYACC */ if (yychar < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); } #endif } if (yychar == YYEOF) goto yyaccept; goto yyloop; } if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) yystate = yytable[yyn]; else yystate = yydgoto[yym]; #if YYDEBUG if (yydebug) { fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); #ifdef YYSTYPE_TOSTRING #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); #endif fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); } #endif if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; *++yystack.s_mark = (YYINT) yystate; *++yystack.l_mark = yyval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *++yystack.p_mark = yyloc; #endif goto yyloop; #if YYBTYACC /* Reduction declares that this path is valid. Set yypath and do a full parse */ yyvalid: if (yypath) YYABORT; while (yyps->save) { YYParseState *save = yyps->save; yyps->save = save->save; save->save = yypath; yypath = save; } #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); #endif if (yyerrctx) { yyFreeState(yyerrctx); yyerrctx = NULL; } yylvp = yylvals + yypath->lexeme; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpsns + yypath->lexeme; #endif yylexp = yylexemes + yypath->lexeme; yychar = YYEMPTY; yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif yystate = yypath->state; goto yyloop; #endif /* YYBTYACC */ yyoverflow: YYERROR_CALL("yacc stack overflow"); #if YYBTYACC goto yyabort_nomem; yyenomem: YYERROR_CALL("memory exhausted"); yyabort_nomem: #endif /* YYBTYACC */ yyresult = 2; goto yyreturn; yyabort: yyresult = 1; goto yyreturn; yyaccept: #if YYBTYACC if (yyps->save) goto yyvalid; #endif /* YYBTYACC */ yyresult = 0; yyreturn: #if defined(YYDESTRUCT_CALL) if (yychar != YYEOF && yychar != YYEMPTY) #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); #else YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ { YYSTYPE *pv; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE *pp; for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) YYDESTRUCT_CALL("cleanup: discarding state", yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); #else for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) YYDESTRUCT_CALL("cleanup: discarding state", yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ } #endif /* defined(YYDESTRUCT_CALL) */ #if YYBTYACC if (yyerrctx) { yyFreeState(yyerrctx); yyerrctx = NULL; } while (yyps) { YYParseState *save = yyps; yyps = save->save; save->save = NULL; yyFreeState(save); } while (yypath) { YYParseState *save = yypath; yypath = save->save; save->save = NULL; yyFreeState(save); } #endif /* YYBTYACC */ yyfreestack(&yystack); return (yyresult); } diff --git a/contrib/byacc/test/btyacc/inherit1.tab.h b/contrib/byacc/test/btyacc/inherit1.tab.h index 41b0e2937d3d..3b8aa3d2a914 100644 --- a/contrib/byacc/test/btyacc/inherit1.tab.h +++ b/contrib/byacc/test/btyacc/inherit1.tab.h @@ -1,25 +1,25 @@ #ifndef _inherit1__defines_h_ #define _inherit1__defines_h_ #define GLOBAL 257 #define LOCAL 258 #define REAL 259 #define INTEGER 260 #define NAME 261 #ifdef YYSTYPE #undef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 #endif #ifndef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 -typedef union YYSTYPE +typedef union { class cval; type tval; namelist * nlist; name id; } YYSTYPE; #endif /* !YYSTYPE_IS_DECLARED */ extern YYSTYPE inherit1_lval; #endif /* _inherit1__defines_h_ */ diff --git a/contrib/byacc/test/btyacc/inherit2.tab.c b/contrib/byacc/test/btyacc/inherit2.tab.c index 8fb8e39cf2bc..db6fd30b0a24 100644 --- a/contrib/byacc/test/btyacc/inherit2.tab.c +++ b/contrib/byacc/test/btyacc/inherit2.tab.c @@ -1,1439 +1,1439 @@ /* original parser id follows */ /* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ /* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ #define YYBYACC 1 #define YYMAJOR 2 #define YYMINOR 0 #define YYCHECK "yyyymmdd" #define YYEMPTY (-1) #define yyclearin (yychar = YYEMPTY) #define yyerrok (yyerrflag = 0) #define YYRECOVERING() (yyerrflag != 0) #define YYENOMEM (-2) #define YYEOF 0 #undef YYBTYACC #define YYBTYACC 0 #define YYDEBUGSTR YYPREFIX "debug" #ifndef yyparse #define yyparse inherit2_parse #endif /* yyparse */ #ifndef yylex #define yylex inherit2_lex #endif /* yylex */ #ifndef yyerror #define yyerror inherit2_error #endif /* yyerror */ #ifndef yychar #define yychar inherit2_char #endif /* yychar */ #ifndef yyval #define yyval inherit2_val #endif /* yyval */ #ifndef yylval #define yylval inherit2_lval #endif /* yylval */ #ifndef yydebug #define yydebug inherit2_debug #endif /* yydebug */ #ifndef yynerrs #define yynerrs inherit2_nerrs #endif /* yynerrs */ #ifndef yyerrflag #define yyerrflag inherit2_errflag #endif /* yyerrflag */ #ifndef yylhs #define yylhs inherit2_lhs #endif /* yylhs */ #ifndef yylen #define yylen inherit2_len #endif /* yylen */ #ifndef yydefred #define yydefred inherit2_defred #endif /* yydefred */ #ifndef yystos #define yystos inherit2_stos #endif /* yystos */ #ifndef yydgoto #define yydgoto inherit2_dgoto #endif /* yydgoto */ #ifndef yysindex #define yysindex inherit2_sindex #endif /* yysindex */ #ifndef yyrindex #define yyrindex inherit2_rindex #endif /* yyrindex */ #ifndef yygindex #define yygindex inherit2_gindex #endif /* yygindex */ #ifndef yytable #define yytable inherit2_table #endif /* yytable */ #ifndef yycheck #define yycheck inherit2_check #endif /* yycheck */ #ifndef yyname #define yyname inherit2_name #endif /* yyname */ #ifndef yyrule #define yyrule inherit2_rule #endif /* yyrule */ #if YYBTYACC #ifndef yycindex #define yycindex inherit2_cindex #endif /* yycindex */ #ifndef yyctable #define yyctable inherit2_ctable #endif /* yyctable */ #endif /* YYBTYACC */ #define YYPREFIX "inherit2_" #define YYPURE 0 #line 2 "inherit2.y" #include typedef enum {cGLOBAL, cLOCAL} class; typedef enum {tREAL, tINTEGER} type; typedef char * name; struct symbol { class c; type t; name id; }; typedef struct symbol symbol; struct namelist { symbol *s; struct namelist *next; }; typedef struct namelist namelist; extern symbol *mksymbol(type t, class c, name id); #ifdef YYBISON #define YYLEX_DECL() yylex(void) #define YYERROR_DECL() yyerror(const char *s) #endif #ifdef YYSTYPE #undef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 #endif #ifndef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 #line 39 "inherit2.y" -typedef union YYSTYPE +typedef union { class cval; type tval; namelist * nlist; name id; } YYSTYPE; #endif /* !YYSTYPE_IS_DECLARED */ #line 155 "inherit2.tab.c" /* compatibility with bison */ #ifdef YYPARSE_PARAM /* compatibility with FreeBSD */ # ifdef YYPARSE_PARAM_TYPE # define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) # else # define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) # endif #else # define YYPARSE_DECL() yyparse(void) #endif /* Parameters sent to lex. */ #ifdef YYLEX_PARAM # define YYLEX_DECL() yylex(void *YYLEX_PARAM) # define YYLEX yylex(YYLEX_PARAM) #else # define YYLEX_DECL() yylex(void) # define YYLEX yylex() #endif /* Parameters sent to yyerror. */ #ifndef YYERROR_DECL #define YYERROR_DECL() yyerror(const char *s) #endif #ifndef YYERROR_CALL #define YYERROR_CALL(msg) yyerror(msg) #endif #ifndef YYDESTRUCT_DECL #define YYDESTRUCT_DECL() yydestruct(const char *msg, int psymb, YYSTYPE *val) #endif #ifndef YYDESTRUCT_CALL #define YYDESTRUCT_CALL(msg, psymb, val) yydestruct(msg, psymb, val) #endif extern int YYPARSE_DECL(); #define GLOBAL 257 #define LOCAL 258 #define REAL 259 #define INTEGER 260 #define NAME 261 #define YYERRCODE 256 typedef int YYINT; static const YYINT inherit2_lhs[] = { -1, 5, 6, 0, 0, 3, 3, 4, 4, 1, 1, 7, 2, }; static const YYINT inherit2_len[] = { 2, 0, 0, 5, 2, 1, 1, 1, 1, 2, 1, 0, 3, }; static const YYINT inherit2_defred[] = { 0, 5, 6, 7, 8, 0, 0, 11, 1, 4, 2, 2, 0, 0, 10, 0, 0, 9, }; #if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) static const YYINT inherit2_stos[] = { 0, 257, 258, 259, 260, 263, 266, 267, 267, 265, 270, 268, 269, 269, 261, 264, 264, 261, }; #endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ static const YYINT inherit2_dgoto[] = { 5, 15, 9, 6, 7, 11, 12, 10, }; static const YYINT inherit2_sindex[] = { -257, 0, 0, 0, 0, 0, -255, 0, 0, 0, 0, 0, -254, -254, 0, -253, -253, 0, }; static const YYINT inherit2_rindex[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 9, 0, }; #if YYBTYACC static const YYINT inherit2_cindex[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; #endif static const YYINT inherit2_gindex[] = { 0, -3, 0, 0, 5, 0, 1, 0, }; #define YYTABLESIZE 12 static const YYINT inherit2_table[] = { 1, 2, 3, 4, 3, 4, 12, 14, 17, 3, 16, 8, 13, }; static const YYINT inherit2_check[] = { 257, 258, 259, 260, 259, 260, 0, 261, 261, 0, 13, 6, 11, }; #if YYBTYACC static const YYINT inherit2_ctable[] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, }; #endif #define YYFINAL 5 #ifndef YYDEBUG #define YYDEBUG 0 #endif #define YYMAXTOKEN 261 #define YYUNDFTOKEN 271 #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) #if YYDEBUG static const char *const inherit2_name[] = { "$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, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"error","GLOBAL","LOCAL","REAL","INTEGER", "NAME","$accept","declaration","namelist","locnamelist","class","type","$$1", "$$2","$$3","illegal-symbol", }; static const char *const inherit2_rule[] = { "$accept : declaration", "$$1 :", "$$2 :", "declaration : class type $$1 $$2 namelist", "declaration : type locnamelist", "class : GLOBAL", "class : LOCAL", "type : REAL", "type : INTEGER", "namelist : namelist NAME", "namelist : NAME", "$$3 :", "locnamelist : $$3 $$2 namelist", }; #endif #if YYDEBUG int yydebug; #endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; int yynerrs; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyloc; /* position returned by actions */ YYLTYPE yylloc; /* position from the lexer */ #endif #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) #ifndef YYLLOC_DEFAULT #define YYLLOC_DEFAULT(loc, rhs, n) \ do \ { \ if (n == 0) \ { \ (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ } \ else \ { \ (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ (loc).last_line = YYRHSLOC(rhs, n).last_line; \ (loc).last_column = YYRHSLOC(rhs, n).last_column; \ } \ } while (0) #endif /* YYLLOC_DEFAULT */ #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ #if YYBTYACC #ifndef YYLVQUEUEGROWTH #define YYLVQUEUEGROWTH 32 #endif #endif /* YYBTYACC */ /* define the initial stack-sizes */ #ifdef YYSTACKSIZE #undef YYMAXDEPTH #define YYMAXDEPTH YYSTACKSIZE #else #ifdef YYMAXDEPTH #define YYSTACKSIZE YYMAXDEPTH #else #define YYSTACKSIZE 10000 #define YYMAXDEPTH 10000 #endif #endif #ifndef YYINITSTACKSIZE #define YYINITSTACKSIZE 200 #endif typedef struct { unsigned stacksize; YYINT *s_base; YYINT *s_mark; YYINT *s_last; YYSTYPE *l_base; YYSTYPE *l_mark; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE *p_base; YYLTYPE *p_mark; #endif } YYSTACKDATA; #if YYBTYACC struct YYParseState_s { struct YYParseState_s *save; /* Previously saved parser state */ YYSTACKDATA yystack; /* saved parser stack */ int state; /* saved parser state */ int errflag; /* saved error recovery status */ int lexeme; /* saved index of the conflict lexeme in the lexical queue */ YYINT ctry; /* saved index in yyctable[] for this conflict */ }; typedef struct YYParseState_s YYParseState; #endif /* YYBTYACC */ /* variables for the parser stack */ static YYSTACKDATA yystack; #if YYBTYACC /* Current parser state */ static YYParseState *yyps = 0; /* yypath != NULL: do the full parse, starting at *yypath parser state. */ static YYParseState *yypath = 0; /* Base of the lexical value queue */ static YYSTYPE *yylvals = 0; /* Current position at lexical value queue */ static YYSTYPE *yylvp = 0; /* End position of lexical value queue */ static YYSTYPE *yylve = 0; /* The last allocated position at the lexical value queue */ static YYSTYPE *yylvlim = 0; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* Base of the lexical position queue */ static YYLTYPE *yylpsns = 0; /* Current position at lexical position queue */ static YYLTYPE *yylpp = 0; /* End position of lexical position queue */ static YYLTYPE *yylpe = 0; /* The last allocated position at the lexical position queue */ static YYLTYPE *yylplim = 0; #endif /* Current position at lexical token queue */ static YYINT *yylexp = 0; static YYINT *yylexemes = 0; #endif /* YYBTYACC */ #line 78 "inherit2.y" extern int YYLEX_DECL(); extern void YYERROR_DECL(); #line 424 "inherit2.tab.c" /* Release memory associated with symbol. */ #if ! defined YYDESTRUCT_IS_DECLARED static void YYDESTRUCT_DECL() { switch (psymb) { case 263: #line 30 "inherit2.y" { namelist *p = (*val).nlist; while (p != NULL) { namelist *pp = p; p = p->next; free(pp->s); free(pp); } } #line 443 "inherit2.tab.c" break; case 264: #line 30 "inherit2.y" { namelist *p = (*val).nlist; while (p != NULL) { namelist *pp = p; p = p->next; free(pp->s); free(pp); } } #line 455 "inherit2.tab.c" break; case 265: #line 30 "inherit2.y" { namelist *p = (*val).nlist; while (p != NULL) { namelist *pp = p; p = p->next; free(pp->s); free(pp); } } #line 467 "inherit2.tab.c" break; } } #define YYDESTRUCT_IS_DECLARED 1 #endif /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) #if YYBTYACC #define yytrial (yyps->save) #endif /* YYBTYACC */ #if YYDEBUG #include /* needed for printf */ #endif #include /* needed for malloc, etc */ #include /* needed for memset */ /* allocate initial stack or double stack size, up to YYMAXDEPTH */ static int yygrowstack(YYSTACKDATA *data) { int i; unsigned newsize; YYINT *newss; YYSTYPE *newvs; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE *newps; #endif if ((newsize = data->stacksize) == 0) newsize = YYINITSTACKSIZE; else if (newsize >= YYMAXDEPTH) return YYENOMEM; else if ((newsize *= 2) > YYMAXDEPTH) newsize = YYMAXDEPTH; i = (int) (data->s_mark - data->s_base); newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); if (newss == NULL) return YYENOMEM; data->s_base = newss; data->s_mark = newss + i; newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); if (newvs == NULL) return YYENOMEM; data->l_base = newvs; data->l_mark = newvs + i; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); if (newps == NULL) return YYENOMEM; data->p_base = newps; data->p_mark = newps + i; #endif data->stacksize = newsize; data->s_last = data->s_base + newsize - 1; #if YYDEBUG if (yydebug) fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); #endif return 0; } #if YYPURE || defined(YY_NO_LEAKS) static void yyfreestack(YYSTACKDATA *data) { free(data->s_base); free(data->l_base); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) free(data->p_base); #endif memset(data, 0, sizeof(*data)); } #else #define yyfreestack(data) /* nothing */ #endif /* YYPURE || defined(YY_NO_LEAKS) */ #if YYBTYACC static YYParseState * yyNewState(unsigned size) { YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); if (p == NULL) return NULL; p->yystack.stacksize = size; if (size == 0) { p->yystack.s_base = NULL; p->yystack.l_base = NULL; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) p->yystack.p_base = NULL; #endif return p; } p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); if (p->yystack.s_base == NULL) return NULL; p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); if (p->yystack.l_base == NULL) return NULL; memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); if (p->yystack.p_base == NULL) return NULL; memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); #endif return p; } static void yyFreeState(YYParseState *p) { yyfreestack(&p->yystack); free(p); } #endif /* YYBTYACC */ #define YYABORT goto yyabort #define YYREJECT goto yyabort #define YYACCEPT goto yyaccept #define YYERROR goto yyerrlab #if YYBTYACC #define YYVALID do { if (yyps->save) goto yyvalid; } while(0) #define YYVALID_NESTED do { if (yyps->save && \ yyps->save->save == 0) goto yyvalid; } while(0) #endif /* YYBTYACC */ int YYPARSE_DECL() { int yym, yyn, yystate, yyresult; #if YYBTYACC int yynewerrflag; YYParseState *yyerrctx = NULL; #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ #endif #if YYDEBUG const char *yys; if ((yys = getenv("YYDEBUG")) != NULL) { yyn = *yys; if (yyn >= '0' && yyn <= '9') yydebug = yyn - '0'; } if (yydebug) fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); #endif #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); #endif #if YYBTYACC yyps = yyNewState(0); if (yyps == 0) goto yyenomem; yyps->save = 0; #endif /* YYBTYACC */ yym = 0; /* yyn is set below */ yynerrs = 0; yyerrflag = 0; yychar = YYEMPTY; yystate = 0; #if YYPURE memset(&yystack, 0, sizeof(yystack)); #endif if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystack.s_mark = yystack.s_base; yystack.l_mark = yystack.l_base; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark = yystack.p_base; #endif yystate = 0; *yystack.s_mark = 0; yyloop: if ((yyn = yydefred[yystate]) != 0) goto yyreduce; if (yychar < 0) { #if YYBTYACC do { if (yylvp < yylve) { /* we're currently re-reading tokens */ yylval = *yylvp++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylloc = *yylpp++; #endif yychar = *yylexp++; break; } if (yyps->save) { /* in trial mode; save scanner results for future parse attempts */ if (yylvp == yylvlim) { /* Enlarge lexical value queue */ size_t p = (size_t) (yylvp - yylvals); size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpe = yylpsns + p; yylplim = yylpsns + s; #endif yylexp = yylexemes + p; } *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpp++ = yylloc; yylpe++; #endif yychar = *yylexp++; break; } /* normal operation, no conflict encountered */ #endif /* YYBTYACC */ yychar = YYLEX; #if YYBTYACC } while (0); #endif /* YYBTYACC */ if (yychar < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", YYDEBUGSTR, yydepth, yystate, yychar, yys); #ifdef YYSTYPE_TOSTRING #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); #endif fputc('\n', stderr); } #endif } #if YYBTYACC /* Do we have a conflict? */ if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) { YYINT ctry; if (yypath) { YYParseState *save; #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", YYDEBUGSTR, yydepth, yystate); #endif /* Switch to the next conflict context */ save = yypath; yypath = save->save; save->save = NULL; ctry = save->ctry; if (save->state != yystate) YYABORT; yyFreeState(save); } else { /* Unresolved conflict - start/continue trial parse */ YYParseState *save; #if YYDEBUG if (yydebug) { fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); if (yyps->save) fputs("ALREADY in conflict, continuing trial parse.\n", stderr); else fputs("Starting trial parse.\n", stderr); } #endif save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); if (save == NULL) goto yyenomem; save->save = yyps->save; save->state = yystate; save->errflag = yyerrflag; save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif ctry = yytable[yyn]; if (yyctable[ctry] == -1) { #if YYDEBUG if (yydebug && yychar >= YYEOF) fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); #endif ctry++; } save->ctry = ctry; if (yyps->save == NULL) { /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; yylvlim = yylvals + YYLVQUEUEGROWTH; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); if (yylpsns == NULL) goto yyenomem; yylplim = yylpsns + YYLVQUEUEGROWTH; #endif } if (yylvp == yylve) { yylvp = yylve = yylvals; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpe = yylpsns; #endif yylexp = yylexemes; if (yychar >= YYEOF) { *yylve++ = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpe++ = yylloc; #endif *yylexp = (YYINT) yychar; yychar = YYEMPTY; } } } if (yychar >= YYEOF) { yylvp--; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp--; #endif yylexp--; yychar = YYEMPTY; } save->lexeme = (int) (yylvp - yylvals); yyps->save = save; } if (yytable[yyn] == ctry) { #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); #endif if (yychar < 0) { yylvp++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp++; #endif yylexp++; } if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystate = yyctable[ctry]; *++yystack.s_mark = (YYINT) yystate; *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *++yystack.p_mark = yylloc; #endif yychar = YYEMPTY; if (yyerrflag > 0) --yyerrflag; goto yyloop; } else { yyn = yyctable[ctry]; goto yyreduce; } } /* End of code dealing with conflicts */ #endif /* YYBTYACC */ if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) { #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", YYDEBUGSTR, yydepth, yystate, yytable[yyn]); #endif if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystate = yytable[yyn]; *++yystack.s_mark = yytable[yyn]; *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *++yystack.p_mark = yylloc; #endif yychar = YYEMPTY; if (yyerrflag > 0) --yyerrflag; goto yyloop; } if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) { yyn = yytable[yyn]; goto yyreduce; } if (yyerrflag != 0) goto yyinrecovery; #if YYBTYACC yynewerrflag = 1; goto yyerrhandler; goto yyerrlab; /* redundant goto avoids 'unused label' warning */ yyerrlab: /* explicit YYERROR from an action -- pop the rhs of the rule reduced * before looking for error recovery */ yystack.s_mark -= yym; yystate = *yystack.s_mark; yystack.l_mark -= yym; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark -= yym; #endif yynewerrflag = 0; yyerrhandler: while (yyps->save) { int ctry; YYParseState *save = yyps->save; #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", YYDEBUGSTR, yydepth, yystate, yyps->save->state, (int)(yylvp - yylvals - yyps->save->lexeme)); #endif /* Memorize most forward-looking error state in case it's really an error. */ if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) { /* Free old saved error context state */ if (yyerrctx) yyFreeState(yyerrctx); /* Create and fill out new saved error context state */ yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); if (yyerrctx == NULL) goto yyenomem; yyerrctx->save = yyps->save; yyerrctx->state = yystate; yyerrctx->errflag = yyerrflag; yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif yyerrctx->lexeme = (int) (yylvp - yylvals); } yylvp = yylvals + save->lexeme; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpsns + save->lexeme; #endif yylexp = yylexemes + save->lexeme; yychar = YYEMPTY; yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif ctry = ++save->ctry; yystate = save->state; /* We tried shift, try reduce now */ if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; yyps->save = save->save; save->save = NULL; yyFreeState(save); /* Nothing left on the stack -- error */ if (!yyps->save) { #if YYDEBUG if (yydebug) fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", YYPREFIX, yydepth); #endif /* Restore state as it was in the most forward-advanced error */ yylvp = yylvals + yyerrctx->lexeme; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpsns + yyerrctx->lexeme; #endif yylexp = yylexemes + yyerrctx->lexeme; yychar = yylexp[-1]; yylval = yylvp[-1]; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylloc = yylpp[-1]; #endif yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif yystate = yyerrctx->state; yyFreeState(yyerrctx); yyerrctx = NULL; } yynewerrflag = 1; } if (yynewerrflag == 0) goto yyinrecovery; #endif /* YYBTYACC */ YYERROR_CALL("syntax error"); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ #endif #if !YYBTYACC goto yyerrlab; /* redundant goto avoids 'unused label' warning */ yyerrlab: #endif ++yynerrs; yyinrecovery: if (yyerrflag < 3) { yyerrflag = 3; for (;;) { if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) { #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); #endif if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystate = yytable[yyn]; *++yystack.s_mark = yytable[yyn]; *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* lookahead position is error end position */ yyerror_loc_range[2] = yylloc; YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ *++yystack.p_mark = yyloc; #endif goto yyloop; } else { #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", YYDEBUGSTR, yydepth, *yystack.s_mark); #endif if (yystack.s_mark <= yystack.s_base) goto yyabort; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* the current TOS position is the error start position */ yyerror_loc_range[1] = *yystack.p_mark; #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYDESTRUCT_CALL("error: discarding state", yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); #else YYDESTRUCT_CALL("error: discarding state", yystos[*yystack.s_mark], yystack.l_mark); #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ #endif /* defined(YYDESTRUCT_CALL) */ --yystack.s_mark; --yystack.l_mark; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) --yystack.p_mark; #endif } } } else { if (yychar == YYEOF) goto yyabort; #if YYDEBUG if (yydebug) { if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", YYDEBUGSTR, yydepth, yystate, yychar, yys); } #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); #else YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ #endif /* defined(YYDESTRUCT_CALL) */ yychar = YYEMPTY; goto yyloop; } yyreduce: yym = yylen[yyn]; #if YYDEBUG if (yydebug) { fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); #ifdef YYSTYPE_TOSTRING #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ if (yym > 0) { int i; fputc('<', stderr); for (i = yym; i > 0; i--) { if (i != yym) fputs(", ", stderr); fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], yystack.l_mark[1-i]), stderr); } fputc('>', stderr); } #endif fputc('\n', stderr); } #endif if (yym > 0) yyval = yystack.l_mark[1-yym]; else memset(&yyval, 0, sizeof yyval); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* Perform position reduction */ memset(&yyloc, 0, sizeof(yyloc)); #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ { YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); /* just in case YYERROR is invoked within the action, save the start of the rhs as the error start position */ yyerror_loc_range[1] = yystack.p_mark[1-yym]; } #endif switch (yyn) { case 1: #line 50 "inherit2.y" yyval.cval = yystack.l_mark[-1].cval; #line 1145 "inherit2.tab.c" break; case 2: #line 50 "inherit2.y" yyval.tval = yystack.l_mark[-1].tval; #line 1150 "inherit2.tab.c" break; case 3: #line 51 "inherit2.y" { yyval.nlist = yystack.l_mark[0].nlist; } #line 1155 "inherit2.tab.c" break; case 4: #line 53 "inherit2.y" { yyval.nlist = yystack.l_mark[0].nlist; } #line 1160 "inherit2.tab.c" break; case 5: #line 56 "inherit2.y" { yyval.cval = cGLOBAL; } #line 1165 "inherit2.tab.c" break; case 6: #line 57 "inherit2.y" { yyval.cval = cLOCAL; } #line 1170 "inherit2.tab.c" break; case 7: #line 60 "inherit2.y" { yyval.tval = tREAL; } #line 1175 "inherit2.tab.c" break; case 8: #line 61 "inherit2.y" { yyval.tval = tINTEGER; } #line 1180 "inherit2.tab.c" break; case 9: #line 65 "inherit2.y" { yyval.nlist->s = mksymbol(yystack.l_mark[-2].tval, yystack.l_mark[-3].cval, yystack.l_mark[0].id); yyval.nlist->next = yystack.l_mark[-1].nlist; } #line 1187 "inherit2.tab.c" break; case 10: #line 69 "inherit2.y" { yyval.nlist->s = mksymbol(yystack.l_mark[-1].tval, yystack.l_mark[-2].cval, yystack.l_mark[0].id); yyval.nlist->next = NULL; } #line 1194 "inherit2.tab.c" break; case 11: #line 74 "inherit2.y" yyval.cval = cLOCAL; #line 1199 "inherit2.tab.c" break; case 12: #line 75 "inherit2.y" { yyval.nlist = yystack.l_mark[0].nlist; } #line 1204 "inherit2.tab.c" break; #line 1206 "inherit2.tab.c" default: break; } yystack.s_mark -= yym; yystate = *yystack.s_mark; yystack.l_mark -= yym; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark -= yym; #endif yym = yylhs[yyn]; if (yystate == 0 && yym == 0) { #if YYDEBUG if (yydebug) { fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); #ifdef YYSTYPE_TOSTRING #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); #endif fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); } #endif yystate = YYFINAL; *++yystack.s_mark = YYFINAL; *++yystack.l_mark = yyval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *++yystack.p_mark = yyloc; #endif if (yychar < 0) { #if YYBTYACC do { if (yylvp < yylve) { /* we're currently re-reading tokens */ yylval = *yylvp++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylloc = *yylpp++; #endif yychar = *yylexp++; break; } if (yyps->save) { /* in trial mode; save scanner results for future parse attempts */ if (yylvp == yylvlim) { /* Enlarge lexical value queue */ size_t p = (size_t) (yylvp - yylvals); size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpe = yylpsns + p; yylplim = yylpsns + s; #endif yylexp = yylexemes + p; } *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpp++ = yylloc; yylpe++; #endif yychar = *yylexp++; break; } /* normal operation, no conflict encountered */ #endif /* YYBTYACC */ yychar = YYLEX; #if YYBTYACC } while (0); #endif /* YYBTYACC */ if (yychar < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); } #endif } if (yychar == YYEOF) goto yyaccept; goto yyloop; } if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) yystate = yytable[yyn]; else yystate = yydgoto[yym]; #if YYDEBUG if (yydebug) { fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); #ifdef YYSTYPE_TOSTRING #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); #endif fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); } #endif if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; *++yystack.s_mark = (YYINT) yystate; *++yystack.l_mark = yyval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *++yystack.p_mark = yyloc; #endif goto yyloop; #if YYBTYACC /* Reduction declares that this path is valid. Set yypath and do a full parse */ yyvalid: if (yypath) YYABORT; while (yyps->save) { YYParseState *save = yyps->save; yyps->save = save->save; save->save = yypath; yypath = save; } #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); #endif if (yyerrctx) { yyFreeState(yyerrctx); yyerrctx = NULL; } yylvp = yylvals + yypath->lexeme; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpsns + yypath->lexeme; #endif yylexp = yylexemes + yypath->lexeme; yychar = YYEMPTY; yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif yystate = yypath->state; goto yyloop; #endif /* YYBTYACC */ yyoverflow: YYERROR_CALL("yacc stack overflow"); #if YYBTYACC goto yyabort_nomem; yyenomem: YYERROR_CALL("memory exhausted"); yyabort_nomem: #endif /* YYBTYACC */ yyresult = 2; goto yyreturn; yyabort: yyresult = 1; goto yyreturn; yyaccept: #if YYBTYACC if (yyps->save) goto yyvalid; #endif /* YYBTYACC */ yyresult = 0; yyreturn: #if defined(YYDESTRUCT_CALL) if (yychar != YYEOF && yychar != YYEMPTY) #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); #else YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ { YYSTYPE *pv; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE *pp; for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) YYDESTRUCT_CALL("cleanup: discarding state", yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); #else for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) YYDESTRUCT_CALL("cleanup: discarding state", yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ } #endif /* defined(YYDESTRUCT_CALL) */ #if YYBTYACC if (yyerrctx) { yyFreeState(yyerrctx); yyerrctx = NULL; } while (yyps) { YYParseState *save = yyps; yyps = save->save; save->save = NULL; yyFreeState(save); } while (yypath) { YYParseState *save = yypath; yypath = save->save; save->save = NULL; yyFreeState(save); } #endif /* YYBTYACC */ yyfreestack(&yystack); return (yyresult); } diff --git a/contrib/byacc/test/btyacc/inherit2.tab.h b/contrib/byacc/test/btyacc/inherit2.tab.h index 333dab588b3a..efaf4555d6dd 100644 --- a/contrib/byacc/test/btyacc/inherit2.tab.h +++ b/contrib/byacc/test/btyacc/inherit2.tab.h @@ -1,25 +1,25 @@ #ifndef _inherit2__defines_h_ #define _inherit2__defines_h_ #define GLOBAL 257 #define LOCAL 258 #define REAL 259 #define INTEGER 260 #define NAME 261 #ifdef YYSTYPE #undef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 #endif #ifndef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 -typedef union YYSTYPE +typedef union { class cval; type tval; namelist * nlist; name id; } YYSTYPE; #endif /* !YYSTYPE_IS_DECLARED */ extern YYSTYPE inherit2_lval; #endif /* _inherit2__defines_h_ */ diff --git a/contrib/byacc/test/btyacc/ok_syntax1.tab.c b/contrib/byacc/test/btyacc/ok_syntax1.tab.c index c7458178ddc2..6d94e6d2f5c8 100644 --- a/contrib/byacc/test/btyacc/ok_syntax1.tab.c +++ b/contrib/byacc/test/btyacc/ok_syntax1.tab.c @@ -1,1539 +1,1539 @@ /* original parser id follows */ /* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ /* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ #define YYBYACC 1 #define YYMAJOR 2 #define YYMINOR 0 #define YYCHECK "yyyymmdd" #define YYEMPTY (-1) #define yyclearin (yychar = YYEMPTY) #define yyerrok (yyerrflag = 0) #define YYRECOVERING() (yyerrflag != 0) #define YYENOMEM (-2) #define YYEOF 0 #undef YYBTYACC #define YYBTYACC 0 #define YYDEBUGSTR YYPREFIX "debug" #ifndef yyparse #define yyparse ok_syntax1_parse #endif /* yyparse */ #ifndef yylex #define yylex ok_syntax1_lex #endif /* yylex */ #ifndef yyerror #define yyerror ok_syntax1_error #endif /* yyerror */ #ifndef yychar #define yychar ok_syntax1_char #endif /* yychar */ #ifndef yyval #define yyval ok_syntax1_val #endif /* yyval */ #ifndef yylval #define yylval ok_syntax1_lval #endif /* yylval */ #ifndef yydebug #define yydebug ok_syntax1_debug #endif /* yydebug */ #ifndef yynerrs #define yynerrs ok_syntax1_nerrs #endif /* yynerrs */ #ifndef yyerrflag #define yyerrflag ok_syntax1_errflag #endif /* yyerrflag */ #ifndef yylhs #define yylhs ok_syntax1_lhs #endif /* yylhs */ #ifndef yylen #define yylen ok_syntax1_len #endif /* yylen */ #ifndef yydefred #define yydefred ok_syntax1_defred #endif /* yydefred */ #ifndef yystos #define yystos ok_syntax1_stos #endif /* yystos */ #ifndef yydgoto #define yydgoto ok_syntax1_dgoto #endif /* yydgoto */ #ifndef yysindex #define yysindex ok_syntax1_sindex #endif /* yysindex */ #ifndef yyrindex #define yyrindex ok_syntax1_rindex #endif /* yyrindex */ #ifndef yygindex #define yygindex ok_syntax1_gindex #endif /* yygindex */ #ifndef yytable #define yytable ok_syntax1_table #endif /* yytable */ #ifndef yycheck #define yycheck ok_syntax1_check #endif /* yycheck */ #ifndef yyname #define yyname ok_syntax1_name #endif /* yyname */ #ifndef yyrule #define yyrule ok_syntax1_rule #endif /* yyrule */ #if YYBTYACC #ifndef yycindex #define yycindex ok_syntax1_cindex #endif /* yycindex */ #ifndef yyctable #define yyctable ok_syntax1_ctable #endif /* yyctable */ #endif /* YYBTYACC */ #define YYPREFIX "ok_syntax1_" #define YYPURE 1 #line 9 "ok_syntax1.y" # include # include #ifdef YYBISON #define YYSTYPE int #define YYLEX_PARAM base #define YYLEX_DECL() yylex(YYSTYPE *yylval, int *YYLEX_PARAM) #define YYERROR_DECL() yyerror(int regs[26], int *base, const char *s) int YYLEX_DECL(); static void YYERROR_DECL(); #endif #ifdef YYSTYPE #undef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 #endif #ifndef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 #line 43 "ok_syntax1.y" -typedef union YYSTYPE +typedef union { char * cval; int ival; double dval; } YYSTYPE; #endif /* !YYSTYPE_IS_DECLARED */ #line 148 "ok_syntax1.tab.c" /* compatibility with bison */ #ifdef YYPARSE_PARAM /* compatibility with FreeBSD */ # ifdef YYPARSE_PARAM_TYPE # define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) # else # define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) # endif #else # define YYPARSE_DECL() yyparse(int regs[26], int *base) #endif /* Parameters sent to lex. */ #ifdef YYLEX_PARAM # ifdef YYLEX_PARAM_TYPE # define YYLEX_DECL() yylex(YYSTYPE *yylval, YYLEX_PARAM_TYPE YYLEX_PARAM) # else # define YYLEX_DECL() yylex(YYSTYPE *yylval, void * YYLEX_PARAM) # endif # define YYLEX yylex(&yylval, YYLEX_PARAM) #else # define YYLEX_DECL() yylex(YYSTYPE *yylval, int *base) # define YYLEX yylex(&yylval, base) #endif /* Parameters sent to yyerror. */ #ifndef YYERROR_DECL #define YYERROR_DECL() yyerror(int regs[26], int *base, const char *s) #endif #ifndef YYERROR_CALL #define YYERROR_CALL(msg) yyerror(regs, base, msg) #endif extern int YYPARSE_DECL(); #define DIGIT 257 #define LETTER 258 #define OCT1 259 #define HEX1 260 #define HEX2 261 #define HEX3 262 #define STR1 263 #define STR2 265 #define BELL 266 #define BS 267 #define NL 268 #define LF 269 #define CR 270 #define TAB 271 #define VT 272 #define UMINUS 273 #define YYERRCODE 256 typedef int YYINT; static const YYINT ok_syntax1_lhs[] = { -1, 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, }; static const YYINT ok_syntax1_len[] = { 2, 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 1, 1, 1, 2, }; static const YYINT ok_syntax1_defred[] = { 1, 0, 0, 17, 0, 0, 0, 0, 0, 0, 3, 0, 15, 14, 0, 2, 0, 0, 0, 0, 0, 0, 0, 18, 0, 6, 0, 0, 0, 0, 9, 10, 11, }; #if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) static const YYINT ok_syntax1_stos[] = { 0, 275, 256, 257, 258, 45, 40, 276, 277, 278, 10, 61, 258, 277, 277, 10, 124, 38, 43, 45, 42, 47, 37, 257, 277, 41, 277, 277, 277, 277, 277, 277, 277, }; #endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ static const YYINT ok_syntax1_dgoto[] = { 1, 7, 8, 9, }; static const YYINT ok_syntax1_sindex[] = { 0, -40, -7, 0, -55, -38, -38, 1, -29, -247, 0, -38, 0, 0, 22, 0, -38, -38, -38, -38, -38, -38, -38, 0, -29, 0, 51, 60, -20, -20, 0, 0, 0, }; static const YYINT ok_syntax1_rindex[] = { 0, 0, 0, 0, 2, 0, 0, 0, 9, -9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, -6, 14, 5, 13, 0, 0, 0, }; #if YYBTYACC static const YYINT ok_syntax1_cindex[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; #endif static const YYINT ok_syntax1_gindex[] = { 0, 0, 65, 0, }; #define YYTABLESIZE 220 static const YYINT ok_syntax1_table[] = { 6, 16, 6, 10, 13, 5, 11, 5, 22, 17, 23, 15, 15, 20, 18, 7, 19, 22, 21, 4, 5, 0, 20, 8, 12, 0, 0, 21, 16, 16, 0, 0, 16, 16, 16, 13, 16, 0, 16, 15, 15, 0, 0, 7, 15, 15, 7, 15, 7, 15, 7, 8, 12, 0, 8, 12, 8, 0, 8, 22, 17, 0, 0, 25, 20, 18, 0, 19, 0, 21, 13, 14, 0, 0, 0, 0, 24, 0, 0, 0, 0, 26, 27, 28, 29, 30, 31, 32, 22, 17, 0, 0, 0, 20, 18, 16, 19, 22, 21, 0, 0, 0, 20, 18, 0, 19, 0, 21, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 13, 0, 0, 0, 0, 0, 0, 0, 15, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 8, 12, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 4, 3, 12, }; static const YYINT ok_syntax1_check[] = { 40, 10, 40, 10, 10, 45, 61, 45, 37, 38, 257, 10, 10, 42, 43, 10, 45, 37, 47, 10, 10, -1, 42, 10, 10, -1, -1, 47, 37, 38, -1, -1, 41, 42, 43, 41, 45, -1, 47, 37, 38, -1, -1, 38, 42, 43, 41, 45, 43, 47, 45, 38, 38, -1, 41, 41, 43, -1, 45, 37, 38, -1, -1, 41, 42, 43, -1, 45, -1, 47, 5, 6, -1, -1, -1, -1, 11, -1, -1, -1, -1, 16, 17, 18, 19, 20, 21, 22, 37, 38, -1, -1, -1, 42, 43, 124, 45, 37, 47, -1, -1, -1, 42, 43, -1, 45, -1, 47, -1, -1, -1, -1, -1, -1, -1, 124, -1, -1, 124, -1, -1, -1, -1, -1, -1, -1, 124, -1, -1, 124, -1, -1, -1, -1, -1, -1, -1, 124, 124, -1, -1, -1, -1, -1, -1, -1, 124, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 256, 257, 258, 257, 258, }; #if YYBTYACC static const YYINT ok_syntax1_ctable[] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, }; #endif #define YYFINAL 1 #ifndef YYDEBUG #define YYDEBUG 0 #endif #define YYMAXTOKEN 273 #define YYUNDFTOKEN 279 #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) #if YYDEBUG static const char *const ok_syntax1_name[] = { "$end",0,0,0,0,0,0,"'\\a'","'\\b'","'\\t'","'\\n'","'\\v'","'\\f'","'\\r'",0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'#'",0,"'%'","'&'",0,"'('","')'","'*'", "'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,0,0,0,0,0,0,"'='",0,0,"'@'",0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'^'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,"'~'","'\\177'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'\\377'", "error","DIGIT","LETTER","OCT1","HEX1","HEX2","HEX3","STR1", "\"\\177\\177\\\\\\n\"","STR2","BELL","BS","NL","LF","CR","TAB","VT","UMINUS", "$accept","list","stat","expr","number","illegal-symbol", }; static const char *const ok_syntax1_rule[] = { "$accept : list", "list :", "list : list stat '\\n'", "list : list error '\\n'", "stat : expr", "stat : LETTER '=' expr", "expr : '(' expr ')'", "expr : expr '+' expr", "expr : expr '-' expr", "expr : expr '*' expr", "expr : expr '/' expr", "expr : expr '%' expr", "expr : expr '&' expr", "expr : expr '|' expr", "expr : '-' expr", "expr : LETTER", "expr : number", "number : DIGIT", "number : number DIGIT", }; #endif #if YYDEBUG int yydebug; #endif #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) #ifndef YYLLOC_DEFAULT #define YYLLOC_DEFAULT(loc, rhs, n) \ do \ { \ if (n == 0) \ { \ (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ } \ else \ { \ (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ (loc).last_line = YYRHSLOC(rhs, n).last_line; \ (loc).last_column = YYRHSLOC(rhs, n).last_column; \ } \ } while (0) #endif /* YYLLOC_DEFAULT */ #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ #if YYBTYACC #ifndef YYLVQUEUEGROWTH #define YYLVQUEUEGROWTH 32 #endif #endif /* YYBTYACC */ /* define the initial stack-sizes */ #ifdef YYSTACKSIZE #undef YYMAXDEPTH #define YYMAXDEPTH YYSTACKSIZE #else #ifdef YYMAXDEPTH #define YYSTACKSIZE YYMAXDEPTH #else #define YYSTACKSIZE 10000 #define YYMAXDEPTH 10000 #endif #endif #ifndef YYINITSTACKSIZE #define YYINITSTACKSIZE 200 #endif typedef struct { unsigned stacksize; YYINT *s_base; YYINT *s_mark; YYINT *s_last; YYSTYPE *l_base; YYSTYPE *l_mark; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE *p_base; YYLTYPE *p_mark; #endif } YYSTACKDATA; #if YYBTYACC struct YYParseState_s { struct YYParseState_s *save; /* Previously saved parser state */ YYSTACKDATA yystack; /* saved parser stack */ int state; /* saved parser state */ int errflag; /* saved error recovery status */ int lexeme; /* saved index of the conflict lexeme in the lexical queue */ YYINT ctry; /* saved index in yyctable[] for this conflict */ }; typedef struct YYParseState_s YYParseState; #endif /* YYBTYACC */ #line 104 "ok_syntax1.y" /* start of programs */ #ifdef YYBYACC extern int YYLEX_DECL(); #endif int main (void) { int regs[26]; int base = 10; while(!feof(stdin)) { yyparse(regs, &base); } return 0; } #define UNUSED(x) ((void)(x)) static void YYERROR_DECL() { UNUSED(regs); /* %parse-param regs is not actually used here */ UNUSED(base); /* %parse-param base is not actually used here */ fprintf(stderr, "%s\n", s); } int YYLEX_DECL() { /* lexical analysis routine */ /* returns LETTER for a lower case letter, yylval = 0 through 25 */ /* return DIGIT for a digit, yylval = 0 through 9 */ /* all other characters are returned immediately */ int c; while( (c=getchar()) == ' ' ) { /* skip blanks */ } /* c is now nonblank */ if( islower( c )) { yylval->ival = (c - 'a'); return ( LETTER ); } if( isdigit( c )) { yylval->ival = (c - '0') % (*base); return ( DIGIT ); } return( c ); } #line 500 "ok_syntax1.tab.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) #if YYBTYACC #define yytrial (yyps->save) #endif /* YYBTYACC */ #if YYDEBUG #include /* needed for printf */ #endif #include /* needed for malloc, etc */ #include /* needed for memset */ /* allocate initial stack or double stack size, up to YYMAXDEPTH */ static int yygrowstack(YYSTACKDATA *data) { int i; unsigned newsize; YYINT *newss; YYSTYPE *newvs; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE *newps; #endif if ((newsize = data->stacksize) == 0) newsize = YYINITSTACKSIZE; else if (newsize >= YYMAXDEPTH) return YYENOMEM; else if ((newsize *= 2) > YYMAXDEPTH) newsize = YYMAXDEPTH; i = (int) (data->s_mark - data->s_base); newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); if (newss == NULL) return YYENOMEM; data->s_base = newss; data->s_mark = newss + i; newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); if (newvs == NULL) return YYENOMEM; data->l_base = newvs; data->l_mark = newvs + i; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); if (newps == NULL) return YYENOMEM; data->p_base = newps; data->p_mark = newps + i; #endif data->stacksize = newsize; data->s_last = data->s_base + newsize - 1; #if YYDEBUG if (yydebug) fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); #endif return 0; } #if YYPURE || defined(YY_NO_LEAKS) static void yyfreestack(YYSTACKDATA *data) { free(data->s_base); free(data->l_base); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) free(data->p_base); #endif memset(data, 0, sizeof(*data)); } #else #define yyfreestack(data) /* nothing */ #endif /* YYPURE || defined(YY_NO_LEAKS) */ #if YYBTYACC static YYParseState * yyNewState(unsigned size) { YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); if (p == NULL) return NULL; p->yystack.stacksize = size; if (size == 0) { p->yystack.s_base = NULL; p->yystack.l_base = NULL; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) p->yystack.p_base = NULL; #endif return p; } p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); if (p->yystack.s_base == NULL) return NULL; p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); if (p->yystack.l_base == NULL) return NULL; memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); if (p->yystack.p_base == NULL) return NULL; memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); #endif return p; } static void yyFreeState(YYParseState *p) { yyfreestack(&p->yystack); free(p); } #endif /* YYBTYACC */ #define YYABORT goto yyabort #define YYREJECT goto yyabort #define YYACCEPT goto yyaccept #define YYERROR goto yyerrlab #if YYBTYACC #define YYVALID do { if (yyps->save) goto yyvalid; } while(0) #define YYVALID_NESTED do { if (yyps->save && \ yyps->save->save == 0) goto yyvalid; } while(0) #endif /* YYBTYACC */ int YYPARSE_DECL() { int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; int yynerrs; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyloc; /* position returned by actions */ YYLTYPE yylloc; /* position from the lexer */ #endif /* variables for the parser stack */ YYSTACKDATA yystack; #if YYBTYACC /* Current parser state */ static YYParseState *yyps = 0; /* yypath != NULL: do the full parse, starting at *yypath parser state. */ static YYParseState *yypath = 0; /* Base of the lexical value queue */ static YYSTYPE *yylvals = 0; /* Current position at lexical value queue */ static YYSTYPE *yylvp = 0; /* End position of lexical value queue */ static YYSTYPE *yylve = 0; /* The last allocated position at the lexical value queue */ static YYSTYPE *yylvlim = 0; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* Base of the lexical position queue */ static YYLTYPE *yylpsns = 0; /* Current position at lexical position queue */ static YYLTYPE *yylpp = 0; /* End position of lexical position queue */ static YYLTYPE *yylpe = 0; /* The last allocated position at the lexical position queue */ static YYLTYPE *yylplim = 0; #endif /* Current position at lexical token queue */ static YYINT *yylexp = 0; static YYINT *yylexemes = 0; #endif /* YYBTYACC */ int yym, yyn, yystate, yyresult; #if YYBTYACC int yynewerrflag; YYParseState *yyerrctx = NULL; #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ #endif #if YYDEBUG const char *yys; if ((yys = getenv("YYDEBUG")) != NULL) { yyn = *yys; if (yyn >= '0' && yyn <= '9') yydebug = yyn - '0'; } if (yydebug) fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); #endif #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); #endif yyerrflag = 0; yychar = 0; memset(&yyval, 0, sizeof(yyval)); memset(&yylval, 0, sizeof(yylval)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) memset(&yyloc, 0, sizeof(yyloc)); memset(&yylloc, 0, sizeof(yylloc)); #endif #if YYBTYACC yyps = yyNewState(0); if (yyps == 0) goto yyenomem; yyps->save = 0; #endif /* YYBTYACC */ yym = 0; /* yyn is set below */ yynerrs = 0; yyerrflag = 0; yychar = YYEMPTY; yystate = 0; #if YYPURE memset(&yystack, 0, sizeof(yystack)); #endif if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystack.s_mark = yystack.s_base; yystack.l_mark = yystack.l_base; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark = yystack.p_base; #endif yystate = 0; *yystack.s_mark = 0; yyloop: if ((yyn = yydefred[yystate]) != 0) goto yyreduce; if (yychar < 0) { #if YYBTYACC do { if (yylvp < yylve) { /* we're currently re-reading tokens */ yylval = *yylvp++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylloc = *yylpp++; #endif yychar = *yylexp++; break; } if (yyps->save) { /* in trial mode; save scanner results for future parse attempts */ if (yylvp == yylvlim) { /* Enlarge lexical value queue */ size_t p = (size_t) (yylvp - yylvals); size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpe = yylpsns + p; yylplim = yylpsns + s; #endif yylexp = yylexemes + p; } *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpp++ = yylloc; yylpe++; #endif yychar = *yylexp++; break; } /* normal operation, no conflict encountered */ #endif /* YYBTYACC */ yychar = YYLEX; #if YYBTYACC } while (0); #endif /* YYBTYACC */ if (yychar < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", YYDEBUGSTR, yydepth, yystate, yychar, yys); #ifdef YYSTYPE_TOSTRING #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); #endif fputc('\n', stderr); } #endif } #if YYBTYACC /* Do we have a conflict? */ if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) { YYINT ctry; if (yypath) { YYParseState *save; #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", YYDEBUGSTR, yydepth, yystate); #endif /* Switch to the next conflict context */ save = yypath; yypath = save->save; save->save = NULL; ctry = save->ctry; if (save->state != yystate) YYABORT; yyFreeState(save); } else { /* Unresolved conflict - start/continue trial parse */ YYParseState *save; #if YYDEBUG if (yydebug) { fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); if (yyps->save) fputs("ALREADY in conflict, continuing trial parse.\n", stderr); else fputs("Starting trial parse.\n", stderr); } #endif save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); if (save == NULL) goto yyenomem; save->save = yyps->save; save->state = yystate; save->errflag = yyerrflag; save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif ctry = yytable[yyn]; if (yyctable[ctry] == -1) { #if YYDEBUG if (yydebug && yychar >= YYEOF) fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); #endif ctry++; } save->ctry = ctry; if (yyps->save == NULL) { /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; yylvlim = yylvals + YYLVQUEUEGROWTH; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); if (yylpsns == NULL) goto yyenomem; yylplim = yylpsns + YYLVQUEUEGROWTH; #endif } if (yylvp == yylve) { yylvp = yylve = yylvals; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpe = yylpsns; #endif yylexp = yylexemes; if (yychar >= YYEOF) { *yylve++ = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpe++ = yylloc; #endif *yylexp = (YYINT) yychar; yychar = YYEMPTY; } } } if (yychar >= YYEOF) { yylvp--; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp--; #endif yylexp--; yychar = YYEMPTY; } save->lexeme = (int) (yylvp - yylvals); yyps->save = save; } if (yytable[yyn] == ctry) { #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); #endif if (yychar < 0) { yylvp++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp++; #endif yylexp++; } if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystate = yyctable[ctry]; *++yystack.s_mark = (YYINT) yystate; *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *++yystack.p_mark = yylloc; #endif yychar = YYEMPTY; if (yyerrflag > 0) --yyerrflag; goto yyloop; } else { yyn = yyctable[ctry]; goto yyreduce; } } /* End of code dealing with conflicts */ #endif /* YYBTYACC */ if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) { #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", YYDEBUGSTR, yydepth, yystate, yytable[yyn]); #endif if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystate = yytable[yyn]; *++yystack.s_mark = yytable[yyn]; *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *++yystack.p_mark = yylloc; #endif yychar = YYEMPTY; if (yyerrflag > 0) --yyerrflag; goto yyloop; } if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) { yyn = yytable[yyn]; goto yyreduce; } if (yyerrflag != 0) goto yyinrecovery; #if YYBTYACC yynewerrflag = 1; goto yyerrhandler; goto yyerrlab; /* redundant goto avoids 'unused label' warning */ yyerrlab: /* explicit YYERROR from an action -- pop the rhs of the rule reduced * before looking for error recovery */ yystack.s_mark -= yym; yystate = *yystack.s_mark; yystack.l_mark -= yym; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark -= yym; #endif yynewerrflag = 0; yyerrhandler: while (yyps->save) { int ctry; YYParseState *save = yyps->save; #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", YYDEBUGSTR, yydepth, yystate, yyps->save->state, (int)(yylvp - yylvals - yyps->save->lexeme)); #endif /* Memorize most forward-looking error state in case it's really an error. */ if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) { /* Free old saved error context state */ if (yyerrctx) yyFreeState(yyerrctx); /* Create and fill out new saved error context state */ yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); if (yyerrctx == NULL) goto yyenomem; yyerrctx->save = yyps->save; yyerrctx->state = yystate; yyerrctx->errflag = yyerrflag; yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif yyerrctx->lexeme = (int) (yylvp - yylvals); } yylvp = yylvals + save->lexeme; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpsns + save->lexeme; #endif yylexp = yylexemes + save->lexeme; yychar = YYEMPTY; yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif ctry = ++save->ctry; yystate = save->state; /* We tried shift, try reduce now */ if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; yyps->save = save->save; save->save = NULL; yyFreeState(save); /* Nothing left on the stack -- error */ if (!yyps->save) { #if YYDEBUG if (yydebug) fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", YYPREFIX, yydepth); #endif /* Restore state as it was in the most forward-advanced error */ yylvp = yylvals + yyerrctx->lexeme; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpsns + yyerrctx->lexeme; #endif yylexp = yylexemes + yyerrctx->lexeme; yychar = yylexp[-1]; yylval = yylvp[-1]; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylloc = yylpp[-1]; #endif yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif yystate = yyerrctx->state; yyFreeState(yyerrctx); yyerrctx = NULL; } yynewerrflag = 1; } if (yynewerrflag == 0) goto yyinrecovery; #endif /* YYBTYACC */ YYERROR_CALL("syntax error"); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ #endif #if !YYBTYACC goto yyerrlab; /* redundant goto avoids 'unused label' warning */ yyerrlab: #endif ++yynerrs; yyinrecovery: if (yyerrflag < 3) { yyerrflag = 3; for (;;) { if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) { #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); #endif if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystate = yytable[yyn]; *++yystack.s_mark = yytable[yyn]; *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* lookahead position is error end position */ yyerror_loc_range[2] = yylloc; YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ *++yystack.p_mark = yyloc; #endif goto yyloop; } else { #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", YYDEBUGSTR, yydepth, *yystack.s_mark); #endif if (yystack.s_mark <= yystack.s_base) goto yyabort; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* the current TOS position is the error start position */ yyerror_loc_range[1] = *yystack.p_mark; #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYDESTRUCT_CALL("error: discarding state", yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); #else YYDESTRUCT_CALL("error: discarding state", yystos[*yystack.s_mark], yystack.l_mark); #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ #endif /* defined(YYDESTRUCT_CALL) */ --yystack.s_mark; --yystack.l_mark; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) --yystack.p_mark; #endif } } } else { if (yychar == YYEOF) goto yyabort; #if YYDEBUG if (yydebug) { if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", YYDEBUGSTR, yydepth, yystate, yychar, yys); } #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); #else YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ #endif /* defined(YYDESTRUCT_CALL) */ yychar = YYEMPTY; goto yyloop; } yyreduce: yym = yylen[yyn]; #if YYDEBUG if (yydebug) { fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); #ifdef YYSTYPE_TOSTRING #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ if (yym > 0) { int i; fputc('<', stderr); for (i = yym; i > 0; i--) { if (i != yym) fputs(", ", stderr); fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], yystack.l_mark[1-i]), stderr); } fputc('>', stderr); } #endif fputc('\n', stderr); } #endif if (yym > 0) yyval = yystack.l_mark[1-yym]; else memset(&yyval, 0, sizeof yyval); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* Perform position reduction */ memset(&yyloc, 0, sizeof(yyloc)); #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ { YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); /* just in case YYERROR is invoked within the action, save the start of the rhs as the error start position */ yyerror_loc_range[1] = yystack.p_mark[1-yym]; } #endif switch (yyn) { case 3: #line 66 "ok_syntax1.y" { yyerrok ; } #line 1234 "ok_syntax1.tab.c" break; case 4: #line 70 "ok_syntax1.y" { printf("%d\n",yystack.l_mark[0].ival);} #line 1239 "ok_syntax1.tab.c" break; case 5: #line 72 "ok_syntax1.y" { regs[yystack.l_mark[-2].ival] = yystack.l_mark[0].ival; } #line 1244 "ok_syntax1.tab.c" break; case 6: #line 76 "ok_syntax1.y" { yyval.ival = yystack.l_mark[-1].ival; } #line 1249 "ok_syntax1.tab.c" break; case 7: #line 78 "ok_syntax1.y" { yyval.ival = yystack.l_mark[-2].ival + yystack.l_mark[0].ival; } #line 1254 "ok_syntax1.tab.c" break; case 8: #line 80 "ok_syntax1.y" { yyval.ival = yystack.l_mark[-2].ival - yystack.l_mark[0].ival; } #line 1259 "ok_syntax1.tab.c" break; case 9: #line 82 "ok_syntax1.y" { yyval.ival = yystack.l_mark[-2].ival * yystack.l_mark[0].ival; } #line 1264 "ok_syntax1.tab.c" break; case 10: #line 84 "ok_syntax1.y" { yyval.ival = yystack.l_mark[-2].ival / yystack.l_mark[0].ival; } #line 1269 "ok_syntax1.tab.c" break; case 11: #line 86 "ok_syntax1.y" { yyval.ival = yystack.l_mark[-2].ival % yystack.l_mark[0].ival; } #line 1274 "ok_syntax1.tab.c" break; case 12: #line 88 "ok_syntax1.y" { yyval.ival = yystack.l_mark[-2].ival & yystack.l_mark[0].ival; } #line 1279 "ok_syntax1.tab.c" break; case 13: #line 90 "ok_syntax1.y" { yyval.ival = yystack.l_mark[-2].ival | yystack.l_mark[0].ival; } #line 1284 "ok_syntax1.tab.c" break; case 14: #line 92 "ok_syntax1.y" { yyval.ival = - yystack.l_mark[0].ival; } #line 1289 "ok_syntax1.tab.c" break; case 15: #line 94 "ok_syntax1.y" { yyval.ival = regs[yystack.l_mark[0].ival]; } #line 1294 "ok_syntax1.tab.c" break; case 17: #line 99 "ok_syntax1.y" { yyval.ival = yystack.l_mark[0].ival; (*base) = (yystack.l_mark[0].ival==0) ? 8 : 10; } #line 1299 "ok_syntax1.tab.c" break; case 18: #line 101 "ok_syntax1.y" { yyval.ival = (*base) * yystack.l_mark[-1].ival + yystack.l_mark[0].ival; } #line 1304 "ok_syntax1.tab.c" break; #line 1306 "ok_syntax1.tab.c" default: break; } yystack.s_mark -= yym; yystate = *yystack.s_mark; yystack.l_mark -= yym; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark -= yym; #endif yym = yylhs[yyn]; if (yystate == 0 && yym == 0) { #if YYDEBUG if (yydebug) { fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); #ifdef YYSTYPE_TOSTRING #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); #endif fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); } #endif yystate = YYFINAL; *++yystack.s_mark = YYFINAL; *++yystack.l_mark = yyval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *++yystack.p_mark = yyloc; #endif if (yychar < 0) { #if YYBTYACC do { if (yylvp < yylve) { /* we're currently re-reading tokens */ yylval = *yylvp++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylloc = *yylpp++; #endif yychar = *yylexp++; break; } if (yyps->save) { /* in trial mode; save scanner results for future parse attempts */ if (yylvp == yylvlim) { /* Enlarge lexical value queue */ size_t p = (size_t) (yylvp - yylvals); size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpe = yylpsns + p; yylplim = yylpsns + s; #endif yylexp = yylexemes + p; } *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpp++ = yylloc; yylpe++; #endif yychar = *yylexp++; break; } /* normal operation, no conflict encountered */ #endif /* YYBTYACC */ yychar = YYLEX; #if YYBTYACC } while (0); #endif /* YYBTYACC */ if (yychar < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); } #endif } if (yychar == YYEOF) goto yyaccept; goto yyloop; } if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) yystate = yytable[yyn]; else yystate = yydgoto[yym]; #if YYDEBUG if (yydebug) { fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); #ifdef YYSTYPE_TOSTRING #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); #endif fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); } #endif if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; *++yystack.s_mark = (YYINT) yystate; *++yystack.l_mark = yyval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *++yystack.p_mark = yyloc; #endif goto yyloop; #if YYBTYACC /* Reduction declares that this path is valid. Set yypath and do a full parse */ yyvalid: if (yypath) YYABORT; while (yyps->save) { YYParseState *save = yyps->save; yyps->save = save->save; save->save = yypath; yypath = save; } #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); #endif if (yyerrctx) { yyFreeState(yyerrctx); yyerrctx = NULL; } yylvp = yylvals + yypath->lexeme; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpsns + yypath->lexeme; #endif yylexp = yylexemes + yypath->lexeme; yychar = YYEMPTY; yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif yystate = yypath->state; goto yyloop; #endif /* YYBTYACC */ yyoverflow: YYERROR_CALL("yacc stack overflow"); #if YYBTYACC goto yyabort_nomem; yyenomem: YYERROR_CALL("memory exhausted"); yyabort_nomem: #endif /* YYBTYACC */ yyresult = 2; goto yyreturn; yyabort: yyresult = 1; goto yyreturn; yyaccept: #if YYBTYACC if (yyps->save) goto yyvalid; #endif /* YYBTYACC */ yyresult = 0; yyreturn: #if defined(YYDESTRUCT_CALL) if (yychar != YYEOF && yychar != YYEMPTY) #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); #else YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ { YYSTYPE *pv; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE *pp; for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) YYDESTRUCT_CALL("cleanup: discarding state", yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); #else for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) YYDESTRUCT_CALL("cleanup: discarding state", yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ } #endif /* defined(YYDESTRUCT_CALL) */ #if YYBTYACC if (yyerrctx) { yyFreeState(yyerrctx); yyerrctx = NULL; } while (yyps) { YYParseState *save = yyps; yyps = save->save; save->save = NULL; yyFreeState(save); } while (yypath) { YYParseState *save = yypath; yypath = save->save; save->save = NULL; yyFreeState(save); } #endif /* YYBTYACC */ yyfreestack(&yystack); return (yyresult); } diff --git a/contrib/byacc/test/btyacc/ok_syntax1.tab.h b/contrib/byacc/test/btyacc/ok_syntax1.tab.h index 9f7028913ee2..44b8dc3e95d3 100644 --- a/contrib/byacc/test/btyacc/ok_syntax1.tab.h +++ b/contrib/byacc/test/btyacc/ok_syntax1.tab.h @@ -1,34 +1,34 @@ #ifndef _ok_syntax1__defines_h_ #define _ok_syntax1__defines_h_ #define DIGIT 257 #define LETTER 258 #define OCT1 259 #define HEX1 260 #define HEX2 261 #define HEX3 262 #define STR1 263 #define STR2 265 #define BELL 266 #define BS 267 #define NL 268 #define LF 269 #define CR 270 #define TAB 271 #define VT 272 #define UMINUS 273 #ifdef YYSTYPE #undef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 #endif #ifndef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 -typedef union YYSTYPE +typedef union { char * cval; int ival; double dval; } YYSTYPE; #endif /* !YYSTYPE_IS_DECLARED */ #endif /* _ok_syntax1__defines_h_ */ diff --git a/contrib/byacc/test/btyacc/varsyntax_calc1.tab.c b/contrib/byacc/test/btyacc/varsyntax_calc1.tab.c index 381102f7207f..2d35aade2579 100644 --- a/contrib/byacc/test/btyacc/varsyntax_calc1.tab.c +++ b/contrib/byacc/test/btyacc/varsyntax_calc1.tab.c @@ -1,1747 +1,1747 @@ /* original parser id follows */ /* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ /* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ #define YYBYACC 1 #define YYMAJOR 2 #define YYMINOR 0 #define YYCHECK "yyyymmdd" #define YYEMPTY (-1) #define yyclearin (yychar = YYEMPTY) #define yyerrok (yyerrflag = 0) #define YYRECOVERING() (yyerrflag != 0) #define YYENOMEM (-2) #define YYEOF 0 #ident "check variant syntax features" #undef YYBTYACC #define YYBTYACC 0 #define YYDEBUGSTR YYPREFIX "debug" #ifndef yyparse #define yyparse varsyntax_calc1_parse #endif /* yyparse */ #ifndef yylex #define yylex varsyntax_calc1_lex #endif /* yylex */ #ifndef yyerror #define yyerror varsyntax_calc1_error #endif /* yyerror */ #ifndef yychar #define yychar varsyntax_calc1_char #endif /* yychar */ #ifndef yyval #define yyval varsyntax_calc1_val #endif /* yyval */ #ifndef yylval #define yylval varsyntax_calc1_lval #endif /* yylval */ #ifndef yydebug #define yydebug varsyntax_calc1_debug #endif /* yydebug */ #ifndef yynerrs #define yynerrs varsyntax_calc1_nerrs #endif /* yynerrs */ #ifndef yyerrflag #define yyerrflag varsyntax_calc1_errflag #endif /* yyerrflag */ #ifndef yylhs #define yylhs varsyntax_calc1_lhs #endif /* yylhs */ #ifndef yylen #define yylen varsyntax_calc1_len #endif /* yylen */ #ifndef yydefred #define yydefred varsyntax_calc1_defred #endif /* yydefred */ #ifndef yystos #define yystos varsyntax_calc1_stos #endif /* yystos */ #ifndef yydgoto #define yydgoto varsyntax_calc1_dgoto #endif /* yydgoto */ #ifndef yysindex #define yysindex varsyntax_calc1_sindex #endif /* yysindex */ #ifndef yyrindex #define yyrindex varsyntax_calc1_rindex #endif /* yyrindex */ #ifndef yygindex #define yygindex varsyntax_calc1_gindex #endif /* yygindex */ #ifndef yytable #define yytable varsyntax_calc1_table #endif /* yytable */ #ifndef yycheck #define yycheck varsyntax_calc1_check #endif /* yycheck */ #ifndef yyname #define yyname varsyntax_calc1_name #endif /* yyname */ #ifndef yyrule #define yyrule varsyntax_calc1_rule #endif /* yyrule */ #if YYBTYACC #ifndef yycindex #define yycindex varsyntax_calc1_cindex #endif /* yycindex */ #ifndef yyctable #define yyctable varsyntax_calc1_ctable #endif /* yyctable */ #endif /* YYBTYACC */ #define YYPREFIX "varsyntax_calc1_" #define YYPURE 0 #line 3 "varsyntax_calc1.y" /* http://dinosaur.compilertools.net/yacc/index.html * /*/ #include #include #include #include typedef struct interval { double lo, hi; } INTERVAL; INTERVAL vmul(double, double, INTERVAL); INTERVAL vdiv(double, double, INTERVAL); extern int yylex(void); static void yyerror(const char *s); int dcheck(INTERVAL); double dreg[26]; INTERVAL vreg[26]; #ifdef YYSTYPE #undef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 #endif #ifndef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 #line 32 "varsyntax_calc1.y" -typedef union YYSTYPE +typedef union { int ival; /* dreg & vreg array index values*/ double dval; /* floating point values*/ INTERVAL vval; /* interval values*/ } YYSTYPE; #endif /* !YYSTYPE_IS_DECLARED */ #line 162 "varsyntax_calc1.tab.c" /* compatibility with bison */ #ifdef YYPARSE_PARAM /* compatibility with FreeBSD */ # ifdef YYPARSE_PARAM_TYPE # define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) # else # define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) # endif #else # define YYPARSE_DECL() yyparse(void) #endif /* Parameters sent to lex. */ #ifdef YYLEX_PARAM # define YYLEX_DECL() yylex(void *YYLEX_PARAM) # define YYLEX yylex(YYLEX_PARAM) #else # define YYLEX_DECL() yylex(void) # define YYLEX yylex() #endif /* Parameters sent to yyerror. */ #ifndef YYERROR_DECL #define YYERROR_DECL() yyerror(const char *s) #endif #ifndef YYERROR_CALL #define YYERROR_CALL(msg) yyerror(msg) #endif extern int YYPARSE_DECL(); #define DREG 257 #define VREG 258 #define CONST 259 #define UMINUS 260 #define YYERRCODE 256 typedef int YYINT; static const YYINT varsyntax_calc1_lhs[] = { -1, 3, 3, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, }; static const YYINT varsyntax_calc1_len[] = { 2, 0, 2, 2, 2, 4, 4, 2, 1, 1, 3, 3, 3, 3, 2, 3, 1, 5, 1, 3, 3, 3, 3, 3, 3, 3, 3, 2, 3, }; static const YYINT varsyntax_calc1_defred[] = { 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 7, 0, 0, 9, 18, 14, 27, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 15, 0, 28, 0, 0, 0, 0, 12, 24, 13, 26, 0, 0, 23, 25, 14, 0, 0, 0, 0, 0, 5, 6, 0, 0, 0, 12, 13, 17, }; #if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) static const YYINT varsyntax_calc1_stos[] = { 0, 256, 257, 258, 259, 45, 40, 262, 263, 264, 10, 61, 61, 257, 258, 263, 264, 263, 264, 43, 45, 42, 47, 10, 43, 45, 42, 47, 10, 45, 40, 263, 263, 264, 41, 44, 41, 263, 264, 263, 264, 263, 264, 263, 264, 264, 264, 264, 264, 263, 263, 43, 45, 42, 47, 10, 10, 263, 263, 263, 263, 263, 41, }; #endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ static const YYINT varsyntax_calc1_dgoto[] = { 7, 32, 9, 0, }; static const YYINT varsyntax_calc1_sindex[] = { -40, -8, -48, -47, 0, -37, -37, 0, 2, 17, 0, -34, -37, 0, 0, 0, 0, -25, 90, -37, -37, -37, -37, 0, -37, -37, -37, -37, 0, -34, -34, 25, 125, 31, 0, -34, 0, -11, 37, -11, 37, 0, 0, 0, 0, 37, 37, 0, 0, 0, 111, -34, -34, -34, -34, 0, 0, 118, 69, 69, 0, 0, 0, }; static const YYINT varsyntax_calc1_rindex[] = { 0, 0, 38, 44, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -9, 0, 0, 0, 0, 51, -3, 56, 61, 0, 0, 0, 0, 67, 72, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 78, 83, 0, 0, 0, }; #if YYBTYACC static const YYINT varsyntax_calc1_cindex[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; #endif static const YYINT varsyntax_calc1_gindex[] = { 0, 4, 124, 0, }; #define YYTABLESIZE 225 static const YYINT varsyntax_calc1_table[] = { 6, 16, 10, 6, 8, 5, 30, 20, 5, 15, 17, 29, 23, 11, 12, 31, 34, 21, 19, 35, 20, 0, 22, 37, 39, 41, 43, 28, 0, 0, 0, 21, 16, 49, 50, 55, 22, 0, 20, 57, 20, 56, 20, 0, 21, 19, 0, 20, 9, 22, 0, 0, 0, 0, 18, 58, 59, 60, 61, 26, 24, 10, 25, 0, 27, 0, 11, 53, 51, 0, 52, 22, 54, 26, 24, 0, 25, 19, 27, 26, 9, 9, 21, 9, 27, 9, 18, 18, 10, 18, 0, 18, 10, 11, 10, 10, 10, 11, 0, 11, 11, 11, 22, 0, 22, 0, 22, 0, 19, 0, 19, 53, 19, 21, 0, 21, 54, 21, 0, 10, 0, 10, 0, 10, 11, 0, 11, 0, 11, 16, 18, 36, 26, 24, 0, 25, 33, 27, 0, 0, 0, 0, 0, 38, 40, 42, 44, 0, 45, 46, 47, 48, 34, 53, 51, 0, 52, 0, 54, 62, 53, 51, 0, 52, 0, 54, 0, 21, 19, 0, 20, 0, 22, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 13, 14, 4, 13, 0, 4, }; static const YYINT varsyntax_calc1_check[] = { 40, 10, 10, 40, 0, 45, 40, 10, 45, 5, 6, 45, 10, 61, 61, 11, 41, 42, 43, 44, 45, -1, 47, 19, 20, 21, 22, 10, -1, -1, -1, 42, 41, 29, 30, 10, 47, -1, 41, 35, 43, 10, 45, -1, 42, 43, -1, 45, 10, 47, -1, -1, -1, -1, 10, 51, 52, 53, 54, 42, 43, 10, 45, -1, 47, -1, 10, 42, 43, -1, 45, 10, 47, 42, 43, -1, 45, 10, 47, 42, 42, 43, 10, 45, 47, 47, 42, 43, 10, 45, -1, 47, 41, 10, 43, 44, 45, 41, -1, 43, 44, 45, 41, -1, 43, -1, 45, -1, 41, -1, 43, 42, 45, 41, -1, 43, 47, 45, -1, 41, -1, 43, -1, 45, 41, -1, 43, -1, 45, 5, 6, 41, 42, 43, -1, 45, 12, 47, -1, -1, -1, -1, -1, 19, 20, 21, 22, -1, 24, 25, 26, 27, 41, 42, 43, -1, 45, -1, 47, 41, 42, 43, -1, 45, -1, 47, -1, 42, 43, -1, 45, -1, 47, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 256, 257, 258, 259, 257, 258, 259, 257, -1, 259, }; #if YYBTYACC static const YYINT varsyntax_calc1_ctable[] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, }; #endif #define YYFINAL 7 #ifndef YYDEBUG #define YYDEBUG 0 #endif #define YYMAXTOKEN 260 #define YYUNDFTOKEN 266 #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) #if YYDEBUG static const char *const varsyntax_calc1_name[] = { "$end",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,"'('","')'","'*'","'+'","','","'-'",0,"'/'",0,0,0,0,0,0,0,0,0,0,0,0, 0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, "error","DREG","VREG","CONST","UMINUS","$accept","line","dexp","vexp","lines", "illegal-symbol", }; static const char *const varsyntax_calc1_rule[] = { "$accept : line", "lines :", "lines : lines line", "line : dexp '\\n'", "line : vexp '\\n'", "line : DREG '=' dexp '\\n'", "line : VREG '=' vexp '\\n'", "line : error '\\n'", "dexp : CONST", "dexp : DREG", "dexp : dexp '+' dexp", "dexp : dexp '-' dexp", "dexp : dexp '*' dexp", "dexp : dexp '/' dexp", "dexp : '-' dexp", "dexp : '(' dexp ')'", "vexp : dexp", "vexp : '(' dexp ',' dexp ')'", "vexp : VREG", "vexp : vexp '+' vexp", "vexp : dexp '+' vexp", "vexp : vexp '-' vexp", "vexp : dexp '-' vexp", "vexp : vexp '*' vexp", "vexp : dexp '*' vexp", "vexp : vexp '/' vexp", "vexp : dexp '/' vexp", "vexp : '-' vexp", "vexp : '(' vexp ')'", }; #endif #if YYDEBUG int yydebug; #endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; int yynerrs; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyloc; /* position returned by actions */ YYLTYPE yylloc; /* position from the lexer */ #endif #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) #ifndef YYLLOC_DEFAULT #define YYLLOC_DEFAULT(loc, rhs, n) \ do \ { \ if (n == 0) \ { \ (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ } \ else \ { \ (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ (loc).last_line = YYRHSLOC(rhs, n).last_line; \ (loc).last_column = YYRHSLOC(rhs, n).last_column; \ } \ } while (0) #endif /* YYLLOC_DEFAULT */ #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ #if YYBTYACC #ifndef YYLVQUEUEGROWTH #define YYLVQUEUEGROWTH 32 #endif #endif /* YYBTYACC */ /* define the initial stack-sizes */ #ifdef YYSTACKSIZE #undef YYMAXDEPTH #define YYMAXDEPTH YYSTACKSIZE #else #ifdef YYMAXDEPTH #define YYSTACKSIZE YYMAXDEPTH #else #define YYSTACKSIZE 10000 #define YYMAXDEPTH 10000 #endif #endif #ifndef YYINITSTACKSIZE #define YYINITSTACKSIZE 200 #endif typedef struct { unsigned stacksize; YYINT *s_base; YYINT *s_mark; YYINT *s_last; YYSTYPE *l_base; YYSTYPE *l_mark; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE *p_base; YYLTYPE *p_mark; #endif } YYSTACKDATA; #if YYBTYACC struct YYParseState_s { struct YYParseState_s *save; /* Previously saved parser state */ YYSTACKDATA yystack; /* saved parser stack */ int state; /* saved parser state */ int errflag; /* saved error recovery status */ int lexeme; /* saved index of the conflict lexeme in the lexical queue */ YYINT ctry; /* saved index in yyctable[] for this conflict */ }; typedef struct YYParseState_s YYParseState; #endif /* YYBTYACC */ /* variables for the parser stack */ static YYSTACKDATA yystack; #if YYBTYACC /* Current parser state */ static YYParseState *yyps = 0; /* yypath != NULL: do the full parse, starting at *yypath parser state. */ static YYParseState *yypath = 0; /* Base of the lexical value queue */ static YYSTYPE *yylvals = 0; /* Current position at lexical value queue */ static YYSTYPE *yylvp = 0; /* End position of lexical value queue */ static YYSTYPE *yylve = 0; /* The last allocated position at the lexical value queue */ static YYSTYPE *yylvlim = 0; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* Base of the lexical position queue */ static YYLTYPE *yylpsns = 0; /* Current position at lexical position queue */ static YYLTYPE *yylpp = 0; /* End position of lexical position queue */ static YYLTYPE *yylpe = 0; /* The last allocated position at the lexical position queue */ static YYLTYPE *yylplim = 0; #endif /* Current position at lexical token queue */ static YYINT *yylexp = 0; static YYINT *yylexemes = 0; #endif /* YYBTYACC */ #line 178 "varsyntax_calc1.y" /* beginning of subroutines section */ #define BSZ 50 /* buffer size for floating point numbers */ /* lexical analysis */ static void yyerror(const char *s) { fprintf(stderr, "%s\n", s); } int yylex(void) { int c; while ((c = getchar()) == ' ') { /* skip over blanks */ } if (isupper(c)) { yylval.ival = c - 'A'; return (VREG); } if (islower(c)) { yylval.ival = c - 'a'; return (DREG); } if (isdigit(c) || c == '.') { /* gobble up digits, points, exponents */ char buf[BSZ + 1], *cp = buf; int dot = 0, expr = 0; for (; (cp - buf) < BSZ; ++cp, c = getchar()) { *cp = (char) c; if (isdigit(c)) continue; if (c == '.') { if (dot++ || expr) return ('.'); /* will cause syntax error */ continue; } if (c == 'e') { if (expr++) return ('e'); /* will cause syntax error */ continue; } /* end of number */ break; } *cp = '\0'; if ((cp - buf) >= BSZ) printf("constant too long: truncated\n"); else ungetc(c, stdin); /* push back last char read */ yylval.dval = atof(buf); return (CONST); } return (c); } static INTERVAL hilo(double a, double b, double c, double d) { /* returns the smallest interval containing a, b, c, and d */ /* used by *, / routines */ INTERVAL v; if (a > b) { v.hi = a; v.lo = b; } else { v.hi = b; v.lo = a; } if (c > d) { if (c > v.hi) v.hi = c; if (d < v.lo) v.lo = d; } else { if (d > v.hi) v.hi = d; if (c < v.lo) v.lo = c; } return (v); } INTERVAL vmul(double a, double b, INTERVAL v) { return (hilo(a * v.hi, a * v.lo, b * v.hi, b * v.lo)); } int dcheck(INTERVAL v) { if (v.hi >= 0. && v.lo <= 0.) { printf("divisor interval contains 0.\n"); return (1); } return (0); } INTERVAL vdiv(double a, double b, INTERVAL v) { return (hilo(a / v.hi, a / v.lo, b / v.hi, b / v.lo)); } #line 656 "varsyntax_calc1.tab.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) #if YYBTYACC #define yytrial (yyps->save) #endif /* YYBTYACC */ #if YYDEBUG #include /* needed for printf */ #endif #include /* needed for malloc, etc */ #include /* needed for memset */ /* allocate initial stack or double stack size, up to YYMAXDEPTH */ static int yygrowstack(YYSTACKDATA *data) { int i; unsigned newsize; YYINT *newss; YYSTYPE *newvs; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE *newps; #endif if ((newsize = data->stacksize) == 0) newsize = YYINITSTACKSIZE; else if (newsize >= YYMAXDEPTH) return YYENOMEM; else if ((newsize *= 2) > YYMAXDEPTH) newsize = YYMAXDEPTH; i = (int) (data->s_mark - data->s_base); newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); if (newss == NULL) return YYENOMEM; data->s_base = newss; data->s_mark = newss + i; newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); if (newvs == NULL) return YYENOMEM; data->l_base = newvs; data->l_mark = newvs + i; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); if (newps == NULL) return YYENOMEM; data->p_base = newps; data->p_mark = newps + i; #endif data->stacksize = newsize; data->s_last = data->s_base + newsize - 1; #if YYDEBUG if (yydebug) fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); #endif return 0; } #if YYPURE || defined(YY_NO_LEAKS) static void yyfreestack(YYSTACKDATA *data) { free(data->s_base); free(data->l_base); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) free(data->p_base); #endif memset(data, 0, sizeof(*data)); } #else #define yyfreestack(data) /* nothing */ #endif /* YYPURE || defined(YY_NO_LEAKS) */ #if YYBTYACC static YYParseState * yyNewState(unsigned size) { YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); if (p == NULL) return NULL; p->yystack.stacksize = size; if (size == 0) { p->yystack.s_base = NULL; p->yystack.l_base = NULL; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) p->yystack.p_base = NULL; #endif return p; } p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); if (p->yystack.s_base == NULL) return NULL; p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); if (p->yystack.l_base == NULL) return NULL; memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); if (p->yystack.p_base == NULL) return NULL; memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); #endif return p; } static void yyFreeState(YYParseState *p) { yyfreestack(&p->yystack); free(p); } #endif /* YYBTYACC */ #define YYABORT goto yyabort #define YYREJECT goto yyabort #define YYACCEPT goto yyaccept #define YYERROR goto yyerrlab #if YYBTYACC #define YYVALID do { if (yyps->save) goto yyvalid; } while(0) #define YYVALID_NESTED do { if (yyps->save && \ yyps->save->save == 0) goto yyvalid; } while(0) #endif /* YYBTYACC */ int YYPARSE_DECL() { int yym, yyn, yystate, yyresult; #if YYBTYACC int yynewerrflag; YYParseState *yyerrctx = NULL; #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ #endif #if YYDEBUG const char *yys; if ((yys = getenv("YYDEBUG")) != NULL) { yyn = *yys; if (yyn >= '0' && yyn <= '9') yydebug = yyn - '0'; } if (yydebug) fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); #endif #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); #endif #if YYBTYACC yyps = yyNewState(0); if (yyps == 0) goto yyenomem; yyps->save = 0; #endif /* YYBTYACC */ yym = 0; /* yyn is set below */ yynerrs = 0; yyerrflag = 0; yychar = YYEMPTY; yystate = 0; #if YYPURE memset(&yystack, 0, sizeof(yystack)); #endif if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystack.s_mark = yystack.s_base; yystack.l_mark = yystack.l_base; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark = yystack.p_base; #endif yystate = 0; *yystack.s_mark = 0; yyloop: if ((yyn = yydefred[yystate]) != 0) goto yyreduce; if (yychar < 0) { #if YYBTYACC do { if (yylvp < yylve) { /* we're currently re-reading tokens */ yylval = *yylvp++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylloc = *yylpp++; #endif yychar = *yylexp++; break; } if (yyps->save) { /* in trial mode; save scanner results for future parse attempts */ if (yylvp == yylvlim) { /* Enlarge lexical value queue */ size_t p = (size_t) (yylvp - yylvals); size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpe = yylpsns + p; yylplim = yylpsns + s; #endif yylexp = yylexemes + p; } *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpp++ = yylloc; yylpe++; #endif yychar = *yylexp++; break; } /* normal operation, no conflict encountered */ #endif /* YYBTYACC */ yychar = YYLEX; #if YYBTYACC } while (0); #endif /* YYBTYACC */ if (yychar < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", YYDEBUGSTR, yydepth, yystate, yychar, yys); #ifdef YYSTYPE_TOSTRING #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); #endif fputc('\n', stderr); } #endif } #if YYBTYACC /* Do we have a conflict? */ if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) { YYINT ctry; if (yypath) { YYParseState *save; #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", YYDEBUGSTR, yydepth, yystate); #endif /* Switch to the next conflict context */ save = yypath; yypath = save->save; save->save = NULL; ctry = save->ctry; if (save->state != yystate) YYABORT; yyFreeState(save); } else { /* Unresolved conflict - start/continue trial parse */ YYParseState *save; #if YYDEBUG if (yydebug) { fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); if (yyps->save) fputs("ALREADY in conflict, continuing trial parse.\n", stderr); else fputs("Starting trial parse.\n", stderr); } #endif save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); if (save == NULL) goto yyenomem; save->save = yyps->save; save->state = yystate; save->errflag = yyerrflag; save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif ctry = yytable[yyn]; if (yyctable[ctry] == -1) { #if YYDEBUG if (yydebug && yychar >= YYEOF) fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); #endif ctry++; } save->ctry = ctry; if (yyps->save == NULL) { /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; yylvlim = yylvals + YYLVQUEUEGROWTH; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); if (yylpsns == NULL) goto yyenomem; yylplim = yylpsns + YYLVQUEUEGROWTH; #endif } if (yylvp == yylve) { yylvp = yylve = yylvals; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpe = yylpsns; #endif yylexp = yylexemes; if (yychar >= YYEOF) { *yylve++ = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpe++ = yylloc; #endif *yylexp = (YYINT) yychar; yychar = YYEMPTY; } } } if (yychar >= YYEOF) { yylvp--; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp--; #endif yylexp--; yychar = YYEMPTY; } save->lexeme = (int) (yylvp - yylvals); yyps->save = save; } if (yytable[yyn] == ctry) { #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); #endif if (yychar < 0) { yylvp++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp++; #endif yylexp++; } if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystate = yyctable[ctry]; *++yystack.s_mark = (YYINT) yystate; *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *++yystack.p_mark = yylloc; #endif yychar = YYEMPTY; if (yyerrflag > 0) --yyerrflag; goto yyloop; } else { yyn = yyctable[ctry]; goto yyreduce; } } /* End of code dealing with conflicts */ #endif /* YYBTYACC */ if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) { #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", YYDEBUGSTR, yydepth, yystate, yytable[yyn]); #endif if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystate = yytable[yyn]; *++yystack.s_mark = yytable[yyn]; *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *++yystack.p_mark = yylloc; #endif yychar = YYEMPTY; if (yyerrflag > 0) --yyerrflag; goto yyloop; } if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) { yyn = yytable[yyn]; goto yyreduce; } if (yyerrflag != 0) goto yyinrecovery; #if YYBTYACC yynewerrflag = 1; goto yyerrhandler; goto yyerrlab; /* redundant goto avoids 'unused label' warning */ yyerrlab: /* explicit YYERROR from an action -- pop the rhs of the rule reduced * before looking for error recovery */ yystack.s_mark -= yym; yystate = *yystack.s_mark; yystack.l_mark -= yym; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark -= yym; #endif yynewerrflag = 0; yyerrhandler: while (yyps->save) { int ctry; YYParseState *save = yyps->save; #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", YYDEBUGSTR, yydepth, yystate, yyps->save->state, (int)(yylvp - yylvals - yyps->save->lexeme)); #endif /* Memorize most forward-looking error state in case it's really an error. */ if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) { /* Free old saved error context state */ if (yyerrctx) yyFreeState(yyerrctx); /* Create and fill out new saved error context state */ yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); if (yyerrctx == NULL) goto yyenomem; yyerrctx->save = yyps->save; yyerrctx->state = yystate; yyerrctx->errflag = yyerrflag; yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif yyerrctx->lexeme = (int) (yylvp - yylvals); } yylvp = yylvals + save->lexeme; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpsns + save->lexeme; #endif yylexp = yylexemes + save->lexeme; yychar = YYEMPTY; yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif ctry = ++save->ctry; yystate = save->state; /* We tried shift, try reduce now */ if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; yyps->save = save->save; save->save = NULL; yyFreeState(save); /* Nothing left on the stack -- error */ if (!yyps->save) { #if YYDEBUG if (yydebug) fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", YYPREFIX, yydepth); #endif /* Restore state as it was in the most forward-advanced error */ yylvp = yylvals + yyerrctx->lexeme; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpsns + yyerrctx->lexeme; #endif yylexp = yylexemes + yyerrctx->lexeme; yychar = yylexp[-1]; yylval = yylvp[-1]; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylloc = yylpp[-1]; #endif yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif yystate = yyerrctx->state; yyFreeState(yyerrctx); yyerrctx = NULL; } yynewerrflag = 1; } if (yynewerrflag == 0) goto yyinrecovery; #endif /* YYBTYACC */ YYERROR_CALL("syntax error"); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ #endif #if !YYBTYACC goto yyerrlab; /* redundant goto avoids 'unused label' warning */ yyerrlab: #endif ++yynerrs; yyinrecovery: if (yyerrflag < 3) { yyerrflag = 3; for (;;) { if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) { #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); #endif if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystate = yytable[yyn]; *++yystack.s_mark = yytable[yyn]; *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* lookahead position is error end position */ yyerror_loc_range[2] = yylloc; YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ *++yystack.p_mark = yyloc; #endif goto yyloop; } else { #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", YYDEBUGSTR, yydepth, *yystack.s_mark); #endif if (yystack.s_mark <= yystack.s_base) goto yyabort; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* the current TOS position is the error start position */ yyerror_loc_range[1] = *yystack.p_mark; #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYDESTRUCT_CALL("error: discarding state", yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); #else YYDESTRUCT_CALL("error: discarding state", yystos[*yystack.s_mark], yystack.l_mark); #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ #endif /* defined(YYDESTRUCT_CALL) */ --yystack.s_mark; --yystack.l_mark; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) --yystack.p_mark; #endif } } } else { if (yychar == YYEOF) goto yyabort; #if YYDEBUG if (yydebug) { if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", YYDEBUGSTR, yydepth, yystate, yychar, yys); } #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); #else YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ #endif /* defined(YYDESTRUCT_CALL) */ yychar = YYEMPTY; goto yyloop; } yyreduce: yym = yylen[yyn]; #if YYDEBUG if (yydebug) { fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); #ifdef YYSTYPE_TOSTRING #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ if (yym > 0) { int i; fputc('<', stderr); for (i = yym; i > 0; i--) { if (i != yym) fputs(", ", stderr); fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], yystack.l_mark[1-i]), stderr); } fputc('>', stderr); } #endif fputc('\n', stderr); } #endif if (yym > 0) yyval = yystack.l_mark[1-yym]; else memset(&yyval, 0, sizeof yyval); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* Perform position reduction */ memset(&yyloc, 0, sizeof(yyloc)); #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ { YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); /* just in case YYERROR is invoked within the action, save the start of the rhs as the error start position */ yyerror_loc_range[1] = yystack.p_mark[1-yym]; } #endif switch (yyn) { case 3: #line 59 "varsyntax_calc1.y" { (void) printf("%15.8f\n", yystack.l_mark[-1].dval); } #line 1331 "varsyntax_calc1.tab.c" break; case 4: #line 63 "varsyntax_calc1.y" { (void) printf("(%15.8f, %15.8f)\n", yystack.l_mark[-1].vval.lo, yystack.l_mark[-1].vval.hi); } #line 1338 "varsyntax_calc1.tab.c" break; case 5: #line 67 "varsyntax_calc1.y" { dreg[yystack.l_mark[-3].ival] = yystack.l_mark[-1].dval; } #line 1345 "varsyntax_calc1.tab.c" break; case 6: #line 71 "varsyntax_calc1.y" { vreg[yystack.l_mark[-3].ival] = yystack.l_mark[-1].vval; } #line 1352 "varsyntax_calc1.tab.c" break; case 7: #line 75 "varsyntax_calc1.y" { yyerrok; } #line 1359 "varsyntax_calc1.tab.c" break; case 9: #line 82 "varsyntax_calc1.y" { yyval.dval = dreg[yystack.l_mark[0].ival]; /* $$ & $1 are sufficient here*/ } #line 1366 "varsyntax_calc1.tab.c" break; case 10: #line 86 "varsyntax_calc1.y" { yyval.dval = yystack.l_mark[-2].dval + yystack.l_mark[0].dval; } #line 1373 "varsyntax_calc1.tab.c" break; case 11: #line 90 "varsyntax_calc1.y" { yyval.dval = yystack.l_mark[-2].dval - yystack.l_mark[0].dval; } #line 1380 "varsyntax_calc1.tab.c" break; case 12: #line 94 "varsyntax_calc1.y" { yyval.dval = yystack.l_mark[-2].dval * yystack.l_mark[0].dval; } #line 1387 "varsyntax_calc1.tab.c" break; case 13: #line 98 "varsyntax_calc1.y" { yyval.dval = yystack.l_mark[-2].dval / yystack.l_mark[0].dval; } #line 1394 "varsyntax_calc1.tab.c" break; case 14: #line 102 "varsyntax_calc1.y" { yyval.dval = -yystack.l_mark[0].dval; } #line 1401 "varsyntax_calc1.tab.c" break; case 15: #line 106 "varsyntax_calc1.y" { yyval.dval = yystack.l_mark[-1].dval; } #line 1408 "varsyntax_calc1.tab.c" break; case 16: #line 112 "varsyntax_calc1.y" { yyval.vval.hi = yyval.vval.lo = yystack.l_mark[0].dval; } #line 1415 "varsyntax_calc1.tab.c" break; case 17: #line 116 "varsyntax_calc1.y" { yyval.vval.lo = yystack.l_mark[-3].dval; yyval.vval.hi = yystack.l_mark[-1].dval; if ( yyval.vval.lo > yyval.vval.hi ) { (void) printf("interval out of order\n"); YYERROR; } } #line 1428 "varsyntax_calc1.tab.c" break; case 18: #line 126 "varsyntax_calc1.y" { yyval.vval = vreg[yystack.l_mark[0].ival]; } #line 1435 "varsyntax_calc1.tab.c" break; case 19: #line 130 "varsyntax_calc1.y" { yyval.vval.hi = yystack.l_mark[-2].vval.hi + yystack.l_mark[0].vval.hi; yyval.vval.lo = yystack.l_mark[-2].vval.lo + yystack.l_mark[0].vval.lo; } #line 1443 "varsyntax_calc1.tab.c" break; case 20: #line 135 "varsyntax_calc1.y" { yyval.vval.hi = yystack.l_mark[-2].dval + yystack.l_mark[0].vval.hi; yyval.vval.lo = yystack.l_mark[-2].dval + yystack.l_mark[0].vval.lo; } #line 1451 "varsyntax_calc1.tab.c" break; case 21: #line 140 "varsyntax_calc1.y" { yyval.vval.hi = yystack.l_mark[-2].vval.hi - yystack.l_mark[0].vval.lo; yyval.vval.lo = yystack.l_mark[-2].vval.lo - yystack.l_mark[0].vval.hi; } #line 1459 "varsyntax_calc1.tab.c" break; case 22: #line 145 "varsyntax_calc1.y" { yyval.vval.hi = yystack.l_mark[-2].dval - yystack.l_mark[0].vval.lo; yyval.vval.lo = yystack.l_mark[-2].dval - yystack.l_mark[0].vval.hi; } #line 1467 "varsyntax_calc1.tab.c" break; case 23: #line 150 "varsyntax_calc1.y" { yyval.vval = vmul( yystack.l_mark[-2].vval.lo, yystack.l_mark[-2].vval.hi, yystack.l_mark[0].vval ); } #line 1474 "varsyntax_calc1.tab.c" break; case 24: #line 154 "varsyntax_calc1.y" { yyval.vval = vmul (yystack.l_mark[-2].dval, yystack.l_mark[-2].dval, yystack.l_mark[0].vval ); } #line 1481 "varsyntax_calc1.tab.c" break; case 25: #line 158 "varsyntax_calc1.y" { if (dcheck(yystack.l_mark[0].vval)) YYERROR; yyval.vval = vdiv ( yystack.l_mark[-2].vval.lo, yystack.l_mark[-2].vval.hi, yystack.l_mark[0].vval ); } #line 1489 "varsyntax_calc1.tab.c" break; case 26: #line 163 "varsyntax_calc1.y" { if (dcheck ( yystack.l_mark[0].vval )) YYERROR; yyval.vval = vdiv (yystack.l_mark[-2].dval, yystack.l_mark[-2].dval, yystack.l_mark[0].vval ); } #line 1497 "varsyntax_calc1.tab.c" break; case 27: #line 168 "varsyntax_calc1.y" { yyval.vval.hi = -yystack.l_mark[0].vval.lo; yyval.vval.lo = -yystack.l_mark[0].vval.hi; } #line 1505 "varsyntax_calc1.tab.c" break; case 28: #line 173 "varsyntax_calc1.y" { yyval.vval = yystack.l_mark[-1].vval; } #line 1512 "varsyntax_calc1.tab.c" break; #line 1514 "varsyntax_calc1.tab.c" default: break; } yystack.s_mark -= yym; yystate = *yystack.s_mark; yystack.l_mark -= yym; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark -= yym; #endif yym = yylhs[yyn]; if (yystate == 0 && yym == 0) { #if YYDEBUG if (yydebug) { fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); #ifdef YYSTYPE_TOSTRING #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); #endif fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); } #endif yystate = YYFINAL; *++yystack.s_mark = YYFINAL; *++yystack.l_mark = yyval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *++yystack.p_mark = yyloc; #endif if (yychar < 0) { #if YYBTYACC do { if (yylvp < yylve) { /* we're currently re-reading tokens */ yylval = *yylvp++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylloc = *yylpp++; #endif yychar = *yylexp++; break; } if (yyps->save) { /* in trial mode; save scanner results for future parse attempts */ if (yylvp == yylvlim) { /* Enlarge lexical value queue */ size_t p = (size_t) (yylvp - yylvals); size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpe = yylpsns + p; yylplim = yylpsns + s; #endif yylexp = yylexemes + p; } *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpp++ = yylloc; yylpe++; #endif yychar = *yylexp++; break; } /* normal operation, no conflict encountered */ #endif /* YYBTYACC */ yychar = YYLEX; #if YYBTYACC } while (0); #endif /* YYBTYACC */ if (yychar < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); } #endif } if (yychar == YYEOF) goto yyaccept; goto yyloop; } if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) yystate = yytable[yyn]; else yystate = yydgoto[yym]; #if YYDEBUG if (yydebug) { fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); #ifdef YYSTYPE_TOSTRING #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); #endif fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); } #endif if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; *++yystack.s_mark = (YYINT) yystate; *++yystack.l_mark = yyval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *++yystack.p_mark = yyloc; #endif goto yyloop; #if YYBTYACC /* Reduction declares that this path is valid. Set yypath and do a full parse */ yyvalid: if (yypath) YYABORT; while (yyps->save) { YYParseState *save = yyps->save; yyps->save = save->save; save->save = yypath; yypath = save; } #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); #endif if (yyerrctx) { yyFreeState(yyerrctx); yyerrctx = NULL; } yylvp = yylvals + yypath->lexeme; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpsns + yypath->lexeme; #endif yylexp = yylexemes + yypath->lexeme; yychar = YYEMPTY; yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif yystate = yypath->state; goto yyloop; #endif /* YYBTYACC */ yyoverflow: YYERROR_CALL("yacc stack overflow"); #if YYBTYACC goto yyabort_nomem; yyenomem: YYERROR_CALL("memory exhausted"); yyabort_nomem: #endif /* YYBTYACC */ yyresult = 2; goto yyreturn; yyabort: yyresult = 1; goto yyreturn; yyaccept: #if YYBTYACC if (yyps->save) goto yyvalid; #endif /* YYBTYACC */ yyresult = 0; yyreturn: #if defined(YYDESTRUCT_CALL) if (yychar != YYEOF && yychar != YYEMPTY) #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); #else YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ { YYSTYPE *pv; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE *pp; for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) YYDESTRUCT_CALL("cleanup: discarding state", yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); #else for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) YYDESTRUCT_CALL("cleanup: discarding state", yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ } #endif /* defined(YYDESTRUCT_CALL) */ #if YYBTYACC if (yyerrctx) { yyFreeState(yyerrctx); yyerrctx = NULL; } while (yyps) { YYParseState *save = yyps; yyps = save->save; save->save = NULL; yyFreeState(save); } while (yypath) { YYParseState *save = yypath; yypath = save->save; save->save = NULL; yyFreeState(save); } #endif /* YYBTYACC */ yyfreestack(&yystack); return (yyresult); } diff --git a/contrib/byacc/test/btyacc/varsyntax_calc1.tab.h b/contrib/byacc/test/btyacc/varsyntax_calc1.tab.h index 5c28ca8ef131..49e269cdb8a4 100644 --- a/contrib/byacc/test/btyacc/varsyntax_calc1.tab.h +++ b/contrib/byacc/test/btyacc/varsyntax_calc1.tab.h @@ -1,23 +1,23 @@ #ifndef _varsyntax_calc1__defines_h_ #define _varsyntax_calc1__defines_h_ #define DREG 257 #define VREG 258 #define CONST 259 #define UMINUS 260 #ifdef YYSTYPE #undef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 #endif #ifndef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 -typedef union YYSTYPE +typedef union { int ival; /* dreg & vreg array index values*/ double dval; /* floating point values*/ INTERVAL vval; /* interval values*/ } YYSTYPE; #endif /* !YYSTYPE_IS_DECLARED */ extern YYSTYPE varsyntax_calc1_lval; #endif /* _varsyntax_calc1__defines_h_ */ diff --git a/contrib/byacc/test/yacc/calc1.tab.c b/contrib/byacc/test/yacc/calc1.tab.c index b78999115ee5..c8c7b6cff9be 100644 --- a/contrib/byacc/test/yacc/calc1.tab.c +++ b/contrib/byacc/test/yacc/calc1.tab.c @@ -1,936 +1,936 @@ /* original parser id follows */ /* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ /* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ #define YYBYACC 1 #define YYMAJOR 2 #define YYMINOR 0 #define YYCHECK "yyyymmdd" #define YYEMPTY (-1) #define yyclearin (yychar = YYEMPTY) #define yyerrok (yyerrflag = 0) #define YYRECOVERING() (yyerrflag != 0) #define YYENOMEM (-2) #define YYEOF 0 #ifndef yyparse #define yyparse calc1_parse #endif /* yyparse */ #ifndef yylex #define yylex calc1_lex #endif /* yylex */ #ifndef yyerror #define yyerror calc1_error #endif /* yyerror */ #ifndef yychar #define yychar calc1_char #endif /* yychar */ #ifndef yyval #define yyval calc1_val #endif /* yyval */ #ifndef yylval #define yylval calc1_lval #endif /* yylval */ #ifndef yydebug #define yydebug calc1_debug #endif /* yydebug */ #ifndef yynerrs #define yynerrs calc1_nerrs #endif /* yynerrs */ #ifndef yyerrflag #define yyerrflag calc1_errflag #endif /* yyerrflag */ #ifndef yylhs #define yylhs calc1_lhs #endif /* yylhs */ #ifndef yylen #define yylen calc1_len #endif /* yylen */ #ifndef yydefred #define yydefred calc1_defred #endif /* yydefred */ #ifndef yydgoto #define yydgoto calc1_dgoto #endif /* yydgoto */ #ifndef yysindex #define yysindex calc1_sindex #endif /* yysindex */ #ifndef yyrindex #define yyrindex calc1_rindex #endif /* yyrindex */ #ifndef yygindex #define yygindex calc1_gindex #endif /* yygindex */ #ifndef yytable #define yytable calc1_table #endif /* yytable */ #ifndef yycheck #define yycheck calc1_check #endif /* yycheck */ #ifndef yyname #define yyname calc1_name #endif /* yyname */ #ifndef yyrule #define yyrule calc1_rule #endif /* yyrule */ #define YYPREFIX "calc1_" #define YYPURE 0 #line 2 "calc1.y" /* http://dinosaur.compilertools.net/yacc/index.html */ #include #include #include #include typedef struct interval { double lo, hi; } INTERVAL; INTERVAL vmul(double, double, INTERVAL); INTERVAL vdiv(double, double, INTERVAL); extern int yylex(void); static void yyerror(const char *s); int dcheck(INTERVAL); double dreg[26]; INTERVAL vreg[26]; #ifdef YYSTYPE #undef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 #endif #ifndef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 #line 31 "calc1.y" -typedef union YYSTYPE +typedef union { int ival; double dval; INTERVAL vval; } YYSTYPE; #endif /* !YYSTYPE_IS_DECLARED */ #line 141 "calc1.tab.c" /* compatibility with bison */ #ifdef YYPARSE_PARAM /* compatibility with FreeBSD */ # ifdef YYPARSE_PARAM_TYPE # define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) # else # define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) # endif #else # define YYPARSE_DECL() yyparse(void) #endif /* Parameters sent to lex. */ #ifdef YYLEX_PARAM # define YYLEX_DECL() yylex(void *YYLEX_PARAM) # define YYLEX yylex(YYLEX_PARAM) #else # define YYLEX_DECL() yylex(void) # define YYLEX yylex() #endif /* Parameters sent to yyerror. */ #ifndef YYERROR_DECL #define YYERROR_DECL() yyerror(const char *s) #endif #ifndef YYERROR_CALL #define YYERROR_CALL(msg) yyerror(msg) #endif extern int YYPARSE_DECL(); #define DREG 257 #define VREG 258 #define CONST 259 #define UMINUS 260 #define YYERRCODE 256 typedef int YYINT; static const YYINT calc1_lhs[] = { -1, 3, 3, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, }; static const YYINT calc1_len[] = { 2, 0, 2, 2, 2, 4, 4, 2, 1, 1, 3, 3, 3, 3, 2, 3, 1, 5, 1, 3, 3, 3, 3, 3, 3, 3, 3, 2, 3, }; static const YYINT calc1_defred[] = { 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 7, 0, 0, 9, 18, 14, 27, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 15, 0, 28, 0, 0, 0, 0, 12, 24, 13, 26, 0, 0, 23, 25, 14, 0, 0, 0, 0, 0, 5, 6, 0, 0, 0, 12, 13, 17, }; static const YYINT calc1_dgoto[] = { 7, 32, 9, 0, }; static const YYINT calc1_sindex[] = { -40, -8, -48, -47, 0, -37, -37, 0, 2, 17, 0, -34, -37, 0, 0, 0, 0, -25, 90, -37, -37, -37, -37, 0, -37, -37, -37, -37, 0, -34, -34, 25, 125, 31, 0, -34, 0, -11, 37, -11, 37, 0, 0, 0, 0, 37, 37, 0, 0, 0, 111, -34, -34, -34, -34, 0, 0, 118, 69, 69, 0, 0, 0, }; static const YYINT calc1_rindex[] = { 0, 0, 38, 44, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -9, 0, 0, 0, 0, 51, -3, 56, 61, 0, 0, 0, 0, 67, 72, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 78, 83, 0, 0, 0, }; static const YYINT calc1_gindex[] = { 0, 4, 124, 0, }; #define YYTABLESIZE 225 static const YYINT calc1_table[] = { 6, 16, 10, 6, 8, 5, 30, 20, 5, 15, 17, 29, 23, 11, 12, 31, 34, 21, 19, 35, 20, 0, 22, 37, 39, 41, 43, 28, 0, 0, 0, 21, 16, 49, 50, 55, 22, 0, 20, 57, 20, 56, 20, 0, 21, 19, 0, 20, 9, 22, 0, 0, 0, 0, 18, 58, 59, 60, 61, 26, 24, 10, 25, 0, 27, 0, 11, 53, 51, 0, 52, 22, 54, 26, 24, 0, 25, 19, 27, 26, 9, 9, 21, 9, 27, 9, 18, 18, 10, 18, 0, 18, 10, 11, 10, 10, 10, 11, 0, 11, 11, 11, 22, 0, 22, 0, 22, 0, 19, 0, 19, 53, 19, 21, 0, 21, 54, 21, 0, 10, 0, 10, 0, 10, 11, 0, 11, 0, 11, 16, 18, 36, 26, 24, 0, 25, 33, 27, 0, 0, 0, 0, 0, 38, 40, 42, 44, 0, 45, 46, 47, 48, 34, 53, 51, 0, 52, 0, 54, 62, 53, 51, 0, 52, 0, 54, 0, 21, 19, 0, 20, 0, 22, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 13, 14, 4, 13, 0, 4, }; static const YYINT calc1_check[] = { 40, 10, 10, 40, 0, 45, 40, 10, 45, 5, 6, 45, 10, 61, 61, 11, 41, 42, 43, 44, 45, -1, 47, 19, 20, 21, 22, 10, -1, -1, -1, 42, 41, 29, 30, 10, 47, -1, 41, 35, 43, 10, 45, -1, 42, 43, -1, 45, 10, 47, -1, -1, -1, -1, 10, 51, 52, 53, 54, 42, 43, 10, 45, -1, 47, -1, 10, 42, 43, -1, 45, 10, 47, 42, 43, -1, 45, 10, 47, 42, 42, 43, 10, 45, 47, 47, 42, 43, 10, 45, -1, 47, 41, 10, 43, 44, 45, 41, -1, 43, 44, 45, 41, -1, 43, -1, 45, -1, 41, -1, 43, 42, 45, 41, -1, 43, 47, 45, -1, 41, -1, 43, -1, 45, 41, -1, 43, -1, 45, 5, 6, 41, 42, 43, -1, 45, 12, 47, -1, -1, -1, -1, -1, 19, 20, 21, 22, -1, 24, 25, 26, 27, 41, 42, 43, -1, 45, -1, 47, 41, 42, 43, -1, 45, -1, 47, -1, 42, 43, -1, 45, -1, 47, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 256, 257, 258, 259, 257, 258, 259, 257, -1, 259, }; #define YYFINAL 7 #ifndef YYDEBUG #define YYDEBUG 0 #endif #define YYMAXTOKEN 260 #define YYUNDFTOKEN 266 #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) #if YYDEBUG static const char *const calc1_name[] = { "end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,"'('","')'","'*'","'+'","','","'-'",0,"'/'",0,0,0,0,0,0,0,0,0, 0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,"DREG","VREG","CONST","UMINUS",0,0,0,0,0,"illegal-symbol", }; static const char *const calc1_rule[] = { "$accept : line", "lines :", "lines : lines line", "line : dexp '\\n'", "line : vexp '\\n'", "line : DREG '=' dexp '\\n'", "line : VREG '=' vexp '\\n'", "line : error '\\n'", "dexp : CONST", "dexp : DREG", "dexp : dexp '+' dexp", "dexp : dexp '-' dexp", "dexp : dexp '*' dexp", "dexp : dexp '/' dexp", "dexp : '-' dexp", "dexp : '(' dexp ')'", "vexp : dexp", "vexp : '(' dexp ',' dexp ')'", "vexp : VREG", "vexp : vexp '+' vexp", "vexp : dexp '+' vexp", "vexp : vexp '-' vexp", "vexp : dexp '-' vexp", "vexp : vexp '*' vexp", "vexp : dexp '*' vexp", "vexp : vexp '/' vexp", "vexp : dexp '/' vexp", "vexp : '-' vexp", "vexp : '(' vexp ')'", }; #endif #if YYDEBUG int yydebug; #endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; int yynerrs; /* define the initial stack-sizes */ #ifdef YYSTACKSIZE #undef YYMAXDEPTH #define YYMAXDEPTH YYSTACKSIZE #else #ifdef YYMAXDEPTH #define YYSTACKSIZE YYMAXDEPTH #else #define YYSTACKSIZE 10000 #define YYMAXDEPTH 10000 #endif #endif #define YYINITSTACKSIZE 200 typedef struct { unsigned stacksize; YYINT *s_base; YYINT *s_mark; YYINT *s_last; YYSTYPE *l_base; YYSTYPE *l_mark; } YYSTACKDATA; /* variables for the parser stack */ static YYSTACKDATA yystack; #line 176 "calc1.y" /* beginning of subroutines section */ #define BSZ 50 /* buffer size for floating point numbers */ /* lexical analysis */ static void yyerror(const char *s) { fprintf(stderr, "%s\n", s); } int yylex(void) { int c; while ((c = getchar()) == ' ') { /* skip over blanks */ } if (isupper(c)) { yylval.ival = c - 'A'; return (VREG); } if (islower(c)) { yylval.ival = c - 'a'; return (DREG); } if (isdigit(c) || c == '.') { /* gobble up digits, points, exponents */ char buf[BSZ + 1], *cp = buf; int dot = 0, expr = 0; for (; (cp - buf) < BSZ; ++cp, c = getchar()) { *cp = (char) c; if (isdigit(c)) continue; if (c == '.') { if (dot++ || expr) return ('.'); /* will cause syntax error */ continue; } if (c == 'e') { if (expr++) return ('e'); /* will cause syntax error */ continue; } /* end of number */ break; } *cp = '\0'; if ((cp - buf) >= BSZ) printf("constant too long: truncated\n"); else ungetc(c, stdin); /* push back last char read */ yylval.dval = atof(buf); return (CONST); } return (c); } static INTERVAL hilo(double a, double b, double c, double d) { /* returns the smallest interval containing a, b, c, and d */ /* used by *, / routines */ INTERVAL v; if (a > b) { v.hi = a; v.lo = b; } else { v.hi = b; v.lo = a; } if (c > d) { if (c > v.hi) v.hi = c; if (d < v.lo) v.lo = d; } else { if (d > v.hi) v.hi = d; if (c < v.lo) v.lo = c; } return (v); } INTERVAL vmul(double a, double b, INTERVAL v) { return (hilo(a * v.hi, a * v.lo, b * v.hi, b * v.lo)); } int dcheck(INTERVAL v) { if (v.hi >= 0. && v.lo <= 0.) { printf("divisor interval contains 0.\n"); return (1); } return (0); } INTERVAL vdiv(double a, double b, INTERVAL v) { return (hilo(a / v.hi, a / v.lo, b / v.hi, b / v.lo)); } #line 493 "calc1.tab.c" #if YYDEBUG #include /* needed for printf */ #endif #include /* needed for malloc, etc */ #include /* needed for memset */ /* allocate initial stack or double stack size, up to YYMAXDEPTH */ static int yygrowstack(YYSTACKDATA *data) { int i; unsigned newsize; YYINT *newss; YYSTYPE *newvs; if ((newsize = data->stacksize) == 0) newsize = YYINITSTACKSIZE; else if (newsize >= YYMAXDEPTH) return YYENOMEM; else if ((newsize *= 2) > YYMAXDEPTH) newsize = YYMAXDEPTH; i = (int) (data->s_mark - data->s_base); newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); if (newss == NULL) return YYENOMEM; data->s_base = newss; data->s_mark = newss + i; newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); if (newvs == NULL) return YYENOMEM; data->l_base = newvs; data->l_mark = newvs + i; data->stacksize = newsize; data->s_last = data->s_base + newsize - 1; return 0; } #if YYPURE || defined(YY_NO_LEAKS) static void yyfreestack(YYSTACKDATA *data) { free(data->s_base); free(data->l_base); memset(data, 0, sizeof(*data)); } #else #define yyfreestack(data) /* nothing */ #endif #define YYABORT goto yyabort #define YYREJECT goto yyabort #define YYACCEPT goto yyaccept #define YYERROR goto yyerrlab int YYPARSE_DECL() { int yym, yyn, yystate; #if YYDEBUG const char *yys; if ((yys = getenv("YYDEBUG")) != NULL) { yyn = *yys; if (yyn >= '0' && yyn <= '9') yydebug = yyn - '0'; } #endif /* yym is set below */ /* yyn is set below */ yynerrs = 0; yyerrflag = 0; yychar = YYEMPTY; yystate = 0; #if YYPURE memset(&yystack, 0, sizeof(yystack)); #endif if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystack.s_mark = yystack.s_base; yystack.l_mark = yystack.l_base; yystate = 0; *yystack.s_mark = 0; yyloop: if ((yyn = yydefred[yystate]) != 0) goto yyreduce; if (yychar < 0) { yychar = YYLEX; if (yychar < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; printf("%sdebug: state %d, reading %d (%s)\n", YYPREFIX, yystate, yychar, yys); } #endif } if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) { #if YYDEBUG if (yydebug) printf("%sdebug: state %d, shifting to state %d\n", YYPREFIX, yystate, yytable[yyn]); #endif if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystate = yytable[yyn]; *++yystack.s_mark = yytable[yyn]; *++yystack.l_mark = yylval; yychar = YYEMPTY; if (yyerrflag > 0) --yyerrflag; goto yyloop; } if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) { yyn = yytable[yyn]; goto yyreduce; } if (yyerrflag != 0) goto yyinrecovery; YYERROR_CALL("syntax error"); goto yyerrlab; /* redundant goto avoids 'unused label' warning */ yyerrlab: ++yynerrs; yyinrecovery: if (yyerrflag < 3) { yyerrflag = 3; for (;;) { if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) { #if YYDEBUG if (yydebug) printf("%sdebug: state %d, error recovery shifting\ to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); #endif if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystate = yytable[yyn]; *++yystack.s_mark = yytable[yyn]; *++yystack.l_mark = yylval; goto yyloop; } else { #if YYDEBUG if (yydebug) printf("%sdebug: error recovery discarding state %d\n", YYPREFIX, *yystack.s_mark); #endif if (yystack.s_mark <= yystack.s_base) goto yyabort; --yystack.s_mark; --yystack.l_mark; } } } else { if (yychar == YYEOF) goto yyabort; #if YYDEBUG if (yydebug) { if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; printf("%sdebug: state %d, error recovery discards token %d (%s)\n", YYPREFIX, yystate, yychar, yys); } #endif yychar = YYEMPTY; goto yyloop; } yyreduce: #if YYDEBUG if (yydebug) printf("%sdebug: state %d, reducing by rule %d (%s)\n", YYPREFIX, yystate, yyn, yyrule[yyn]); #endif yym = yylen[yyn]; if (yym > 0) yyval = yystack.l_mark[1-yym]; else memset(&yyval, 0, sizeof yyval); switch (yyn) { case 3: #line 57 "calc1.y" { (void) printf("%15.8f\n", yystack.l_mark[-1].dval); } #line 697 "calc1.tab.c" break; case 4: #line 61 "calc1.y" { (void) printf("(%15.8f, %15.8f)\n", yystack.l_mark[-1].vval.lo, yystack.l_mark[-1].vval.hi); } #line 704 "calc1.tab.c" break; case 5: #line 65 "calc1.y" { dreg[yystack.l_mark[-3].ival] = yystack.l_mark[-1].dval; } #line 711 "calc1.tab.c" break; case 6: #line 69 "calc1.y" { vreg[yystack.l_mark[-3].ival] = yystack.l_mark[-1].vval; } #line 718 "calc1.tab.c" break; case 7: #line 73 "calc1.y" { yyerrok; } #line 725 "calc1.tab.c" break; case 9: #line 80 "calc1.y" { yyval.dval = dreg[yystack.l_mark[0].ival]; } #line 732 "calc1.tab.c" break; case 10: #line 84 "calc1.y" { yyval.dval = yystack.l_mark[-2].dval + yystack.l_mark[0].dval; } #line 739 "calc1.tab.c" break; case 11: #line 88 "calc1.y" { yyval.dval = yystack.l_mark[-2].dval - yystack.l_mark[0].dval; } #line 746 "calc1.tab.c" break; case 12: #line 92 "calc1.y" { yyval.dval = yystack.l_mark[-2].dval * yystack.l_mark[0].dval; } #line 753 "calc1.tab.c" break; case 13: #line 96 "calc1.y" { yyval.dval = yystack.l_mark[-2].dval / yystack.l_mark[0].dval; } #line 760 "calc1.tab.c" break; case 14: #line 100 "calc1.y" { yyval.dval = -yystack.l_mark[0].dval; } #line 767 "calc1.tab.c" break; case 15: #line 104 "calc1.y" { yyval.dval = yystack.l_mark[-1].dval; } #line 774 "calc1.tab.c" break; case 16: #line 110 "calc1.y" { yyval.vval.hi = yyval.vval.lo = yystack.l_mark[0].dval; } #line 781 "calc1.tab.c" break; case 17: #line 114 "calc1.y" { yyval.vval.lo = yystack.l_mark[-3].dval; yyval.vval.hi = yystack.l_mark[-1].dval; if ( yyval.vval.lo > yyval.vval.hi ) { (void) printf("interval out of order\n"); YYERROR; } } #line 794 "calc1.tab.c" break; case 18: #line 124 "calc1.y" { yyval.vval = vreg[yystack.l_mark[0].ival]; } #line 801 "calc1.tab.c" break; case 19: #line 128 "calc1.y" { yyval.vval.hi = yystack.l_mark[-2].vval.hi + yystack.l_mark[0].vval.hi; yyval.vval.lo = yystack.l_mark[-2].vval.lo + yystack.l_mark[0].vval.lo; } #line 809 "calc1.tab.c" break; case 20: #line 133 "calc1.y" { yyval.vval.hi = yystack.l_mark[-2].dval + yystack.l_mark[0].vval.hi; yyval.vval.lo = yystack.l_mark[-2].dval + yystack.l_mark[0].vval.lo; } #line 817 "calc1.tab.c" break; case 21: #line 138 "calc1.y" { yyval.vval.hi = yystack.l_mark[-2].vval.hi - yystack.l_mark[0].vval.lo; yyval.vval.lo = yystack.l_mark[-2].vval.lo - yystack.l_mark[0].vval.hi; } #line 825 "calc1.tab.c" break; case 22: #line 143 "calc1.y" { yyval.vval.hi = yystack.l_mark[-2].dval - yystack.l_mark[0].vval.lo; yyval.vval.lo = yystack.l_mark[-2].dval - yystack.l_mark[0].vval.hi; } #line 833 "calc1.tab.c" break; case 23: #line 148 "calc1.y" { yyval.vval = vmul( yystack.l_mark[-2].vval.lo, yystack.l_mark[-2].vval.hi, yystack.l_mark[0].vval ); } #line 840 "calc1.tab.c" break; case 24: #line 152 "calc1.y" { yyval.vval = vmul (yystack.l_mark[-2].dval, yystack.l_mark[-2].dval, yystack.l_mark[0].vval ); } #line 847 "calc1.tab.c" break; case 25: #line 156 "calc1.y" { if (dcheck(yystack.l_mark[0].vval)) YYERROR; yyval.vval = vdiv ( yystack.l_mark[-2].vval.lo, yystack.l_mark[-2].vval.hi, yystack.l_mark[0].vval ); } #line 855 "calc1.tab.c" break; case 26: #line 161 "calc1.y" { if (dcheck ( yystack.l_mark[0].vval )) YYERROR; yyval.vval = vdiv (yystack.l_mark[-2].dval, yystack.l_mark[-2].dval, yystack.l_mark[0].vval ); } #line 863 "calc1.tab.c" break; case 27: #line 166 "calc1.y" { yyval.vval.hi = -yystack.l_mark[0].vval.lo; yyval.vval.lo = -yystack.l_mark[0].vval.hi; } #line 871 "calc1.tab.c" break; case 28: #line 171 "calc1.y" { yyval.vval = yystack.l_mark[-1].vval; } #line 878 "calc1.tab.c" break; #line 880 "calc1.tab.c" } yystack.s_mark -= yym; yystate = *yystack.s_mark; yystack.l_mark -= yym; yym = yylhs[yyn]; if (yystate == 0 && yym == 0) { #if YYDEBUG if (yydebug) printf("%sdebug: after reduction, shifting from state 0 to\ state %d\n", YYPREFIX, YYFINAL); #endif yystate = YYFINAL; *++yystack.s_mark = YYFINAL; *++yystack.l_mark = yyval; if (yychar < 0) { yychar = YYLEX; if (yychar < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; printf("%sdebug: state %d, reading %d (%s)\n", YYPREFIX, YYFINAL, yychar, yys); } #endif } if (yychar == YYEOF) goto yyaccept; goto yyloop; } if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) yystate = yytable[yyn]; else yystate = yydgoto[yym]; #if YYDEBUG if (yydebug) printf("%sdebug: after reduction, shifting from state %d \ to state %d\n", YYPREFIX, *yystack.s_mark, yystate); #endif if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; *++yystack.s_mark = (YYINT) yystate; *++yystack.l_mark = yyval; goto yyloop; yyoverflow: YYERROR_CALL("yacc stack overflow"); yyabort: yyfreestack(&yystack); return (1); yyaccept: yyfreestack(&yystack); return (0); } diff --git a/contrib/byacc/test/yacc/calc1.tab.h b/contrib/byacc/test/yacc/calc1.tab.h index dd493d013c26..c0633e37dfa8 100644 --- a/contrib/byacc/test/yacc/calc1.tab.h +++ b/contrib/byacc/test/yacc/calc1.tab.h @@ -1,18 +1,18 @@ #define DREG 257 #define VREG 258 #define CONST 259 #define UMINUS 260 #ifdef YYSTYPE #undef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 #endif #ifndef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 -typedef union YYSTYPE +typedef union { int ival; double dval; INTERVAL vval; } YYSTYPE; #endif /* !YYSTYPE_IS_DECLARED */ extern YYSTYPE calc1_lval; diff --git a/contrib/byacc/test/yacc/expr.oxout.tab.c b/contrib/byacc/test/yacc/expr.oxout.tab.c index 1e2ad2cab7bd..56e3b59d6f44 100644 --- a/contrib/byacc/test/yacc/expr.oxout.tab.c +++ b/contrib/byacc/test/yacc/expr.oxout.tab.c @@ -1,1970 +1,1970 @@ /* original parser id follows */ /* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ /* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ #define YYBYACC 1 #define YYMAJOR 2 #define YYMINOR 0 #define YYCHECK "yyyymmdd" #define YYEMPTY (-1) #define yyclearin (yychar = YYEMPTY) #define yyerrok (yyerrflag = 0) #define YYRECOVERING() (yyerrflag != 0) #define YYENOMEM (-2) #define YYEOF 0 #ifndef yyparse #define yyparse expr_oxout_parse #endif /* yyparse */ #ifndef yylex #define yylex expr_oxout_lex #endif /* yylex */ #ifndef yyerror #define yyerror expr_oxout_error #endif /* yyerror */ #ifndef yychar #define yychar expr_oxout_char #endif /* yychar */ #ifndef yyval #define yyval expr_oxout_val #endif /* yyval */ #ifndef yylval #define yylval expr_oxout_lval #endif /* yylval */ #ifndef yydebug #define yydebug expr_oxout_debug #endif /* yydebug */ #ifndef yynerrs #define yynerrs expr_oxout_nerrs #endif /* yynerrs */ #ifndef yyerrflag #define yyerrflag expr_oxout_errflag #endif /* yyerrflag */ #ifndef yylhs #define yylhs expr_oxout_lhs #endif /* yylhs */ #ifndef yylen #define yylen expr_oxout_len #endif /* yylen */ #ifndef yydefred #define yydefred expr_oxout_defred #endif /* yydefred */ #ifndef yydgoto #define yydgoto expr_oxout_dgoto #endif /* yydgoto */ #ifndef yysindex #define yysindex expr_oxout_sindex #endif /* yysindex */ #ifndef yyrindex #define yyrindex expr_oxout_rindex #endif /* yyrindex */ #ifndef yygindex #define yygindex expr_oxout_gindex #endif /* yygindex */ #ifndef yytable #define yytable expr_oxout_table #endif /* yytable */ #ifndef yycheck #define yycheck expr_oxout_check #endif /* yycheck */ #ifndef yyname #define yyname expr_oxout_name #endif /* yyname */ #ifndef yyrule #define yyrule expr_oxout_rule #endif /* yyrule */ #define YYPREFIX "expr_oxout_" #define YYPURE 0 #line 5 "expr.oxout.y" #include #include #line 8 "expr.Y" #include "expr.oxout.h" #include extern int yylex(void); extern void yyerror(const char *); #line 27 "expr.oxout.y" #include #define yyyR USHRT_MAX #ifdef YYSTYPE #undef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 #endif #ifndef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 #line 31 "expr.oxout.y" -typedef union YYSTYPE { +typedef union { struct yyyOxAttrbs { struct yyyStackItem *yyyOxStackItem; } yyyOxAttrbs; } YYSTYPE; #endif /* !YYSTYPE_IS_DECLARED */ #line 38 "expr.oxout.y" #include #include static int yyyYok = 1; extern yyyFT yyyRCIL[]; void yyyExecuteRRsection(yyyGNT *rootNode); void yyyYoxInit(void); void yyyDecorate(void); struct yyyOxAttrbs; /* hack required to compensate for 'msta' behavior */ void yyyGenIntNode(long yyyProdNum, int yyyRHSlength, int yyyNattrbs, struct yyyOxAttrbs *yyval_OxAttrbs, ...); void yyyAdjustINRC(long yyyProdNum, int yyyRHSlength, long startP, long stopP, struct yyyOxAttrbs *yyval_OxAttrbs, ...); void yyyCheckUnsolvedInstTrav(yyyGNT *rootNode,long *nNZrc,long *cycleSum); void yyyUnsolvedInstSearchTrav(yyyGNT *pNode); void yyyUnsolvedInstSearchTravAux(yyyGNT *pNode); void yyyabort(void); #line 146 "expr.oxout.tab.c" /* compatibility with bison */ #ifdef YYPARSE_PARAM /* compatibility with FreeBSD */ # ifdef YYPARSE_PARAM_TYPE # define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) # else # define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) # endif #else # define YYPARSE_DECL() yyparse(void) #endif /* Parameters sent to lex. */ #ifdef YYLEX_PARAM # define YYLEX_DECL() yylex(void *YYLEX_PARAM) # define YYLEX yylex(YYLEX_PARAM) #else # define YYLEX_DECL() yylex(void) # define YYLEX yylex() #endif /* Parameters sent to yyerror. */ #ifndef YYERROR_DECL #define YYERROR_DECL() yyerror(const char *s) #endif #ifndef YYERROR_CALL #define YYERROR_CALL(msg) yyerror(msg) #endif extern int YYPARSE_DECL(); #define ID 257 #define CONST 258 #define YYERRCODE 256 typedef int YYINT; static const YYINT expr_oxout_lhs[] = { -1, 2, 0, 1, 3, 3, 3, 3, 3, 3, 3, }; static const YYINT expr_oxout_len[] = { 2, 0, 2, 1, 3, 3, 3, 3, 3, 1, 1, }; static const YYINT expr_oxout_defred[] = { 1, 0, 0, 9, 10, 0, 2, 0, 0, 0, 0, 0, 0, 8, 0, 0, 4, 0, }; static const YYINT expr_oxout_dgoto[] = { 1, 6, 2, 7, }; static const YYINT expr_oxout_sindex[] = { 0, 0, -40, 0, 0, -40, 0, -18, -24, -40, -40, -40, -40, 0, -37, -37, 0, -39, }; static const YYINT expr_oxout_rindex[] = { 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 2, 8, 0, 1, }; static const YYINT expr_oxout_gindex[] = { 0, 0, 0, 4, }; #define YYTABLESIZE 218 static const YYINT expr_oxout_table[] = { 5, 6, 5, 11, 0, 11, 3, 0, 7, 8, 12, 0, 0, 14, 15, 16, 17, 13, 11, 9, 0, 10, 0, 12, 11, 9, 0, 10, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 5, 6, 5, 6, 5, 6, 7, 0, 7, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 4, }; static const YYINT expr_oxout_check[] = { 40, 0, 0, 42, -1, 42, 0, -1, 0, 5, 47, -1, -1, 9, 10, 11, 12, 41, 42, 43, -1, 45, -1, 47, 42, 43, -1, 45, -1, 47, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 41, 41, 43, 43, 45, 45, 47, 41, -1, 43, -1, 45, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 257, 258, }; #define YYFINAL 1 #ifndef YYDEBUG #define YYDEBUG 0 #endif #define YYMAXTOKEN 258 #define YYUNDFTOKEN 264 #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) #if YYDEBUG static const char *const expr_oxout_name[] = { "end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"ID", "CONST",0,0,0,0,0,"illegal-symbol", }; static const char *const expr_oxout_rule[] = { "$accept : yyyAugNonterm", "$$1 :", "yyyAugNonterm : $$1 s", "s : expr", "expr : expr '*' expr", "expr : expr '+' expr", "expr : expr '/' expr", "expr : expr '-' expr", "expr : '(' expr ')'", "expr : ID", "expr : CONST", }; #endif #if YYDEBUG int yydebug; #endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; int yynerrs; /* define the initial stack-sizes */ #ifdef YYSTACKSIZE #undef YYMAXDEPTH #define YYMAXDEPTH YYSTACKSIZE #else #ifdef YYMAXDEPTH #define YYSTACKSIZE YYMAXDEPTH #else #define YYSTACKSIZE 10000 #define YYMAXDEPTH 10000 #endif #endif #define YYINITSTACKSIZE 200 typedef struct { unsigned stacksize; YYINT *s_base; YYINT *s_mark; YYINT *s_last; YYSTYPE *l_base; YYSTYPE *l_mark; } YYSTACKDATA; /* variables for the parser stack */ static YYSTACKDATA yystack; #line 53 "expr.Y" int yyparse(void); int main() {yyparse(); } #line 138 "expr.oxout.y" long yyySSALspaceSize = 20000; long yyyRSmaxSize = 1000; long yyyTravStackMaxSize = 2000; struct yyySolvedSAlistCell {yyyWAT attrbNum; long next; }; #define yyyLambdaSSAL 0 long yyySSALCfreeList = yyyLambdaSSAL; long yyyNewSSALC = 1; struct yyySolvedSAlistCell *yyySSALspace; long yyyNbytesStackStg; yyyFT yyyRCIL[1]; short yyyIIIEL[] = {0, 0,2,6,10,14,18,22,24, }; long yyyIIEL[] = { 0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0, 1,1, }; long yyyIEL[] = { 0,0,0, }; yyyFT yyyEntL[1]; void yyyfatal(char *msg) {fputs(msg,stderr);exit(-1);} #define yyySSALof 'S' #define yyyRSof 'q' #define yyyTSof 't' void yyyHandleOverflow(char which) {char *msg1 = "?", *msg2; long oldSize = 0, newSize; switch(which) { case yyySSALof : msg1 = "SSAL overflow: "; oldSize = yyySSALspaceSize; break; case yyyRSof : msg1 = "ready set overflow: "; oldSize = yyyRSmaxSize; break; case yyyTSof : msg1 = "traversal stack overflow: "; oldSize = yyyTravStackMaxSize; break; default :; } newSize = (3*oldSize)/2; if (newSize < 100) newSize = 100; fputs(msg1,stderr); fprintf(stderr,"size was %ld.\n",oldSize); msg2 = " Have to modify evaluator: -Y%c%ld.\n"; fprintf(stderr,msg2,which,newSize); exit(-1); } void yyySignalEnts(yyyGNT *node,long startP,long stopP) {yyyGNT *dumNode; while (startP < stopP) { if (!yyyEntL[startP]) dumNode = node; else dumNode = (node->cL)[yyyEntL[startP]-1]; if (!(--((dumNode->refCountList)[yyyEntL[startP+1]] ) ) ) { if (++yyyRSTop == yyyAfterRS) {yyyHandleOverflow(yyyRSof); break; } yyyRSTop->node = dumNode; yyyRSTop->whichSym = yyyEntL[startP]; yyyRSTop->wa = yyyEntL[startP+1]; } startP += 2; } } void yyySolveAndSignal() { long yyyiDum,*yyypL; int yyyws,yyywa; yyyGNT *yyyRSTopN,*yyyRefN; yyyParent yyyRSTopNp; yyyRSTopNp = (yyyRSTopN = yyyRSTop->node)->parent; yyyRefN= (yyyws = (yyyRSTop->whichSym))?yyyRSTopNp.noderef:yyyRSTopN; yyywa = yyyRSTop->wa; yyyRSTop--; switch(yyyRefN->prodNum) { case 1: /***yacc rule 1***/ switch (yyyws) { } break; case 2: /***yacc rule 2***/ switch (yyyws) { } break; case 3: /***yacc rule 3***/ switch (yyyws) { } break; case 4: /***yacc rule 4***/ switch (yyyws) { } break; case 5: /***yacc rule 5***/ switch (yyyws) { } break; case 6: /***yacc rule 6***/ switch (yyyws) { } break; case 7: /***yacc rule 7***/ switch (yyyws) { case 1: /**/ switch (yyywa) { } break; } break; case 8: /***yacc rule 8***/ switch (yyyws) { case 1: /**/ switch (yyywa) { } break; } break; } /* switch */ if (yyyws) /* the just-solved instance was inherited. */ {if (yyyRSTopN->prodNum) {yyyiDum = yyyIIEL[yyyIIIEL[yyyRSTopN->prodNum]] + yyywa; yyySignalEnts(yyyRSTopN,yyyIEL[yyyiDum], yyyIEL[yyyiDum+1] ); } } else /* the just-solved instance was synthesized. */ {if (!(yyyRSTopN->parentIsStack)) /* node has a parent. */ {yyyiDum = yyyIIEL[yyyIIIEL[yyyRSTopNp.noderef->prodNum] + yyyRSTopN->whichSym ] + yyywa; yyySignalEnts(yyyRSTopNp.noderef, yyyIEL[yyyiDum], yyyIEL[yyyiDum+1] ); } else /* node is still on the stack--it has no parent yet. */ {yyypL = &(yyyRSTopNp.stackref->solvedSAlist); if (yyySSALCfreeList == yyyLambdaSSAL) {yyySSALspace[yyyNewSSALC].next = *yyypL; if ((*yyypL = yyyNewSSALC++) == yyySSALspaceSize) yyyHandleOverflow(yyySSALof); } else {yyyiDum = yyySSALCfreeList; yyySSALCfreeList = yyySSALspace[yyySSALCfreeList].next; yyySSALspace[yyyiDum].next = *yyypL; *yyypL = yyyiDum; } yyySSALspace[*yyypL].attrbNum = yyywa; } } } /* yyySolveAndSignal */ #define condStg unsigned int conds; #define yyyClearConds {yyyTST->conds = 0;} #define yyySetCond(n) {yyyTST->conds += (1<<(n));} #define yyyCond(n) ((yyyTST->conds & (1<<(n)))?1:0) struct yyyTravStackItem {yyyGNT *node; char isReady; condStg }; void yyyDoTraversals(yyyGNT *rootNode) {struct yyyTravStackItem *yyyTravStack,*yyyTST,*yyyAfterTravStack; yyyGNT *yyyTSTn,**yyyCLptr2; int yyyi,yyyRL,yyyPass; int i; if (!yyyYok) return; if ((yyyTravStack = ((struct yyyTravStackItem *) calloc((size_t)yyyTravStackMaxSize, (size_t)sizeof(struct yyyTravStackItem) ) ) ) == (struct yyyTravStackItem *)NULL ) {fputs("malloc error in traversal stack allocation\n",stderr); exit(-1); } yyyAfterTravStack = yyyTravStack + yyyTravStackMaxSize; yyyTravStack++; for (yyyi=0; yyyi<2; yyyi++) { yyyTST = yyyTravStack; yyyTST->node = rootNode; yyyTST->isReady = 0; yyyClearConds while(yyyTST >= yyyTravStack) {yyyTSTn = yyyTST->node; if (yyyTST->isReady) {yyyPass = 1; goto yyyTravSwitch; yyyTpop: yyyTST--; } else {yyyPass = 0; goto yyyTravSwitch; yyyTpush: yyyTST->isReady = 1; if (yyyTSTn->prodNum) {if (yyyRL) {yyyCLptr2 = yyyTSTn->cL; i = yyyTSTn->cLlen; while (i--) {if (++yyyTST == yyyAfterTravStack) yyyHandleOverflow(yyyTSof); else {yyyTST->node = *yyyCLptr2; yyyTST->isReady = 0; yyyClearConds } yyyCLptr2++; } } /* right to left */ else /* left to right */ {i = yyyTSTn->cLlen; yyyCLptr2 = yyyTSTn->cL + i; while (i--) {yyyCLptr2--; if (++yyyTST == yyyAfterTravStack) yyyHandleOverflow(yyyTSof); else {yyyTST->node = *yyyCLptr2; yyyTST->isReady = 0; yyyClearConds } } } /* left to right */ } } /* else */ continue; yyyTravSwitch: switch(yyyTSTn->prodNum) { case 1: switch(yyyi) { case 0: switch(yyyPass) { case 0: yyyRL = 0;yyySetCond(0) if (! #line 24 "expr.Y" (1) #line 444 "expr.oxout.y" ) yyySetCond(1) yyySetCond(2) case 1: if (yyyCond(0) != yyyPass) { #line 24 "expr.Y" #line 453 "expr.oxout.y" } if (yyyCond(1) != yyyPass) { #line 24 "expr.Y" printf("\n"); #line 459 "expr.oxout.y" } if (yyyCond(2) != yyyPass) { #line 25 "expr.Y" printf("prefix: "); #line 465 "expr.oxout.y" } break; } break; case 1: switch(yyyPass) { case 0: yyyRL = 0; if ( #line 23 "expr.Y" (1) #line 477 "expr.oxout.y" ) yyySetCond(2) case 1: if (yyyCond(0) != yyyPass) { #line 22 "expr.Y" printf("\n"); #line 486 "expr.oxout.y" } if (yyyCond(1) != yyyPass) { #line 23 "expr.Y" #line 491 "expr.oxout.y" } if (yyyCond(2) != yyyPass) { #line 23 "expr.Y" printf("postfix: "); #line 497 "expr.oxout.y" } break; } break; } break; case 2: switch(yyyi) { case 0: switch(yyyPass) { case 0: yyyRL = 0;yyySetCond(0) case 1: if (yyyCond(0) != yyyPass) { #line 29 "expr.Y" printf(" * "); #line 518 "expr.oxout.y" } break; } break; case 1: switch(yyyPass) { case 0: yyyRL = 0; case 1: if (yyyCond(0) != yyyPass) { #line 28 "expr.Y" printf(" * "); #line 533 "expr.oxout.y" } break; } break; } break; case 3: switch(yyyi) { case 0: switch(yyyPass) { case 0: yyyRL = 0;yyySetCond(0) case 1: if (yyyCond(0) != yyyPass) { #line 32 "expr.Y" printf(" + "); #line 554 "expr.oxout.y" } break; } break; case 1: switch(yyyPass) { case 0: yyyRL = 0; case 1: if (yyyCond(0) != yyyPass) { #line 33 "expr.Y" printf(" + "); #line 569 "expr.oxout.y" } break; } break; } break; case 4: switch(yyyi) { case 0: switch(yyyPass) { case 0: yyyRL = 0;yyySetCond(0) case 1: if (yyyCond(0) != yyyPass) { #line 37 "expr.Y" printf(" / "); #line 590 "expr.oxout.y" } break; } break; case 1: switch(yyyPass) { case 0: yyyRL = 0; case 1: if (yyyCond(0) != yyyPass) { #line 36 "expr.Y" printf(" / "); #line 605 "expr.oxout.y" } break; } break; } break; case 5: switch(yyyi) { case 0: switch(yyyPass) { case 0: yyyRL = 0;yyySetCond(0) case 1: if (yyyCond(0) != yyyPass) { #line 41 "expr.Y" printf(" - "); #line 626 "expr.oxout.y" } break; } break; case 1: switch(yyyPass) { case 0: yyyRL = 0; case 1: if (yyyCond(0) != yyyPass) { #line 40 "expr.Y" printf(" - "); #line 641 "expr.oxout.y" } break; } break; } break; case 6: switch(yyyi) { case 0: switch(yyyPass) { case 0: yyyRL = 0; case 1: break; } break; case 1: switch(yyyPass) { case 0: yyyRL = 0; case 1: break; } break; } break; case 7: switch(yyyi) { case 0: switch(yyyPass) { case 0: yyyRL = 0;yyySetCond(0) case 1: if (yyyCond(0) != yyyPass) { #line 46 "expr.Y" printf(" %s ",yyyTSTn->cL[0]->yyyAttrbs.yyyAttrb1.lexeme); #line 685 "expr.oxout.y" } break; } break; case 1: switch(yyyPass) { case 0: yyyRL = 0; case 1: if (yyyCond(0) != yyyPass) { #line 45 "expr.Y" printf(" %s ",yyyTSTn->cL[0]->yyyAttrbs.yyyAttrb1.lexeme); #line 700 "expr.oxout.y" } break; } break; } break; case 8: switch(yyyi) { case 0: switch(yyyPass) { case 0: yyyRL = 0;yyySetCond(0) case 1: if (yyyCond(0) != yyyPass) { #line 50 "expr.Y" printf(" %s ",yyyTSTn->cL[0]->yyyAttrbs.yyyAttrb1.lexeme); #line 721 "expr.oxout.y" } break; } break; case 1: switch(yyyPass) { case 0: yyyRL = 0; case 1: if (yyyCond(0) != yyyPass) { #line 49 "expr.Y" printf(" %s ",yyyTSTn->cL[0]->yyyAttrbs.yyyAttrb1.lexeme); #line 736 "expr.oxout.y" } break; } break; } break; } /* switch */ if (yyyPass) goto yyyTpop; else goto yyyTpush; } /* while */ } /* for */ } /* yyyDoTraversals */ void yyyExecuteRRsection(yyyGNT *rootNode) { int yyyi; long cycleSum = 0; long nNZrc = 0; if (!yyyYok) return; yyyCheckUnsolvedInstTrav(rootNode,&nNZrc,&cycleSum); if (nNZrc) { fputs("\n\n\n**********\n",stderr); fputs("cycle detected in completed parse tree",stderr); fputs(" after decoration.\n",stderr); #if CYCLE_VERBOSE fprintf(stderr, "number of unsolved attribute instances == %ld.\n", nNZrc ); fprintf(stderr, "total number of remaining dependencies == %ld.\n", cycleSum ); fputs("average number of remaining dependencies\n",stderr); fprintf(stderr," per unsolved instance == %f.\n", ((float)(cycleSum)/(float)(nNZrc)) ); #endif fprintf(stderr, "searching parse tree for %ld unsolved instances:\n", nNZrc ); yyyUnsolvedInstSearchTravAux(rootNode); } yyyDoTraversals(rootNode); } /* yyyExecuteRRsection */ yyyWAT yyyLRCIL[2] = {0,0, }; void yyyYoxInit(void) { static int yyyInitDone = 0; if (yyyInitDone) return; if ((yyyRS = (yyyRSitem *) calloc((size_t)(yyyRSmaxSize+1), (size_t)sizeof(yyyRSitem)) ) == ((yyyRSitem *) NULL) ) yyyfatal("malloc error in ox ready set space allocation\n"); yyyRS++; yyyAfterRS = yyyRS + yyyRSmaxSize; if ((yyySSALspace = (struct yyySolvedSAlistCell *) calloc((size_t)(yyySSALspaceSize+1), (size_t)sizeof(struct yyySolvedSAlistCell)) ) == ((struct yyySolvedSAlistCell *) NULL) ) yyyfatal("malloc error in stack solved list space allocation\n"); yyyInitDone = 1; yyyRSTop = yyyRS - 1; } /* yyyYoxInit */ void yyyDecorate(void) { while (yyyRSTop >= yyyRS) yyySolveAndSignal(); } void yyyGenIntNode(long yyyProdNum, int yyyRHSlength, int yyyNattrbs, struct yyyOxAttrbs *yyval_OxAttrbs, ...) {yyyWST i; yyySIT **yyyOxStackItem = &yyval_OxAttrbs->yyyOxStackItem; yyyGNT *gnpDum; va_list ap; *yyyOxStackItem = (yyySIT *) malloc((size_t)sizeof(yyySIT)); if (*yyyOxStackItem == (yyySIT *) NULL) yyyfatal("malloc error in ox yacc semantic stack space allocation\n"); (*yyyOxStackItem)->node = (yyyGNT *) malloc((size_t)sizeof(yyyGNT)); if ((*yyyOxStackItem)->node == (yyyGNT *) NULL) yyyfatal("malloc error in ox node space allocation\n"); (*yyyOxStackItem)->solvedSAlist = yyyLambdaSSAL; (*yyyOxStackItem)->node->parent.stackref = *yyyOxStackItem; (*yyyOxStackItem)->node->parentIsStack = 1; (*yyyOxStackItem)->node->cLlen = yyyRHSlength; (*yyyOxStackItem)->node->cL = (yyyGNT **) calloc((size_t)yyyRHSlength, (size_t)sizeof(yyyGNT *)); if ((*yyyOxStackItem)->node->cL == (yyyGNT **) NULL) yyyfatal("malloc error in ox child list space allocation\n"); (*yyyOxStackItem)->node->refCountListLen = yyyNattrbs; (*yyyOxStackItem)->node->refCountList = (yyyRCT *) calloc((size_t)yyyNattrbs, (size_t)sizeof(yyyRCT)); if ((*yyyOxStackItem)->node->refCountList == (yyyRCT *) NULL) yyyfatal("malloc error in ox reference count list space allocation\n"); (*yyyOxStackItem)->node->prodNum = (int) yyyProdNum; va_start(ap, yyval_OxAttrbs); for (i=1;i<=yyyRHSlength;i++) {yyySIT *yaccStDum = va_arg(ap,struct yyyOxAttrbs *)->yyyOxStackItem; gnpDum = (*yyyOxStackItem)->node->cL[i-1] = yaccStDum->node; gnpDum->whichSym = i; gnpDum->parent.noderef = (*yyyOxStackItem)->node; gnpDum->parentIsStack = 0; } va_end(ap); } #define yyyDECORfREQ 50 void yyyAdjustINRC(long yyyProdNum, int yyyRHSlength, long startP, long stopP, struct yyyOxAttrbs *yyval_OxAttrbs, ...) {yyyWST i; yyySIT *yyyOxStackItem = yyval_OxAttrbs->yyyOxStackItem; long SSALptr,SSALptrHead,*cPtrPtr; long *pL; yyyGNT *gnpDum; long iTemp; long nextP; static unsigned short intNodeCount = yyyDECORfREQ; va_list ap; nextP = startP; while (nextP < stopP) {if (yyyRCIL[nextP] == yyyR) {(yyyOxStackItem->node->refCountList)[yyyRCIL[nextP+1]] = yyyRCIL[nextP+2]; } else {(((yyyOxStackItem->node->cL)[yyyRCIL[nextP]])->refCountList)[yyyRCIL[nextP+1]] = yyyRCIL[nextP+2]; } nextP += 3; } pL = yyyIIEL + yyyIIIEL[yyyProdNum]; va_start(ap, yyval_OxAttrbs); for (i=1;i<=yyyRHSlength;i++) {yyySIT *yaccStDum = va_arg(ap,struct yyyOxAttrbs *)->yyyOxStackItem; pL++; SSALptrHead = SSALptr = *(cPtrPtr = &(yaccStDum->solvedSAlist)); if (SSALptr != yyyLambdaSSAL) {*cPtrPtr = yyyLambdaSSAL; do { iTemp = (*pL+yyySSALspace[SSALptr].attrbNum); yyySignalEnts(yyyOxStackItem->node, yyyIEL[iTemp], yyyIEL[iTemp+1] ); SSALptr = *(cPtrPtr = &(yyySSALspace[SSALptr].next)); } while (SSALptr != yyyLambdaSSAL); *cPtrPtr = yyySSALCfreeList; yyySSALCfreeList = SSALptrHead; } } va_end(ap); nextP = startP + 2; while (nextP < stopP) {if (!yyyRCIL[nextP]) {if (yyyRCIL[nextP-2] == yyyR) {pL = &(yyyOxStackItem->solvedSAlist); if (yyySSALCfreeList == yyyLambdaSSAL) {yyySSALspace[yyyNewSSALC].next = *pL; if ((*pL = yyyNewSSALC++) == yyySSALspaceSize) yyyHandleOverflow(yyySSALof); } else {iTemp = yyySSALCfreeList; yyySSALCfreeList = yyySSALspace[yyySSALCfreeList].next; yyySSALspace[iTemp].next = *pL; *pL = iTemp; } yyySSALspace[*pL].attrbNum = yyyRCIL[nextP-1]; } else {if ((gnpDum = (yyyOxStackItem->node->cL)[yyyRCIL[nextP-2]])->prodNum != 0) { iTemp = yyyIIEL[yyyIIIEL[gnpDum->prodNum]] + yyyRCIL[nextP-1]; yyySignalEnts(gnpDum, yyyIEL[iTemp], yyyIEL[iTemp+1] ); } } } nextP += 3; } if (!--intNodeCount) {intNodeCount = yyyDECORfREQ; yyyDecorate(); } } void yyyGenLeaf(int nAttrbs,int typeNum,long startP,long stopP,YYSTYPE *mylval) {yyyRCT *rcPdum; yyySIT **yyyOxStackItem = &mylval->yyyOxAttrbs.yyyOxStackItem; (*yyyOxStackItem) = (yyySIT *) malloc((size_t)sizeof(yyySIT)); if ((*yyyOxStackItem) == (yyySIT *) NULL) yyyfatal("malloc error in ox yacc semantic stack space allocation\n"); (*yyyOxStackItem)->node = (yyyGNT *) malloc((size_t)sizeof(yyyGNT)) ; if ((*yyyOxStackItem)->node == (yyyGNT *) NULL) yyyfatal("malloc error in ox node space allocation\n"); (*yyyOxStackItem)->solvedSAlist = yyyLambdaSSAL; (*yyyOxStackItem)->node->parent.stackref = *yyyOxStackItem; (*yyyOxStackItem)->node->parentIsStack = 1; (*yyyOxStackItem)->node->cLlen = 0; (*yyyOxStackItem)->node->cL = (yyyGNT **)NULL; (*yyyOxStackItem)->node->refCountListLen = nAttrbs; rcPdum = (*yyyOxStackItem)->node->refCountList = (yyyRCT *) calloc((size_t)nAttrbs, (size_t)sizeof(yyyRCT)); if (rcPdum == (yyyRCT *) NULL) yyyfatal("malloc error in ox reference count list space allocation\n"); while (startP < stopP) rcPdum[yyyLRCIL[startP++]] = 0; (*yyyOxStackItem)->node->prodNum = 0; (*yyyOxStackItem)->node->whichSym = 0; } void yyyabort(void) {yyyYok = 0; } #define yyyLastProdNum 8 #define yyyNsorts 1 int yyyProdsInd[] = { 0, 0, 2, 6, 10, 14, 18, 22, 24, 26, }; int yyyProds[][2] = { { 116, 0},{ 462, 0},{ 462, 0},{ 462, 0},{ 412, 0}, { 462, 0},{ 462, 0},{ 462, 0},{ 420, 0},{ 462, 0}, { 462, 0},{ 462, 0},{ 452, 0},{ 462, 0},{ 462, 0}, { 462, 0},{ 436, 0},{ 462, 0},{ 462, 0},{ 396, 0}, { 462, 0},{ 404, 0},{ 462, 0},{ 619, 1},{ 462, 0}, { 567, 1}, }; int yyySortsInd[] = { 0, 0, 1, }; int yyySorts[] = { 413, }; char *yyyStringTab[] = { 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,"s",0,0,0, 0,0,"y",0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,"LRpre",0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,"'('",0,0,0, 0,0,0,0,"')'", 0,0,0,0,0, 0,0,"'*'","lexeme",0, 0,0,0,0,0, "'+'",0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,"'-'",0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,"'/'",0,0, 0,0,0,0,0, 0,0,"expr",0,0, 0,0,0,0,0, 0,0,0,0,0, 0,"printf",0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,"CONST","LRpost",0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,"ID", 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0, }; #define yyySizeofProd(num) (yyyProdsInd[(num)+1] - yyyProdsInd[(num)]) #define yyyGSoccurStr(prodNum,symPos) \ (yyyStringTab[yyyProds[yyyProdsInd[(prodNum)] + (symPos)][0]]) #define yyySizeofSort(num) (yyySortsInd[(num)+1] - yyySortsInd[(num)]) #define yyySortOf(prodNum,symPos) \ (yyyProds[yyyProdsInd[(prodNum)] + (symPos)][1]) #define yyyAttrbStr(prodNum,symPos,attrbNum) \ (yyyStringTab[yyySorts[yyySortsInd[yyySortOf(prodNum,symPos)] + \ (attrbNum) \ ] \ ] \ ) void yyyShowProd(int i) {int j,nSyms; nSyms = yyySizeofProd(i); for (j=0; j\n",stderr); else putc('\n',stderr); } } } void yyyCheckNodeInstancesSolved(yyyGNT *np) {int mysort,sortSize,i,prodNum,symPos,inTerminalNode; int nUnsolvedInsts = 0; if (np->prodNum != 0) {inTerminalNode = 0; prodNum = np->prodNum; symPos = 0; } else {inTerminalNode = 1; prodNum = np->parent.noderef->prodNum; symPos = np->whichSym; } mysort = yyySortOf(prodNum,symPos); sortSize = yyySizeofSort(mysort); for (i=0; irefCountList)[i] != 0) nUnsolvedInsts += 1; if (nUnsolvedInsts) {fprintf(stderr, "\nFound node that has %d unsolved attribute instance(s).\n", nUnsolvedInsts ); fprintf(stderr,"Node is labeled \"%s\".\n", yyyGSoccurStr(prodNum,symPos)); if (inTerminalNode) {fputs("Node is terminal. Its parent production is:\n ",stderr); yyyShowProd(prodNum); } else {fputs("Node is nonterminal. ",stderr); if (!(np->parentIsStack)) {fprintf(stderr, "Node is %dth child in its parent production:\n ", np->whichSym ); yyyShowProd(np->parent.noderef->prodNum); } fputs("Node is on left hand side of this production:\n ",stderr); yyyShowProd(np->prodNum); } fputs("The following instances are unsolved:\n",stderr); for (i=0; irefCountList)[i] != 0) fprintf(stderr," %-16s still has %1d dependencies.\n", yyyAttrbStr(prodNum,symPos,i),(np->refCountList)[i]); } } void yyyCheckUnsolvedInstTrav(yyyGNT *pNode,long *nNZrc,long *cycleSum) {yyyGNT **yyyCLpdum; yyyRCT *rcp; int i; /* visit the refCountList of each node in the tree, and sum the non-zero refCounts */ rcp = pNode->refCountList; i = pNode->refCountListLen; while (i--) if (*rcp++) {*cycleSum += *(rcp - 1); (*nNZrc)++;} yyyCLpdum = pNode->cL; i = pNode->cLlen; while (i--) { yyyCheckUnsolvedInstTrav(*yyyCLpdum,nNZrc,cycleSum); yyyCLpdum++; } } void yyyUnsolvedInstSearchTravAux(yyyGNT *pNode) {yyyGNT **yyyCLpdum; int i; yyyCheckNodeInstancesSolved(pNode); yyyCLpdum = pNode->cL; i = pNode->cLlen; while (i--) { yyyUnsolvedInstSearchTravAux(*yyyCLpdum); yyyCLpdum++; } } void yyyUnsolvedInstSearchTrav(yyyGNT *pNode) {yyyGNT **yyyCLpdum; int i; yyyCLpdum = pNode->cL; i = pNode->cLlen; while (i--) { yyyUnsolvedInstSearchTravAux(*yyyCLpdum); yyyCLpdum++; } } #line 1647 "expr.oxout.tab.c" #if YYDEBUG #include /* needed for printf */ #endif #include /* needed for malloc, etc */ #include /* needed for memset */ /* allocate initial stack or double stack size, up to YYMAXDEPTH */ static int yygrowstack(YYSTACKDATA *data) { int i; unsigned newsize; YYINT *newss; YYSTYPE *newvs; if ((newsize = data->stacksize) == 0) newsize = YYINITSTACKSIZE; else if (newsize >= YYMAXDEPTH) return YYENOMEM; else if ((newsize *= 2) > YYMAXDEPTH) newsize = YYMAXDEPTH; i = (int) (data->s_mark - data->s_base); newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); if (newss == NULL) return YYENOMEM; data->s_base = newss; data->s_mark = newss + i; newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); if (newvs == NULL) return YYENOMEM; data->l_base = newvs; data->l_mark = newvs + i; data->stacksize = newsize; data->s_last = data->s_base + newsize - 1; return 0; } #if YYPURE || defined(YY_NO_LEAKS) static void yyfreestack(YYSTACKDATA *data) { free(data->s_base); free(data->l_base); memset(data, 0, sizeof(*data)); } #else #define yyfreestack(data) /* nothing */ #endif #define YYABORT goto yyabort #define YYREJECT goto yyabort #define YYACCEPT goto yyaccept #define YYERROR goto yyerrlab int YYPARSE_DECL() { int yym, yyn, yystate; #if YYDEBUG const char *yys; if ((yys = getenv("YYDEBUG")) != NULL) { yyn = *yys; if (yyn >= '0' && yyn <= '9') yydebug = yyn - '0'; } #endif /* yym is set below */ /* yyn is set below */ yynerrs = 0; yyerrflag = 0; yychar = YYEMPTY; yystate = 0; #if YYPURE memset(&yystack, 0, sizeof(yystack)); #endif if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystack.s_mark = yystack.s_base; yystack.l_mark = yystack.l_base; yystate = 0; *yystack.s_mark = 0; yyloop: if ((yyn = yydefred[yystate]) != 0) goto yyreduce; if (yychar < 0) { yychar = YYLEX; if (yychar < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; printf("%sdebug: state %d, reading %d (%s)\n", YYPREFIX, yystate, yychar, yys); } #endif } if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) { #if YYDEBUG if (yydebug) printf("%sdebug: state %d, shifting to state %d\n", YYPREFIX, yystate, yytable[yyn]); #endif if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystate = yytable[yyn]; *++yystack.s_mark = yytable[yyn]; *++yystack.l_mark = yylval; yychar = YYEMPTY; if (yyerrflag > 0) --yyerrflag; goto yyloop; } if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) { yyn = yytable[yyn]; goto yyreduce; } if (yyerrflag != 0) goto yyinrecovery; YYERROR_CALL("syntax error"); goto yyerrlab; /* redundant goto avoids 'unused label' warning */ yyerrlab: ++yynerrs; yyinrecovery: if (yyerrflag < 3) { yyerrflag = 3; for (;;) { if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) { #if YYDEBUG if (yydebug) printf("%sdebug: state %d, error recovery shifting\ to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); #endif if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystate = yytable[yyn]; *++yystack.s_mark = yytable[yyn]; *++yystack.l_mark = yylval; goto yyloop; } else { #if YYDEBUG if (yydebug) printf("%sdebug: error recovery discarding state %d\n", YYPREFIX, *yystack.s_mark); #endif if (yystack.s_mark <= yystack.s_base) goto yyabort; --yystack.s_mark; --yystack.l_mark; } } } else { if (yychar == YYEOF) goto yyabort; #if YYDEBUG if (yydebug) { if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; printf("%sdebug: state %d, error recovery discards token %d (%s)\n", YYPREFIX, yystate, yychar, yys); } #endif yychar = YYEMPTY; goto yyloop; } yyreduce: #if YYDEBUG if (yydebug) printf("%sdebug: state %d, reducing by rule %d (%s)\n", YYPREFIX, yystate, yyn, yyrule[yyn]); #endif yym = yylen[yyn]; if (yym > 0) yyval = yystack.l_mark[1-yym]; else memset(&yyval, 0, sizeof yyval); switch (yyn) { case 1: #line 64 "expr.oxout.y" {yyyYoxInit();} #line 1849 "expr.oxout.tab.c" break; case 2: #line 66 "expr.oxout.y" { yyyDecorate(); yyyExecuteRRsection(yystack.l_mark[0].yyyOxAttrbs.yyyOxStackItem->node); } #line 1856 "expr.oxout.tab.c" break; case 3: #line 73 "expr.oxout.y" {if(yyyYok){ yyyGenIntNode(1,1,0,&yyval.yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); yyyAdjustINRC(1,1,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} #line 1863 "expr.oxout.tab.c" break; case 4: #line 80 "expr.oxout.y" {if(yyyYok){ yyyGenIntNode(2,3,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); yyyAdjustINRC(2,3,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} #line 1870 "expr.oxout.tab.c" break; case 5: #line 87 "expr.oxout.y" {if(yyyYok){ yyyGenIntNode(3,3,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); yyyAdjustINRC(3,3,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} #line 1877 "expr.oxout.tab.c" break; case 6: #line 94 "expr.oxout.y" {if(yyyYok){ yyyGenIntNode(4,3,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); yyyAdjustINRC(4,3,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} #line 1884 "expr.oxout.tab.c" break; case 7: #line 101 "expr.oxout.y" {if(yyyYok){ yyyGenIntNode(5,3,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); yyyAdjustINRC(5,3,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} #line 1891 "expr.oxout.tab.c" break; case 8: #line 108 "expr.oxout.y" {if(yyyYok){ yyyGenIntNode(6,3,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); yyyAdjustINRC(6,3,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[-2].yyyOxAttrbs,&yystack.l_mark[-1].yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} #line 1898 "expr.oxout.tab.c" break; case 9: #line 114 "expr.oxout.y" {if(yyyYok){ yyyGenIntNode(7,1,0,&yyval.yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); yyyAdjustINRC(7,1,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} #line 1905 "expr.oxout.tab.c" break; case 10: #line 121 "expr.oxout.y" {if(yyyYok){ yyyGenIntNode(8,1,0,&yyval.yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs); yyyAdjustINRC(8,1,0,0,&yyval.yyyOxAttrbs,&yystack.l_mark[0].yyyOxAttrbs);}} #line 1912 "expr.oxout.tab.c" break; #line 1914 "expr.oxout.tab.c" } yystack.s_mark -= yym; yystate = *yystack.s_mark; yystack.l_mark -= yym; yym = yylhs[yyn]; if (yystate == 0 && yym == 0) { #if YYDEBUG if (yydebug) printf("%sdebug: after reduction, shifting from state 0 to\ state %d\n", YYPREFIX, YYFINAL); #endif yystate = YYFINAL; *++yystack.s_mark = YYFINAL; *++yystack.l_mark = yyval; if (yychar < 0) { yychar = YYLEX; if (yychar < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; printf("%sdebug: state %d, reading %d (%s)\n", YYPREFIX, YYFINAL, yychar, yys); } #endif } if (yychar == YYEOF) goto yyaccept; goto yyloop; } if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) yystate = yytable[yyn]; else yystate = yydgoto[yym]; #if YYDEBUG if (yydebug) printf("%sdebug: after reduction, shifting from state %d \ to state %d\n", YYPREFIX, *yystack.s_mark, yystate); #endif if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; *++yystack.s_mark = (YYINT) yystate; *++yystack.l_mark = yyval; goto yyloop; yyoverflow: YYERROR_CALL("yacc stack overflow"); yyabort: yyfreestack(&yystack); return (1); yyaccept: yyfreestack(&yystack); return (0); } diff --git a/contrib/byacc/test/yacc/expr.oxout.tab.h b/contrib/byacc/test/yacc/expr.oxout.tab.h index 03527bb036a4..1084ea4abf79 100644 --- a/contrib/byacc/test/yacc/expr.oxout.tab.h +++ b/contrib/byacc/test/yacc/expr.oxout.tab.h @@ -1,15 +1,15 @@ #define ID 257 #define CONST 258 #ifdef YYSTYPE #undef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 #endif #ifndef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 -typedef union YYSTYPE { +typedef union { struct yyyOxAttrbs { struct yyyStackItem *yyyOxStackItem; } yyyOxAttrbs; } YYSTYPE; #endif /* !YYSTYPE_IS_DECLARED */ extern YYSTYPE expr_oxout_lval; diff --git a/contrib/byacc/test/yacc/ok_syntax1.tab.c b/contrib/byacc/test/yacc/ok_syntax1.tab.c index 8714a0bbe73b..f035bed50053 100644 --- a/contrib/byacc/test/yacc/ok_syntax1.tab.c +++ b/contrib/byacc/test/yacc/ok_syntax1.tab.c @@ -1,731 +1,731 @@ /* original parser id follows */ /* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ /* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ #define YYBYACC 1 #define YYMAJOR 2 #define YYMINOR 0 #define YYCHECK "yyyymmdd" #define YYEMPTY (-1) #define yyclearin (yychar = YYEMPTY) #define yyerrok (yyerrflag = 0) #define YYRECOVERING() (yyerrflag != 0) #define YYENOMEM (-2) #define YYEOF 0 #ifndef yyparse #define yyparse ok_syntax1_parse #endif /* yyparse */ #ifndef yylex #define yylex ok_syntax1_lex #endif /* yylex */ #ifndef yyerror #define yyerror ok_syntax1_error #endif /* yyerror */ #ifndef yychar #define yychar ok_syntax1_char #endif /* yychar */ #ifndef yyval #define yyval ok_syntax1_val #endif /* yyval */ #ifndef yylval #define yylval ok_syntax1_lval #endif /* yylval */ #ifndef yydebug #define yydebug ok_syntax1_debug #endif /* yydebug */ #ifndef yynerrs #define yynerrs ok_syntax1_nerrs #endif /* yynerrs */ #ifndef yyerrflag #define yyerrflag ok_syntax1_errflag #endif /* yyerrflag */ #ifndef yylhs #define yylhs ok_syntax1_lhs #endif /* yylhs */ #ifndef yylen #define yylen ok_syntax1_len #endif /* yylen */ #ifndef yydefred #define yydefred ok_syntax1_defred #endif /* yydefred */ #ifndef yydgoto #define yydgoto ok_syntax1_dgoto #endif /* yydgoto */ #ifndef yysindex #define yysindex ok_syntax1_sindex #endif /* yysindex */ #ifndef yyrindex #define yyrindex ok_syntax1_rindex #endif /* yyrindex */ #ifndef yygindex #define yygindex ok_syntax1_gindex #endif /* yygindex */ #ifndef yytable #define yytable ok_syntax1_table #endif /* yytable */ #ifndef yycheck #define yycheck ok_syntax1_check #endif /* yycheck */ #ifndef yyname #define yyname ok_syntax1_name #endif /* yyname */ #ifndef yyrule #define yyrule ok_syntax1_rule #endif /* yyrule */ #define YYPREFIX "ok_syntax1_" #define YYPURE 1 #line 9 "ok_syntax1.y" # include # include #ifdef YYBISON #define YYSTYPE int #define YYLEX_PARAM base #define YYLEX_DECL() yylex(YYSTYPE *yylval, int *YYLEX_PARAM) #define YYERROR_DECL() yyerror(int regs[26], int *base, const char *s) int YYLEX_DECL(); static void YYERROR_DECL(); #endif #ifdef YYSTYPE #undef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 #endif #ifndef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 #line 43 "ok_syntax1.y" -typedef union YYSTYPE +typedef union { char * cval; int ival; double dval; } YYSTYPE; #endif /* !YYSTYPE_IS_DECLARED */ #line 128 "ok_syntax1.tab.c" /* compatibility with bison */ #ifdef YYPARSE_PARAM /* compatibility with FreeBSD */ # ifdef YYPARSE_PARAM_TYPE # define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) # else # define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) # endif #else # define YYPARSE_DECL() yyparse(int regs[26], int *base) #endif /* Parameters sent to lex. */ #ifdef YYLEX_PARAM # ifdef YYLEX_PARAM_TYPE # define YYLEX_DECL() yylex(YYSTYPE *yylval, YYLEX_PARAM_TYPE YYLEX_PARAM) # else # define YYLEX_DECL() yylex(YYSTYPE *yylval, void * YYLEX_PARAM) # endif # define YYLEX yylex(&yylval, YYLEX_PARAM) #else # define YYLEX_DECL() yylex(YYSTYPE *yylval, int *base) # define YYLEX yylex(&yylval, base) #endif /* Parameters sent to yyerror. */ #ifndef YYERROR_DECL #define YYERROR_DECL() yyerror(int regs[26], int *base, const char *s) #endif #ifndef YYERROR_CALL #define YYERROR_CALL(msg) yyerror(regs, base, msg) #endif extern int YYPARSE_DECL(); #define DIGIT 257 #define LETTER 258 #define OCT1 259 #define HEX1 260 #define HEX2 261 #define HEX3 262 #define STR1 263 #define STR2 265 #define BELL 266 #define BS 267 #define NL 268 #define LF 269 #define CR 270 #define TAB 271 #define VT 272 #define UMINUS 273 #define YYERRCODE 256 typedef int YYINT; static const YYINT ok_syntax1_lhs[] = { -1, 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, }; static const YYINT ok_syntax1_len[] = { 2, 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 1, 1, 1, 2, }; static const YYINT ok_syntax1_defred[] = { 1, 0, 0, 17, 0, 0, 0, 0, 0, 0, 3, 0, 15, 14, 0, 2, 0, 0, 0, 0, 0, 0, 0, 18, 0, 6, 0, 0, 0, 0, 9, 10, 11, }; static const YYINT ok_syntax1_dgoto[] = { 1, 7, 8, 9, }; static const YYINT ok_syntax1_sindex[] = { 0, -40, -7, 0, -55, -38, -38, 1, -29, -247, 0, -38, 0, 0, 22, 0, -38, -38, -38, -38, -38, -38, -38, 0, -29, 0, 51, 60, -20, -20, 0, 0, 0, }; static const YYINT ok_syntax1_rindex[] = { 0, 0, 0, 0, 2, 0, 0, 0, 9, -9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, -6, 14, 5, 13, 0, 0, 0, }; static const YYINT ok_syntax1_gindex[] = { 0, 0, 65, 0, }; #define YYTABLESIZE 220 static const YYINT ok_syntax1_table[] = { 6, 16, 6, 10, 13, 5, 11, 5, 22, 17, 23, 15, 15, 20, 18, 7, 19, 22, 21, 4, 5, 0, 20, 8, 12, 0, 0, 21, 16, 16, 0, 0, 16, 16, 16, 13, 16, 0, 16, 15, 15, 0, 0, 7, 15, 15, 7, 15, 7, 15, 7, 8, 12, 0, 8, 12, 8, 0, 8, 22, 17, 0, 0, 25, 20, 18, 0, 19, 0, 21, 13, 14, 0, 0, 0, 0, 24, 0, 0, 0, 0, 26, 27, 28, 29, 30, 31, 32, 22, 17, 0, 0, 0, 20, 18, 16, 19, 22, 21, 0, 0, 0, 20, 18, 0, 19, 0, 21, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 13, 0, 0, 0, 0, 0, 0, 0, 15, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 8, 12, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 4, 3, 12, }; static const YYINT ok_syntax1_check[] = { 40, 10, 40, 10, 10, 45, 61, 45, 37, 38, 257, 10, 10, 42, 43, 10, 45, 37, 47, 10, 10, -1, 42, 10, 10, -1, -1, 47, 37, 38, -1, -1, 41, 42, 43, 41, 45, -1, 47, 37, 38, -1, -1, 38, 42, 43, 41, 45, 43, 47, 45, 38, 38, -1, 41, 41, 43, -1, 45, 37, 38, -1, -1, 41, 42, 43, -1, 45, -1, 47, 5, 6, -1, -1, -1, -1, 11, -1, -1, -1, -1, 16, 17, 18, 19, 20, 21, 22, 37, 38, -1, -1, -1, 42, 43, 124, 45, 37, 47, -1, -1, -1, 42, 43, -1, 45, -1, 47, -1, -1, -1, -1, -1, -1, -1, 124, -1, -1, 124, -1, -1, -1, -1, -1, -1, -1, 124, -1, -1, 124, -1, -1, -1, -1, -1, -1, -1, 124, 124, -1, -1, -1, -1, -1, -1, -1, 124, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 256, 257, 258, 257, 258, }; #define YYFINAL 1 #ifndef YYDEBUG #define YYDEBUG 0 #endif #define YYMAXTOKEN 273 #define YYUNDFTOKEN 279 #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) #if YYDEBUG static const char *const ok_syntax1_name[] = { "end-of-file",0,0,0,0,0,0,"'\\a'","'\\b'","'\\t'","'\\n'","'\\v'","'\\f'", "'\\r'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'#'",0,"'%'","'&'",0,"'('", "')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,0,0,0,0,0,0,"'='",0,0,"'@'",0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'^'",0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,"'~'","'\\177'",0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, "'\\377'",0,"DIGIT","LETTER","OCT1","HEX1","HEX2","HEX3","STR1", "\"\\177\\177\\\\\\n\"","STR2","BELL","BS","NL","LF","CR","TAB","VT","UMINUS",0, 0,0,0,0,"illegal-symbol", }; static const char *const ok_syntax1_rule[] = { "$accept : list", "list :", "list : list stat '\\n'", "list : list error '\\n'", "stat : expr", "stat : LETTER '=' expr", "expr : '(' expr ')'", "expr : expr '+' expr", "expr : expr '-' expr", "expr : expr '*' expr", "expr : expr '/' expr", "expr : expr '%' expr", "expr : expr '&' expr", "expr : expr '|' expr", "expr : '-' expr", "expr : LETTER", "expr : number", "number : DIGIT", "number : number DIGIT", }; #endif #if YYDEBUG int yydebug; #endif /* define the initial stack-sizes */ #ifdef YYSTACKSIZE #undef YYMAXDEPTH #define YYMAXDEPTH YYSTACKSIZE #else #ifdef YYMAXDEPTH #define YYSTACKSIZE YYMAXDEPTH #else #define YYSTACKSIZE 10000 #define YYMAXDEPTH 10000 #endif #endif #define YYINITSTACKSIZE 200 typedef struct { unsigned stacksize; YYINT *s_base; YYINT *s_mark; YYINT *s_last; YYSTYPE *l_base; YYSTYPE *l_mark; } YYSTACKDATA; #line 104 "ok_syntax1.y" /* start of programs */ #ifdef YYBYACC extern int YYLEX_DECL(); #endif int main (void) { int regs[26]; int base = 10; while(!feof(stdin)) { yyparse(regs, &base); } return 0; } #define UNUSED(x) ((void)(x)) static void YYERROR_DECL() { UNUSED(regs); /* %parse-param regs is not actually used here */ UNUSED(base); /* %parse-param base is not actually used here */ fprintf(stderr, "%s\n", s); } int YYLEX_DECL() { /* lexical analysis routine */ /* returns LETTER for a lower case letter, yylval = 0 through 25 */ /* return DIGIT for a digit, yylval = 0 through 9 */ /* all other characters are returned immediately */ int c; while( (c=getchar()) == ' ' ) { /* skip blanks */ } /* c is now nonblank */ if( islower( c )) { yylval->ival = (c - 'a'); return ( LETTER ); } if( isdigit( c )) { yylval->ival = (c - '0') % (*base); return ( DIGIT ); } return( c ); } #line 390 "ok_syntax1.tab.c" #if YYDEBUG #include /* needed for printf */ #endif #include /* needed for malloc, etc */ #include /* needed for memset */ /* allocate initial stack or double stack size, up to YYMAXDEPTH */ static int yygrowstack(YYSTACKDATA *data) { int i; unsigned newsize; YYINT *newss; YYSTYPE *newvs; if ((newsize = data->stacksize) == 0) newsize = YYINITSTACKSIZE; else if (newsize >= YYMAXDEPTH) return YYENOMEM; else if ((newsize *= 2) > YYMAXDEPTH) newsize = YYMAXDEPTH; i = (int) (data->s_mark - data->s_base); newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); if (newss == NULL) return YYENOMEM; data->s_base = newss; data->s_mark = newss + i; newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); if (newvs == NULL) return YYENOMEM; data->l_base = newvs; data->l_mark = newvs + i; data->stacksize = newsize; data->s_last = data->s_base + newsize - 1; return 0; } #if YYPURE || defined(YY_NO_LEAKS) static void yyfreestack(YYSTACKDATA *data) { free(data->s_base); free(data->l_base); memset(data, 0, sizeof(*data)); } #else #define yyfreestack(data) /* nothing */ #endif #define YYABORT goto yyabort #define YYREJECT goto yyabort #define YYACCEPT goto yyaccept #define YYERROR goto yyerrlab int YYPARSE_DECL() { int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; int yynerrs; /* variables for the parser stack */ YYSTACKDATA yystack; int yym, yyn, yystate; #if YYDEBUG const char *yys; if ((yys = getenv("YYDEBUG")) != NULL) { yyn = *yys; if (yyn >= '0' && yyn <= '9') yydebug = yyn - '0'; } #endif memset(&yyval, 0, sizeof(yyval)); memset(&yylval, 0, sizeof(yylval)); /* yym is set below */ /* yyn is set below */ yynerrs = 0; yyerrflag = 0; yychar = YYEMPTY; yystate = 0; #if YYPURE memset(&yystack, 0, sizeof(yystack)); #endif if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystack.s_mark = yystack.s_base; yystack.l_mark = yystack.l_base; yystate = 0; *yystack.s_mark = 0; yyloop: if ((yyn = yydefred[yystate]) != 0) goto yyreduce; if (yychar < 0) { yychar = YYLEX; if (yychar < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; printf("%sdebug: state %d, reading %d (%s)\n", YYPREFIX, yystate, yychar, yys); } #endif } if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) { #if YYDEBUG if (yydebug) printf("%sdebug: state %d, shifting to state %d\n", YYPREFIX, yystate, yytable[yyn]); #endif if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystate = yytable[yyn]; *++yystack.s_mark = yytable[yyn]; *++yystack.l_mark = yylval; yychar = YYEMPTY; if (yyerrflag > 0) --yyerrflag; goto yyloop; } if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) { yyn = yytable[yyn]; goto yyreduce; } if (yyerrflag != 0) goto yyinrecovery; YYERROR_CALL("syntax error"); goto yyerrlab; /* redundant goto avoids 'unused label' warning */ yyerrlab: ++yynerrs; yyinrecovery: if (yyerrflag < 3) { yyerrflag = 3; for (;;) { if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) { #if YYDEBUG if (yydebug) printf("%sdebug: state %d, error recovery shifting\ to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); #endif if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystate = yytable[yyn]; *++yystack.s_mark = yytable[yyn]; *++yystack.l_mark = yylval; goto yyloop; } else { #if YYDEBUG if (yydebug) printf("%sdebug: error recovery discarding state %d\n", YYPREFIX, *yystack.s_mark); #endif if (yystack.s_mark <= yystack.s_base) goto yyabort; --yystack.s_mark; --yystack.l_mark; } } } else { if (yychar == YYEOF) goto yyabort; #if YYDEBUG if (yydebug) { if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; printf("%sdebug: state %d, error recovery discards token %d (%s)\n", YYPREFIX, yystate, yychar, yys); } #endif yychar = YYEMPTY; goto yyloop; } yyreduce: #if YYDEBUG if (yydebug) printf("%sdebug: state %d, reducing by rule %d (%s)\n", YYPREFIX, yystate, yyn, yyrule[yyn]); #endif yym = yylen[yyn]; if (yym > 0) yyval = yystack.l_mark[1-yym]; else memset(&yyval, 0, sizeof yyval); switch (yyn) { case 3: #line 66 "ok_syntax1.y" { yyerrok ; } #line 603 "ok_syntax1.tab.c" break; case 4: #line 70 "ok_syntax1.y" { printf("%d\n",yystack.l_mark[0].ival);} #line 608 "ok_syntax1.tab.c" break; case 5: #line 72 "ok_syntax1.y" { regs[yystack.l_mark[-2].ival] = yystack.l_mark[0].ival; } #line 613 "ok_syntax1.tab.c" break; case 6: #line 76 "ok_syntax1.y" { yyval.ival = yystack.l_mark[-1].ival; } #line 618 "ok_syntax1.tab.c" break; case 7: #line 78 "ok_syntax1.y" { yyval.ival = yystack.l_mark[-2].ival + yystack.l_mark[0].ival; } #line 623 "ok_syntax1.tab.c" break; case 8: #line 80 "ok_syntax1.y" { yyval.ival = yystack.l_mark[-2].ival - yystack.l_mark[0].ival; } #line 628 "ok_syntax1.tab.c" break; case 9: #line 82 "ok_syntax1.y" { yyval.ival = yystack.l_mark[-2].ival * yystack.l_mark[0].ival; } #line 633 "ok_syntax1.tab.c" break; case 10: #line 84 "ok_syntax1.y" { yyval.ival = yystack.l_mark[-2].ival / yystack.l_mark[0].ival; } #line 638 "ok_syntax1.tab.c" break; case 11: #line 86 "ok_syntax1.y" { yyval.ival = yystack.l_mark[-2].ival % yystack.l_mark[0].ival; } #line 643 "ok_syntax1.tab.c" break; case 12: #line 88 "ok_syntax1.y" { yyval.ival = yystack.l_mark[-2].ival & yystack.l_mark[0].ival; } #line 648 "ok_syntax1.tab.c" break; case 13: #line 90 "ok_syntax1.y" { yyval.ival = yystack.l_mark[-2].ival | yystack.l_mark[0].ival; } #line 653 "ok_syntax1.tab.c" break; case 14: #line 92 "ok_syntax1.y" { yyval.ival = - yystack.l_mark[0].ival; } #line 658 "ok_syntax1.tab.c" break; case 15: #line 94 "ok_syntax1.y" { yyval.ival = regs[yystack.l_mark[0].ival]; } #line 663 "ok_syntax1.tab.c" break; case 17: #line 99 "ok_syntax1.y" { yyval.ival = yystack.l_mark[0].ival; (*base) = (yystack.l_mark[0].ival==0) ? 8 : 10; } #line 668 "ok_syntax1.tab.c" break; case 18: #line 101 "ok_syntax1.y" { yyval.ival = (*base) * yystack.l_mark[-1].ival + yystack.l_mark[0].ival; } #line 673 "ok_syntax1.tab.c" break; #line 675 "ok_syntax1.tab.c" } yystack.s_mark -= yym; yystate = *yystack.s_mark; yystack.l_mark -= yym; yym = yylhs[yyn]; if (yystate == 0 && yym == 0) { #if YYDEBUG if (yydebug) printf("%sdebug: after reduction, shifting from state 0 to\ state %d\n", YYPREFIX, YYFINAL); #endif yystate = YYFINAL; *++yystack.s_mark = YYFINAL; *++yystack.l_mark = yyval; if (yychar < 0) { yychar = YYLEX; if (yychar < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; printf("%sdebug: state %d, reading %d (%s)\n", YYPREFIX, YYFINAL, yychar, yys); } #endif } if (yychar == YYEOF) goto yyaccept; goto yyloop; } if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) yystate = yytable[yyn]; else yystate = yydgoto[yym]; #if YYDEBUG if (yydebug) printf("%sdebug: after reduction, shifting from state %d \ to state %d\n", YYPREFIX, *yystack.s_mark, yystate); #endif if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; *++yystack.s_mark = (YYINT) yystate; *++yystack.l_mark = yyval; goto yyloop; yyoverflow: YYERROR_CALL("yacc stack overflow"); yyabort: yyfreestack(&yystack); return (1); yyaccept: yyfreestack(&yystack); return (0); } diff --git a/contrib/byacc/test/yacc/ok_syntax1.tab.h b/contrib/byacc/test/yacc/ok_syntax1.tab.h index ca92fd77dfc2..892b211c8a71 100644 --- a/contrib/byacc/test/yacc/ok_syntax1.tab.h +++ b/contrib/byacc/test/yacc/ok_syntax1.tab.h @@ -1,29 +1,29 @@ #define DIGIT 257 #define LETTER 258 #define OCT1 259 #define HEX1 260 #define HEX2 261 #define HEX3 262 #define STR1 263 #define STR2 265 #define BELL 266 #define BS 267 #define NL 268 #define LF 269 #define CR 270 #define TAB 271 #define VT 272 #define UMINUS 273 #ifdef YYSTYPE #undef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 #endif #ifndef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 -typedef union YYSTYPE +typedef union { char * cval; int ival; double dval; } YYSTYPE; #endif /* !YYSTYPE_IS_DECLARED */ diff --git a/contrib/byacc/test/yacc/varsyntax_calc1.tab.c b/contrib/byacc/test/yacc/varsyntax_calc1.tab.c index 6c7f2f8b12fe..5ac5c9c07b78 100644 --- a/contrib/byacc/test/yacc/varsyntax_calc1.tab.c +++ b/contrib/byacc/test/yacc/varsyntax_calc1.tab.c @@ -1,937 +1,937 @@ /* original parser id follows */ /* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ /* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ #define YYBYACC 1 #define YYMAJOR 2 #define YYMINOR 0 #define YYCHECK "yyyymmdd" #define YYEMPTY (-1) #define yyclearin (yychar = YYEMPTY) #define yyerrok (yyerrflag = 0) #define YYRECOVERING() (yyerrflag != 0) #define YYENOMEM (-2) #define YYEOF 0 #ident "check variant syntax features" #ifndef yyparse #define yyparse varsyntax_calc1_parse #endif /* yyparse */ #ifndef yylex #define yylex varsyntax_calc1_lex #endif /* yylex */ #ifndef yyerror #define yyerror varsyntax_calc1_error #endif /* yyerror */ #ifndef yychar #define yychar varsyntax_calc1_char #endif /* yychar */ #ifndef yyval #define yyval varsyntax_calc1_val #endif /* yyval */ #ifndef yylval #define yylval varsyntax_calc1_lval #endif /* yylval */ #ifndef yydebug #define yydebug varsyntax_calc1_debug #endif /* yydebug */ #ifndef yynerrs #define yynerrs varsyntax_calc1_nerrs #endif /* yynerrs */ #ifndef yyerrflag #define yyerrflag varsyntax_calc1_errflag #endif /* yyerrflag */ #ifndef yylhs #define yylhs varsyntax_calc1_lhs #endif /* yylhs */ #ifndef yylen #define yylen varsyntax_calc1_len #endif /* yylen */ #ifndef yydefred #define yydefred varsyntax_calc1_defred #endif /* yydefred */ #ifndef yydgoto #define yydgoto varsyntax_calc1_dgoto #endif /* yydgoto */ #ifndef yysindex #define yysindex varsyntax_calc1_sindex #endif /* yysindex */ #ifndef yyrindex #define yyrindex varsyntax_calc1_rindex #endif /* yyrindex */ #ifndef yygindex #define yygindex varsyntax_calc1_gindex #endif /* yygindex */ #ifndef yytable #define yytable varsyntax_calc1_table #endif /* yytable */ #ifndef yycheck #define yycheck varsyntax_calc1_check #endif /* yycheck */ #ifndef yyname #define yyname varsyntax_calc1_name #endif /* yyname */ #ifndef yyrule #define yyrule varsyntax_calc1_rule #endif /* yyrule */ #define YYPREFIX "varsyntax_calc1_" #define YYPURE 0 #line 3 "varsyntax_calc1.y" /* http://dinosaur.compilertools.net/yacc/index.html * /*/ #include #include #include #include typedef struct interval { double lo, hi; } INTERVAL; INTERVAL vmul(double, double, INTERVAL); INTERVAL vdiv(double, double, INTERVAL); extern int yylex(void); static void yyerror(const char *s); int dcheck(INTERVAL); double dreg[26]; INTERVAL vreg[26]; #ifdef YYSTYPE #undef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 #endif #ifndef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 #line 32 "varsyntax_calc1.y" -typedef union YYSTYPE +typedef union { int ival; /* dreg & vreg array index values*/ double dval; /* floating point values*/ INTERVAL vval; /* interval values*/ } YYSTYPE; #endif /* !YYSTYPE_IS_DECLARED */ #line 142 "varsyntax_calc1.tab.c" /* compatibility with bison */ #ifdef YYPARSE_PARAM /* compatibility with FreeBSD */ # ifdef YYPARSE_PARAM_TYPE # define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) # else # define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) # endif #else # define YYPARSE_DECL() yyparse(void) #endif /* Parameters sent to lex. */ #ifdef YYLEX_PARAM # define YYLEX_DECL() yylex(void *YYLEX_PARAM) # define YYLEX yylex(YYLEX_PARAM) #else # define YYLEX_DECL() yylex(void) # define YYLEX yylex() #endif /* Parameters sent to yyerror. */ #ifndef YYERROR_DECL #define YYERROR_DECL() yyerror(const char *s) #endif #ifndef YYERROR_CALL #define YYERROR_CALL(msg) yyerror(msg) #endif extern int YYPARSE_DECL(); #define DREG 257 #define VREG 258 #define CONST 259 #define UMINUS 260 #define YYERRCODE 256 typedef int YYINT; static const YYINT varsyntax_calc1_lhs[] = { -1, 3, 3, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, }; static const YYINT varsyntax_calc1_len[] = { 2, 0, 2, 2, 2, 4, 4, 2, 1, 1, 3, 3, 3, 3, 2, 3, 1, 5, 1, 3, 3, 3, 3, 3, 3, 3, 3, 2, 3, }; static const YYINT varsyntax_calc1_defred[] = { 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 7, 0, 0, 9, 18, 14, 27, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 15, 0, 28, 0, 0, 0, 0, 12, 24, 13, 26, 0, 0, 23, 25, 14, 0, 0, 0, 0, 0, 5, 6, 0, 0, 0, 12, 13, 17, }; static const YYINT varsyntax_calc1_dgoto[] = { 7, 32, 9, 0, }; static const YYINT varsyntax_calc1_sindex[] = { -40, -8, -48, -47, 0, -37, -37, 0, 2, 17, 0, -34, -37, 0, 0, 0, 0, -25, 90, -37, -37, -37, -37, 0, -37, -37, -37, -37, 0, -34, -34, 25, 125, 31, 0, -34, 0, -11, 37, -11, 37, 0, 0, 0, 0, 37, 37, 0, 0, 0, 111, -34, -34, -34, -34, 0, 0, 118, 69, 69, 0, 0, 0, }; static const YYINT varsyntax_calc1_rindex[] = { 0, 0, 38, 44, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -9, 0, 0, 0, 0, 51, -3, 56, 61, 0, 0, 0, 0, 67, 72, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 78, 83, 0, 0, 0, }; static const YYINT varsyntax_calc1_gindex[] = { 0, 4, 124, 0, }; #define YYTABLESIZE 225 static const YYINT varsyntax_calc1_table[] = { 6, 16, 10, 6, 8, 5, 30, 20, 5, 15, 17, 29, 23, 11, 12, 31, 34, 21, 19, 35, 20, 0, 22, 37, 39, 41, 43, 28, 0, 0, 0, 21, 16, 49, 50, 55, 22, 0, 20, 57, 20, 56, 20, 0, 21, 19, 0, 20, 9, 22, 0, 0, 0, 0, 18, 58, 59, 60, 61, 26, 24, 10, 25, 0, 27, 0, 11, 53, 51, 0, 52, 22, 54, 26, 24, 0, 25, 19, 27, 26, 9, 9, 21, 9, 27, 9, 18, 18, 10, 18, 0, 18, 10, 11, 10, 10, 10, 11, 0, 11, 11, 11, 22, 0, 22, 0, 22, 0, 19, 0, 19, 53, 19, 21, 0, 21, 54, 21, 0, 10, 0, 10, 0, 10, 11, 0, 11, 0, 11, 16, 18, 36, 26, 24, 0, 25, 33, 27, 0, 0, 0, 0, 0, 38, 40, 42, 44, 0, 45, 46, 47, 48, 34, 53, 51, 0, 52, 0, 54, 62, 53, 51, 0, 52, 0, 54, 0, 21, 19, 0, 20, 0, 22, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 13, 14, 4, 13, 0, 4, }; static const YYINT varsyntax_calc1_check[] = { 40, 10, 10, 40, 0, 45, 40, 10, 45, 5, 6, 45, 10, 61, 61, 11, 41, 42, 43, 44, 45, -1, 47, 19, 20, 21, 22, 10, -1, -1, -1, 42, 41, 29, 30, 10, 47, -1, 41, 35, 43, 10, 45, -1, 42, 43, -1, 45, 10, 47, -1, -1, -1, -1, 10, 51, 52, 53, 54, 42, 43, 10, 45, -1, 47, -1, 10, 42, 43, -1, 45, 10, 47, 42, 43, -1, 45, 10, 47, 42, 42, 43, 10, 45, 47, 47, 42, 43, 10, 45, -1, 47, 41, 10, 43, 44, 45, 41, -1, 43, 44, 45, 41, -1, 43, -1, 45, -1, 41, -1, 43, 42, 45, 41, -1, 43, 47, 45, -1, 41, -1, 43, -1, 45, 41, -1, 43, -1, 45, 5, 6, 41, 42, 43, -1, 45, 12, 47, -1, -1, -1, -1, -1, 19, 20, 21, 22, -1, 24, 25, 26, 27, 41, 42, 43, -1, 45, -1, 47, 41, 42, 43, -1, 45, -1, 47, -1, 42, 43, -1, 45, -1, 47, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 256, 257, 258, 259, 257, 258, 259, 257, -1, 259, }; #define YYFINAL 7 #ifndef YYDEBUG #define YYDEBUG 0 #endif #define YYMAXTOKEN 260 #define YYUNDFTOKEN 266 #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) #if YYDEBUG static const char *const varsyntax_calc1_name[] = { "end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,"'('","')'","'*'","'+'","','","'-'",0,"'/'",0,0,0,0,0,0,0,0,0, 0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,"DREG","VREG","CONST","UMINUS",0,0,0,0,0,"illegal-symbol", }; static const char *const varsyntax_calc1_rule[] = { "$accept : line", "lines :", "lines : lines line", "line : dexp '\\n'", "line : vexp '\\n'", "line : DREG '=' dexp '\\n'", "line : VREG '=' vexp '\\n'", "line : error '\\n'", "dexp : CONST", "dexp : DREG", "dexp : dexp '+' dexp", "dexp : dexp '-' dexp", "dexp : dexp '*' dexp", "dexp : dexp '/' dexp", "dexp : '-' dexp", "dexp : '(' dexp ')'", "vexp : dexp", "vexp : '(' dexp ',' dexp ')'", "vexp : VREG", "vexp : vexp '+' vexp", "vexp : dexp '+' vexp", "vexp : vexp '-' vexp", "vexp : dexp '-' vexp", "vexp : vexp '*' vexp", "vexp : dexp '*' vexp", "vexp : vexp '/' vexp", "vexp : dexp '/' vexp", "vexp : '-' vexp", "vexp : '(' vexp ')'", }; #endif #if YYDEBUG int yydebug; #endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; int yynerrs; /* define the initial stack-sizes */ #ifdef YYSTACKSIZE #undef YYMAXDEPTH #define YYMAXDEPTH YYSTACKSIZE #else #ifdef YYMAXDEPTH #define YYSTACKSIZE YYMAXDEPTH #else #define YYSTACKSIZE 10000 #define YYMAXDEPTH 10000 #endif #endif #define YYINITSTACKSIZE 200 typedef struct { unsigned stacksize; YYINT *s_base; YYINT *s_mark; YYINT *s_last; YYSTYPE *l_base; YYSTYPE *l_mark; } YYSTACKDATA; /* variables for the parser stack */ static YYSTACKDATA yystack; #line 178 "varsyntax_calc1.y" /* beginning of subroutines section */ #define BSZ 50 /* buffer size for floating point numbers */ /* lexical analysis */ static void yyerror(const char *s) { fprintf(stderr, "%s\n", s); } int yylex(void) { int c; while ((c = getchar()) == ' ') { /* skip over blanks */ } if (isupper(c)) { yylval.ival = c - 'A'; return (VREG); } if (islower(c)) { yylval.ival = c - 'a'; return (DREG); } if (isdigit(c) || c == '.') { /* gobble up digits, points, exponents */ char buf[BSZ + 1], *cp = buf; int dot = 0, expr = 0; for (; (cp - buf) < BSZ; ++cp, c = getchar()) { *cp = (char) c; if (isdigit(c)) continue; if (c == '.') { if (dot++ || expr) return ('.'); /* will cause syntax error */ continue; } if (c == 'e') { if (expr++) return ('e'); /* will cause syntax error */ continue; } /* end of number */ break; } *cp = '\0'; if ((cp - buf) >= BSZ) printf("constant too long: truncated\n"); else ungetc(c, stdin); /* push back last char read */ yylval.dval = atof(buf); return (CONST); } return (c); } static INTERVAL hilo(double a, double b, double c, double d) { /* returns the smallest interval containing a, b, c, and d */ /* used by *, / routines */ INTERVAL v; if (a > b) { v.hi = a; v.lo = b; } else { v.hi = b; v.lo = a; } if (c > d) { if (c > v.hi) v.hi = c; if (d < v.lo) v.lo = d; } else { if (d > v.hi) v.hi = d; if (c < v.lo) v.lo = c; } return (v); } INTERVAL vmul(double a, double b, INTERVAL v) { return (hilo(a * v.hi, a * v.lo, b * v.hi, b * v.lo)); } int dcheck(INTERVAL v) { if (v.hi >= 0. && v.lo <= 0.) { printf("divisor interval contains 0.\n"); return (1); } return (0); } INTERVAL vdiv(double a, double b, INTERVAL v) { return (hilo(a / v.hi, a / v.lo, b / v.hi, b / v.lo)); } #line 494 "varsyntax_calc1.tab.c" #if YYDEBUG #include /* needed for printf */ #endif #include /* needed for malloc, etc */ #include /* needed for memset */ /* allocate initial stack or double stack size, up to YYMAXDEPTH */ static int yygrowstack(YYSTACKDATA *data) { int i; unsigned newsize; YYINT *newss; YYSTYPE *newvs; if ((newsize = data->stacksize) == 0) newsize = YYINITSTACKSIZE; else if (newsize >= YYMAXDEPTH) return YYENOMEM; else if ((newsize *= 2) > YYMAXDEPTH) newsize = YYMAXDEPTH; i = (int) (data->s_mark - data->s_base); newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); if (newss == NULL) return YYENOMEM; data->s_base = newss; data->s_mark = newss + i; newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); if (newvs == NULL) return YYENOMEM; data->l_base = newvs; data->l_mark = newvs + i; data->stacksize = newsize; data->s_last = data->s_base + newsize - 1; return 0; } #if YYPURE || defined(YY_NO_LEAKS) static void yyfreestack(YYSTACKDATA *data) { free(data->s_base); free(data->l_base); memset(data, 0, sizeof(*data)); } #else #define yyfreestack(data) /* nothing */ #endif #define YYABORT goto yyabort #define YYREJECT goto yyabort #define YYACCEPT goto yyaccept #define YYERROR goto yyerrlab int YYPARSE_DECL() { int yym, yyn, yystate; #if YYDEBUG const char *yys; if ((yys = getenv("YYDEBUG")) != NULL) { yyn = *yys; if (yyn >= '0' && yyn <= '9') yydebug = yyn - '0'; } #endif /* yym is set below */ /* yyn is set below */ yynerrs = 0; yyerrflag = 0; yychar = YYEMPTY; yystate = 0; #if YYPURE memset(&yystack, 0, sizeof(yystack)); #endif if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystack.s_mark = yystack.s_base; yystack.l_mark = yystack.l_base; yystate = 0; *yystack.s_mark = 0; yyloop: if ((yyn = yydefred[yystate]) != 0) goto yyreduce; if (yychar < 0) { yychar = YYLEX; if (yychar < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; printf("%sdebug: state %d, reading %d (%s)\n", YYPREFIX, yystate, yychar, yys); } #endif } if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) { #if YYDEBUG if (yydebug) printf("%sdebug: state %d, shifting to state %d\n", YYPREFIX, yystate, yytable[yyn]); #endif if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystate = yytable[yyn]; *++yystack.s_mark = yytable[yyn]; *++yystack.l_mark = yylval; yychar = YYEMPTY; if (yyerrflag > 0) --yyerrflag; goto yyloop; } if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) { yyn = yytable[yyn]; goto yyreduce; } if (yyerrflag != 0) goto yyinrecovery; YYERROR_CALL("syntax error"); goto yyerrlab; /* redundant goto avoids 'unused label' warning */ yyerrlab: ++yynerrs; yyinrecovery: if (yyerrflag < 3) { yyerrflag = 3; for (;;) { if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) { #if YYDEBUG if (yydebug) printf("%sdebug: state %d, error recovery shifting\ to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); #endif if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystate = yytable[yyn]; *++yystack.s_mark = yytable[yyn]; *++yystack.l_mark = yylval; goto yyloop; } else { #if YYDEBUG if (yydebug) printf("%sdebug: error recovery discarding state %d\n", YYPREFIX, *yystack.s_mark); #endif if (yystack.s_mark <= yystack.s_base) goto yyabort; --yystack.s_mark; --yystack.l_mark; } } } else { if (yychar == YYEOF) goto yyabort; #if YYDEBUG if (yydebug) { if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; printf("%sdebug: state %d, error recovery discards token %d (%s)\n", YYPREFIX, yystate, yychar, yys); } #endif yychar = YYEMPTY; goto yyloop; } yyreduce: #if YYDEBUG if (yydebug) printf("%sdebug: state %d, reducing by rule %d (%s)\n", YYPREFIX, yystate, yyn, yyrule[yyn]); #endif yym = yylen[yyn]; if (yym > 0) yyval = yystack.l_mark[1-yym]; else memset(&yyval, 0, sizeof yyval); switch (yyn) { case 3: #line 59 "varsyntax_calc1.y" { (void) printf("%15.8f\n", yystack.l_mark[-1].dval); } #line 698 "varsyntax_calc1.tab.c" break; case 4: #line 63 "varsyntax_calc1.y" { (void) printf("(%15.8f, %15.8f)\n", yystack.l_mark[-1].vval.lo, yystack.l_mark[-1].vval.hi); } #line 705 "varsyntax_calc1.tab.c" break; case 5: #line 67 "varsyntax_calc1.y" { dreg[yystack.l_mark[-3].ival] = yystack.l_mark[-1].dval; } #line 712 "varsyntax_calc1.tab.c" break; case 6: #line 71 "varsyntax_calc1.y" { vreg[yystack.l_mark[-3].ival] = yystack.l_mark[-1].vval; } #line 719 "varsyntax_calc1.tab.c" break; case 7: #line 75 "varsyntax_calc1.y" { yyerrok; } #line 726 "varsyntax_calc1.tab.c" break; case 9: #line 82 "varsyntax_calc1.y" { yyval.dval = dreg[yystack.l_mark[0].ival]; /* $$ & $1 are sufficient here*/ } #line 733 "varsyntax_calc1.tab.c" break; case 10: #line 86 "varsyntax_calc1.y" { yyval.dval = yystack.l_mark[-2].dval + yystack.l_mark[0].dval; } #line 740 "varsyntax_calc1.tab.c" break; case 11: #line 90 "varsyntax_calc1.y" { yyval.dval = yystack.l_mark[-2].dval - yystack.l_mark[0].dval; } #line 747 "varsyntax_calc1.tab.c" break; case 12: #line 94 "varsyntax_calc1.y" { yyval.dval = yystack.l_mark[-2].dval * yystack.l_mark[0].dval; } #line 754 "varsyntax_calc1.tab.c" break; case 13: #line 98 "varsyntax_calc1.y" { yyval.dval = yystack.l_mark[-2].dval / yystack.l_mark[0].dval; } #line 761 "varsyntax_calc1.tab.c" break; case 14: #line 102 "varsyntax_calc1.y" { yyval.dval = -yystack.l_mark[0].dval; } #line 768 "varsyntax_calc1.tab.c" break; case 15: #line 106 "varsyntax_calc1.y" { yyval.dval = yystack.l_mark[-1].dval; } #line 775 "varsyntax_calc1.tab.c" break; case 16: #line 112 "varsyntax_calc1.y" { yyval.vval.hi = yyval.vval.lo = yystack.l_mark[0].dval; } #line 782 "varsyntax_calc1.tab.c" break; case 17: #line 116 "varsyntax_calc1.y" { yyval.vval.lo = yystack.l_mark[-3].dval; yyval.vval.hi = yystack.l_mark[-1].dval; if ( yyval.vval.lo > yyval.vval.hi ) { (void) printf("interval out of order\n"); YYERROR; } } #line 795 "varsyntax_calc1.tab.c" break; case 18: #line 126 "varsyntax_calc1.y" { yyval.vval = vreg[yystack.l_mark[0].ival]; } #line 802 "varsyntax_calc1.tab.c" break; case 19: #line 130 "varsyntax_calc1.y" { yyval.vval.hi = yystack.l_mark[-2].vval.hi + yystack.l_mark[0].vval.hi; yyval.vval.lo = yystack.l_mark[-2].vval.lo + yystack.l_mark[0].vval.lo; } #line 810 "varsyntax_calc1.tab.c" break; case 20: #line 135 "varsyntax_calc1.y" { yyval.vval.hi = yystack.l_mark[-2].dval + yystack.l_mark[0].vval.hi; yyval.vval.lo = yystack.l_mark[-2].dval + yystack.l_mark[0].vval.lo; } #line 818 "varsyntax_calc1.tab.c" break; case 21: #line 140 "varsyntax_calc1.y" { yyval.vval.hi = yystack.l_mark[-2].vval.hi - yystack.l_mark[0].vval.lo; yyval.vval.lo = yystack.l_mark[-2].vval.lo - yystack.l_mark[0].vval.hi; } #line 826 "varsyntax_calc1.tab.c" break; case 22: #line 145 "varsyntax_calc1.y" { yyval.vval.hi = yystack.l_mark[-2].dval - yystack.l_mark[0].vval.lo; yyval.vval.lo = yystack.l_mark[-2].dval - yystack.l_mark[0].vval.hi; } #line 834 "varsyntax_calc1.tab.c" break; case 23: #line 150 "varsyntax_calc1.y" { yyval.vval = vmul( yystack.l_mark[-2].vval.lo, yystack.l_mark[-2].vval.hi, yystack.l_mark[0].vval ); } #line 841 "varsyntax_calc1.tab.c" break; case 24: #line 154 "varsyntax_calc1.y" { yyval.vval = vmul (yystack.l_mark[-2].dval, yystack.l_mark[-2].dval, yystack.l_mark[0].vval ); } #line 848 "varsyntax_calc1.tab.c" break; case 25: #line 158 "varsyntax_calc1.y" { if (dcheck(yystack.l_mark[0].vval)) YYERROR; yyval.vval = vdiv ( yystack.l_mark[-2].vval.lo, yystack.l_mark[-2].vval.hi, yystack.l_mark[0].vval ); } #line 856 "varsyntax_calc1.tab.c" break; case 26: #line 163 "varsyntax_calc1.y" { if (dcheck ( yystack.l_mark[0].vval )) YYERROR; yyval.vval = vdiv (yystack.l_mark[-2].dval, yystack.l_mark[-2].dval, yystack.l_mark[0].vval ); } #line 864 "varsyntax_calc1.tab.c" break; case 27: #line 168 "varsyntax_calc1.y" { yyval.vval.hi = -yystack.l_mark[0].vval.lo; yyval.vval.lo = -yystack.l_mark[0].vval.hi; } #line 872 "varsyntax_calc1.tab.c" break; case 28: #line 173 "varsyntax_calc1.y" { yyval.vval = yystack.l_mark[-1].vval; } #line 879 "varsyntax_calc1.tab.c" break; #line 881 "varsyntax_calc1.tab.c" } yystack.s_mark -= yym; yystate = *yystack.s_mark; yystack.l_mark -= yym; yym = yylhs[yyn]; if (yystate == 0 && yym == 0) { #if YYDEBUG if (yydebug) printf("%sdebug: after reduction, shifting from state 0 to\ state %d\n", YYPREFIX, YYFINAL); #endif yystate = YYFINAL; *++yystack.s_mark = YYFINAL; *++yystack.l_mark = yyval; if (yychar < 0) { yychar = YYLEX; if (yychar < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; printf("%sdebug: state %d, reading %d (%s)\n", YYPREFIX, YYFINAL, yychar, yys); } #endif } if (yychar == YYEOF) goto yyaccept; goto yyloop; } if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) yystate = yytable[yyn]; else yystate = yydgoto[yym]; #if YYDEBUG if (yydebug) printf("%sdebug: after reduction, shifting from state %d \ to state %d\n", YYPREFIX, *yystack.s_mark, yystate); #endif if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; *++yystack.s_mark = (YYINT) yystate; *++yystack.l_mark = yyval; goto yyloop; yyoverflow: YYERROR_CALL("yacc stack overflow"); yyabort: yyfreestack(&yystack); return (1); yyaccept: yyfreestack(&yystack); return (0); } diff --git a/contrib/byacc/test/yacc/varsyntax_calc1.tab.h b/contrib/byacc/test/yacc/varsyntax_calc1.tab.h index 50369b226429..fd07f2cc3d41 100644 --- a/contrib/byacc/test/yacc/varsyntax_calc1.tab.h +++ b/contrib/byacc/test/yacc/varsyntax_calc1.tab.h @@ -1,18 +1,18 @@ #define DREG 257 #define VREG 258 #define CONST 259 #define UMINUS 260 #ifdef YYSTYPE #undef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 #endif #ifndef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 -typedef union YYSTYPE +typedef union { int ival; /* dreg & vreg array index values*/ double dval; /* floating point values*/ INTERVAL vval; /* interval values*/ } YYSTYPE; #endif /* !YYSTYPE_IS_DECLARED */ extern YYSTYPE varsyntax_calc1_lval;