1 /* A Bison parser, made by GNU Bison 3.0.2. */
3 /* Bison implementation for Yacc-like parsers in C
5 Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
7 This program is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 /* As a special exception, you may create a larger work that contains
21 part or all of the Bison parser skeleton and distribute that work
22 under terms of your choice, so long as that work isn't itself a
23 parser generator using the skeleton or a modified version thereof
24 as a parser skeleton. Alternatively, if you modify or redistribute
25 the parser skeleton itself, you may (at your option) remove this
26 special exception, which will cause the skeleton and the resulting
27 Bison output files to be licensed under the GNU General Public
28 License without this special exception.
30 This special exception was added by the Free Software Foundation in
31 version 2.2 of Bison. */
33 /* C LALR(1) parser skeleton written by Richard Stallman, by
34 simplifying the original so-called "semantic" parser. */
36 /* All symbols defined below should begin with yy or YY, to avoid
37 infringing on user name space. This should be done even for local
38 variables, as they might otherwise be expanded by user macros.
39 There are some unavoidable exceptions within include files to
40 define necessary library symbols; they are noted "INFRINGES ON
41 USER NAME SPACE" below. */
43 /* Identify Bison output. */
47 #define YYBISON_VERSION "3.0.2"
50 #define YYSKELETON_NAME "yacc.c"
64 /* Copy the first part of user declarations. */
65 #line 1 "parsedate.y" /* yacc.c:339 */
69 ** Originally written by Steven M. Bellovin <smb@research.att.com> while
70 ** at the University of North Carolina at Chapel Hill. Later tweaked by
71 ** a couple of people on Usenet. Completely overhauled by Rich $alz
72 ** <rsalz@osf.org> and Jim Berets <jberets@bbn.com> in August, 1990.
73 ** Further revised (removed obsolete constructs and cleaned up timezone
74 ** names) in August, 1991, by Rich. Paul Eggert <eggert@twinsun.com>
75 ** helped in September, 1992. Art Cancro <ajc@citadel.org> cleaned
76 ** it up for ANSI C in December, 1999.
78 ** This grammar has six shift/reduce conflicts.
80 ** This code is in the public domain and has no copyright.
82 /* SUPPRESS 530 *//* Empty body for statement */
83 /* SUPPRESS 593 on yyerrlab *//* Label was not used */
84 /* SUPPRESS 593 on yynewstate *//* Label was not used */
85 /* SUPPRESS 595 on yypvt *//* Automatic variable may be used before set */
91 #include <sys/types.h>
95 # if !STDC_HEADERS && HAVE_MEMORY_H
101 # include <strings.h>
104 #include "parsedate.h"
108 #define yyparse date_parse
109 #define yylex date_lex
110 #define yyerror date_error
113 /* See the LeapYears table in Convert. */
115 #define END_OF_TIME 2038
116 /* Constants for general time calculations. */
118 #define SECSPERDAY (24L * 60L * 60L)
119 /* Readability for TABLE stuff. */
120 #define HOUR(x) (x * 60)
124 #define IS7BIT(x) ((unsigned int)(x) < 0200)
126 #define SIZEOF(array) ((int)(sizeof array / sizeof array[0]))
127 #define ENDOF(array) (&array[SIZEOF(array)])
131 ** An entry in the lexical lookup table.
133 typedef struct _TABLE {
140 ** Daylight-savings mode: on, off, or not yet known.
142 typedef enum _DSTMODE {
143 DSTon, DSToff, DSTmaybe
147 ** Meridian: am, pm, or 24-hour style.
149 typedef enum _MERIDIAN {
155 ** Global variables. We could get rid of most of them by using a yacc
156 ** union, but this is more efficient. (This routine predates the
157 ** yacc %union construct.)
159 static const char *yyInput;
160 static DSTMODE yyDSTmode;
161 static int yyHaveDate;
162 static int yyHaveRel;
163 static int yyHaveTime;
164 static time_t yyTimezone;
166 static time_t yyHour;
167 static time_t yyMinutes;
168 static time_t yyMonth;
169 static time_t yySeconds;
170 static time_t yyYear;
171 static MERIDIAN yyMeridian;
172 static time_t yyRelMonth;
173 static time_t yyRelSeconds;
176 static void date_error(char *);
178 #line 179 "y.tab.c" /* yacc.c:339 */
181 # if defined __cplusplus && 201103L <= __cplusplus
182 # define YY_NULLPTR nullptr
184 # define YY_NULLPTR 0
188 /* Enabling verbose error messages. */
189 #ifdef YYERROR_VERBOSE
190 # undef YYERROR_VERBOSE
191 # define YYERROR_VERBOSE 1
193 # define YYERROR_VERBOSE 0
224 #define tMERIDIAN 260
226 #define tMONTH_UNIT 262
227 #define tSEC_UNIT 263
233 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
234 typedef union YYSTYPE YYSTYPE;
237 #line 114 "parsedate.y" /* yacc.c:355 */
240 enum _MERIDIAN Meridian;
242 #line 243 "y.tab.c" /* yacc.c:355 */
244 # define YYSTYPE_IS_TRIVIAL 1
245 # define YYSTYPE_IS_DECLARED 1
249 extern YYSTYPE yylval;
255 /* Copy the second part of user declarations. */
257 #line 258 "y.tab.c" /* yacc.c:358 */
264 typedef YYTYPE_UINT8 yytype_uint8;
266 typedef unsigned char yytype_uint8;
270 typedef YYTYPE_INT8 yytype_int8;
272 typedef signed char yytype_int8;
276 typedef YYTYPE_UINT16 yytype_uint16;
278 typedef unsigned short int yytype_uint16;
282 typedef YYTYPE_INT16 yytype_int16;
284 typedef short int yytype_int16;
288 # ifdef __SIZE_TYPE__
289 # define YYSIZE_T __SIZE_TYPE__
290 # elif defined size_t
291 # define YYSIZE_T size_t
292 # elif ! defined YYSIZE_T
293 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
294 # define YYSIZE_T size_t
296 # define YYSIZE_T unsigned int
300 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
303 # if defined YYENABLE_NLS && YYENABLE_NLS
305 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
306 # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
310 # define YY_(Msgid) Msgid
315 # if (defined __GNUC__ \
316 && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
317 || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
318 # define YY_ATTRIBUTE(Spec) __attribute__(Spec)
320 # define YY_ATTRIBUTE(Spec) /* empty */
324 #ifndef YY_ATTRIBUTE_PURE
325 # define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
328 #ifndef YY_ATTRIBUTE_UNUSED
329 # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
332 #if !defined _Noreturn \
333 && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
334 # if defined _MSC_VER && 1200 <= _MSC_VER
335 # define _Noreturn __declspec (noreturn)
337 # define _Noreturn YY_ATTRIBUTE ((__noreturn__))
341 /* Suppress unused-variable warnings by "using" E. */
342 #if ! defined lint || defined __GNUC__
343 # define YYUSE(E) ((void) (E))
345 # define YYUSE(E) /* empty */
348 #if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
349 /* Suppress an incorrect diagnostic about yylval being uninitialized. */
350 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
351 _Pragma ("GCC diagnostic push") \
352 _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
353 _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
354 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
355 _Pragma ("GCC diagnostic pop")
357 # define YY_INITIAL_VALUE(Value) Value
359 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
360 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
361 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
363 #ifndef YY_INITIAL_VALUE
364 # define YY_INITIAL_VALUE(Value) /* Nothing. */
368 #if ! defined yyoverflow || YYERROR_VERBOSE
370 /* The parser invokes alloca or malloc; define the necessary symbols. */
372 # ifdef YYSTACK_USE_ALLOCA
373 # if YYSTACK_USE_ALLOCA
375 # define YYSTACK_ALLOC __builtin_alloca
376 # elif defined __BUILTIN_VA_ARG_INCR
377 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
379 # define YYSTACK_ALLOC __alloca
380 # elif defined _MSC_VER
381 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
382 # define alloca _alloca
384 # define YYSTACK_ALLOC alloca
385 # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
386 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
387 /* Use EXIT_SUCCESS as a witness for stdlib.h. */
388 # ifndef EXIT_SUCCESS
389 # define EXIT_SUCCESS 0
396 # ifdef YYSTACK_ALLOC
397 /* Pacify GCC's 'empty if-body' warning. */
398 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
399 # ifndef YYSTACK_ALLOC_MAXIMUM
400 /* The OS might guarantee only one guard page at the bottom of the stack,
401 and a page size can be as small as 4096 bytes. So we cannot safely
402 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
403 to allow for a few compiler-allocated temporary stack slots. */
404 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
407 # define YYSTACK_ALLOC YYMALLOC
408 # define YYSTACK_FREE YYFREE
409 # ifndef YYSTACK_ALLOC_MAXIMUM
410 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
412 # if (defined __cplusplus && ! defined EXIT_SUCCESS \
413 && ! ((defined YYMALLOC || defined malloc) \
414 && (defined YYFREE || defined free)))
415 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
416 # ifndef EXIT_SUCCESS
417 # define EXIT_SUCCESS 0
421 # define YYMALLOC malloc
422 # if ! defined malloc && ! defined EXIT_SUCCESS
423 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
428 # if ! defined free && ! defined EXIT_SUCCESS
429 void free (void *); /* INFRINGES ON USER NAME SPACE */
433 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
436 #if (! defined yyoverflow \
437 && (! defined __cplusplus \
438 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
440 /* A type that is properly aligned for any stack member. */
443 yytype_int16 yyss_alloc;
447 /* The size of the maximum gap between one aligned stack and the next. */
448 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
450 /* The size of an array large to enough to hold all stacks, each with
452 # define YYSTACK_BYTES(N) \
453 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
454 + YYSTACK_GAP_MAXIMUM)
456 # define YYCOPY_NEEDED 1
458 /* Relocate STACK from its old location to the new one. The
459 local variables YYSIZE and YYSTACKSIZE give the old and new number of
460 elements in the stack, and YYPTR gives the new location of the
461 stack. Advance YYPTR to a properly aligned location for the next
463 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
466 YYSIZE_T yynewbytes; \
467 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
468 Stack = &yyptr->Stack_alloc; \
469 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
470 yyptr += yynewbytes / sizeof (*yyptr); \
476 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
477 /* Copy COUNT objects from SRC to DST. The source and destination do
480 # if defined __GNUC__ && 1 < __GNUC__
481 # define YYCOPY(Dst, Src, Count) \
482 __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
484 # define YYCOPY(Dst, Src, Count) \
488 for (yyi = 0; yyi < (Count); yyi++) \
489 (Dst)[yyi] = (Src)[yyi]; \
494 #endif /* !YYCOPY_NEEDED */
496 /* YYFINAL -- State number of the termination state. */
498 /* YYLAST -- Last index in YYTABLE. */
501 /* YYNTOKENS -- Number of terminals. */
503 /* YYNNTS -- Number of nonterminals. */
505 /* YYNRULES -- Number of rules. */
507 /* YYNSTATES -- Number of states. */
510 /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
511 by yylex, with out-of-bounds checking. */
513 #define YYMAXUTOK 266
515 #define YYTRANSLATE(YYX) \
516 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
518 /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
519 as returned by yylex, without out-of-bounds checking. */
520 static const yytype_uint8 yytranslate[] =
522 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
523 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
524 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
525 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
526 2, 2, 2, 2, 14, 2, 2, 13, 2, 2,
527 2, 2, 2, 2, 2, 2, 2, 2, 12, 2,
528 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
529 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
530 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
531 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
532 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
533 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
534 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
535 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
536 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
537 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
538 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
539 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
540 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
541 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
542 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
543 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
544 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
545 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
546 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
547 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
548 5, 6, 7, 8, 9, 10, 11
552 /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
553 static const yytype_uint16 yyrline[] =
555 0, 128, 128, 129, 132, 141, 145, 148, 153, 165,
556 171, 178, 184, 194, 198, 202, 210, 216, 237, 241,
557 253, 257, 262, 266, 271, 278, 281, 284, 287, 292,
562 #if YYDEBUG || YYERROR_VERBOSE || 0
563 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
564 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
565 static const char *const yytname[] =
567 "$end", "error", "$undefined", "tDAY", "tDAYZONE", "tMERIDIAN",
568 "tMONTH", "tMONTH_UNIT", "tSEC_UNIT", "tSNUMBER", "tUNUMBER", "tZONE",
569 "':'", "'/'", "','", "$accept", "spec", "item", "time", "zone",
570 "numzone", "date", "rel", "o_merid", YY_NULLPTR
575 /* YYTOKNUM[NUM] -- (External) token number corresponding to the
576 (internal) symbol number NUM (which must be that of a token). */
577 static const yytype_uint16 yytoknum[] =
579 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
584 #define YYPACT_NINF -29
586 #define yypact_value_is_default(Yystate) \
587 (!!((Yystate) == (-29)))
589 #define YYTABLE_NINF -1
591 #define yytable_value_is_error(Yytable_value) \
594 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
596 static const yytype_int8 yypact[] =
598 -29, 1, -29, -11, 11, 20, 12, -29, 4, -29,
599 -29, 13, 16, -29, -29, -29, 21, -29, -29, 22,
600 23, -29, -29, -29, 5, -29, -29, 28, 25, -29,
601 17, 24, -29, 26, -29, 29, -29, -29, 30, -29,
605 /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
606 Performed when YYTABLE does not specify something else to do. Zero
607 means the default is an error. */
608 static const yytype_uint8 yydefact[] =
610 2, 0, 1, 0, 0, 0, 29, 3, 4, 6,
611 7, 0, 20, 27, 25, 30, 22, 28, 26, 0,
612 0, 8, 14, 17, 13, 5, 16, 0, 0, 23,
613 29, 18, 15, 0, 21, 0, 10, 9, 0, 24,
617 /* YYPGOTO[NTERM-NUM]. */
618 static const yytype_int8 yypgoto[] =
620 -29, -29, -29, -29, -29, -24, -29, -29, -28
623 /* YYDEFGOTO[NTERM-NUM]. */
624 static const yytype_int8 yydefgoto[] =
626 -1, 1, 7, 8, 25, 26, 9, 10, 21
629 /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
630 positive, shift that token. If negative, reduce the rule whose
631 number is the opposite. If YYTABLE_NINF, syntax error. */
632 static const yytype_uint8 yytable[] =
634 32, 2, 37, 11, 3, 15, 36, 4, 22, 23,
635 5, 6, 43, 23, 23, 24, 42, 15, 16, 17,
636 18, 12, 15, 27, 19, 20, 23, 13, 14, 35,
637 28, 29, 30, 31, 33, 34, 39, 38, 0, 40,
641 static const yytype_int8 yycheck[] =
643 24, 0, 30, 14, 3, 5, 30, 6, 4, 9,
644 9, 10, 40, 9, 9, 11, 40, 5, 6, 7,
645 8, 10, 5, 10, 12, 13, 9, 7, 8, 12,
646 14, 10, 10, 10, 6, 10, 10, 13, -1, 10,
650 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
651 symbol of state STATE-NUM. */
652 static const yytype_uint8 yystos[] =
654 0, 16, 0, 3, 6, 9, 10, 17, 18, 21,
655 22, 14, 10, 7, 8, 5, 6, 7, 8, 12,
656 13, 23, 4, 9, 11, 19, 20, 10, 14, 10,
657 10, 10, 20, 6, 10, 12, 20, 23, 13, 10,
661 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
662 static const yytype_uint8 yyr1[] =
664 0, 15, 16, 16, 17, 17, 17, 17, 18, 18,
665 18, 18, 18, 19, 19, 19, 19, 20, 21, 21,
666 21, 21, 21, 21, 21, 22, 22, 22, 22, 23,
670 /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
671 static const yytype_uint8 yyr2[] =
673 0, 2, 0, 2, 1, 2, 1, 1, 2, 4,
674 4, 6, 6, 1, 1, 2, 1, 1, 3, 5,
675 2, 4, 2, 3, 5, 2, 2, 2, 2, 0,
680 #define yyerrok (yyerrstatus = 0)
681 #define yyclearin (yychar = YYEMPTY)
685 #define YYACCEPT goto yyacceptlab
686 #define YYABORT goto yyabortlab
687 #define YYERROR goto yyerrorlab
690 #define YYRECOVERING() (!!yyerrstatus)
692 #define YYBACKUP(Token, Value) \
694 if (yychar == YYEMPTY) \
698 YYPOPSTACK (yylen); \
704 yyerror (YY_("syntax error: cannot back up")); \
709 /* Error token number */
711 #define YYERRCODE 256
715 /* Enable debugging if requested. */
719 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
720 # define YYFPRINTF fprintf
723 # define YYDPRINTF(Args) \
729 /* This macro is provided for backward compatibility. */
730 #ifndef YY_LOCATION_PRINT
731 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
735 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
739 YYFPRINTF (stderr, "%s ", Title); \
740 yy_symbol_print (stderr, \
742 YYFPRINTF (stderr, "\n"); \
747 /*----------------------------------------.
748 | Print this symbol's value on YYOUTPUT. |
749 `----------------------------------------*/
752 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
754 FILE *yyo = yyoutput;
759 if (yytype < YYNTOKENS)
760 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
766 /*--------------------------------.
767 | Print this symbol on YYOUTPUT. |
768 `--------------------------------*/
771 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
773 YYFPRINTF (yyoutput, "%s %s (",
774 yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
776 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
777 YYFPRINTF (yyoutput, ")");
780 /*------------------------------------------------------------------.
781 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
783 `------------------------------------------------------------------*/
786 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
788 YYFPRINTF (stderr, "Stack now");
789 for (; yybottom <= yytop; yybottom++)
791 int yybot = *yybottom;
792 YYFPRINTF (stderr, " %d", yybot);
794 YYFPRINTF (stderr, "\n");
797 # define YY_STACK_PRINT(Bottom, Top) \
800 yy_stack_print ((Bottom), (Top)); \
804 /*------------------------------------------------.
805 | Report that the YYRULE is going to be reduced. |
806 `------------------------------------------------*/
809 yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule)
811 unsigned long int yylno = yyrline[yyrule];
812 int yynrhs = yyr2[yyrule];
814 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
816 /* The symbols being reduced. */
817 for (yyi = 0; yyi < yynrhs; yyi++)
819 YYFPRINTF (stderr, " $%d = ", yyi + 1);
820 yy_symbol_print (stderr,
821 yystos[yyssp[yyi + 1 - yynrhs]],
822 &(yyvsp[(yyi + 1) - (yynrhs)])
824 YYFPRINTF (stderr, "\n");
828 # define YY_REDUCE_PRINT(Rule) \
831 yy_reduce_print (yyssp, yyvsp, Rule); \
834 /* Nonzero means print parse trace. It is left uninitialized so that
835 multiple parsers can coexist. */
838 # define YYDPRINTF(Args)
839 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
840 # define YY_STACK_PRINT(Bottom, Top)
841 # define YY_REDUCE_PRINT(Rule)
842 #endif /* !YYDEBUG */
845 /* YYINITDEPTH -- initial size of the parser's stacks. */
847 # define YYINITDEPTH 200
850 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
851 if the built-in stack extension method is used).
853 Do not make this value too large; the results are undefined if
854 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
855 evaluated with infinite-precision integer arithmetic. */
858 # define YYMAXDEPTH 10000
865 # if defined __GLIBC__ && defined _STRING_H
866 # define yystrlen strlen
868 /* Return the length of YYSTR. */
870 yystrlen (const char *yystr)
873 for (yylen = 0; yystr[yylen]; yylen++)
881 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
882 # define yystpcpy stpcpy
884 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
887 yystpcpy (char *yydest, const char *yysrc)
890 const char *yys = yysrc;
892 while ((*yyd++ = *yys++) != '\0')
901 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
902 quotes and backslashes, so that it's suitable for yyerror. The
903 heuristic is that double-quoting is unnecessary unless the string
904 contains an apostrophe, a comma, or backslash (other than
905 backslash-backslash). YYSTR is taken from yytname. If YYRES is
906 null, do not copy; instead, return the length of what the result
909 yytnamerr (char *yyres, const char *yystr)
914 char const *yyp = yystr;
921 goto do_not_strip_quotes;
925 goto do_not_strip_quotes;
938 do_not_strip_quotes: ;
942 return yystrlen (yystr);
944 return yystpcpy (yyres, yystr) - yyres;
948 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
949 about the unexpected token YYTOKEN for the state stack whose top is
952 Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
953 not large enough to hold the message. In that case, also set
954 *YYMSG_ALLOC to the required number of bytes. Return 2 if the
955 required number of bytes is too large to store. */
957 yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
958 yytype_int16 *yyssp, int yytoken)
960 YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
961 YYSIZE_T yysize = yysize0;
962 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
963 /* Internationalized format string. */
964 const char *yyformat = YY_NULLPTR;
965 /* Arguments of yyformat. */
966 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
967 /* Number of reported tokens (one for the "unexpected", one per
971 /* There are many possibilities here to consider:
972 - If this state is a consistent state with a default action, then
973 the only way this function was invoked is if the default action
974 is an error action. In that case, don't check for expected
975 tokens because there are none.
976 - The only way there can be no lookahead present (in yychar) is if
977 this state is a consistent state with a default action. Thus,
978 detecting the absence of a lookahead is sufficient to determine
979 that there is no unexpected or expected token to report. In that
980 case, just report a simple "syntax error".
981 - Don't assume there isn't a lookahead just because this state is a
982 consistent state with a default action. There might have been a
983 previous inconsistent state, consistent state with a non-default
984 action, or user semantic action that manipulated yychar.
985 - Of course, the expected token list depends on states to have
986 correct lookahead information, and it depends on the parser not
987 to perform extra reductions after fetching a lookahead from the
988 scanner and before detecting a syntax error. Thus, state merging
989 (from LALR or IELR) and default reductions corrupt the expected
990 token list. However, the list is correct for canonical LR with
991 one exception: it will still contain any token that will not be
992 accepted due to an error action in a later state.
994 if (yytoken != YYEMPTY)
996 int yyn = yypact[*yyssp];
997 yyarg[yycount++] = yytname[yytoken];
998 if (!yypact_value_is_default (yyn))
1000 /* Start YYX at -YYN if negative to avoid negative indexes in
1001 YYCHECK. In other words, skip the first -YYN actions for
1002 this state because they are default actions. */
1003 int yyxbegin = yyn < 0 ? -yyn : 0;
1004 /* Stay within bounds of both yycheck and yytname. */
1005 int yychecklim = YYLAST - yyn + 1;
1006 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1009 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1010 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
1011 && !yytable_value_is_error (yytable[yyx + yyn]))
1013 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1019 yyarg[yycount++] = yytname[yyx];
1021 YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
1022 if (! (yysize <= yysize1
1023 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1033 # define YYCASE_(N, S) \
1037 YYCASE_(0, YY_("syntax error"));
1038 YYCASE_(1, YY_("syntax error, unexpected %s"));
1039 YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1040 YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1041 YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1042 YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1047 YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
1048 if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1053 if (*yymsg_alloc < yysize)
1055 *yymsg_alloc = 2 * yysize;
1056 if (! (yysize <= *yymsg_alloc
1057 && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1058 *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1062 /* Avoid sprintf, as that infringes on the user's name space.
1063 Don't have undefined behavior even if the translation
1064 produced a string with the wrong number of "%s"s. */
1068 while ((*yyp = *yyformat) != '\0')
1069 if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1071 yyp += yytnamerr (yyp, yyarg[yyi++]);
1082 #endif /* YYERROR_VERBOSE */
1084 /*-----------------------------------------------.
1085 | Release the memory associated to this symbol. |
1086 `-----------------------------------------------*/
1089 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1094 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1096 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1098 YY_IGNORE_MAYBE_UNINITIALIZED_END
1104 /* The lookahead symbol. */
1107 /* The semantic value of the lookahead symbol. */
1109 /* Number of syntax errors so far. */
1121 /* Number of tokens to shift before error messages enabled. */
1124 /* The stacks and their tools:
1125 'yyss': related to states.
1126 'yyvs': related to semantic values.
1128 Refer to the stacks through separate pointers, to allow yyoverflow
1129 to reallocate them elsewhere. */
1131 /* The state stack. */
1132 yytype_int16 yyssa[YYINITDEPTH];
1134 yytype_int16 *yyssp;
1136 /* The semantic value stack. */
1137 YYSTYPE yyvsa[YYINITDEPTH];
1141 YYSIZE_T yystacksize;
1145 /* Lookahead token as an internal (translated) token number. */
1147 /* The variables used to return semantic value and location from the
1152 /* Buffer for error messages, and its allocated size. */
1154 char *yymsg = yymsgbuf;
1155 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1158 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1160 /* The number of symbols on the RHS of the reduced rule.
1161 Keep to zero when no symbol should be popped. */
1164 yyssp = yyss = yyssa;
1165 yyvsp = yyvs = yyvsa;
1166 yystacksize = YYINITDEPTH;
1168 YYDPRINTF ((stderr, "Starting parse\n"));
1173 yychar = YYEMPTY; /* Cause a token to be read. */
1176 /*------------------------------------------------------------.
1177 | yynewstate -- Push a new state, which is found in yystate. |
1178 `------------------------------------------------------------*/
1180 /* In all cases, when you get here, the value and location stacks
1181 have just been pushed. So pushing a state here evens the stacks. */
1187 if (yyss + yystacksize - 1 <= yyssp)
1189 /* Get the current used size of the three stacks, in elements. */
1190 YYSIZE_T yysize = yyssp - yyss + 1;
1194 /* Give user a chance to reallocate the stack. Use copies of
1195 these so that the &'s don't force the real ones into
1197 YYSTYPE *yyvs1 = yyvs;
1198 yytype_int16 *yyss1 = yyss;
1200 /* Each stack pointer address is followed by the size of the
1201 data in use in that stack, in bytes. This used to be a
1202 conditional around just the two extra args, but that might
1203 be undefined if yyoverflow is a macro. */
1204 yyoverflow (YY_("memory exhausted"),
1205 &yyss1, yysize * sizeof (*yyssp),
1206 &yyvs1, yysize * sizeof (*yyvsp),
1212 #else /* no yyoverflow */
1213 # ifndef YYSTACK_RELOCATE
1214 goto yyexhaustedlab;
1216 /* Extend the stack our own way. */
1217 if (YYMAXDEPTH <= yystacksize)
1218 goto yyexhaustedlab;
1220 if (YYMAXDEPTH < yystacksize)
1221 yystacksize = YYMAXDEPTH;
1224 yytype_int16 *yyss1 = yyss;
1225 union yyalloc *yyptr =
1226 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1228 goto yyexhaustedlab;
1229 YYSTACK_RELOCATE (yyss_alloc, yyss);
1230 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1231 # undef YYSTACK_RELOCATE
1233 YYSTACK_FREE (yyss1);
1236 #endif /* no yyoverflow */
1238 yyssp = yyss + yysize - 1;
1239 yyvsp = yyvs + yysize - 1;
1241 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1242 (unsigned long int) yystacksize));
1244 if (yyss + yystacksize - 1 <= yyssp)
1248 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1250 if (yystate == YYFINAL)
1260 /* Do appropriate processing given the current state. Read a
1261 lookahead token if we need one and don't already have one. */
1263 /* First try to decide what to do without reference to lookahead token. */
1264 yyn = yypact[yystate];
1265 if (yypact_value_is_default (yyn))
1268 /* Not known => get a lookahead token if don't already have one. */
1270 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1271 if (yychar == YYEMPTY)
1273 YYDPRINTF ((stderr, "Reading a token: "));
1277 if (yychar <= YYEOF)
1279 yychar = yytoken = YYEOF;
1280 YYDPRINTF ((stderr, "Now at end of input.\n"));
1284 yytoken = YYTRANSLATE (yychar);
1285 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1288 /* If the proper action on seeing token YYTOKEN is to reduce or to
1289 detect an error, take that action. */
1291 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1296 if (yytable_value_is_error (yyn))
1302 /* Count tokens shifted since error; after three, turn off error
1307 /* Shift the lookahead token. */
1308 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1310 /* Discard the shifted token. */
1314 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1316 YY_IGNORE_MAYBE_UNINITIALIZED_END
1321 /*-----------------------------------------------------------.
1322 | yydefault -- do the default action for the current state. |
1323 `-----------------------------------------------------------*/
1325 yyn = yydefact[yystate];
1331 /*-----------------------------.
1332 | yyreduce -- Do a reduction. |
1333 `-----------------------------*/
1335 /* yyn is the number of a rule to reduce with. */
1338 /* If YYLEN is nonzero, implement the default value of the action:
1341 Otherwise, the following line sets YYVAL to garbage.
1342 This behavior is undocumented and Bison
1343 users should not rely upon it. Assigning to YYVAL
1344 unconditionally makes the parser a bit smaller, and it avoids a
1345 GCC warning that YYVAL may be used uninitialized. */
1346 yyval = yyvsp[1-yylen];
1349 YY_REDUCE_PRINT (yyn);
1353 #line 132 "parsedate.y" /* yacc.c:1646 */
1357 /* I am compulsive about lint natterings... */
1358 if (yyHaveTime == -1) {
1363 #line 1364 "y.tab.c" /* yacc.c:1646 */
1367 #line 141 "parsedate.y" /* yacc.c:1646 */
1370 yyTimezone = (yyvsp[0].Number);
1372 #line 1373 "y.tab.c" /* yacc.c:1646 */
1376 #line 145 "parsedate.y" /* yacc.c:1646 */
1380 #line 1381 "y.tab.c" /* yacc.c:1646 */
1384 #line 148 "parsedate.y" /* yacc.c:1646 */
1388 #line 1389 "y.tab.c" /* yacc.c:1646 */
1392 #line 153 "parsedate.y" /* yacc.c:1646 */
1394 if ((yyvsp[-1].Number) < 100) {
1395 yyHour = (yyvsp[-1].Number);
1399 yyHour = (yyvsp[-1].Number) / 100;
1400 yyMinutes = (yyvsp[-1].Number) % 100;
1403 yyMeridian = (yyvsp[0].Meridian);
1405 #line 1406 "y.tab.c" /* yacc.c:1646 */
1409 #line 165 "parsedate.y" /* yacc.c:1646 */
1411 yyHour = (yyvsp[-3].Number);
1412 yyMinutes = (yyvsp[-1].Number);
1414 yyMeridian = (yyvsp[0].Meridian);
1416 #line 1417 "y.tab.c" /* yacc.c:1646 */
1420 #line 171 "parsedate.y" /* yacc.c:1646 */
1422 yyHour = (yyvsp[-3].Number);
1423 yyMinutes = (yyvsp[-1].Number);
1424 yyTimezone = (yyvsp[0].Number);
1428 #line 1429 "y.tab.c" /* yacc.c:1646 */
1432 #line 178 "parsedate.y" /* yacc.c:1646 */
1434 yyHour = (yyvsp[-5].Number);
1435 yyMinutes = (yyvsp[-3].Number);
1436 yySeconds = (yyvsp[-1].Number);
1437 yyMeridian = (yyvsp[0].Meridian);
1439 #line 1440 "y.tab.c" /* yacc.c:1646 */
1443 #line 184 "parsedate.y" /* yacc.c:1646 */
1445 yyHour = (yyvsp[-5].Number);
1446 yyMinutes = (yyvsp[-3].Number);
1447 yySeconds = (yyvsp[-1].Number);
1448 yyTimezone = (yyvsp[0].Number);
1452 #line 1453 "y.tab.c" /* yacc.c:1646 */
1456 #line 194 "parsedate.y" /* yacc.c:1646 */
1458 (yyval.Number) = (yyvsp[0].Number);
1461 #line 1462 "y.tab.c" /* yacc.c:1646 */
1465 #line 198 "parsedate.y" /* yacc.c:1646 */
1467 (yyval.Number) = (yyvsp[0].Number);
1470 #line 1471 "y.tab.c" /* yacc.c:1646 */
1474 #line 202 "parsedate.y" /* yacc.c:1646 */
1476 /* Only allow "GMT+300" and "GMT-0800" */
1477 if ((yyvsp[-1].Number) != 0) {
1480 (yyval.Number) = (yyvsp[0].Number);
1483 #line 1484 "y.tab.c" /* yacc.c:1646 */
1487 #line 210 "parsedate.y" /* yacc.c:1646 */
1489 (yyval.Number) = (yyvsp[0].Number);
1492 #line 1493 "y.tab.c" /* yacc.c:1646 */
1496 #line 216 "parsedate.y" /* yacc.c:1646 */
1500 /* Unix and GMT and numeric timezones -- a little confusing. */
1501 if ((yyvsp[0].Number) < 0) {
1502 /* Don't work with negative modulus. */
1503 (yyvsp[0].Number) = -(yyvsp[0].Number);
1504 if ((yyvsp[0].Number) > 9999 || (i = (yyvsp[0].Number) % 100) >= 60) {
1507 (yyval.Number) = ((yyvsp[0].Number) / 100) * 60 + i;
1510 if ((yyvsp[0].Number) > 9999 || (i = (yyvsp[0].Number) % 100) >= 60) {
1513 (yyval.Number) = -(((yyvsp[0].Number) / 100) * 60 + i);
1516 #line 1517 "y.tab.c" /* yacc.c:1646 */
1520 #line 237 "parsedate.y" /* yacc.c:1646 */
1522 yyMonth = (yyvsp[-2].Number);
1523 yyDay = (yyvsp[0].Number);
1525 #line 1526 "y.tab.c" /* yacc.c:1646 */
1529 #line 241 "parsedate.y" /* yacc.c:1646 */
1531 if ((yyvsp[-4].Number) > 100) {
1532 yyYear = (yyvsp[-4].Number);
1533 yyMonth = (yyvsp[-2].Number);
1534 yyDay = (yyvsp[0].Number);
1537 yyMonth = (yyvsp[-4].Number);
1538 yyDay = (yyvsp[-2].Number);
1539 yyYear = (yyvsp[0].Number);
1542 #line 1543 "y.tab.c" /* yacc.c:1646 */
1546 #line 253 "parsedate.y" /* yacc.c:1646 */
1548 yyMonth = (yyvsp[-1].Number);
1549 yyDay = (yyvsp[0].Number);
1551 #line 1552 "y.tab.c" /* yacc.c:1646 */
1555 #line 257 "parsedate.y" /* yacc.c:1646 */
1557 yyMonth = (yyvsp[-3].Number);
1558 yyDay = (yyvsp[-2].Number);
1559 yyYear = (yyvsp[0].Number);
1561 #line 1562 "y.tab.c" /* yacc.c:1646 */
1565 #line 262 "parsedate.y" /* yacc.c:1646 */
1567 yyDay = (yyvsp[-1].Number);
1568 yyMonth = (yyvsp[0].Number);
1570 #line 1571 "y.tab.c" /* yacc.c:1646 */
1574 #line 266 "parsedate.y" /* yacc.c:1646 */
1576 yyDay = (yyvsp[-2].Number);
1577 yyMonth = (yyvsp[-1].Number);
1578 yyYear = (yyvsp[0].Number);
1580 #line 1581 "y.tab.c" /* yacc.c:1646 */
1584 #line 271 "parsedate.y" /* yacc.c:1646 */
1586 yyDay = (yyvsp[-2].Number);
1587 yyMonth = (yyvsp[-1].Number);
1588 yyYear = (yyvsp[0].Number);
1590 #line 1591 "y.tab.c" /* yacc.c:1646 */
1594 #line 278 "parsedate.y" /* yacc.c:1646 */
1596 yyRelSeconds += (yyvsp[-1].Number) * (yyvsp[0].Number);
1598 #line 1599 "y.tab.c" /* yacc.c:1646 */
1602 #line 281 "parsedate.y" /* yacc.c:1646 */
1604 yyRelSeconds += (yyvsp[-1].Number) * (yyvsp[0].Number);
1606 #line 1607 "y.tab.c" /* yacc.c:1646 */
1610 #line 284 "parsedate.y" /* yacc.c:1646 */
1612 yyRelMonth += (yyvsp[-1].Number) * (yyvsp[0].Number);
1614 #line 1615 "y.tab.c" /* yacc.c:1646 */
1618 #line 287 "parsedate.y" /* yacc.c:1646 */
1620 yyRelMonth += (yyvsp[-1].Number) * (yyvsp[0].Number);
1622 #line 1623 "y.tab.c" /* yacc.c:1646 */
1626 #line 292 "parsedate.y" /* yacc.c:1646 */
1628 (yyval.Meridian) = MER24;
1630 #line 1631 "y.tab.c" /* yacc.c:1646 */
1634 #line 295 "parsedate.y" /* yacc.c:1646 */
1636 (yyval.Meridian) = (yyvsp[0].Meridian);
1638 #line 1639 "y.tab.c" /* yacc.c:1646 */
1642 #line 1643 "y.tab.c" /* yacc.c:1646 */
1645 /* User semantic actions sometimes alter yychar, and that requires
1646 that yytoken be updated with the new translation. We take the
1647 approach of translating immediately before every use of yytoken.
1648 One alternative is translating here after every semantic action,
1649 but that translation would be missed if the semantic action invokes
1650 YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1651 if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
1652 incorrect destructor might then be invoked immediately. In the
1653 case of YYERROR or YYBACKUP, subsequent parser actions might lead
1654 to an incorrect destructor call or verbose syntax error message
1655 before the lookahead is translated. */
1656 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1660 YY_STACK_PRINT (yyss, yyssp);
1664 /* Now 'shift' the result of the reduction. Determine what state
1665 that goes to, based on the state we popped back to and the rule
1666 number reduced by. */
1670 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1671 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1672 yystate = yytable[yystate];
1674 yystate = yydefgoto[yyn - YYNTOKENS];
1679 /*--------------------------------------.
1680 | yyerrlab -- here on detecting error. |
1681 `--------------------------------------*/
1683 /* Make sure we have latest lookahead translation. See comments at
1684 user semantic actions for why this is necessary. */
1685 yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
1687 /* If not already recovering from an error, report this error. */
1691 #if ! YYERROR_VERBOSE
1692 yyerror (YY_("syntax error"));
1694 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
1697 char const *yymsgp = YY_("syntax error");
1698 int yysyntax_error_status;
1699 yysyntax_error_status = YYSYNTAX_ERROR;
1700 if (yysyntax_error_status == 0)
1702 else if (yysyntax_error_status == 1)
1704 if (yymsg != yymsgbuf)
1705 YYSTACK_FREE (yymsg);
1706 yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
1710 yymsg_alloc = sizeof yymsgbuf;
1711 yysyntax_error_status = 2;
1715 yysyntax_error_status = YYSYNTAX_ERROR;
1720 if (yysyntax_error_status == 2)
1721 goto yyexhaustedlab;
1723 # undef YYSYNTAX_ERROR
1729 if (yyerrstatus == 3)
1731 /* If just tried and failed to reuse lookahead token after an
1732 error, discard it. */
1734 if (yychar <= YYEOF)
1736 /* Return failure if at end of input. */
1737 if (yychar == YYEOF)
1742 yydestruct ("Error: discarding",
1748 /* Else will try to reuse lookahead token after shifting the error
1753 /*---------------------------------------------------.
1754 | yyerrorlab -- error raised explicitly by YYERROR. |
1755 `---------------------------------------------------*/
1758 /* Pacify compilers like GCC when the user code never invokes
1759 YYERROR and the label yyerrorlab therefore never appears in user
1761 if (/*CONSTCOND*/ 0)
1764 /* Do not reclaim the symbols of the rule whose action triggered
1768 YY_STACK_PRINT (yyss, yyssp);
1773 /*-------------------------------------------------------------.
1774 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1775 `-------------------------------------------------------------*/
1777 yyerrstatus = 3; /* Each real token shifted decrements this. */
1781 yyn = yypact[yystate];
1782 if (!yypact_value_is_default (yyn))
1785 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1793 /* Pop the current state because it cannot handle the error token. */
1798 yydestruct ("Error: popping",
1799 yystos[yystate], yyvsp);
1802 YY_STACK_PRINT (yyss, yyssp);
1805 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1807 YY_IGNORE_MAYBE_UNINITIALIZED_END
1810 /* Shift the error token. */
1811 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1817 /*-------------------------------------.
1818 | yyacceptlab -- YYACCEPT comes here. |
1819 `-------------------------------------*/
1824 /*-----------------------------------.
1825 | yyabortlab -- YYABORT comes here. |
1826 `-----------------------------------*/
1831 #if !defined yyoverflow || YYERROR_VERBOSE
1832 /*-------------------------------------------------.
1833 | yyexhaustedlab -- memory exhaustion comes here. |
1834 `-------------------------------------------------*/
1836 yyerror (YY_("memory exhausted"));
1842 if (yychar != YYEMPTY)
1844 /* Make sure we have latest lookahead translation. See comments at
1845 user semantic actions for why this is necessary. */
1846 yytoken = YYTRANSLATE (yychar);
1847 yydestruct ("Cleanup: discarding lookahead",
1850 /* Do not reclaim the symbols of the rule whose action triggered
1851 this YYABORT or YYACCEPT. */
1853 YY_STACK_PRINT (yyss, yyssp);
1854 while (yyssp != yyss)
1856 yydestruct ("Cleanup: popping",
1857 yystos[*yyssp], yyvsp);
1862 YYSTACK_FREE (yyss);
1865 if (yymsg != yymsgbuf)
1866 YYSTACK_FREE (yymsg);
1870 #line 300 "parsedate.y" /* yacc.c:1906 */
1873 /* Month and day table. */
1874 static TABLE MonthDayTable[] = {
1875 { "january", tMONTH, 1 },
1876 { "february", tMONTH, 2 },
1877 { "march", tMONTH, 3 },
1878 { "april", tMONTH, 4 },
1879 { "may", tMONTH, 5 },
1880 { "june", tMONTH, 6 },
1881 { "july", tMONTH, 7 },
1882 { "august", tMONTH, 8 },
1883 { "september", tMONTH, 9 },
1884 { "october", tMONTH, 10 },
1885 { "november", tMONTH, 11 },
1886 { "december", tMONTH, 12 },
1887 /* The value of the day isn't used... */
1888 { "sunday", tDAY, 0 },
1889 { "monday", tDAY, 0 },
1890 { "tuesday", tDAY, 0 },
1891 { "wednesday", tDAY, 0 },
1892 { "thursday", tDAY, 0 },
1893 { "friday", tDAY, 0 },
1894 { "saturday", tDAY, 0 },
1897 /* Time units table. */
1898 static TABLE UnitsTable[] = {
1899 { "year", tMONTH_UNIT, 12 },
1900 { "month", tMONTH_UNIT, 1 },
1901 { "week", tSEC_UNIT, 7L * 24 * 60 * 60 },
1902 { "day", tSEC_UNIT, 1L * 24 * 60 * 60 },
1903 { "hour", tSEC_UNIT, 60 * 60 },
1904 { "minute", tSEC_UNIT, 60 },
1905 { "min", tSEC_UNIT, 60 },
1906 { "second", tSEC_UNIT, 1 },
1907 { "sec", tSEC_UNIT, 1 },
1910 /* Timezone table. */
1911 static TABLE TimezoneTable[] = {
1912 { "gmt", tZONE, HOUR( 0) }, /* Greenwich Mean */
1913 { "ut", tZONE, HOUR( 0) }, /* Universal */
1914 { "utc", tZONE, HOUR( 0) }, /* Universal Coordinated */
1915 { "cut", tZONE, HOUR( 0) }, /* Coordinated Universal */
1916 { "z", tZONE, HOUR( 0) }, /* Greenwich Mean */
1917 { "wet", tZONE, HOUR( 0) }, /* Western European */
1918 { "bst", tDAYZONE, HOUR( 0) }, /* British Summer */
1919 { "nst", tZONE, HOUR(3)+30 }, /* Newfoundland Standard */
1920 { "ndt", tDAYZONE, HOUR(3)+30 }, /* Newfoundland Daylight */
1921 { "ast", tZONE, HOUR( 4) }, /* Atlantic Standard */
1922 { "adt", tDAYZONE, HOUR( 4) }, /* Atlantic Daylight */
1923 { "est", tZONE, HOUR( 5) }, /* Eastern Standard */
1924 { "edt", tDAYZONE, HOUR( 5) }, /* Eastern Daylight */
1925 { "cst", tZONE, HOUR( 6) }, /* Central Standard */
1926 { "cdt", tDAYZONE, HOUR( 6) }, /* Central Daylight */
1927 { "mst", tZONE, HOUR( 7) }, /* Mountain Standard */
1928 { "mdt", tDAYZONE, HOUR( 7) }, /* Mountain Daylight */
1929 { "pst", tZONE, HOUR( 8) }, /* Pacific Standard */
1930 { "pdt", tDAYZONE, HOUR( 8) }, /* Pacific Daylight */
1931 { "yst", tZONE, HOUR( 9) }, /* Yukon Standard */
1932 { "ydt", tDAYZONE, HOUR( 9) }, /* Yukon Daylight */
1933 { "akst", tZONE, HOUR( 9) }, /* Alaska Standard */
1934 { "akdt", tDAYZONE, HOUR( 9) }, /* Alaska Daylight */
1935 { "hst", tZONE, HOUR(10) }, /* Hawaii Standard */
1936 { "hast", tZONE, HOUR(10) }, /* Hawaii-Aleutian Standard */
1937 { "hadt", tDAYZONE, HOUR(10) }, /* Hawaii-Aleutian Daylight */
1938 { "ces", tDAYZONE, -HOUR(1) }, /* Central European Summer */
1939 { "cest", tDAYZONE, -HOUR(1) }, /* Central European Summer */
1940 { "mez", tZONE, -HOUR(1) }, /* Middle European */
1941 { "mezt", tDAYZONE, -HOUR(1) }, /* Middle European Summer */
1942 { "cet", tZONE, -HOUR(1) }, /* Central European */
1943 { "met", tZONE, -HOUR(1) }, /* Middle European */
1944 { "eet", tZONE, -HOUR(2) }, /* Eastern Europe */
1945 { "msk", tZONE, -HOUR(3) }, /* Moscow Winter */
1946 { "msd", tDAYZONE, -HOUR(3) }, /* Moscow Summer */
1947 { "wast", tZONE, -HOUR(8) }, /* West Australian Standard */
1948 { "wadt", tDAYZONE, -HOUR(8) }, /* West Australian Daylight */
1949 { "hkt", tZONE, -HOUR(8) }, /* Hong Kong */
1950 { "cct", tZONE, -HOUR(8) }, /* China Coast */
1951 { "jst", tZONE, -HOUR(9) }, /* Japan Standard */
1952 { "kst", tZONE, -HOUR(9) }, /* Korean Standard */
1953 { "kdt", tZONE, -HOUR(9) }, /* Korean Daylight */
1954 { "cast", tZONE, -(HOUR(9)+30) }, /* Central Australian Standard */
1955 { "cadt", tDAYZONE, -(HOUR(9)+30) }, /* Central Australian Daylight */
1956 { "east", tZONE, -HOUR(10) }, /* Eastern Australian Standard */
1957 { "eadt", tDAYZONE, -HOUR(10) }, /* Eastern Australian Daylight */
1958 { "nzst", tZONE, -HOUR(12) }, /* New Zealand Standard */
1959 { "nzdt", tDAYZONE, -HOUR(12) }, /* New Zealand Daylight */
1961 /* For completeness we include the following entries. */
1964 /* Duplicate names. Either they conflict with a zone listed above
1965 * (which is either more likely to be seen or just been in circulation
1966 * longer), or they conflict with another zone in this section and
1967 * we could not reasonably choose one over the other. */
1968 { "fst", tZONE, HOUR( 2) }, /* Fernando De Noronha Standard */
1969 { "fdt", tDAYZONE, HOUR( 2) }, /* Fernando De Noronha Daylight */
1970 { "bst", tZONE, HOUR( 3) }, /* Brazil Standard */
1971 { "est", tZONE, HOUR( 3) }, /* Eastern Standard (Brazil) */
1972 { "edt", tDAYZONE, HOUR( 3) }, /* Eastern Daylight (Brazil) */
1973 { "wst", tZONE, HOUR( 4) }, /* Western Standard (Brazil) */
1974 { "wdt", tDAYZONE, HOUR( 4) }, /* Western Daylight (Brazil) */
1975 { "cst", tZONE, HOUR( 5) }, /* Chile Standard */
1976 { "cdt", tDAYZONE, HOUR( 5) }, /* Chile Daylight */
1977 { "ast", tZONE, HOUR( 5) }, /* Acre Standard */
1978 { "adt", tDAYZONE, HOUR( 5) }, /* Acre Daylight */
1979 { "cst", tZONE, HOUR( 5) }, /* Cuba Standard */
1980 { "cdt", tDAYZONE, HOUR( 5) }, /* Cuba Daylight */
1981 { "est", tZONE, HOUR( 6) }, /* Easter Island Standard */
1982 { "edt", tDAYZONE, HOUR( 6) }, /* Easter Island Daylight */
1983 { "sst", tZONE, HOUR(11) }, /* Samoa Standard */
1984 { "ist", tZONE, -HOUR(2) }, /* Israel Standard */
1985 { "idt", tDAYZONE, -HOUR(2) }, /* Israel Daylight */
1986 { "idt", tDAYZONE, -(HOUR(3)+30) }, /* Iran Daylight */
1987 { "ist", tZONE, -(HOUR(3)+30) }, /* Iran Standard */
1988 { "cst", tZONE, -HOUR(8) }, /* China Standard */
1989 { "cdt", tDAYZONE, -HOUR(8) }, /* China Daylight */
1990 { "sst", tZONE, -HOUR(8) }, /* Singapore Standard */
1992 /* Dubious (e.g., not in Olson's TIMEZONE package) or obsolete. */
1993 { "gst", tZONE, HOUR( 3) }, /* Greenland Standard */
1994 { "wat", tZONE, -HOUR(1) }, /* West Africa */
1995 { "at", tZONE, HOUR( 2) }, /* Azores */
1996 { "gst", tZONE, -HOUR(10) }, /* Guam Standard */
1997 { "nft", tZONE, HOUR(3)+30 }, /* Newfoundland */
1998 { "idlw", tZONE, HOUR(12) }, /* International Date Line West */
1999 { "mewt", tZONE, -HOUR(1) }, /* Middle European Winter */
2000 { "mest", tDAYZONE, -HOUR(1) }, /* Middle European Summer */
2001 { "swt", tZONE, -HOUR(1) }, /* Swedish Winter */
2002 { "sst", tDAYZONE, -HOUR(1) }, /* Swedish Summer */
2003 { "fwt", tZONE, -HOUR(1) }, /* French Winter */
2004 { "fst", tDAYZONE, -HOUR(1) }, /* French Summer */
2005 { "bt", tZONE, -HOUR(3) }, /* Baghdad */
2006 { "it", tZONE, -(HOUR(3)+30) }, /* Iran */
2007 { "zp4", tZONE, -HOUR(4) }, /* USSR Zone 3 */
2008 { "zp5", tZONE, -HOUR(5) }, /* USSR Zone 4 */
2009 { "ist", tZONE, -(HOUR(5)+30) }, /* Indian Standard */
2010 { "zp6", tZONE, -HOUR(6) }, /* USSR Zone 5 */
2011 { "nst", tZONE, -HOUR(7) }, /* North Sumatra */
2012 { "sst", tZONE, -HOUR(7) }, /* South Sumatra */
2013 { "jt", tZONE, -(HOUR(7)+30) }, /* Java (3pm in Cronusland!) */
2014 { "nzt", tZONE, -HOUR(12) }, /* New Zealand */
2015 { "idle", tZONE, -HOUR(12) }, /* International Date Line East */
2016 { "cat", tZONE, HOUR(10) }, /* -- expired 1967 */
2017 { "nt", tZONE, HOUR(11) }, /* -- expired 1967 */
2018 { "ahst", tZONE, HOUR(10) }, /* -- expired 1983 */
2019 { "hdt", tDAYZONE, HOUR(10) }, /* -- expired 1986 */
2033 ToSeconds(time_t Hours, time_t Minutes, time_t Seconds, MERIDIAN Meridian)
2035 if (Minutes < 0 || Minutes > 59 || Seconds < 0 || Seconds > 61)
2037 if (Meridian == MER24) {
2038 if (Hours < 0 || Hours > 23)
2042 if (Hours < 1 || Hours > 12)
2046 if (Meridian == MERpm)
2049 return (Hours * 60L + Minutes) * 60L + Seconds;
2054 Convert(time_t Month, time_t Day, time_t Year,
2055 time_t Hours, time_t Minutes, time_t Seconds,
2056 MERIDIAN Meridian, DSTMODE dst)
2058 static int DaysNormal[13] = {
2059 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
2061 static int DaysLeap[13] = {
2062 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
2064 static int LeapYears[] = {
2065 1972, 1976, 1980, 1984, 1988, 1992, 1996,
2066 2000, 2004, 2008, 2012, 2016, 2020, 2024, 2028, 2032, 2036
2070 register time_t Julian;
2080 for (mp = DaysNormal, yp = LeapYears; yp < ENDOF(LeapYears); yp++)
2085 if (Year < EPOCH || Year > END_OF_TIME
2086 || Month < 1 || Month > 12
2087 /* NOSTRICT *//* conversion from long may lose accuracy */
2088 || Day < 1 || Day > mp[(int)Month])
2091 Julian = Day - 1 + (Year - EPOCH) * 365;
2092 for (yp = LeapYears; yp < ENDOF(LeapYears); yp++, Julian++)
2095 for (i = 1; i < Month; i++)
2097 Julian *= SECSPERDAY;
2098 Julian += yyTimezone * 60L;
2099 if ((tod = ToSeconds(Hours, Minutes, Seconds, Meridian)) < 0)
2103 if (dst == DSTon || (dst == DSTmaybe && localtime(&tod)->tm_isdst))
2104 Julian -= DST_OFFSET * 60L * 60L;
2110 DSTcorrect(time_t Start, time_t Future)
2115 StartDay = (localtime(&Start)->tm_hour + 1) % 24;
2116 FutureDay = (localtime(&Future)->tm_hour + 1) % 24;
2117 return (Future - Start) + (StartDay - FutureDay) * DST_OFFSET * 60L * 60L;
2122 RelativeMonth(time_t Start, time_t RelMonth)
2128 tm = localtime(&Start);
2129 Month = 12 * tm->tm_year + tm->tm_mon + RelMonth;
2131 Month = Month % 12 + 1;
2132 return DSTcorrect(Start,
2133 Convert(Month, (time_t)tm->tm_mday, Year,
2134 (time_t)tm->tm_hour, (time_t)tm->tm_min, (time_t)tm->tm_sec,
2140 LookupWord(char *buff, register int length)
2150 /* See if we have an abbreviation for a month. */
2151 if (length == 3 || (length == 4 && p[3] == '.'))
2152 for (tp = MonthDayTable; tp < ENDOF(MonthDayTable); tp++) {
2154 if (c == q[0] && p[1] == q[1] && p[2] == q[2]) {
2155 yylval.Number = tp->value;
2160 for (tp = MonthDayTable; tp < ENDOF(MonthDayTable); tp++)
2161 if (c == tp->name[0] && strcmp(p, tp->name) == 0) {
2162 yylval.Number = tp->value;
2166 /* Try for a timezone. */
2167 for (tp = TimezoneTable; tp < ENDOF(TimezoneTable); tp++)
2168 if (c == tp->name[0] && p[1] == tp->name[1]
2169 && strcmp(p, tp->name) == 0) {
2170 yylval.Number = tp->value;
2174 /* Try the units table. */
2175 for (tp = UnitsTable; tp < ENDOF(UnitsTable); tp++)
2176 if (c == tp->name[0] && strcmp(p, tp->name) == 0) {
2177 yylval.Number = tp->value;
2181 /* Strip off any plural and try the units table again. */
2182 if (--length > 0 && p[length] == 's') {
2184 for (tp = UnitsTable; tp < ENDOF(UnitsTable); tp++)
2185 if (c == tp->name[0] && strcmp(p, tp->name) == 0) {
2187 yylval.Number = tp->value;
2194 /* Drop out any periods. */
2195 for (p = buff, q = (char*)buff; *q; q++)
2200 /* Try the meridians. */
2201 if (buff[1] == 'm' && buff[2] == '\0') {
2202 if (buff[0] == 'a') {
2203 yylval.Meridian = MERam;
2206 if (buff[0] == 'p') {
2207 yylval.Meridian = MERpm;
2212 /* If we saw any periods, try the timezones again. */
2213 if (p - buff != length) {
2215 for (p = buff, tp = TimezoneTable; tp < ENDOF(TimezoneTable); tp++)
2216 if (c == tp->name[0] && p[1] == tp->name[1]
2217 && strcmp(p, tp->name) == 0) {
2218 yylval.Number = tp->value;
2223 /* Unknown word -- assume GMT timezone. */
2237 register int nesting;
2240 /* Get first character after the whitespace. */
2242 while (isspace(*yyInput))
2246 /* Ignore RFC 822 comments, typically time zone names. */
2249 for (nesting = 1; (c = *++yyInput) != RPAREN || --nesting; )
2252 else if (!IS7BIT(c) || c == '\0' || c == '\r'
2253 || (c == '\\' && ((c = *++yyInput) == '\0' || !IS7BIT(c))))
2254 /* Lexical error: bad comment. */
2260 if (isdigit(c) || c == '-' || c == '+') {
2261 if (c == '-' || c == '+') {
2262 sign = c == '-' ? -1 : 1;
2264 if (!isdigit(*yyInput))
2265 /* Skip the plus or minus sign. */
2270 for (i = 0; (c = *yyInput++) != '\0' && isdigit(c); )
2271 i = 10 * i + c - '0';
2273 yylval.Number = sign < 0 ? -i : i;
2274 return sign ? tSNUMBER : tUNUMBER;
2279 for (p = buff; (c = *yyInput++) == '.' || isalpha(c); )
2280 if (p < &buff[sizeof buff - 1])
2281 *p++ = isupper(c) ? tolower(c) : c;
2284 return LookupWord(buff, p - buff);
2293 parsedate(const char *p)
2295 extern int date_parse(void);
2298 yyInput = p; /* well, its supposed to be const... */
2304 yyDSTmode = DSTmaybe;
2315 if (date_parse() || yyHaveTime > 1 || yyHaveDate > 1)
2318 if (yyHaveDate || yyHaveTime) {
2319 Start = Convert(yyMonth, yyDay, yyYear, yyHour, yyMinutes, yySeconds,
2320 yyMeridian, yyDSTmode);
2327 Start += yyRelSeconds;
2329 Start += RelativeMonth(Start, yyRelMonth);
2331 /* Have to do *something* with a legitimate -1 so it's distinguishable
2332 * from the error return value. (Alternately could set errno on error.) */
2333 return Start == -1 ? 0 : Start;
2341 #endif /* YYDEBUG */
2345 main(int ac, char *av[])
2352 #endif /* YYDEBUG */
2354 (void)printf("Enter date, or blank line to exit.\n\t> ");
2356 (void)printf("\t> ");
2357 (void)fflush(stdout);
2358 if (fgets(buff, sizeof buff, stdin) == NULL || buff[0] == '\n')
2361 if (strcmp(buff, "yydebug") == 0) {
2363 printf("yydebug = %s\n", yydebug ? "on" : "off");
2366 #endif /* YYDEBUG */
2367 d = parsedate(buff, (TIMEINFO *)NULL);
2369 (void)printf("Bad format - couldn't convert.\n");
2371 (void)printf("%s", ctime(&d));