1 /* A Bison parser, made by GNU Bison 3.0.4. */
3 /* Bison implementation for Yacc-like parsers in C
5 Copyright (C) 1984, 1989-1990, 2000-2015 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.4"
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
237 #line 114 "parsedate.y" /* yacc.c:355 */
240 enum _MERIDIAN Meridian;
242 #line 243 "y.tab.c" /* yacc.c:355 */
245 typedef union YYSTYPE YYSTYPE;
246 # define YYSTYPE_IS_TRIVIAL 1
247 # define YYSTYPE_IS_DECLARED 1
251 extern YYSTYPE yylval;
257 /* Copy the second part of user declarations. */
259 #line 260 "y.tab.c" /* yacc.c:358 */
266 typedef YYTYPE_UINT8 yytype_uint8;
268 typedef unsigned char yytype_uint8;
272 typedef YYTYPE_INT8 yytype_int8;
274 typedef signed char yytype_int8;
278 typedef YYTYPE_UINT16 yytype_uint16;
280 typedef unsigned short int yytype_uint16;
284 typedef YYTYPE_INT16 yytype_int16;
286 typedef short int yytype_int16;
290 # ifdef __SIZE_TYPE__
291 # define YYSIZE_T __SIZE_TYPE__
292 # elif defined size_t
293 # define YYSIZE_T size_t
294 # elif ! defined YYSIZE_T
295 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
296 # define YYSIZE_T size_t
298 # define YYSIZE_T unsigned int
302 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
305 # if defined YYENABLE_NLS && YYENABLE_NLS
307 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
308 # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
312 # define YY_(Msgid) Msgid
317 # if (defined __GNUC__ \
318 && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
319 || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
320 # define YY_ATTRIBUTE(Spec) __attribute__(Spec)
322 # define YY_ATTRIBUTE(Spec) /* empty */
326 #ifndef YY_ATTRIBUTE_PURE
327 # define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
330 #ifndef YY_ATTRIBUTE_UNUSED
331 # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
334 #if !defined _Noreturn \
335 && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
336 # if defined _MSC_VER && 1200 <= _MSC_VER
337 # define _Noreturn __declspec (noreturn)
339 # define _Noreturn YY_ATTRIBUTE ((__noreturn__))
343 /* Suppress unused-variable warnings by "using" E. */
344 #if ! defined lint || defined __GNUC__
345 # define YYUSE(E) ((void) (E))
347 # define YYUSE(E) /* empty */
350 #if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
351 /* Suppress an incorrect diagnostic about yylval being uninitialized. */
352 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
353 _Pragma ("GCC diagnostic push") \
354 _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
355 _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
356 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
357 _Pragma ("GCC diagnostic pop")
359 # define YY_INITIAL_VALUE(Value) Value
361 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
362 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
363 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
365 #ifndef YY_INITIAL_VALUE
366 # define YY_INITIAL_VALUE(Value) /* Nothing. */
370 #if ! defined yyoverflow || YYERROR_VERBOSE
372 /* The parser invokes alloca or malloc; define the necessary symbols. */
374 # ifdef YYSTACK_USE_ALLOCA
375 # if YYSTACK_USE_ALLOCA
377 # define YYSTACK_ALLOC __builtin_alloca
378 # elif defined __BUILTIN_VA_ARG_INCR
379 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
381 # define YYSTACK_ALLOC __alloca
382 # elif defined _MSC_VER
383 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
384 # define alloca _alloca
386 # define YYSTACK_ALLOC alloca
387 # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
388 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
389 /* Use EXIT_SUCCESS as a witness for stdlib.h. */
390 # ifndef EXIT_SUCCESS
391 # define EXIT_SUCCESS 0
398 # ifdef YYSTACK_ALLOC
399 /* Pacify GCC's 'empty if-body' warning. */
400 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
401 # ifndef YYSTACK_ALLOC_MAXIMUM
402 /* The OS might guarantee only one guard page at the bottom of the stack,
403 and a page size can be as small as 4096 bytes. So we cannot safely
404 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
405 to allow for a few compiler-allocated temporary stack slots. */
406 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
409 # define YYSTACK_ALLOC YYMALLOC
410 # define YYSTACK_FREE YYFREE
411 # ifndef YYSTACK_ALLOC_MAXIMUM
412 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
414 # if (defined __cplusplus && ! defined EXIT_SUCCESS \
415 && ! ((defined YYMALLOC || defined malloc) \
416 && (defined YYFREE || defined free)))
417 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
418 # ifndef EXIT_SUCCESS
419 # define EXIT_SUCCESS 0
423 # define YYMALLOC malloc
424 # if ! defined malloc && ! defined EXIT_SUCCESS
425 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
430 # if ! defined free && ! defined EXIT_SUCCESS
431 void free (void *); /* INFRINGES ON USER NAME SPACE */
435 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
438 #if (! defined yyoverflow \
439 && (! defined __cplusplus \
440 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
442 /* A type that is properly aligned for any stack member. */
445 yytype_int16 yyss_alloc;
449 /* The size of the maximum gap between one aligned stack and the next. */
450 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
452 /* The size of an array large to enough to hold all stacks, each with
454 # define YYSTACK_BYTES(N) \
455 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
456 + YYSTACK_GAP_MAXIMUM)
458 # define YYCOPY_NEEDED 1
460 /* Relocate STACK from its old location to the new one. The
461 local variables YYSIZE and YYSTACKSIZE give the old and new number of
462 elements in the stack, and YYPTR gives the new location of the
463 stack. Advance YYPTR to a properly aligned location for the next
465 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
468 YYSIZE_T yynewbytes; \
469 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
470 Stack = &yyptr->Stack_alloc; \
471 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
472 yyptr += yynewbytes / sizeof (*yyptr); \
478 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
479 /* Copy COUNT objects from SRC to DST. The source and destination do
482 # if defined __GNUC__ && 1 < __GNUC__
483 # define YYCOPY(Dst, Src, Count) \
484 __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
486 # define YYCOPY(Dst, Src, Count) \
490 for (yyi = 0; yyi < (Count); yyi++) \
491 (Dst)[yyi] = (Src)[yyi]; \
496 #endif /* !YYCOPY_NEEDED */
498 /* YYFINAL -- State number of the termination state. */
500 /* YYLAST -- Last index in YYTABLE. */
503 /* YYNTOKENS -- Number of terminals. */
505 /* YYNNTS -- Number of nonterminals. */
507 /* YYNRULES -- Number of rules. */
509 /* YYNSTATES -- Number of states. */
512 /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
513 by yylex, with out-of-bounds checking. */
515 #define YYMAXUTOK 266
517 #define YYTRANSLATE(YYX) \
518 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
520 /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
521 as returned by yylex, without out-of-bounds checking. */
522 static const yytype_uint8 yytranslate[] =
524 0, 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, 2, 2, 2, 2, 2, 2,
527 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
528 2, 2, 2, 2, 14, 2, 2, 13, 2, 2,
529 2, 2, 2, 2, 2, 2, 2, 2, 12, 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, 2, 2, 2, 2,
548 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
549 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
550 5, 6, 7, 8, 9, 10, 11
554 /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
555 static const yytype_uint16 yyrline[] =
557 0, 128, 128, 129, 132, 141, 145, 148, 153, 165,
558 171, 178, 184, 194, 198, 202, 210, 216, 237, 241,
559 253, 257, 262, 266, 271, 278, 281, 284, 287, 292,
564 #if YYDEBUG || YYERROR_VERBOSE || 0
565 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
566 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
567 static const char *const yytname[] =
569 "$end", "error", "$undefined", "tDAY", "tDAYZONE", "tMERIDIAN",
570 "tMONTH", "tMONTH_UNIT", "tSEC_UNIT", "tSNUMBER", "tUNUMBER", "tZONE",
571 "':'", "'/'", "','", "$accept", "spec", "item", "time", "zone",
572 "numzone", "date", "rel", "o_merid", YY_NULLPTR
577 /* YYTOKNUM[NUM] -- (External) token number corresponding to the
578 (internal) symbol number NUM (which must be that of a token). */
579 static const yytype_uint16 yytoknum[] =
581 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
586 #define YYPACT_NINF -29
588 #define yypact_value_is_default(Yystate) \
589 (!!((Yystate) == (-29)))
591 #define YYTABLE_NINF -1
593 #define yytable_value_is_error(Yytable_value) \
596 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
598 static const yytype_int8 yypact[] =
600 -29, 1, -29, -11, 11, 20, 12, -29, 4, -29,
601 -29, 13, 16, -29, -29, -29, 21, -29, -29, 22,
602 23, -29, -29, -29, 5, -29, -29, 28, 25, -29,
603 17, 24, -29, 26, -29, 29, -29, -29, 30, -29,
607 /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
608 Performed when YYTABLE does not specify something else to do. Zero
609 means the default is an error. */
610 static const yytype_uint8 yydefact[] =
612 2, 0, 1, 0, 0, 0, 29, 3, 4, 6,
613 7, 0, 20, 27, 25, 30, 22, 28, 26, 0,
614 0, 8, 14, 17, 13, 5, 16, 0, 0, 23,
615 29, 18, 15, 0, 21, 0, 10, 9, 0, 24,
619 /* YYPGOTO[NTERM-NUM]. */
620 static const yytype_int8 yypgoto[] =
622 -29, -29, -29, -29, -29, -24, -29, -29, -28
625 /* YYDEFGOTO[NTERM-NUM]. */
626 static const yytype_int8 yydefgoto[] =
628 -1, 1, 7, 8, 25, 26, 9, 10, 21
631 /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
632 positive, shift that token. If negative, reduce the rule whose
633 number is the opposite. If YYTABLE_NINF, syntax error. */
634 static const yytype_uint8 yytable[] =
636 32, 2, 37, 11, 3, 15, 36, 4, 22, 23,
637 5, 6, 43, 23, 23, 24, 42, 15, 16, 17,
638 18, 12, 15, 27, 19, 20, 23, 13, 14, 35,
639 28, 29, 30, 31, 33, 34, 39, 38, 0, 40,
643 static const yytype_int8 yycheck[] =
645 24, 0, 30, 14, 3, 5, 30, 6, 4, 9,
646 9, 10, 40, 9, 9, 11, 40, 5, 6, 7,
647 8, 10, 5, 10, 12, 13, 9, 7, 8, 12,
648 14, 10, 10, 10, 6, 10, 10, 13, -1, 10,
652 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
653 symbol of state STATE-NUM. */
654 static const yytype_uint8 yystos[] =
656 0, 16, 0, 3, 6, 9, 10, 17, 18, 21,
657 22, 14, 10, 7, 8, 5, 6, 7, 8, 12,
658 13, 23, 4, 9, 11, 19, 20, 10, 14, 10,
659 10, 10, 20, 6, 10, 12, 20, 23, 13, 10,
663 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
664 static const yytype_uint8 yyr1[] =
666 0, 15, 16, 16, 17, 17, 17, 17, 18, 18,
667 18, 18, 18, 19, 19, 19, 19, 20, 21, 21,
668 21, 21, 21, 21, 21, 22, 22, 22, 22, 23,
672 /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
673 static const yytype_uint8 yyr2[] =
675 0, 2, 0, 2, 1, 2, 1, 1, 2, 4,
676 4, 6, 6, 1, 1, 2, 1, 1, 3, 5,
677 2, 4, 2, 3, 5, 2, 2, 2, 2, 0,
682 #define yyerrok (yyerrstatus = 0)
683 #define yyclearin (yychar = YYEMPTY)
687 #define YYACCEPT goto yyacceptlab
688 #define YYABORT goto yyabortlab
689 #define YYERROR goto yyerrorlab
692 #define YYRECOVERING() (!!yyerrstatus)
694 #define YYBACKUP(Token, Value) \
696 if (yychar == YYEMPTY) \
700 YYPOPSTACK (yylen); \
706 yyerror (YY_("syntax error: cannot back up")); \
711 /* Error token number */
713 #define YYERRCODE 256
717 /* Enable debugging if requested. */
721 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
722 # define YYFPRINTF fprintf
725 # define YYDPRINTF(Args) \
731 /* This macro is provided for backward compatibility. */
732 #ifndef YY_LOCATION_PRINT
733 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
737 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
741 YYFPRINTF (stderr, "%s ", Title); \
742 yy_symbol_print (stderr, \
744 YYFPRINTF (stderr, "\n"); \
749 /*----------------------------------------.
750 | Print this symbol's value on YYOUTPUT. |
751 `----------------------------------------*/
754 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
756 FILE *yyo = yyoutput;
761 if (yytype < YYNTOKENS)
762 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
768 /*--------------------------------.
769 | Print this symbol on YYOUTPUT. |
770 `--------------------------------*/
773 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
775 YYFPRINTF (yyoutput, "%s %s (",
776 yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
778 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
779 YYFPRINTF (yyoutput, ")");
782 /*------------------------------------------------------------------.
783 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
785 `------------------------------------------------------------------*/
788 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
790 YYFPRINTF (stderr, "Stack now");
791 for (; yybottom <= yytop; yybottom++)
793 int yybot = *yybottom;
794 YYFPRINTF (stderr, " %d", yybot);
796 YYFPRINTF (stderr, "\n");
799 # define YY_STACK_PRINT(Bottom, Top) \
802 yy_stack_print ((Bottom), (Top)); \
806 /*------------------------------------------------.
807 | Report that the YYRULE is going to be reduced. |
808 `------------------------------------------------*/
811 yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule)
813 unsigned long int yylno = yyrline[yyrule];
814 int yynrhs = yyr2[yyrule];
816 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
818 /* The symbols being reduced. */
819 for (yyi = 0; yyi < yynrhs; yyi++)
821 YYFPRINTF (stderr, " $%d = ", yyi + 1);
822 yy_symbol_print (stderr,
823 yystos[yyssp[yyi + 1 - yynrhs]],
824 &(yyvsp[(yyi + 1) - (yynrhs)])
826 YYFPRINTF (stderr, "\n");
830 # define YY_REDUCE_PRINT(Rule) \
833 yy_reduce_print (yyssp, yyvsp, Rule); \
836 /* Nonzero means print parse trace. It is left uninitialized so that
837 multiple parsers can coexist. */
840 # define YYDPRINTF(Args)
841 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
842 # define YY_STACK_PRINT(Bottom, Top)
843 # define YY_REDUCE_PRINT(Rule)
844 #endif /* !YYDEBUG */
847 /* YYINITDEPTH -- initial size of the parser's stacks. */
849 # define YYINITDEPTH 200
852 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
853 if the built-in stack extension method is used).
855 Do not make this value too large; the results are undefined if
856 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
857 evaluated with infinite-precision integer arithmetic. */
860 # define YYMAXDEPTH 10000
867 # if defined __GLIBC__ && defined _STRING_H
868 # define yystrlen strlen
870 /* Return the length of YYSTR. */
872 yystrlen (const char *yystr)
875 for (yylen = 0; yystr[yylen]; yylen++)
883 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
884 # define yystpcpy stpcpy
886 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
889 yystpcpy (char *yydest, const char *yysrc)
892 const char *yys = yysrc;
894 while ((*yyd++ = *yys++) != '\0')
903 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
904 quotes and backslashes, so that it's suitable for yyerror. The
905 heuristic is that double-quoting is unnecessary unless the string
906 contains an apostrophe, a comma, or backslash (other than
907 backslash-backslash). YYSTR is taken from yytname. If YYRES is
908 null, do not copy; instead, return the length of what the result
911 yytnamerr (char *yyres, const char *yystr)
916 char const *yyp = yystr;
923 goto do_not_strip_quotes;
927 goto do_not_strip_quotes;
940 do_not_strip_quotes: ;
944 return yystrlen (yystr);
946 return yystpcpy (yyres, yystr) - yyres;
950 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
951 about the unexpected token YYTOKEN for the state stack whose top is
954 Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
955 not large enough to hold the message. In that case, also set
956 *YYMSG_ALLOC to the required number of bytes. Return 2 if the
957 required number of bytes is too large to store. */
959 yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
960 yytype_int16 *yyssp, int yytoken)
962 YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
963 YYSIZE_T yysize = yysize0;
964 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
965 /* Internationalized format string. */
966 const char *yyformat = YY_NULLPTR;
967 /* Arguments of yyformat. */
968 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
969 /* Number of reported tokens (one for the "unexpected", one per
973 /* There are many possibilities here to consider:
974 - If this state is a consistent state with a default action, then
975 the only way this function was invoked is if the default action
976 is an error action. In that case, don't check for expected
977 tokens because there are none.
978 - The only way there can be no lookahead present (in yychar) is if
979 this state is a consistent state with a default action. Thus,
980 detecting the absence of a lookahead is sufficient to determine
981 that there is no unexpected or expected token to report. In that
982 case, just report a simple "syntax error".
983 - Don't assume there isn't a lookahead just because this state is a
984 consistent state with a default action. There might have been a
985 previous inconsistent state, consistent state with a non-default
986 action, or user semantic action that manipulated yychar.
987 - Of course, the expected token list depends on states to have
988 correct lookahead information, and it depends on the parser not
989 to perform extra reductions after fetching a lookahead from the
990 scanner and before detecting a syntax error. Thus, state merging
991 (from LALR or IELR) and default reductions corrupt the expected
992 token list. However, the list is correct for canonical LR with
993 one exception: it will still contain any token that will not be
994 accepted due to an error action in a later state.
996 if (yytoken != YYEMPTY)
998 int yyn = yypact[*yyssp];
999 yyarg[yycount++] = yytname[yytoken];
1000 if (!yypact_value_is_default (yyn))
1002 /* Start YYX at -YYN if negative to avoid negative indexes in
1003 YYCHECK. In other words, skip the first -YYN actions for
1004 this state because they are default actions. */
1005 int yyxbegin = yyn < 0 ? -yyn : 0;
1006 /* Stay within bounds of both yycheck and yytname. */
1007 int yychecklim = YYLAST - yyn + 1;
1008 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1011 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1012 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
1013 && !yytable_value_is_error (yytable[yyx + yyn]))
1015 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1021 yyarg[yycount++] = yytname[yyx];
1023 YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
1024 if (! (yysize <= yysize1
1025 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1035 # define YYCASE_(N, S) \
1039 YYCASE_(0, YY_("syntax error"));
1040 YYCASE_(1, YY_("syntax error, unexpected %s"));
1041 YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1042 YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1043 YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1044 YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1049 YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
1050 if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1055 if (*yymsg_alloc < yysize)
1057 *yymsg_alloc = 2 * yysize;
1058 if (! (yysize <= *yymsg_alloc
1059 && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1060 *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1064 /* Avoid sprintf, as that infringes on the user's name space.
1065 Don't have undefined behavior even if the translation
1066 produced a string with the wrong number of "%s"s. */
1070 while ((*yyp = *yyformat) != '\0')
1071 if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1073 yyp += yytnamerr (yyp, yyarg[yyi++]);
1084 #endif /* YYERROR_VERBOSE */
1086 /*-----------------------------------------------.
1087 | Release the memory associated to this symbol. |
1088 `-----------------------------------------------*/
1091 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1096 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1098 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1100 YY_IGNORE_MAYBE_UNINITIALIZED_END
1106 /* The lookahead symbol. */
1109 /* The semantic value of the lookahead symbol. */
1111 /* Number of syntax errors so far. */
1123 /* Number of tokens to shift before error messages enabled. */
1126 /* The stacks and their tools:
1127 'yyss': related to states.
1128 'yyvs': related to semantic values.
1130 Refer to the stacks through separate pointers, to allow yyoverflow
1131 to reallocate them elsewhere. */
1133 /* The state stack. */
1134 yytype_int16 yyssa[YYINITDEPTH];
1136 yytype_int16 *yyssp;
1138 /* The semantic value stack. */
1139 YYSTYPE yyvsa[YYINITDEPTH];
1143 YYSIZE_T yystacksize;
1147 /* Lookahead token as an internal (translated) token number. */
1149 /* The variables used to return semantic value and location from the
1154 /* Buffer for error messages, and its allocated size. */
1156 char *yymsg = yymsgbuf;
1157 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1160 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1162 /* The number of symbols on the RHS of the reduced rule.
1163 Keep to zero when no symbol should be popped. */
1166 yyssp = yyss = yyssa;
1167 yyvsp = yyvs = yyvsa;
1168 yystacksize = YYINITDEPTH;
1170 YYDPRINTF ((stderr, "Starting parse\n"));
1175 yychar = YYEMPTY; /* Cause a token to be read. */
1178 /*------------------------------------------------------------.
1179 | yynewstate -- Push a new state, which is found in yystate. |
1180 `------------------------------------------------------------*/
1182 /* In all cases, when you get here, the value and location stacks
1183 have just been pushed. So pushing a state here evens the stacks. */
1189 if (yyss + yystacksize - 1 <= yyssp)
1191 /* Get the current used size of the three stacks, in elements. */
1192 YYSIZE_T yysize = yyssp - yyss + 1;
1196 /* Give user a chance to reallocate the stack. Use copies of
1197 these so that the &'s don't force the real ones into
1199 YYSTYPE *yyvs1 = yyvs;
1200 yytype_int16 *yyss1 = yyss;
1202 /* Each stack pointer address is followed by the size of the
1203 data in use in that stack, in bytes. This used to be a
1204 conditional around just the two extra args, but that might
1205 be undefined if yyoverflow is a macro. */
1206 yyoverflow (YY_("memory exhausted"),
1207 &yyss1, yysize * sizeof (*yyssp),
1208 &yyvs1, yysize * sizeof (*yyvsp),
1214 #else /* no yyoverflow */
1215 # ifndef YYSTACK_RELOCATE
1216 goto yyexhaustedlab;
1218 /* Extend the stack our own way. */
1219 if (YYMAXDEPTH <= yystacksize)
1220 goto yyexhaustedlab;
1222 if (YYMAXDEPTH < yystacksize)
1223 yystacksize = YYMAXDEPTH;
1226 yytype_int16 *yyss1 = yyss;
1227 union yyalloc *yyptr =
1228 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1230 goto yyexhaustedlab;
1231 YYSTACK_RELOCATE (yyss_alloc, yyss);
1232 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1233 # undef YYSTACK_RELOCATE
1235 YYSTACK_FREE (yyss1);
1238 #endif /* no yyoverflow */
1240 yyssp = yyss + yysize - 1;
1241 yyvsp = yyvs + yysize - 1;
1243 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1244 (unsigned long int) yystacksize));
1246 if (yyss + yystacksize - 1 <= yyssp)
1250 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1252 if (yystate == YYFINAL)
1262 /* Do appropriate processing given the current state. Read a
1263 lookahead token if we need one and don't already have one. */
1265 /* First try to decide what to do without reference to lookahead token. */
1266 yyn = yypact[yystate];
1267 if (yypact_value_is_default (yyn))
1270 /* Not known => get a lookahead token if don't already have one. */
1272 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1273 if (yychar == YYEMPTY)
1275 YYDPRINTF ((stderr, "Reading a token: "));
1279 if (yychar <= YYEOF)
1281 yychar = yytoken = YYEOF;
1282 YYDPRINTF ((stderr, "Now at end of input.\n"));
1286 yytoken = YYTRANSLATE (yychar);
1287 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1290 /* If the proper action on seeing token YYTOKEN is to reduce or to
1291 detect an error, take that action. */
1293 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1298 if (yytable_value_is_error (yyn))
1304 /* Count tokens shifted since error; after three, turn off error
1309 /* Shift the lookahead token. */
1310 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1312 /* Discard the shifted token. */
1316 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1318 YY_IGNORE_MAYBE_UNINITIALIZED_END
1323 /*-----------------------------------------------------------.
1324 | yydefault -- do the default action for the current state. |
1325 `-----------------------------------------------------------*/
1327 yyn = yydefact[yystate];
1333 /*-----------------------------.
1334 | yyreduce -- Do a reduction. |
1335 `-----------------------------*/
1337 /* yyn is the number of a rule to reduce with. */
1340 /* If YYLEN is nonzero, implement the default value of the action:
1343 Otherwise, the following line sets YYVAL to garbage.
1344 This behavior is undocumented and Bison
1345 users should not rely upon it. Assigning to YYVAL
1346 unconditionally makes the parser a bit smaller, and it avoids a
1347 GCC warning that YYVAL may be used uninitialized. */
1348 yyval = yyvsp[1-yylen];
1351 YY_REDUCE_PRINT (yyn);
1355 #line 132 "parsedate.y" /* yacc.c:1646 */
1359 /* I am compulsive about lint natterings... */
1360 if (yyHaveTime == -1) {
1365 #line 1366 "y.tab.c" /* yacc.c:1646 */
1369 #line 141 "parsedate.y" /* yacc.c:1646 */
1372 yyTimezone = (yyvsp[0].Number);
1374 #line 1375 "y.tab.c" /* yacc.c:1646 */
1378 #line 145 "parsedate.y" /* yacc.c:1646 */
1382 #line 1383 "y.tab.c" /* yacc.c:1646 */
1386 #line 148 "parsedate.y" /* yacc.c:1646 */
1390 #line 1391 "y.tab.c" /* yacc.c:1646 */
1394 #line 153 "parsedate.y" /* yacc.c:1646 */
1396 if ((yyvsp[-1].Number) < 100) {
1397 yyHour = (yyvsp[-1].Number);
1401 yyHour = (yyvsp[-1].Number) / 100;
1402 yyMinutes = (yyvsp[-1].Number) % 100;
1405 yyMeridian = (yyvsp[0].Meridian);
1407 #line 1408 "y.tab.c" /* yacc.c:1646 */
1411 #line 165 "parsedate.y" /* yacc.c:1646 */
1413 yyHour = (yyvsp[-3].Number);
1414 yyMinutes = (yyvsp[-1].Number);
1416 yyMeridian = (yyvsp[0].Meridian);
1418 #line 1419 "y.tab.c" /* yacc.c:1646 */
1422 #line 171 "parsedate.y" /* yacc.c:1646 */
1424 yyHour = (yyvsp[-3].Number);
1425 yyMinutes = (yyvsp[-1].Number);
1426 yyTimezone = (yyvsp[0].Number);
1430 #line 1431 "y.tab.c" /* yacc.c:1646 */
1434 #line 178 "parsedate.y" /* yacc.c:1646 */
1436 yyHour = (yyvsp[-5].Number);
1437 yyMinutes = (yyvsp[-3].Number);
1438 yySeconds = (yyvsp[-1].Number);
1439 yyMeridian = (yyvsp[0].Meridian);
1441 #line 1442 "y.tab.c" /* yacc.c:1646 */
1445 #line 184 "parsedate.y" /* yacc.c:1646 */
1447 yyHour = (yyvsp[-5].Number);
1448 yyMinutes = (yyvsp[-3].Number);
1449 yySeconds = (yyvsp[-1].Number);
1450 yyTimezone = (yyvsp[0].Number);
1454 #line 1455 "y.tab.c" /* yacc.c:1646 */
1458 #line 194 "parsedate.y" /* yacc.c:1646 */
1460 (yyval.Number) = (yyvsp[0].Number);
1463 #line 1464 "y.tab.c" /* yacc.c:1646 */
1467 #line 198 "parsedate.y" /* yacc.c:1646 */
1469 (yyval.Number) = (yyvsp[0].Number);
1472 #line 1473 "y.tab.c" /* yacc.c:1646 */
1476 #line 202 "parsedate.y" /* yacc.c:1646 */
1478 /* Only allow "GMT+300" and "GMT-0800" */
1479 if ((yyvsp[-1].Number) != 0) {
1482 (yyval.Number) = (yyvsp[0].Number);
1485 #line 1486 "y.tab.c" /* yacc.c:1646 */
1489 #line 210 "parsedate.y" /* yacc.c:1646 */
1491 (yyval.Number) = (yyvsp[0].Number);
1494 #line 1495 "y.tab.c" /* yacc.c:1646 */
1498 #line 216 "parsedate.y" /* yacc.c:1646 */
1502 /* Unix and GMT and numeric timezones -- a little confusing. */
1503 if ((yyvsp[0].Number) < 0) {
1504 /* Don't work with negative modulus. */
1505 (yyvsp[0].Number) = -(yyvsp[0].Number);
1506 if ((yyvsp[0].Number) > 9999 || (i = (yyvsp[0].Number) % 100) >= 60) {
1509 (yyval.Number) = ((yyvsp[0].Number) / 100) * 60 + i;
1512 if ((yyvsp[0].Number) > 9999 || (i = (yyvsp[0].Number) % 100) >= 60) {
1515 (yyval.Number) = -(((yyvsp[0].Number) / 100) * 60 + i);
1518 #line 1519 "y.tab.c" /* yacc.c:1646 */
1522 #line 237 "parsedate.y" /* yacc.c:1646 */
1524 yyMonth = (yyvsp[-2].Number);
1525 yyDay = (yyvsp[0].Number);
1527 #line 1528 "y.tab.c" /* yacc.c:1646 */
1531 #line 241 "parsedate.y" /* yacc.c:1646 */
1533 if ((yyvsp[-4].Number) > 100) {
1534 yyYear = (yyvsp[-4].Number);
1535 yyMonth = (yyvsp[-2].Number);
1536 yyDay = (yyvsp[0].Number);
1539 yyMonth = (yyvsp[-4].Number);
1540 yyDay = (yyvsp[-2].Number);
1541 yyYear = (yyvsp[0].Number);
1544 #line 1545 "y.tab.c" /* yacc.c:1646 */
1548 #line 253 "parsedate.y" /* yacc.c:1646 */
1550 yyMonth = (yyvsp[-1].Number);
1551 yyDay = (yyvsp[0].Number);
1553 #line 1554 "y.tab.c" /* yacc.c:1646 */
1557 #line 257 "parsedate.y" /* yacc.c:1646 */
1559 yyMonth = (yyvsp[-3].Number);
1560 yyDay = (yyvsp[-2].Number);
1561 yyYear = (yyvsp[0].Number);
1563 #line 1564 "y.tab.c" /* yacc.c:1646 */
1567 #line 262 "parsedate.y" /* yacc.c:1646 */
1569 yyDay = (yyvsp[-1].Number);
1570 yyMonth = (yyvsp[0].Number);
1572 #line 1573 "y.tab.c" /* yacc.c:1646 */
1576 #line 266 "parsedate.y" /* yacc.c:1646 */
1578 yyDay = (yyvsp[-2].Number);
1579 yyMonth = (yyvsp[-1].Number);
1580 yyYear = (yyvsp[0].Number);
1582 #line 1583 "y.tab.c" /* yacc.c:1646 */
1586 #line 271 "parsedate.y" /* yacc.c:1646 */
1588 yyDay = (yyvsp[-2].Number);
1589 yyMonth = (yyvsp[-1].Number);
1590 yyYear = (yyvsp[0].Number);
1592 #line 1593 "y.tab.c" /* yacc.c:1646 */
1596 #line 278 "parsedate.y" /* yacc.c:1646 */
1598 yyRelSeconds += (yyvsp[-1].Number) * (yyvsp[0].Number);
1600 #line 1601 "y.tab.c" /* yacc.c:1646 */
1604 #line 281 "parsedate.y" /* yacc.c:1646 */
1606 yyRelSeconds += (yyvsp[-1].Number) * (yyvsp[0].Number);
1608 #line 1609 "y.tab.c" /* yacc.c:1646 */
1612 #line 284 "parsedate.y" /* yacc.c:1646 */
1614 yyRelMonth += (yyvsp[-1].Number) * (yyvsp[0].Number);
1616 #line 1617 "y.tab.c" /* yacc.c:1646 */
1620 #line 287 "parsedate.y" /* yacc.c:1646 */
1622 yyRelMonth += (yyvsp[-1].Number) * (yyvsp[0].Number);
1624 #line 1625 "y.tab.c" /* yacc.c:1646 */
1628 #line 292 "parsedate.y" /* yacc.c:1646 */
1630 (yyval.Meridian) = MER24;
1632 #line 1633 "y.tab.c" /* yacc.c:1646 */
1636 #line 295 "parsedate.y" /* yacc.c:1646 */
1638 (yyval.Meridian) = (yyvsp[0].Meridian);
1640 #line 1641 "y.tab.c" /* yacc.c:1646 */
1644 #line 1645 "y.tab.c" /* yacc.c:1646 */
1647 /* User semantic actions sometimes alter yychar, and that requires
1648 that yytoken be updated with the new translation. We take the
1649 approach of translating immediately before every use of yytoken.
1650 One alternative is translating here after every semantic action,
1651 but that translation would be missed if the semantic action invokes
1652 YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1653 if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
1654 incorrect destructor might then be invoked immediately. In the
1655 case of YYERROR or YYBACKUP, subsequent parser actions might lead
1656 to an incorrect destructor call or verbose syntax error message
1657 before the lookahead is translated. */
1658 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1662 YY_STACK_PRINT (yyss, yyssp);
1666 /* Now 'shift' the result of the reduction. Determine what state
1667 that goes to, based on the state we popped back to and the rule
1668 number reduced by. */
1672 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1673 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1674 yystate = yytable[yystate];
1676 yystate = yydefgoto[yyn - YYNTOKENS];
1681 /*--------------------------------------.
1682 | yyerrlab -- here on detecting error. |
1683 `--------------------------------------*/
1685 /* Make sure we have latest lookahead translation. See comments at
1686 user semantic actions for why this is necessary. */
1687 yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
1689 /* If not already recovering from an error, report this error. */
1693 #if ! YYERROR_VERBOSE
1694 yyerror (YY_("syntax error"));
1696 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
1699 char const *yymsgp = YY_("syntax error");
1700 int yysyntax_error_status;
1701 yysyntax_error_status = YYSYNTAX_ERROR;
1702 if (yysyntax_error_status == 0)
1704 else if (yysyntax_error_status == 1)
1706 if (yymsg != yymsgbuf)
1707 YYSTACK_FREE (yymsg);
1708 yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
1712 yymsg_alloc = sizeof yymsgbuf;
1713 yysyntax_error_status = 2;
1717 yysyntax_error_status = YYSYNTAX_ERROR;
1722 if (yysyntax_error_status == 2)
1723 goto yyexhaustedlab;
1725 # undef YYSYNTAX_ERROR
1731 if (yyerrstatus == 3)
1733 /* If just tried and failed to reuse lookahead token after an
1734 error, discard it. */
1736 if (yychar <= YYEOF)
1738 /* Return failure if at end of input. */
1739 if (yychar == YYEOF)
1744 yydestruct ("Error: discarding",
1750 /* Else will try to reuse lookahead token after shifting the error
1755 /*---------------------------------------------------.
1756 | yyerrorlab -- error raised explicitly by YYERROR. |
1757 `---------------------------------------------------*/
1760 /* Pacify compilers like GCC when the user code never invokes
1761 YYERROR and the label yyerrorlab therefore never appears in user
1763 if (/*CONSTCOND*/ 0)
1766 /* Do not reclaim the symbols of the rule whose action triggered
1770 YY_STACK_PRINT (yyss, yyssp);
1775 /*-------------------------------------------------------------.
1776 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1777 `-------------------------------------------------------------*/
1779 yyerrstatus = 3; /* Each real token shifted decrements this. */
1783 yyn = yypact[yystate];
1784 if (!yypact_value_is_default (yyn))
1787 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1795 /* Pop the current state because it cannot handle the error token. */
1800 yydestruct ("Error: popping",
1801 yystos[yystate], yyvsp);
1804 YY_STACK_PRINT (yyss, yyssp);
1807 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1809 YY_IGNORE_MAYBE_UNINITIALIZED_END
1812 /* Shift the error token. */
1813 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1819 /*-------------------------------------.
1820 | yyacceptlab -- YYACCEPT comes here. |
1821 `-------------------------------------*/
1826 /*-----------------------------------.
1827 | yyabortlab -- YYABORT comes here. |
1828 `-----------------------------------*/
1833 #if !defined yyoverflow || YYERROR_VERBOSE
1834 /*-------------------------------------------------.
1835 | yyexhaustedlab -- memory exhaustion comes here. |
1836 `-------------------------------------------------*/
1838 yyerror (YY_("memory exhausted"));
1844 if (yychar != YYEMPTY)
1846 /* Make sure we have latest lookahead translation. See comments at
1847 user semantic actions for why this is necessary. */
1848 yytoken = YYTRANSLATE (yychar);
1849 yydestruct ("Cleanup: discarding lookahead",
1852 /* Do not reclaim the symbols of the rule whose action triggered
1853 this YYABORT or YYACCEPT. */
1855 YY_STACK_PRINT (yyss, yyssp);
1856 while (yyssp != yyss)
1858 yydestruct ("Cleanup: popping",
1859 yystos[*yyssp], yyvsp);
1864 YYSTACK_FREE (yyss);
1867 if (yymsg != yymsgbuf)
1868 YYSTACK_FREE (yymsg);
1872 #line 300 "parsedate.y" /* yacc.c:1906 */
1875 /* Month and day table. */
1876 static TABLE MonthDayTable[] = {
1877 { "january", tMONTH, 1 },
1878 { "february", tMONTH, 2 },
1879 { "march", tMONTH, 3 },
1880 { "april", tMONTH, 4 },
1881 { "may", tMONTH, 5 },
1882 { "june", tMONTH, 6 },
1883 { "july", tMONTH, 7 },
1884 { "august", tMONTH, 8 },
1885 { "september", tMONTH, 9 },
1886 { "october", tMONTH, 10 },
1887 { "november", tMONTH, 11 },
1888 { "december", tMONTH, 12 },
1889 /* The value of the day isn't used... */
1890 { "sunday", tDAY, 0 },
1891 { "monday", tDAY, 0 },
1892 { "tuesday", tDAY, 0 },
1893 { "wednesday", tDAY, 0 },
1894 { "thursday", tDAY, 0 },
1895 { "friday", tDAY, 0 },
1896 { "saturday", tDAY, 0 },
1899 /* Time units table. */
1900 static TABLE UnitsTable[] = {
1901 { "year", tMONTH_UNIT, 12 },
1902 { "month", tMONTH_UNIT, 1 },
1903 { "week", tSEC_UNIT, 7L * 24 * 60 * 60 },
1904 { "day", tSEC_UNIT, 1L * 24 * 60 * 60 },
1905 { "hour", tSEC_UNIT, 60 * 60 },
1906 { "minute", tSEC_UNIT, 60 },
1907 { "min", tSEC_UNIT, 60 },
1908 { "second", tSEC_UNIT, 1 },
1909 { "sec", tSEC_UNIT, 1 },
1912 /* Timezone table. */
1913 static TABLE TimezoneTable[] = {
1914 { "gmt", tZONE, HOUR( 0) }, /* Greenwich Mean */
1915 { "ut", tZONE, HOUR( 0) }, /* Universal */
1916 { "utc", tZONE, HOUR( 0) }, /* Universal Coordinated */
1917 { "cut", tZONE, HOUR( 0) }, /* Coordinated Universal */
1918 { "z", tZONE, HOUR( 0) }, /* Greenwich Mean */
1919 { "wet", tZONE, HOUR( 0) }, /* Western European */
1920 { "bst", tDAYZONE, HOUR( 0) }, /* British Summer */
1921 { "nst", tZONE, HOUR(3)+30 }, /* Newfoundland Standard */
1922 { "ndt", tDAYZONE, HOUR(3)+30 }, /* Newfoundland Daylight */
1923 { "ast", tZONE, HOUR( 4) }, /* Atlantic Standard */
1924 { "adt", tDAYZONE, HOUR( 4) }, /* Atlantic Daylight */
1925 { "est", tZONE, HOUR( 5) }, /* Eastern Standard */
1926 { "edt", tDAYZONE, HOUR( 5) }, /* Eastern Daylight */
1927 { "cst", tZONE, HOUR( 6) }, /* Central Standard */
1928 { "cdt", tDAYZONE, HOUR( 6) }, /* Central Daylight */
1929 { "mst", tZONE, HOUR( 7) }, /* Mountain Standard */
1930 { "mdt", tDAYZONE, HOUR( 7) }, /* Mountain Daylight */
1931 { "pst", tZONE, HOUR( 8) }, /* Pacific Standard */
1932 { "pdt", tDAYZONE, HOUR( 8) }, /* Pacific Daylight */
1933 { "yst", tZONE, HOUR( 9) }, /* Yukon Standard */
1934 { "ydt", tDAYZONE, HOUR( 9) }, /* Yukon Daylight */
1935 { "akst", tZONE, HOUR( 9) }, /* Alaska Standard */
1936 { "akdt", tDAYZONE, HOUR( 9) }, /* Alaska Daylight */
1937 { "hst", tZONE, HOUR(10) }, /* Hawaii Standard */
1938 { "hast", tZONE, HOUR(10) }, /* Hawaii-Aleutian Standard */
1939 { "hadt", tDAYZONE, HOUR(10) }, /* Hawaii-Aleutian Daylight */
1940 { "ces", tDAYZONE, -HOUR(1) }, /* Central European Summer */
1941 { "cest", tDAYZONE, -HOUR(1) }, /* Central European Summer */
1942 { "mez", tZONE, -HOUR(1) }, /* Middle European */
1943 { "mezt", tDAYZONE, -HOUR(1) }, /* Middle European Summer */
1944 { "cet", tZONE, -HOUR(1) }, /* Central European */
1945 { "met", tZONE, -HOUR(1) }, /* Middle European */
1946 { "eet", tZONE, -HOUR(2) }, /* Eastern Europe */
1947 { "msk", tZONE, -HOUR(3) }, /* Moscow Winter */
1948 { "msd", tDAYZONE, -HOUR(3) }, /* Moscow Summer */
1949 { "wast", tZONE, -HOUR(8) }, /* West Australian Standard */
1950 { "wadt", tDAYZONE, -HOUR(8) }, /* West Australian Daylight */
1951 { "hkt", tZONE, -HOUR(8) }, /* Hong Kong */
1952 { "cct", tZONE, -HOUR(8) }, /* China Coast */
1953 { "jst", tZONE, -HOUR(9) }, /* Japan Standard */
1954 { "kst", tZONE, -HOUR(9) }, /* Korean Standard */
1955 { "kdt", tZONE, -HOUR(9) }, /* Korean Daylight */
1956 { "cast", tZONE, -(HOUR(9)+30) }, /* Central Australian Standard */
1957 { "cadt", tDAYZONE, -(HOUR(9)+30) }, /* Central Australian Daylight */
1958 { "east", tZONE, -HOUR(10) }, /* Eastern Australian Standard */
1959 { "eadt", tDAYZONE, -HOUR(10) }, /* Eastern Australian Daylight */
1960 { "nzst", tZONE, -HOUR(12) }, /* New Zealand Standard */
1961 { "nzdt", tDAYZONE, -HOUR(12) }, /* New Zealand Daylight */
1963 /* For completeness we include the following entries. */
1966 /* Duplicate names. Either they conflict with a zone listed above
1967 * (which is either more likely to be seen or just been in circulation
1968 * longer), or they conflict with another zone in this section and
1969 * we could not reasonably choose one over the other. */
1970 { "fst", tZONE, HOUR( 2) }, /* Fernando De Noronha Standard */
1971 { "fdt", tDAYZONE, HOUR( 2) }, /* Fernando De Noronha Daylight */
1972 { "bst", tZONE, HOUR( 3) }, /* Brazil Standard */
1973 { "est", tZONE, HOUR( 3) }, /* Eastern Standard (Brazil) */
1974 { "edt", tDAYZONE, HOUR( 3) }, /* Eastern Daylight (Brazil) */
1975 { "wst", tZONE, HOUR( 4) }, /* Western Standard (Brazil) */
1976 { "wdt", tDAYZONE, HOUR( 4) }, /* Western Daylight (Brazil) */
1977 { "cst", tZONE, HOUR( 5) }, /* Chile Standard */
1978 { "cdt", tDAYZONE, HOUR( 5) }, /* Chile Daylight */
1979 { "ast", tZONE, HOUR( 5) }, /* Acre Standard */
1980 { "adt", tDAYZONE, HOUR( 5) }, /* Acre Daylight */
1981 { "cst", tZONE, HOUR( 5) }, /* Cuba Standard */
1982 { "cdt", tDAYZONE, HOUR( 5) }, /* Cuba Daylight */
1983 { "est", tZONE, HOUR( 6) }, /* Easter Island Standard */
1984 { "edt", tDAYZONE, HOUR( 6) }, /* Easter Island Daylight */
1985 { "sst", tZONE, HOUR(11) }, /* Samoa Standard */
1986 { "ist", tZONE, -HOUR(2) }, /* Israel Standard */
1987 { "idt", tDAYZONE, -HOUR(2) }, /* Israel Daylight */
1988 { "idt", tDAYZONE, -(HOUR(3)+30) }, /* Iran Daylight */
1989 { "ist", tZONE, -(HOUR(3)+30) }, /* Iran Standard */
1990 { "cst", tZONE, -HOUR(8) }, /* China Standard */
1991 { "cdt", tDAYZONE, -HOUR(8) }, /* China Daylight */
1992 { "sst", tZONE, -HOUR(8) }, /* Singapore Standard */
1994 /* Dubious (e.g., not in Olson's TIMEZONE package) or obsolete. */
1995 { "gst", tZONE, HOUR( 3) }, /* Greenland Standard */
1996 { "wat", tZONE, -HOUR(1) }, /* West Africa */
1997 { "at", tZONE, HOUR( 2) }, /* Azores */
1998 { "gst", tZONE, -HOUR(10) }, /* Guam Standard */
1999 { "nft", tZONE, HOUR(3)+30 }, /* Newfoundland */
2000 { "idlw", tZONE, HOUR(12) }, /* International Date Line West */
2001 { "mewt", tZONE, -HOUR(1) }, /* Middle European Winter */
2002 { "mest", tDAYZONE, -HOUR(1) }, /* Middle European Summer */
2003 { "swt", tZONE, -HOUR(1) }, /* Swedish Winter */
2004 { "sst", tDAYZONE, -HOUR(1) }, /* Swedish Summer */
2005 { "fwt", tZONE, -HOUR(1) }, /* French Winter */
2006 { "fst", tDAYZONE, -HOUR(1) }, /* French Summer */
2007 { "bt", tZONE, -HOUR(3) }, /* Baghdad */
2008 { "it", tZONE, -(HOUR(3)+30) }, /* Iran */
2009 { "zp4", tZONE, -HOUR(4) }, /* USSR Zone 3 */
2010 { "zp5", tZONE, -HOUR(5) }, /* USSR Zone 4 */
2011 { "ist", tZONE, -(HOUR(5)+30) }, /* Indian Standard */
2012 { "zp6", tZONE, -HOUR(6) }, /* USSR Zone 5 */
2013 { "nst", tZONE, -HOUR(7) }, /* North Sumatra */
2014 { "sst", tZONE, -HOUR(7) }, /* South Sumatra */
2015 { "jt", tZONE, -(HOUR(7)+30) }, /* Java (3pm in Cronusland!) */
2016 { "nzt", tZONE, -HOUR(12) }, /* New Zealand */
2017 { "idle", tZONE, -HOUR(12) }, /* International Date Line East */
2018 { "cat", tZONE, HOUR(10) }, /* -- expired 1967 */
2019 { "nt", tZONE, HOUR(11) }, /* -- expired 1967 */
2020 { "ahst", tZONE, HOUR(10) }, /* -- expired 1983 */
2021 { "hdt", tDAYZONE, HOUR(10) }, /* -- expired 1986 */
2035 ToSeconds(time_t Hours, time_t Minutes, time_t Seconds, MERIDIAN Meridian)
2037 if (Minutes < 0 || Minutes > 59 || Seconds < 0 || Seconds > 61)
2039 if (Meridian == MER24) {
2040 if (Hours < 0 || Hours > 23)
2044 if (Hours < 1 || Hours > 12)
2048 if (Meridian == MERpm)
2051 return (Hours * 60L + Minutes) * 60L + Seconds;
2056 Convert(time_t Month, time_t Day, time_t Year,
2057 time_t Hours, time_t Minutes, time_t Seconds,
2058 MERIDIAN Meridian, DSTMODE dst)
2060 static int DaysNormal[13] = {
2061 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
2063 static int DaysLeap[13] = {
2064 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
2066 static int LeapYears[] = {
2067 1972, 1976, 1980, 1984, 1988, 1992, 1996,
2068 2000, 2004, 2008, 2012, 2016, 2020, 2024, 2028, 2032, 2036
2072 register time_t Julian;
2082 for (mp = DaysNormal, yp = LeapYears; yp < ENDOF(LeapYears); yp++)
2087 if (Year < EPOCH || Year > END_OF_TIME
2088 || Month < 1 || Month > 12
2089 /* NOSTRICT *//* conversion from long may lose accuracy */
2090 || Day < 1 || Day > mp[(int)Month])
2093 Julian = Day - 1 + (Year - EPOCH) * 365;
2094 for (yp = LeapYears; yp < ENDOF(LeapYears); yp++, Julian++)
2097 for (i = 1; i < Month; i++)
2099 Julian *= SECSPERDAY;
2100 Julian += yyTimezone * 60L;
2101 if ((tod = ToSeconds(Hours, Minutes, Seconds, Meridian)) < 0)
2105 if (dst == DSTon || (dst == DSTmaybe && localtime(&tod)->tm_isdst))
2106 Julian -= DST_OFFSET * 60L * 60L;
2112 DSTcorrect(time_t Start, time_t Future)
2117 StartDay = (localtime(&Start)->tm_hour + 1) % 24;
2118 FutureDay = (localtime(&Future)->tm_hour + 1) % 24;
2119 return (Future - Start) + (StartDay - FutureDay) * DST_OFFSET * 60L * 60L;
2124 RelativeMonth(time_t Start, time_t RelMonth)
2130 tm = localtime(&Start);
2131 Month = 12 * tm->tm_year + tm->tm_mon + RelMonth;
2133 Month = Month % 12 + 1;
2134 return DSTcorrect(Start,
2135 Convert(Month, (time_t)tm->tm_mday, Year,
2136 (time_t)tm->tm_hour, (time_t)tm->tm_min, (time_t)tm->tm_sec,
2142 LookupWord(char *buff, register int length)
2152 /* See if we have an abbreviation for a month. */
2153 if (length == 3 || (length == 4 && p[3] == '.'))
2154 for (tp = MonthDayTable; tp < ENDOF(MonthDayTable); tp++) {
2156 if (c == q[0] && p[1] == q[1] && p[2] == q[2]) {
2157 yylval.Number = tp->value;
2162 for (tp = MonthDayTable; tp < ENDOF(MonthDayTable); tp++)
2163 if (c == tp->name[0] && strcmp(p, tp->name) == 0) {
2164 yylval.Number = tp->value;
2168 /* Try for a timezone. */
2169 for (tp = TimezoneTable; tp < ENDOF(TimezoneTable); tp++)
2170 if (c == tp->name[0] && p[1] == tp->name[1]
2171 && strcmp(p, tp->name) == 0) {
2172 yylval.Number = tp->value;
2176 /* Try the units table. */
2177 for (tp = UnitsTable; tp < ENDOF(UnitsTable); tp++)
2178 if (c == tp->name[0] && strcmp(p, tp->name) == 0) {
2179 yylval.Number = tp->value;
2183 /* Strip off any plural and try the units table again. */
2184 if (--length > 0 && p[length] == 's') {
2186 for (tp = UnitsTable; tp < ENDOF(UnitsTable); tp++)
2187 if (c == tp->name[0] && strcmp(p, tp->name) == 0) {
2189 yylval.Number = tp->value;
2196 /* Drop out any periods. */
2197 for (p = buff, q = (char*)buff; *q; q++)
2202 /* Try the meridians. */
2203 if (buff[1] == 'm' && buff[2] == '\0') {
2204 if (buff[0] == 'a') {
2205 yylval.Meridian = MERam;
2208 if (buff[0] == 'p') {
2209 yylval.Meridian = MERpm;
2214 /* If we saw any periods, try the timezones again. */
2215 if (p - buff != length) {
2217 for (p = buff, tp = TimezoneTable; tp < ENDOF(TimezoneTable); tp++)
2218 if (c == tp->name[0] && p[1] == tp->name[1]
2219 && strcmp(p, tp->name) == 0) {
2220 yylval.Number = tp->value;
2225 /* Unknown word -- assume GMT timezone. */
2239 register int nesting;
2242 /* Get first character after the whitespace. */
2244 while (isspace(*yyInput))
2248 /* Ignore RFC 822 comments, typically time zone names. */
2251 for (nesting = 1; (c = *++yyInput) != RPAREN || --nesting; )
2254 else if (!IS7BIT(c) || c == '\0' || c == '\r'
2255 || (c == '\\' && ((c = *++yyInput) == '\0' || !IS7BIT(c))))
2256 /* Lexical error: bad comment. */
2262 if (isdigit(c) || c == '-' || c == '+') {
2263 if (c == '-' || c == '+') {
2264 sign = c == '-' ? -1 : 1;
2266 if (!isdigit(*yyInput))
2267 /* Skip the plus or minus sign. */
2272 for (i = 0; (c = *yyInput++) != '\0' && isdigit(c); )
2273 i = 10 * i + c - '0';
2275 yylval.Number = sign < 0 ? -i : i;
2276 return sign ? tSNUMBER : tUNUMBER;
2281 for (p = buff; (c = *yyInput++) == '.' || isalpha(c); )
2282 if (p < &buff[sizeof buff - 1])
2283 *p++ = isupper(c) ? tolower(c) : c;
2286 return LookupWord(buff, p - buff);
2295 parsedate(const char *p)
2297 extern int date_parse(void);
2300 yyInput = p; /* well, its supposed to be const... */
2306 yyDSTmode = DSTmaybe;
2317 if (date_parse() || yyHaveTime > 1 || yyHaveDate > 1)
2320 if (yyHaveDate || yyHaveTime) {
2321 Start = Convert(yyMonth, yyDay, yyYear, yyHour, yyMinutes, yySeconds,
2322 yyMeridian, yyDSTmode);
2329 Start += yyRelSeconds;
2331 Start += RelativeMonth(Start, yyRelMonth);
2333 /* Have to do *something* with a legitimate -1 so it's distinguishable
2334 * from the error return value. (Alternately could set errno on error.) */
2335 return Start == -1 ? 0 : Start;
2343 #endif /* YYDEBUG */
2347 main(int ac, char *av[])
2354 #endif /* YYDEBUG */
2356 (void)printf("Enter date, or blank line to exit.\n\t> ");
2358 (void)printf("\t> ");
2359 (void)fflush(stdout);
2360 if (fgets(buff, sizeof buff, stdin) == NULL || buff[0] == '\n')
2363 if (strcmp(buff, "yydebug") == 0) {
2365 printf("yydebug = %s\n", yydebug ? "on" : "off");
2368 #endif /* YYDEBUG */
2369 d = parsedate(buff, (TIMEINFO *)NULL);
2371 (void)printf("Bad format - couldn't convert.\n");
2373 (void)printf("%s", ctime(&d));