47 #define YYBISON_VERSION "2.5"
50 #define YYSKELETON_NAME "yacc.c"
62 #define YYLSP_NEEDED 0
120 #if STDC_HEADERS || (! defined isascii && ! HAVE_ISASCII)
121 # define IN_CTYPE_DOMAIN(c) 1
123 # define IN_CTYPE_DOMAIN(c) isascii (c)
126 #define ISSPACE(c) (IN_CTYPE_DOMAIN (c) && isspace (c))
127 #define ISALPHA(c) (IN_CTYPE_DOMAIN (c) && isalpha (c))
128 #define ISLOWER(c) (IN_CTYPE_DOMAIN (c) && islower (c))
129 #define ISDIGIT_LOCALE(c) (IN_CTYPE_DOMAIN (c) && isdigit (c))
139 #define ISDIGIT(c) ((unsigned) (c) - '0' <= 9)
141 #if STDC_HEADERS || HAVE_STRING_H
145 #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) || __STRICT_ANSI__
146 # define __attribute__(x)
149 #ifndef ATTRIBUTE_UNUSED
150 # define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
153 #define EPOCH_YEAR 1970
154 #define TM_YEAR_BASE 1900
156 #define HOUR(x) ((x) * 60)
226 #define PC (* (parser_control *) parm)
227 #define YYLEX_PARAM parm
228 #define YYPARSE_PARAM parm
233 #line 234 "getdate.c"
241 #ifdef YYERROR_VERBOSE
242 # undef YYERROR_VERBOSE
243 # define YYERROR_VERBOSE 1
245 # define YYERROR_VERBOSE 0
249 #ifndef YYTOKEN_TABLE
250 # define YYTOKEN_TABLE 0
281 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
286 #line 170 "getdate.y"
294 #line 295 "getdate.c"
296 # define YYSTYPE_IS_TRIVIAL 1
297 # define yystype YYSTYPE
298 # define YYSTYPE_IS_DECLARED 1
305 #line 175 "getdate.y"
312 #line 313 "getdate.c"
326 #elif (defined __STDC__ || defined __C99__FUNC__ \
327 || defined __cplusplus || defined _MSC_VER)
346 # ifdef __SIZE_TYPE__
347 # define YYSIZE_T __SIZE_TYPE__
348 # elif defined size_t
349 # define YYSIZE_T size_t
350 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
351 || defined __cplusplus || defined _MSC_VER)
353 # define YYSIZE_T size_t
355 # define YYSIZE_T unsigned int
359 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
362 # if defined YYENABLE_NLS && YYENABLE_NLS
364 # include <libintl.h>
365 # define YY_(msgid) dgettext ("bison-runtime", msgid)
369 # define YY_(msgid) msgid
374 #if ! defined lint || defined __GNUC__
375 # define YYUSE(e) ((void) (e))
384 #if (defined __STDC__ || defined __C99__FUNC__ \
385 || defined __cplusplus || defined _MSC_VER)
398 #if ! defined yyoverflow || YYERROR_VERBOSE
402 # ifdef YYSTACK_USE_ALLOCA
403 # if YYSTACK_USE_ALLOCA
405 # define YYSTACK_ALLOC __builtin_alloca
406 # elif defined __BUILTIN_VA_ARG_INCR
409 # define YYSTACK_ALLOC __alloca
410 # elif defined _MSC_VER
412 # define alloca _alloca
414 # define YYSTACK_ALLOC alloca
415 # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
416 || defined __cplusplus || defined _MSC_VER)
418 # ifndef EXIT_SUCCESS
419 # define EXIT_SUCCESS 0
426 # ifdef YYSTACK_ALLOC
428 # define YYSTACK_FREE(Ptr) do { ; } while (YYID (0))
429 # ifndef YYSTACK_ALLOC_MAXIMUM
434 # define YYSTACK_ALLOC_MAXIMUM 4032
437 # define YYSTACK_ALLOC YYMALLOC
438 # define YYSTACK_FREE YYFREE
439 # ifndef YYSTACK_ALLOC_MAXIMUM
440 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
442 # if (defined __cplusplus && ! defined EXIT_SUCCESS \
443 && ! ((defined YYMALLOC || defined malloc) \
444 && (defined YYFREE || defined free)))
446 # ifndef EXIT_SUCCESS
447 # define EXIT_SUCCESS 0
451 # define YYMALLOC malloc
452 # if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
453 || defined __cplusplus || defined _MSC_VER)
459 # if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
460 || defined __cplusplus || defined _MSC_VER)
468 #if (! defined yyoverflow \
469 && (! defined __cplusplus \
470 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
480 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
484 # define YYSTACK_BYTES(N) \
485 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
486 + YYSTACK_GAP_MAXIMUM)
488 # define YYCOPY_NEEDED 1
495 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
498 YYSIZE_T yynewbytes; \
499 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
500 Stack = &yyptr->Stack_alloc; \
501 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
502 yyptr += yynewbytes / sizeof (*yyptr); \
508 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
512 # if defined __GNUC__ && 1 < __GNUC__
513 # define YYCOPY(To, From, Count) \
514 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
516 # define YYCOPY(To, From, Count) \
520 for (yyi = 0; yyi < (Count); yyi++) \
521 (To)[yyi] = (From)[yyi]; \
544 #define YYMAXUTOK 273
546 #define YYTRANSLATE(YYX) \
547 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
552 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
553 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
554 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
555 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
556 2, 2, 2, 2, 20, 2, 2, 21, 2, 2,
557 2, 2, 2, 2, 2, 2, 2, 2, 19, 2,
558 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
559 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
560 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
561 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
562 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
563 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
564 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
565 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
566 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
567 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
568 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
569 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
570 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
571 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
572 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
573 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
574 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
575 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
576 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
577 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
578 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
587 0, 0, 3, 4, 7, 9, 11, 13, 15, 17,
588 19, 21, 25, 28, 33, 38, 45, 52, 54, 57,
589 59, 61, 64, 66, 69, 72, 76, 82, 86, 90,
590 93, 98, 101, 105, 108, 110, 113, 116, 118, 121,
591 124, 126, 129, 132, 134, 137, 140, 142, 145, 148,
592 150, 153, 156, 158, 160, 161
598 23, 0, -1, -1, 23, 24, -1, 25, -1, 26,
599 -1, 27, -1, 29, -1, 28, -1, 30, -1, 32,
600 -1, 29, 16, 25, -1, 18, 10, -1, 18, 19,
601 18, 33, -1, 18, 19, 18, 17, -1, 18, 19,
602 18, 19, 18, 33, -1, 18, 19, 18, 19, 18,
603 17, -1, 9, -1, 9, 4, -1, 16, -1, 7,
604 -1, 16, 4, -1, 5, -1, 5, 20, -1, 18,
605 5, -1, 18, 21, 18, -1, 18, 21, 18, 21,
606 18, -1, 18, 17, 17, -1, 18, 12, 17, -1,
607 12, 18, -1, 12, 18, 20, 18, -1, 18, 12,
608 -1, 18, 12, 18, -1, 31, 3, -1, 31, -1,
609 18, 15, -1, 17, 15, -1, 15, -1, 18, 13,
610 -1, 17, 13, -1, 13, -1, 18, 6, -1, 17,
611 6, -1, 6, -1, 18, 8, -1, 17, 8, -1,
612 8, -1, 18, 11, -1, 17, 11, -1, 11, -1,
613 18, 14, -1, 17, 14, -1, 14, -1, 18, -1,
620 0, 191, 191, 193, 197, 199, 201, 203, 205, 207,
621 209, 210, 218, 225, 232, 240, 247, 259, 261, 266,
622 268, 270, 275, 280, 285, 293, 298, 318, 325, 333,
623 338, 344, 349, 358, 367, 371, 373, 375, 377, 379,
624 381, 383, 385, 387, 389, 391, 393, 395, 397, 399,
625 401, 403, 405, 410, 447, 448
629 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
632 static const char *
const yytname[] =
634 "$end",
"error",
"$undefined",
"tAGO",
"tDST",
"tDAY",
"tDAY_UNIT",
635 "tDAYZONE",
"tHOUR_UNIT",
"tLOCAL_ZONE",
"tMERIDIAN",
"tMINUTE_UNIT",
636 "tMONTH",
"tMONTH_UNIT",
"tSEC_UNIT",
"tYEAR_UNIT",
"tZONE",
"tSNUMBER",
637 "tUNUMBER",
"':'",
"','",
"'/'",
"$accept",
"spec",
"item",
"time",
638 "local_zone",
"zone",
"day",
"date",
"rel",
"relunit",
"number",
648 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
649 265, 266, 267, 268, 269, 270, 271, 272, 273, 58,
657 0, 22, 23, 23, 24, 24, 24, 24, 24, 24,
658 24, 24, 25, 25, 25, 25, 25, 26, 26, 27,
659 27, 27, 28, 28, 28, 29, 29, 29, 29, 29,
660 29, 29, 29, 30, 30, 31, 31, 31, 31, 31,
661 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
662 31, 31, 31, 32, 33, 33
668 0, 2, 0, 2, 1, 1, 1, 1, 1, 1,
669 1, 3, 2, 4, 4, 6, 6, 1, 2, 1,
670 1, 2, 1, 2, 2, 3, 5, 3, 3, 2,
671 4, 2, 3, 2, 1, 2, 2, 1, 2, 2,
672 1, 2, 2, 1, 2, 2, 1, 2, 2, 1,
681 2, 0, 1, 22, 43, 20, 46, 17, 49, 0,
682 40, 52, 37, 19, 0, 53, 3, 4, 5, 6,
683 8, 7, 9, 34, 10, 23, 18, 29, 21, 42,
684 45, 48, 39, 51, 36, 24, 41, 44, 12, 47,
685 31, 38, 50, 35, 0, 0, 0, 0, 33, 0,
686 28, 32, 27, 54, 25, 0, 11, 30, 55, 14,
687 0, 13, 0, 54, 26, 16, 15
693 -1, 1, 16, 17, 18, 19, 20, 21, 22, 23,
699 #define YYPACT_NINF -17
702 -17, 0, -17, -16, -17, -17, -17, 17, -17, 18,
703 -17, -17, -17, 38, 26, 14, -17, -17, -17, -17,
704 -17, 27, -17, 41, -17, -17, -17, 29, -17, -17,
705 -17, -17, -17, -17, -17, -17, -17, -17, -17, -17,
706 -15, -17, -17, -17, 31, 32, 33, 34, -17, 35,
707 -17, -17, -17, 28, 25, -9, -17, -17, -17, -17,
708 36, -17, 37, 13, -17, -17, -17
714 -17, -17, -17, 9, -17, -17, -17, -17, -17, -17,
721 #define YYTABLE_NINF -1
724 2, 38, 50, 51, 25, 3, 4, 5, 6, 7,
725 45, 8, 9, 10, 11, 12, 13, 14, 15, 35,
726 36, 26, 37, 58, 38, 39, 40, 41, 42, 43,
727 65, 44, 29, 45, 30, 46, 27, 31, 58, 32,
728 33, 34, 28, 47, 48, 59, 62, 60, 52, 49,
729 53, 54, 55, 57, 63, 64, 56, 66
732 #define yypact_value_is_default(yystate) \
735 #define yytable_value_is_error(yytable_value) \
740 0, 10, 17, 18, 20, 5, 6, 7, 8, 9,
741 19, 11, 12, 13, 14, 15, 16, 17, 18, 5,
742 6, 4, 8, 10, 10, 11, 12, 13, 14, 15,
743 17, 17, 6, 19, 8, 21, 18, 11, 10, 13,
744 14, 15, 4, 16, 3, 17, 21, 19, 17, 20,
745 18, 18, 18, 18, 18, 18, 47, 63
752 0, 23, 0, 5, 6, 7, 8, 9, 11, 12,
753 13, 14, 15, 16, 17, 18, 24, 25, 26, 27,
754 28, 29, 30, 31, 32, 20, 4, 18, 4, 6,
755 8, 11, 13, 14, 15, 5, 6, 8, 10, 11,
756 12, 13, 14, 15, 17, 19, 21, 16, 3, 20,
757 17, 18, 17, 18, 18, 18, 25, 18, 10, 17,
758 19, 33, 21, 18, 18, 17, 33
761 #define yyerrok (yyerrstatus = 0)
762 #define yyclearin (yychar = YYEMPTY)
766 #define YYACCEPT goto yyacceptlab
767 #define YYABORT goto yyabortlab
768 #define YYERROR goto yyerrorlab
778 #define YYFAIL goto yyerrlab
786 #define YYRECOVERING() (!!yyerrstatus)
788 #define YYBACKUP(Token, Value) \
790 if (yychar == YYEMPTY && yylen == 1) \
799 yyerror (YY_("syntax error: cannot back up")); \
806 #define YYERRCODE 256
813 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
814 #ifndef YYLLOC_DEFAULT
815 # define YYLLOC_DEFAULT(Current, Rhs, N) \
819 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
820 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
821 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
822 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
826 (Current).first_line = (Current).last_line = \
827 YYRHSLOC (Rhs, 0).last_line; \
828 (Current).first_column = (Current).last_column = \
829 YYRHSLOC (Rhs, 0).last_column; \
837 #ifndef YY_LOCATION_PRINT
838 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
845 # define YYLEX yylex (&yylval, YYLEX_PARAM)
847 # define YYLEX yylex (&yylval)
855 # define YYFPRINTF fprintf
858 # define YYDPRINTF(Args) \
864 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
868 YYFPRINTF (stderr, "%s ", Title); \
869 yy_symbol_print (stderr, \
871 YYFPRINTF (stderr, "\n"); \
881 #if (defined __STDC__ || defined __C99__FUNC__ \
882 || defined __cplusplus || defined _MSC_VER)
884 yy_symbol_value_print (FILE *yyoutput,
int yytype,
YYSTYPE const *
const yyvaluep)
887 yy_symbol_value_print (yyoutput, yytype, yyvaluep)
890 YYSTYPE const *
const yyvaluep;
897 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
913 #if (defined __STDC__ || defined __C99__FUNC__ \
914 || defined __cplusplus || defined _MSC_VER)
916 yy_symbol_print (FILE *yyoutput,
int yytype,
YYSTYPE const *
const yyvaluep)
919 yy_symbol_print (yyoutput, yytype, yyvaluep)
922 YYSTYPE const *
const yyvaluep;
926 YYFPRINTF (yyoutput,
"token %s (", yytname[yytype]);
928 YYFPRINTF (yyoutput,
"nterm %s (", yytname[yytype]);
930 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
931 YYFPRINTF (yyoutput,
")");
939 #if (defined __STDC__ || defined __C99__FUNC__ \
940 || defined __cplusplus || defined _MSC_VER)
945 yy_stack_print (yybottom, yytop)
950 YYFPRINTF (stderr,
"Stack now");
951 for (; yybottom <= yytop; yybottom++)
953 int yybot = *yybottom;
954 YYFPRINTF (stderr,
" %d", yybot);
956 YYFPRINTF (stderr,
"\n");
959 # define YY_STACK_PRINT(Bottom, Top) \
962 yy_stack_print ((Bottom), (Top)); \
970 #if (defined __STDC__ || defined __C99__FUNC__ \
971 || defined __cplusplus || defined _MSC_VER)
973 yy_reduce_print (
YYSTYPE *yyvsp,
int yyrule)
976 yy_reduce_print (yyvsp, yyrule)
981 int yynrhs =
yyr2[yyrule];
983 unsigned long int yylno = yyrline[yyrule];
984 YYFPRINTF (stderr,
"Reducing stack by rule %d (line %lu):\n",
987 for (yyi = 0; yyi < yynrhs; yyi++)
989 YYFPRINTF (stderr,
" $%d = ", yyi + 1);
990 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
991 &(yyvsp[(yyi + 1) - (yynrhs)])
993 YYFPRINTF (stderr,
"\n");
997 # define YY_REDUCE_PRINT(Rule) \
1000 yy_reduce_print (yyvsp, Rule); \
1007 # define YYDPRINTF(Args)
1008 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
1009 # define YY_STACK_PRINT(Bottom, Top)
1010 # define YY_REDUCE_PRINT(Rule)
1016 # define YYINITDEPTH 200
1027 # define YYMAXDEPTH 10000
1034 # if defined __GLIBC__ && defined _STRING_H
1035 # define yystrlen strlen
1038 #if (defined __STDC__ || defined __C99__FUNC__ \
1039 || defined __cplusplus || defined _MSC_VER)
1041 yystrlen (
const char *yystr)
1049 for (yylen = 0; yystr[yylen]; yylen++)
1057 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1058 # define yystpcpy stpcpy
1062 #if (defined __STDC__ || defined __C99__FUNC__ \
1063 || defined __cplusplus || defined _MSC_VER)
1065 yystpcpy (
char *yydest,
const char *yysrc)
1068 yystpcpy (yydest, yysrc)
1074 const char *yys = yysrc;
1076 while ((*yyd++ = *yys++) !=
'\0')
1093 yytnamerr (
char *yyres,
const char *yystr)
1098 char const *yyp = yystr;
1105 goto do_not_strip_quotes;
1109 goto do_not_strip_quotes;
1122 do_not_strip_quotes: ;
1126 return yystrlen (yystr);
1128 return yystpcpy (yyres, yystr) - yyres;
1141 yysyntax_error (
YYSIZE_T *yymsg_alloc,
char **yymsg,
1144 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytoken]);
1147 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1149 const char *yyformat = 0;
1151 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1185 int yyn =
yypact[*yyssp];
1186 yyarg[yycount++] = yytname[yytoken];
1192 int yyxbegin = yyn < 0 ? -yyn : 0;
1194 int yychecklim =
YYLAST - yyn + 1;
1198 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1202 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1208 yyarg[yycount++] = yytname[yyx];
1209 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1210 if (! (yysize <= yysize1
1220 # define YYCASE_(N, S) \
1224 YYCASE_(0,
YY_(
"syntax error"));
1225 YYCASE_(1,
YY_(
"syntax error, unexpected %s"));
1226 YYCASE_(2,
YY_(
"syntax error, unexpected %s, expecting %s"));
1227 YYCASE_(3,
YY_(
"syntax error, unexpected %s, expecting %s or %s"));
1228 YYCASE_(4,
YY_(
"syntax error, unexpected %s, expecting %s or %s or %s"));
1229 YYCASE_(5,
YY_(
"syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1233 yysize1 = yysize + yystrlen (yyformat);
1238 if (*yymsg_alloc < yysize)
1240 *yymsg_alloc = 2 * yysize;
1241 if (! (yysize <= *yymsg_alloc
1253 while ((*yyp = *yyformat) !=
'\0')
1254 if (*yyp ==
'%' && yyformat[1] ==
's' && yyi < yycount)
1256 yyp += yytnamerr (yyp, yyarg[yyi++]);
1274 #if (defined __STDC__ || defined __C99__FUNC__ \
1275 || defined __cplusplus || defined _MSC_VER)
1302 #ifdef YYPARSE_PARAM
1303 #if defined __STDC__ || defined __cplusplus
1309 #if defined __STDC__ || defined __cplusplus
1321 #ifdef YYPARSE_PARAM
1322 #if (defined __STDC__ || defined __C99__FUNC__ \
1323 || defined __cplusplus || defined _MSC_VER)
1332 #if (defined __STDC__ || defined __C99__FUNC__ \
1333 || defined __cplusplus || defined _MSC_VER)
1386 char *yymsg = yymsgbuf;
1387 YYSIZE_T yymsg_alloc =
sizeof yymsgbuf;
1390 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1401 YYDPRINTF ((stderr,
"Starting parse\n"));
1428 if (yyss + yystacksize - 1 <= yyssp)
1431 YYSIZE_T yysize = yyssp - yyss + 1;
1445 yyoverflow (
YY_(
"memory exhausted"),
1446 &yyss1, yysize *
sizeof (*yyssp),
1447 &yyvs1, yysize *
sizeof (*yyvsp),
1454 # ifndef YYSTACK_RELOCATE
1455 goto yyexhaustedlab;
1459 goto yyexhaustedlab;
1469 goto yyexhaustedlab;
1472 # undef YYSTACK_RELOCATE
1479 yyssp = yyss + yysize - 1;
1480 yyvsp = yyvs + yysize - 1;
1482 YYDPRINTF ((stderr,
"Stack size increased to %lu\n",
1483 (
unsigned long int) yystacksize));
1485 if (yyss + yystacksize - 1 <= yyssp)
1489 YYDPRINTF ((stderr,
"Entering state %d\n", yystate));
1514 YYDPRINTF ((stderr,
"Reading a token: "));
1518 if (yychar <=
YYEOF)
1520 yychar = yytoken =
YYEOF;
1521 YYDPRINTF ((stderr,
"Now at end of input.\n"));
1585 yyval = yyvsp[1-yylen];
1594 #line 198 "getdate.y"
1595 {
PC.times_seen++; }
1601 #line 200 "getdate.y"
1602 {
PC.local_zones_seen++; }
1608 #line 202 "getdate.y"
1609 {
PC.zones_seen++; }
1615 #line 204 "getdate.y"
1616 {
PC.dates_seen++; }
1622 #line 206 "getdate.y"
1629 #line 208 "getdate.y"
1636 #line 211 "getdate.y"
1646 #line 219 "getdate.y"
1651 PC.meridian = (yyvsp[(2) - (2)].
intval);
1658 #line 226 "getdate.y"
1663 PC.meridian = (yyvsp[(4) - (4)].
intval);
1670 #line 233 "getdate.y"
1676 PC.time_zone = (yyvsp[(4) - (4)].
textintval).value % 100 + ((yyvsp[(4) - (4)].textintval).value / 100) * 60;
1683 #line 241 "getdate.y"
1688 PC.meridian = (yyvsp[(6) - (6)].
intval);
1695 #line 248 "getdate.y"
1702 PC.time_zone = (yyvsp[(6) - (6)].
textintval).value % 100 + ((yyvsp[(6) - (6)].textintval).value / 100) * 60;
1709 #line 260 "getdate.y"
1710 {
PC.local_isdst = (yyvsp[(1) - (1)].
intval); }
1716 #line 262 "getdate.y"
1717 {
PC.local_isdst = (yyvsp[(1) - (2)].
intval) < 0 ? 1 : (yyvsp[(1) - (2)].intval) + 1; }
1723 #line 267 "getdate.y"
1724 {
PC.time_zone = (yyvsp[(1) - (1)].
intval); }
1730 #line 269 "getdate.y"
1731 {
PC.time_zone = (yyvsp[(1) - (1)].
intval) + 60; }
1737 #line 271 "getdate.y"
1738 {
PC.time_zone = (yyvsp[(1) - (2)].
intval) + 60; }
1744 #line 276 "getdate.y"
1747 PC.day_number = (yyvsp[(1) - (1)].
intval);
1754 #line 281 "getdate.y"
1757 PC.day_number = (yyvsp[(1) - (2)].
intval);
1764 #line 286 "getdate.y"
1767 PC.day_number = (yyvsp[(2) - (2)].
intval);
1774 #line 294 "getdate.y"
1784 #line 299 "getdate.y"
1791 if (4 <= (yyvsp[(1) - (5)].textintval).digits)
1809 #line 319 "getdate.y"
1821 #line 326 "getdate.y"
1825 PC.month = (yyvsp[(2) - (3)].
intval);
1834 #line 334 "getdate.y"
1836 PC.month = (yyvsp[(1) - (2)].
intval);
1844 #line 339 "getdate.y"
1846 PC.month = (yyvsp[(1) - (4)].
intval);
1855 #line 345 "getdate.y"
1858 PC.month = (yyvsp[(2) - (2)].
intval);
1865 #line 350 "getdate.y"
1868 PC.month = (yyvsp[(2) - (3)].
intval);
1876 #line 359 "getdate.y"
1878 PC.rel_seconds = -
PC.rel_seconds;
1879 PC.rel_minutes = -
PC.rel_minutes;
1880 PC.rel_hour = -
PC.rel_hour;
1881 PC.rel_day = -
PC.rel_day;
1882 PC.rel_month = -
PC.rel_month;
1883 PC.rel_year = -
PC.rel_year;
1890 #line 372 "getdate.y"
1891 {
PC.rel_year += (yyvsp[(1) - (2)].
textintval).value * (yyvsp[(2) - (2)].intval); }
1897 #line 374 "getdate.y"
1898 {
PC.rel_year += (yyvsp[(1) - (2)].
textintval).value * (yyvsp[(2) - (2)].intval); }
1904 #line 376 "getdate.y"
1905 {
PC.rel_year += (yyvsp[(1) - (1)].
intval); }
1911 #line 378 "getdate.y"
1912 {
PC.rel_month += (yyvsp[(1) - (2)].
textintval).value * (yyvsp[(2) - (2)].intval); }
1918 #line 380 "getdate.y"
1919 {
PC.rel_month += (yyvsp[(1) - (2)].
textintval).value * (yyvsp[(2) - (2)].intval); }
1925 #line 382 "getdate.y"
1926 {
PC.rel_month += (yyvsp[(1) - (1)].
intval); }
1932 #line 384 "getdate.y"
1933 {
PC.rel_day += (yyvsp[(1) - (2)].
textintval).value * (yyvsp[(2) - (2)].intval); }
1939 #line 386 "getdate.y"
1940 {
PC.rel_day += (yyvsp[(1) - (2)].
textintval).value * (yyvsp[(2) - (2)].intval); }
1946 #line 388 "getdate.y"
1947 {
PC.rel_day += (yyvsp[(1) - (1)].
intval); }
1953 #line 390 "getdate.y"
1954 {
PC.rel_hour += (yyvsp[(1) - (2)].
textintval).value * (yyvsp[(2) - (2)].intval); }
1960 #line 392 "getdate.y"
1961 {
PC.rel_hour += (yyvsp[(1) - (2)].
textintval).value * (yyvsp[(2) - (2)].intval); }
1967 #line 394 "getdate.y"
1968 {
PC.rel_hour += (yyvsp[(1) - (1)].
intval); }
1974 #line 396 "getdate.y"
1975 {
PC.rel_minutes += (yyvsp[(1) - (2)].
textintval).value * (yyvsp[(2) - (2)].intval); }
1981 #line 398 "getdate.y"
1982 {
PC.rel_minutes += (yyvsp[(1) - (2)].
textintval).value * (yyvsp[(2) - (2)].intval); }
1988 #line 400 "getdate.y"
1989 {
PC.rel_minutes += (yyvsp[(1) - (1)].
intval); }
1995 #line 402 "getdate.y"
1996 {
PC.rel_seconds += (yyvsp[(1) - (2)].
textintval).value * (yyvsp[(2) - (2)].intval); }
2002 #line 404 "getdate.y"
2003 {
PC.rel_seconds += (yyvsp[(1) - (2)].
textintval).value * (yyvsp[(2) - (2)].intval); }
2009 #line 406 "getdate.y"
2010 {
PC.rel_seconds += (yyvsp[(1) - (1)].
intval); }
2016 #line 411 "getdate.y"
2019 && !
PC.rels_seen && (
PC.times_seen || 2 < (yyvsp[(1) - (1)].textintval).digits))
2023 if (4 < (yyvsp[(1) - (1)].textintval).digits)
2027 PC.month = ((yyvsp[(1) - (1)].
textintval).value / 100) % 100;
2028 PC.year.value = (yyvsp[(1) - (1)].
textintval).value / 10000;
2029 PC.year.digits = (yyvsp[(1) - (1)].
textintval).digits - 4;
2034 if ((yyvsp[(1) - (1)].textintval).digits <= 2)
2042 PC.minutes = (yyvsp[(1) - (1)].
textintval).value % 100;
2054 #line 447 "getdate.y"
2061 #line 449 "getdate.y"
2062 { (yyval.
intval) = (yyvsp[(1) - (1)].intval); }
2068 #line 2069 "getdate.c"
2097 if (0 <= yystate && yystate <=
YYLAST &&
yycheck[yystate] == *yyssp)
2117 #if ! YYERROR_VERBOSE
2120 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
2123 char const *yymsgp =
YY_(
"syntax error");
2124 int yysyntax_error_status;
2125 yysyntax_error_status = YYSYNTAX_ERROR;
2126 if (yysyntax_error_status == 0)
2128 else if (yysyntax_error_status == 1)
2130 if (yymsg != yymsgbuf)
2136 yymsg_alloc =
sizeof yymsgbuf;
2137 yysyntax_error_status = 2;
2141 yysyntax_error_status = YYSYNTAX_ERROR;
2146 if (yysyntax_error_status == 2)
2147 goto yyexhaustedlab;
2149 # undef YYSYNTAX_ERROR
2155 if (yyerrstatus == 3)
2160 if (yychar <=
YYEOF)
2163 if (yychar ==
YYEOF)
2255 #if !defined(yyoverflow) || YYERROR_VERBOSE
2278 while (yyssp != yyss)
2289 if (yymsg != yymsgbuf)
2293 return YYID (yyresult);
2299 #line 452 "getdate.y"
2323 {
"JANUARY",
tMONTH, 1 },
2324 {
"FEBRUARY",
tMONTH, 2 },
2331 {
"SEPTEMBER",
tMONTH, 9 },
2333 {
"OCTOBER",
tMONTH, 10 },
2334 {
"NOVEMBER",
tMONTH, 11 },
2335 {
"DECEMBER",
tMONTH, 12 },
2336 {
"SUNDAY",
tDAY, 0 },
2337 {
"MONDAY",
tDAY, 1 },
2338 {
"TUESDAY",
tDAY, 2 },
2339 {
"TUES",
tDAY, 2 },
2340 {
"WEDNESDAY",
tDAY, 3 },
2341 {
"WEDNES",
tDAY, 3 },
2342 {
"THURSDAY",
tDAY, 4 },
2343 {
"THUR",
tDAY, 4 },
2344 {
"THURS",
tDAY, 4 },
2345 {
"FRIDAY",
tDAY, 5 },
2346 {
"SATURDAY",
tDAY, 6 },
2490 return 0 <= hours && hours < 24 ? hours : -1;
2492 return 0 < hours && hours < 12 ? hours : hours == 12 ? 0 : -1;
2494 return 0 < hours && hours < 12 ? hours + 12 : hours == 12 ? 12 : -1;
2504 int year = textyear.
value;
2511 if (textyear.
digits == 2)
2512 year += year < 69 ? 2000 : 1900;
2517 static table const *
2534 #if ! HAVE_TM_GMTOFF
2545 int a4 = (
a->tm_year >> 2) + (
TM_YEAR_BASE >> 2) - ! (
a->tm_year & 3);
2546 int b4 = (b->tm_year >> 2) + (
TM_YEAR_BASE >> 2) - ! (b->tm_year & 3);
2547 int a100 = a4 / 25 - (a4 % 25 < 0);
2548 int b100 = b4 / 25 - (b4 % 25 < 0);
2549 int a400 = a100 >> 2;
2550 int b400 = b100 >> 2;
2551 int intervening_leap_days = (a4 - b4) - (a100 - b100) + (a400 - b400);
2552 int years =
a->tm_year - b->tm_year;
2553 int days = (365 * years + intervening_leap_days
2554 + (
a->tm_yday - b->tm_yday));
2555 return (60 * (60 * (24 * days + (
a->tm_hour - b->tm_hour))
2556 + (
a->tm_min - b->tm_min))
2557 + (
a->tm_sec - b->tm_sec));
2561 static table const *
2572 for (
p = word; *
p;
p++)
2574 *
p = toupper ((
unsigned char) *
p);
2577 if (strcmp (word, tp->
name) == 0)
2581 wordlen = strlen (word);
2582 abbrev = wordlen == 3 || (wordlen == 4 && word[3] ==
'.');
2585 if ((abbrev ? strncmp (word, tp->
name, 3) : strcmp (word, tp->
name)) == 0)
2595 if (strcmp (word, tp->
name) == 0)
2599 if (word[wordlen - 1] ==
'S')
2601 word[wordlen - 1] =
'\0';
2603 if (strcmp (word, tp->
name) == 0)
2605 word[wordlen - 1] =
'S';
2609 if (strcmp (word, tp->
name) == 0)
2615 if (word[0] == tp->
name[0])
2619 for (i = 0,
p =
q = word; (*
p = *
q);
q++)
2641 if (
ISDIGIT (c) || c ==
'-' || c ==
'+')
2646 if (c ==
'-' || c ==
'+')
2648 sign = c ==
'-' ? -1 : 1;
2660 value = 10 * value + c -
'0';
2678 if (
p < buff +
sizeof buff - 1)
2682 while (
ISALPHA (c) || c ==
'.');
2693 return *pc->
input++;
2723 time_t Start =
now ? *
now : time (0);
2724 struct tm *tmp = localtime (&Start);
2735 pc.month = tmp->tm_mon + 1;
2736 pc.day = tmp->tm_mday;
2737 pc.hour = tmp->tm_hour;
2738 pc.minutes = tmp->tm_min;
2739 pc.seconds = tmp->tm_sec;
2740 tm.tm_isdst = tmp->tm_isdst;
2742 pc.meridian =
MER24;
2753 pc.local_zones_seen = 0;
2757 pc.local_time_zone_table[0].name = tmp->tm_zone;
2759 pc.local_time_zone_table[0].value = tmp->tm_isdst;
2760 pc.local_time_zone_table[1].name = 0;
2766 for (quarter = 1; quarter <= 3; quarter++)
2768 time_t probe = Start + quarter * (90 * 24 * 60 * 60);
2769 struct tm *probe_tm = localtime (&probe);
2770 if (probe_tm && probe_tm->tm_zone
2771 && probe_tm->tm_isdst != pc.local_time_zone_table[0].value)
2774 pc.local_time_zone_table[1].name = probe_tm->tm_zone;
2776 pc.local_time_zone_table[1].value = probe_tm->tm_isdst;
2777 pc.local_time_zone_table[2].name = 0;
2787 extern char *tzname[];
2790 for (i = 0; i < 2; i++)
2792 pc.local_time_zone_table[i].name = tzname[i];
2794 pc.local_time_zone_table[i].value = i;
2796 pc.local_time_zone_table[i].name = 0;
2799 pc.local_time_zone_table[0].name = 0;
2803 if (pc.local_time_zone_table[0].name && pc.local_time_zone_table[1].name
2804 && ! strcmp (pc.local_time_zone_table[0].name,
2805 pc.local_time_zone_table[1].name))
2810 pc.local_time_zone_table[0].value = -1;
2811 pc.local_time_zone_table[1].name = 0;
2815 || 1 < pc.times_seen || 1 < pc.dates_seen || 1 < pc.days_seen
2816 || 1 < (pc.local_zones_seen + pc.zones_seen)
2817 || (pc.local_zones_seen && 1 < pc.local_isdst))
2821 tm.tm_mon = pc.month - 1 + pc.rel_month;
2822 tm.tm_mday = pc.day + pc.rel_day;
2823 if (pc.times_seen || (pc.rels_seen && ! pc.dates_seen && ! pc.days_seen))
2825 tm.tm_hour =
to_hour (pc.hour, pc.meridian);
2828 tm.tm_min = pc.minutes;
2829 tm.tm_sec = pc.seconds;
2833 tm.tm_hour = tm.tm_min = tm.tm_sec = 0;
2838 if (pc.dates_seen | pc.days_seen | pc.times_seen | pc.rel_day | pc.rel_month | pc.rel_year)
2843 if (pc.local_zones_seen)
2844 tm.tm_isdst = pc.local_isdst;
2848 Start = mktime (&tm);
2850 if (Start == (time_t) -1)
2867 pc.time_zone += 24 * 60;
2872 pc.time_zone -= 24 * 60;
2874 Start = mktime (&tm);
2877 if (Start == (time_t) -1)
2881 if (pc.days_seen && ! pc.dates_seen)
2883 tm.tm_mday += ((pc.day_number - tm.tm_wday + 7) % 7
2884 + 7 * (pc.day_ordinal - (0 < pc.day_ordinal)));
2885 Start = mktime (&tm);
2886 if (Start == (time_t) -1)
2892 int delta = pc.time_zone * 60;
2893 #ifdef HAVE_TM_GMTOFF
2894 delta -= tm.tm_gmtoff;
2896 struct tm *gmt = gmtime (&Start);
2901 if ((Start < Start - delta) != (delta < 0))
2914 long d1 = 60 * 60 * (long) pc.rel_hour;
2915 time_t t1 = t0 + d1;
2916 long d2 = 60 * (
long) pc.rel_minutes;
2917 time_t t2 = t1 + d2;
2918 int d3 = pc.rel_seconds;
2919 time_t t3 = t2 + d3;
2920 if ((d1 / (60 * 60) ^ pc.rel_hour)
2921 | (d2 / 60 ^ pc.rel_minutes)
2922 | ((t0 + d1 < t0) ^ (d1 < 0))
2923 | ((t1 + d2 < t1) ^ (d2 < 0))
2924 | ((t2 + d3 < t2) ^ (d3 < 0)))
2937 main (
int ac,
char **av)
2942 printf (
"Enter date, or blank line to exit.\n\t> ");
2945 buff[BUFSIZ - 1] = 0;
2946 while (fgets (buff, BUFSIZ - 1, stdin) && buff[0])
2949 if (d == (time_t) -1)
2950 printf (
"Bad format - couldn't convert.\n");
2952 printf (
"%s", ctime (&d));
int main(int argc, char *argv[])
unsigned short int yytype_uint16
static const yytype_uint8 yyr1[]
#define YY_SYMBOL_PRINT(Title, Type, Value, Location)
#define yypact_value_is_default(yystate)
static table const relative_time_table[]
static const yytype_uint8 yytranslate[]
time_t get_date(const char *p, const time_t *now)
static table const * lookup_zone(parser_control const *pc, char const *name)
#define YY_REDUCE_PRINT(Rule)
static int yyerror(const char *s ATTRIBUTE_UNUSED)
static const yytype_int8 yypact[]
static table const * lookup_word(parser_control const *pc, char *word)
static table const month_and_day_table[]
static table const time_units_table[]
static int yylex(YYSTYPE *lvalp, parser_control *pc)
unsigned char yytype_uint8
#define YY_STACK_PRINT(Bottom, Top)
#define YYSTACK_ALLOC_MAXIMUM
static table const dst_table[]
static int to_hour(int hours, int meridian)
static const yytype_uint8 yyr2[]
static int to_year(textint textyear)
static const yytype_int8 yypgoto[]
static const yytype_uint8 yystos[]
static table const military_table[]
#define yytable_value_is_error(yytable_value)
static table const meridian_table[]
static void yydestruct(char *yymsg, int yytype, YYSTYPE *yyvaluep) const
static const yytype_int8 yydefgoto[]
#define YYSTACK_RELOCATE(Stack_alloc, Stack)
static const yytype_uint8 yytable[]
static table const time_zone_table[]
static const yytype_uint8 yydefact[]
static int tm_diff(struct tm const *a, struct tm const *b)
static const yytype_uint8 yycheck[]
table local_time_zone_table[3]