diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-06-23 07:13:15 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-06-23 07:13:15 (GMT) |
commit | 75376fc361851e388acdc9c4a64c1987446b808f (patch) | |
tree | eacbc36258d54e0bca98b361e25914963e2239b8 /generic/tclDate.c | |
parent | 6ed8324a384bd6e0b7732b52c9e5bfca0c236ac3 (diff) | |
download | tcl-75376fc361851e388acdc9c4a64c1987446b808f.zip tcl-75376fc361851e388acdc9c4a64c1987446b808f.tar.gz tcl-75376fc361851e388acdc9c4a64c1987446b808f.tar.bz2 |
re-generate with bison 3.1
Diffstat (limited to 'generic/tclDate.c')
-rw-r--r-- | generic/tclDate.c | 315 |
1 files changed, 206 insertions, 109 deletions
diff --git a/generic/tclDate.c b/generic/tclDate.c index daeb1d9..dcb85e9 100644 --- a/generic/tclDate.c +++ b/generic/tclDate.c @@ -1,9 +1,8 @@ -/* A Bison parser, made by GNU Bison 3.4.2. */ +/* A Bison parser, made by GNU Bison 3.1. */ /* Bison implementation for Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2019 Free Software Foundation, - Inc. + Copyright (C) 1984, 1989-1990, 2000-2015, 2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -41,14 +40,11 @@ define necessary library symbols; they are noted "INFRINGES ON USER NAME SPACE" below. */ -/* Undocumented macros, especially those whose name start with YY_, - are private implementation details. Do not rely on them. */ - /* Identify Bison output. */ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "3.4.2" +#define YYBISON_VERSION "3.1" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -71,7 +67,8 @@ #define yynerrs TclDatenerrs -/* First part of user prologue. */ +/* Copy the first part of user declarations. */ + /* * tclDate.c -- @@ -212,15 +209,12 @@ typedef enum _DSTMODE { + # ifndef YY_NULLPTR -# if defined __cplusplus -# if 201103L <= __cplusplus -# define YY_NULLPTR nullptr -# else -# define YY_NULLPTR 0 -# endif +# if defined __cplusplus && 201103L <= __cplusplus +# define YY_NULLPTR nullptr # else -# define YY_NULLPTR ((void*)0) +# define YY_NULLPTR 0 # endif # endif @@ -268,14 +262,17 @@ extern int TclDatedebug; /* Value type. */ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED + union YYSTYPE { + time_t Number; enum _MERIDIAN Meridian; }; + typedef union YYSTYPE YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define YYSTYPE_IS_DECLARED 1 @@ -301,7 +298,8 @@ int TclDateparse (DateInfo* info); -/* Second part of user prologue. */ +/* Copy the second part of user declarations. */ + /* @@ -393,6 +391,15 @@ typedef short yytype_int16; # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__)) #endif +#if !defined _Noreturn \ + && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112) +# if defined _MSC_VER && 1200 <= _MSC_VER +# define _Noreturn __declspec (noreturn) +# else +# define _Noreturn YY_ATTRIBUTE ((__noreturn__)) +# endif +#endif + /* Suppress unused-variable warnings by "using" E. */ #if ! defined lint || defined __GNUC__ # define YYUSE(E) ((void) (E)) @@ -420,8 +427,6 @@ typedef short yytype_int16; #endif -#define YY_ASSERT(E) ((void) (0 && (E))) - #if ! defined yyoverflow || YYERROR_VERBOSE /* The parser invokes alloca or malloc; define the necessary symbols. */ @@ -566,16 +571,16 @@ union yyalloc /* YYNSTATES -- Number of states. */ #define YYNSTATES 89 +/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned + by yylex, with out-of-bounds checking. */ #define YYUNDEFTOK 2 #define YYMAXUTOK 274 -/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM - as returned by yylex, with out-of-bounds checking. */ #define YYTRANSLATE(YYX) \ ((unsigned) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM - as returned by yylex. */ + as returned by yylex, without out-of-bounds checking. */ static const yytype_uint8 yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -781,22 +786,22 @@ static const yytype_uint8 yyr2[] = #define YYRECOVERING() (!!yyerrstatus) -#define YYBACKUP(Token, Value) \ - do \ - if (yychar == YYEMPTY) \ - { \ - yychar = (Token); \ - yylval = (Value); \ - YYPOPSTACK (yylen); \ - yystate = *yyssp; \ - goto yybackup; \ - } \ - else \ - { \ - yyerror (&yylloc, info, YY_("syntax error: cannot back up")); \ - YYERROR; \ - } \ - while (0) +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + YYPOPSTACK (yylen); \ + yystate = *yyssp; \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (&yylloc, info, YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (0) /* Error token number */ #define YYTERROR 1 @@ -855,10 +860,10 @@ do { \ /* Print *YYLOCP on YYO. Private, do not rely on its existence. */ YY_ATTRIBUTE_UNUSED -static int +static unsigned yy_location_print_ (FILE *yyo, YYLTYPE const * const yylocp) { - int res = 0; + unsigned res = 0; int end_col = 0 != yylocp->last_column ? yylocp->last_column - 1 : 0; if (0 <= yylocp->first_line) { @@ -901,43 +906,41 @@ do { \ } while (0) -/*-----------------------------------. -| Print this symbol's value on YYO. | -`-----------------------------------*/ +/*----------------------------------------. +| Print this symbol's value on YYOUTPUT. | +`----------------------------------------*/ static void -yy_symbol_value_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, DateInfo* info) +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, DateInfo* info) { - FILE *yyoutput = yyo; - YYUSE (yyoutput); + FILE *yyo = yyoutput; + YYUSE (yyo); YYUSE (yylocationp); YYUSE (info); if (!yyvaluep) return; # ifdef YYPRINT if (yytype < YYNTOKENS) - YYPRINT (yyo, yytoknum[yytype], *yyvaluep); + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); # endif - YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN YYUSE (yytype); - YY_IGNORE_MAYBE_UNINITIALIZED_END } -/*---------------------------. -| Print this symbol on YYO. | -`---------------------------*/ +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ static void -yy_symbol_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, DateInfo* info) +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, DateInfo* info) { - YYFPRINTF (yyo, "%s %s (", + YYFPRINTF (yyoutput, "%s %s (", yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]); - YY_LOCATION_PRINT (yyo, *yylocationp); - YYFPRINTF (yyo, ": "); - yy_symbol_value_print (yyo, yytype, yyvaluep, yylocationp, info); - YYFPRINTF (yyo, ")"); + YY_LOCATION_PRINT (yyoutput, *yylocationp); + YYFPRINTF (yyoutput, ": "); + yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, info); + YYFPRINTF (yyoutput, ")"); } /*------------------------------------------------------------------. @@ -982,7 +985,7 @@ yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule YYFPRINTF (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, yystos[yyssp[yyi + 1 - yynrhs]], - &yyvsp[(yyi + 1) - (yynrhs)] + &(yyvsp[(yyi + 1) - (yynrhs)]) , &(yylsp[(yyi + 1) - (yynrhs)]) , info); YYFPRINTF (stderr, "\n"); } @@ -1086,10 +1089,7 @@ yytnamerr (char *yyres, const char *yystr) case '\\': if (*++yyp != '\\') goto do_not_strip_quotes; - else - goto append; - - append: + /* Fall through. */ default: if (yyres) yyres[yyn] = *yyp; @@ -1107,7 +1107,7 @@ yytnamerr (char *yyres, const char *yystr) if (! yyres) return yystrlen (yystr); - return (YYSIZE_T) (yystpcpy (yyres, yystr) - yyres); + return yystpcpy (yyres, yystr) - yyres; } # endif @@ -1185,10 +1185,10 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, yyarg[yycount++] = yytname[yyx]; { YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); - if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM) - yysize = yysize1; - else + if (! (yysize <= yysize1 + && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) return 2; + yysize = yysize1; } } } @@ -1212,10 +1212,9 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, { YYSIZE_T yysize1 = yysize + yystrlen (yyformat); - if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM) - yysize = yysize1; - else + if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) return 2; + yysize = yysize1; } if (*yymsg_alloc < yysize) @@ -1367,33 +1366,23 @@ YYLTYPE yylloc = yyloc_default; yylsp[0] = yylloc; goto yysetstate; - /*------------------------------------------------------------. -| yynewstate -- push a new state, which is found in yystate. | +| yynewstate -- Push a new state, which is found in yystate. | `------------------------------------------------------------*/ -yynewstate: + yynewstate: /* In all cases, when you get here, the value and location stacks have just been pushed. So pushing a state here evens the stacks. */ yyssp++; - -/*--------------------------------------------------------------------. -| yynewstate -- set current state (the top of the stack) to yystate. | -`--------------------------------------------------------------------*/ -yysetstate: - YYDPRINTF ((stderr, "Entering state %d\n", yystate)); - YY_ASSERT (0 <= yystate && yystate < YYNSTATES); - *yyssp = (yytype_int16) yystate; + yysetstate: + *yyssp = yystate; if (yyss + yystacksize - 1 <= yyssp) -#if !defined yyoverflow && !defined YYSTACK_RELOCATE - goto yyexhaustedlab; -#else { /* Get the current used size of the three stacks, in elements. */ - YYSIZE_T yysize = (YYSIZE_T) (yyssp - yyss + 1); + YYSIZE_T yysize = yyssp - yyss + 1; -# if defined yyoverflow +#ifdef yyoverflow { /* Give user a chance to reallocate the stack. Use copies of these so that the &'s don't force the real ones into @@ -1411,11 +1400,15 @@ yysetstate: &yyvs1, yysize * sizeof (*yyvsp), &yyls1, yysize * sizeof (*yylsp), &yystacksize); + + yyls = yyls1; yyss = yyss1; yyvs = yyvs1; - yyls = yyls1; } -# else /* defined YYSTACK_RELOCATE */ +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) goto yyexhaustedlab; @@ -1432,11 +1425,12 @@ yysetstate: YYSTACK_RELOCATE (yyss_alloc, yyss); YYSTACK_RELOCATE (yyvs_alloc, yyvs); YYSTACK_RELOCATE (yyls_alloc, yyls); -# undef YYSTACK_RELOCATE +# undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); } # endif +#endif /* no yyoverflow */ yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; @@ -1448,18 +1442,19 @@ yysetstate: if (yyss + yystacksize - 1 <= yyssp) YYABORT; } -#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */ + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); if (yystate == YYFINAL) YYACCEPT; goto yybackup; - /*-----------. | yybackup. | `-----------*/ yybackup: + /* Do appropriate processing given the current state. Read a lookahead token if we need one and don't already have one. */ @@ -1532,7 +1527,7 @@ yydefault: /*-----------------------------. -| yyreduce -- do a reduction. | +| yyreduce -- Do a reduction. | `-----------------------------*/ yyreduce: /* yyn is the number of a rule to reduce with. */ @@ -1554,76 +1549,97 @@ yyreduce: YY_REDUCE_PRINT (yyn); switch (yyn) { - case 4: + case 4: + { yyHaveTime++; } + break; case 5: + { yyHaveZone++; } + break; case 6: + { yyHaveDate++; } + break; case 7: + { yyHaveOrdinalMonth++; } + break; case 8: + { yyHaveDay++; } + break; case 9: + { yyHaveRel++; } + break; case 10: + { yyHaveTime++; yyHaveDate++; } + break; case 11: + { yyHaveTime++; yyHaveDate++; yyHaveRel++; } + break; case 13: + { yyHour = (yyvsp[-1].Number); yyMinutes = 0; yySeconds = 0; yyMeridian = (yyvsp[0].Meridian); } + break; case 14: + { yyHour = (yyvsp[-3].Number); yyMinutes = (yyvsp[-1].Number); yySeconds = 0; yyMeridian = (yyvsp[0].Meridian); } + break; case 15: + { yyHour = (yyvsp[-4].Number); yyMinutes = (yyvsp[-2].Number); @@ -1632,18 +1648,22 @@ yyreduce: yyTimezone = ((yyvsp[0].Number) % 100 + ((yyvsp[0].Number) / 100) * 60); ++yyHaveZone; } + break; case 16: + { yyHour = (yyvsp[-5].Number); yyMinutes = (yyvsp[-3].Number); yySeconds = (yyvsp[-1].Number); yyMeridian = (yyvsp[0].Meridian); } + break; case 17: + { yyHour = (yyvsp[-6].Number); yyMinutes = (yyvsp[-4].Number); @@ -1653,158 +1673,200 @@ yyreduce: yyTimezone = ((yyvsp[0].Number) % 100 + ((yyvsp[0].Number) / 100) * 60); ++yyHaveZone; } + break; case 18: + { yyTimezone = (yyvsp[-1].Number); if (yyTimezone > HOUR( 12)) yyTimezone -= HOUR(100); yyDSTmode = DSTon; } + break; case 19: + { yyTimezone = (yyvsp[0].Number); if (yyTimezone > HOUR( 12)) yyTimezone -= HOUR(100); yyDSTmode = DSToff; } + break; case 20: + { yyTimezone = (yyvsp[0].Number); yyDSTmode = DSTon; } + break; case 21: + { yyDayOrdinal = 1; yyDayNumber = (yyvsp[0].Number); } + break; case 22: + { yyDayOrdinal = 1; yyDayNumber = (yyvsp[-1].Number); } + break; case 23: + { yyDayOrdinal = (yyvsp[-1].Number); yyDayNumber = (yyvsp[0].Number); } + break; case 24: + { yyDayOrdinal = (yyvsp[-2].Number) * (yyvsp[-1].Number); yyDayNumber = (yyvsp[0].Number); } + break; case 25: + { yyDayOrdinal = 2; yyDayNumber = (yyvsp[0].Number); } + break; case 26: + { yyMonth = (yyvsp[-2].Number); yyDay = (yyvsp[0].Number); } + break; case 27: + { yyMonth = (yyvsp[-4].Number); yyDay = (yyvsp[-2].Number); yyYear = (yyvsp[0].Number); } + break; case 28: + { yyYear = (yyvsp[0].Number) / 10000; yyMonth = ((yyvsp[0].Number) % 10000)/100; yyDay = (yyvsp[0].Number) % 100; } + break; case 29: + { yyDay = (yyvsp[-4].Number); yyMonth = (yyvsp[-2].Number); yyYear = (yyvsp[0].Number); } + break; case 30: + { yyMonth = (yyvsp[-2].Number); yyDay = (yyvsp[0].Number); yyYear = (yyvsp[-4].Number); } + break; case 31: + { yyMonth = (yyvsp[-1].Number); yyDay = (yyvsp[0].Number); } + break; case 32: + { yyMonth = (yyvsp[-3].Number); yyDay = (yyvsp[-2].Number); yyYear = (yyvsp[0].Number); } + break; case 33: + { yyMonth = (yyvsp[0].Number); yyDay = (yyvsp[-1].Number); } + break; case 34: + { yyMonth = 1; yyDay = 1; yyYear = EPOCH; } + break; case 35: + { yyMonth = (yyvsp[-1].Number); yyDay = (yyvsp[-2].Number); yyYear = (yyvsp[0].Number); } + break; case 36: + { yyMonthOrdinal = 1; yyMonth = (yyvsp[0].Number); } + break; case 37: + { yyMonthOrdinal = (yyvsp[-1].Number); yyMonth = (yyvsp[0].Number); } + break; case 38: + { if ((yyvsp[-5].Number) != HOUR( 7) + HOUR(100)) YYABORT; yyYear = (yyvsp[-10].Number); @@ -1814,9 +1876,11 @@ yyreduce: yyMinutes = (yyvsp[-2].Number); yySeconds = (yyvsp[0].Number); } + break; case 39: + { if ((yyvsp[-1].Number) != HOUR( 7) + HOUR(100)) YYABORT; yyYear = (yyvsp[-2].Number) / 10000; @@ -1826,9 +1890,11 @@ yyreduce: yyMinutes = ((yyvsp[0].Number) % 10000)/100; yySeconds = (yyvsp[0].Number) % 100; } + break; case 40: + { if ((yyvsp[-5].Number) != HOUR( 7) + HOUR(100)) YYABORT; yyYear = (yyvsp[-6].Number) / 10000; @@ -1838,9 +1904,11 @@ yyreduce: yyMinutes = (yyvsp[-2].Number); yySeconds = (yyvsp[0].Number); } + break; case 41: + { yyYear = (yyvsp[-1].Number) / 10000; yyMonth = ((yyvsp[-1].Number) % 10000)/100; @@ -1849,9 +1917,11 @@ yyreduce: yyMinutes = ((yyvsp[0].Number) % 10000)/100; yySeconds = (yyvsp[0].Number) % 100; } + break; case 42: + { /* * Offset computed year by -377 so that the returned years will be @@ -1864,80 +1934,104 @@ yyreduce: yyRelDay += (((yyvsp[-2].Number)%1000)*(365 + IsLeapYear(yyYear)))/1000; yyRelSeconds += (yyvsp[0].Number) * 144 * 60; } + break; case 43: + { yyRelSeconds *= -1; yyRelMonth *= -1; yyRelDay *= -1; } + break; case 45: + { *yyRelPointer += (yyvsp[-2].Number) * (yyvsp[-1].Number) * (yyvsp[0].Number); } + break; case 46: + { *yyRelPointer += (yyvsp[-1].Number) * (yyvsp[0].Number); } + break; case 47: + { *yyRelPointer += (yyvsp[0].Number); } + break; case 48: + { *yyRelPointer += (yyvsp[-1].Number) * (yyvsp[0].Number); } + break; case 49: + { *yyRelPointer += (yyvsp[0].Number); } + break; case 50: + { (yyval.Number) = -1; } + break; case 51: + { (yyval.Number) = 1; } + break; case 52: + { (yyval.Number) = (yyvsp[0].Number); yyRelPointer = &yyRelSeconds; } + break; case 53: + { (yyval.Number) = (yyvsp[0].Number); yyRelPointer = &yyRelDay; } + break; case 54: + { (yyval.Number) = (yyvsp[0].Number); yyRelPointer = &yyRelMonth; } + break; case 55: + { if (yyHaveTime && yyHaveDate && !yyHaveRel) { yyYear = (yyvsp[0].Number); @@ -1954,18 +2048,23 @@ yyreduce: yyMeridian = MER24; } } + break; case 56: + { (yyval.Meridian) = MER24; } + break; case 57: + { (yyval.Meridian) = (yyvsp[0].Meridian); } + break; @@ -1995,13 +2094,14 @@ yyreduce: /* Now 'shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ - { - const int yylhs = yyr1[yyn] - YYNTOKENS; - const int yyi = yypgoto[yylhs] + *yyssp; - yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp - ? yytable[yyi] - : yydefgoto[yylhs]); - } + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; goto yynewstate; @@ -2084,10 +2184,12 @@ yyerrlab: | yyerrorlab -- error raised explicitly by YYERROR. | `---------------------------------------------------*/ yyerrorlab: - /* Pacify compilers when the user code never invokes YYERROR and the - label yyerrorlab therefore never appears in user code. */ - if (0) - YYERROR; + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; /* Do not reclaim the symbols of the rule whose action triggered this YYERROR. */ @@ -2154,7 +2256,6 @@ yyacceptlab: yyresult = 0; goto yyreturn; - /*-----------------------------------. | yyabortlab -- YYABORT comes here. | `-----------------------------------*/ @@ -2162,7 +2263,6 @@ yyabortlab: yyresult = 1; goto yyreturn; - #if !defined yyoverflow || YYERROR_VERBOSE /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | @@ -2173,10 +2273,6 @@ yyexhaustedlab: /* Fall through. */ #endif - -/*-----------------------------------------------------. -| yyreturn -- parsing is finished, return the result. | -`-----------------------------------------------------*/ yyreturn: if (yychar != YYEMPTY) { @@ -2207,6 +2303,7 @@ yyreturn: return yyresult; } + /* * Month and day table. */ |