1 /* A Bison parser, made by GNU Bison 2.5. */
3 /* Bison implementation for Yacc-like parsers in C
5 Copyright (C) 1984, 1989-1990, 2000-2011 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 "2.5"
50 #define YYSKELETON_NAME "yacc.c"
61 /* Using locations. */
62 #define YYLSP_NEEDED 0
66 /* Copy the first part of user declarations. */
68 /* Line 268 of yacc.c */
73 ** Originally written by Steven M. Bellovin <smb@research.att.com> while
74 ** at the University of North Carolina at Chapel Hill. Later tweaked by
75 ** a couple of people on Usenet. Completely overhauled by Rich $alz
76 ** <rsalz@osf.org> and Jim Berets <jberets@bbn.com> in August, 1990.
77 ** Further revised (removed obsolete constructs and cleaned up timezone
78 ** names) in August, 1991, by Rich. Paul Eggert <eggert@twinsun.com>
79 ** helped in September, 1992. Art Cancro <ajc@citadel.org> cleaned
80 ** it up for ANSI C in December, 1999.
82 ** This grammar has six shift/reduce conflicts.
84 ** This code is in the public domain and has no copyright.
86 /* SUPPRESS 530 *//* Empty body for statement */
87 /* SUPPRESS 593 on yyerrlab *//* Label was not used */
88 /* SUPPRESS 593 on yynewstate *//* Label was not used */
89 /* SUPPRESS 595 on yypvt *//* Automatic variable may be used before set */
95 #include <sys/types.h>
98 #if TIME_WITH_SYS_TIME
99 # include <sys/time.h>
103 # include <sys/time.h>
110 # if !STDC_HEADERS && HAVE_MEMORY_H
116 # include <strings.h>
119 #include "parsedate.h"
123 #define yyparse date_parse
124 #define yylex date_lex
125 #define yyerror date_error
128 /* See the LeapYears table in Convert. */
130 #define END_OF_TIME 2038
131 /* Constants for general time calculations. */
133 #define SECSPERDAY (24L * 60L * 60L)
134 /* Readability for TABLE stuff. */
135 #define HOUR(x) (x * 60)
139 #define IS7BIT(x) ((unsigned int)(x) < 0200)
141 #define SIZEOF(array) ((int)(sizeof array / sizeof array[0]))
142 #define ENDOF(array) (&array[SIZEOF(array)])
146 ** An entry in the lexical lookup table.
148 typedef struct _TABLE {
155 ** Daylight-savings mode: on, off, or not yet known.
157 typedef enum _DSTMODE {
158 DSTon, DSToff, DSTmaybe
162 ** Meridian: am, pm, or 24-hour style.
164 typedef enum _MERIDIAN {
170 ** Global variables. We could get rid of most of them by using a yacc
171 ** union, but this is more efficient. (This routine predates the
172 ** yacc %union construct.)
174 static const char *yyInput;
175 static DSTMODE yyDSTmode;
176 static int yyHaveDate;
177 static int yyHaveRel;
178 static int yyHaveTime;
179 static time_t yyTimezone;
181 static time_t yyHour;
182 static time_t yyMinutes;
183 static time_t yyMonth;
184 static time_t yySeconds;
185 static time_t yyYear;
186 static MERIDIAN yyMeridian;
187 static time_t yyRelMonth;
188 static time_t yyRelSeconds;
191 static void date_error(char *);
194 /* Line 268 of yacc.c */
197 /* Enabling traces. */
202 /* Enabling verbose error messages. */
203 #ifdef YYERROR_VERBOSE
204 # undef YYERROR_VERBOSE
205 # define YYERROR_VERBOSE 1
207 # define YYERROR_VERBOSE 0
210 /* Enabling the token table. */
211 #ifndef YYTOKEN_TABLE
212 # define YYTOKEN_TABLE 0
219 /* Put the tokens into the symbol table, so that GDB and other debuggers
236 #define tMERIDIAN 260
238 #define tMONTH_UNIT 262
239 #define tSEC_UNIT 263
247 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
248 typedef union YYSTYPE
251 /* Line 293 of yacc.c */
252 #line 125 "parsedate.y"
255 enum _MERIDIAN Meridian;
259 /* Line 293 of yacc.c */
262 # define YYSTYPE_IS_TRIVIAL 1
263 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
264 # define YYSTYPE_IS_DECLARED 1
268 /* Copy the second part of user declarations. */
271 /* Line 343 of yacc.c */
279 typedef YYTYPE_UINT8 yytype_uint8;
281 typedef unsigned char yytype_uint8;
285 typedef YYTYPE_INT8 yytype_int8;
286 #elif (defined __STDC__ || defined __C99__FUNC__ \
287 || defined __cplusplus || defined _MSC_VER)
288 typedef signed char yytype_int8;
290 typedef short int yytype_int8;
294 typedef YYTYPE_UINT16 yytype_uint16;
296 typedef unsigned short int yytype_uint16;
300 typedef YYTYPE_INT16 yytype_int16;
302 typedef short int yytype_int16;
306 # ifdef __SIZE_TYPE__
307 # define YYSIZE_T __SIZE_TYPE__
308 # elif defined size_t
309 # define YYSIZE_T size_t
310 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
311 || defined __cplusplus || defined _MSC_VER)
312 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
313 # define YYSIZE_T size_t
315 # define YYSIZE_T unsigned int
319 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
322 # if defined YYENABLE_NLS && YYENABLE_NLS
324 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
325 # define YY_(msgid) dgettext ("bison-runtime", msgid)
329 # define YY_(msgid) msgid
333 /* Suppress unused-variable warnings by "using" E. */
334 #if ! defined lint || defined __GNUC__
335 # define YYUSE(e) ((void) (e))
337 # define YYUSE(e) /* empty */
340 /* Identity function, used to suppress warnings about constant conditions. */
344 #if (defined __STDC__ || defined __C99__FUNC__ \
345 || defined __cplusplus || defined _MSC_VER)
358 #if ! defined yyoverflow || YYERROR_VERBOSE
360 /* The parser invokes alloca or malloc; define the necessary symbols. */
362 # ifdef YYSTACK_USE_ALLOCA
363 # if YYSTACK_USE_ALLOCA
365 # define YYSTACK_ALLOC __builtin_alloca
366 # elif defined __BUILTIN_VA_ARG_INCR
367 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
369 # define YYSTACK_ALLOC __alloca
370 # elif defined _MSC_VER
371 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
372 # define alloca _alloca
374 # define YYSTACK_ALLOC alloca
375 # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
376 || defined __cplusplus || defined _MSC_VER)
377 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
378 # ifndef EXIT_SUCCESS
379 # define EXIT_SUCCESS 0
386 # ifdef YYSTACK_ALLOC
387 /* Pacify GCC's `empty if-body' warning. */
388 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
389 # ifndef YYSTACK_ALLOC_MAXIMUM
390 /* The OS might guarantee only one guard page at the bottom of the stack,
391 and a page size can be as small as 4096 bytes. So we cannot safely
392 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
393 to allow for a few compiler-allocated temporary stack slots. */
394 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
397 # define YYSTACK_ALLOC YYMALLOC
398 # define YYSTACK_FREE YYFREE
399 # ifndef YYSTACK_ALLOC_MAXIMUM
400 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
402 # if (defined __cplusplus && ! defined EXIT_SUCCESS \
403 && ! ((defined YYMALLOC || defined malloc) \
404 && (defined YYFREE || defined free)))
405 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
406 # ifndef EXIT_SUCCESS
407 # define EXIT_SUCCESS 0
411 # define YYMALLOC malloc
412 # if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
413 || defined __cplusplus || defined _MSC_VER)
414 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
419 # if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
420 || defined __cplusplus || defined _MSC_VER)
421 void free (void *); /* INFRINGES ON USER NAME SPACE */
425 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
428 #if (! defined yyoverflow \
429 && (! defined __cplusplus \
430 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
432 /* A type that is properly aligned for any stack member. */
435 yytype_int16 yyss_alloc;
439 /* The size of the maximum gap between one aligned stack and the next. */
440 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
442 /* The size of an array large to enough to hold all stacks, each with
444 # define YYSTACK_BYTES(N) \
445 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
446 + YYSTACK_GAP_MAXIMUM)
448 # define YYCOPY_NEEDED 1
450 /* Relocate STACK from its old location to the new one. The
451 local variables YYSIZE and YYSTACKSIZE give the old and new number of
452 elements in the stack, and YYPTR gives the new location of the
453 stack. Advance YYPTR to a properly aligned location for the next
455 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
458 YYSIZE_T yynewbytes; \
459 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
460 Stack = &yyptr->Stack_alloc; \
461 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
462 yyptr += yynewbytes / sizeof (*yyptr); \
468 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
469 /* Copy COUNT objects from FROM to TO. The source and destination do
472 # if defined __GNUC__ && 1 < __GNUC__
473 # define YYCOPY(To, From, Count) \
474 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
476 # define YYCOPY(To, From, Count) \
480 for (yyi = 0; yyi < (Count); yyi++) \
481 (To)[yyi] = (From)[yyi]; \
486 #endif /* !YYCOPY_NEEDED */
488 /* YYFINAL -- State number of the termination state. */
490 /* YYLAST -- Last index in YYTABLE. */
493 /* YYNTOKENS -- Number of terminals. */
495 /* YYNNTS -- Number of nonterminals. */
497 /* YYNRULES -- Number of rules. */
499 /* YYNRULES -- Number of states. */
502 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
504 #define YYMAXUTOK 266
506 #define YYTRANSLATE(YYX) \
507 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
509 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
510 static const yytype_uint8 yytranslate[] =
512 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
513 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
514 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
515 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
516 2, 2, 2, 2, 14, 2, 2, 13, 2, 2,
517 2, 2, 2, 2, 2, 2, 2, 2, 12, 2,
518 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
519 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
520 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
521 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
522 2, 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, 2, 2, 2, 2, 2, 2,
527 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 1, 2, 3, 4,
538 5, 6, 7, 8, 9, 10, 11
542 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
544 static const yytype_uint8 yyprhs[] =
546 0, 0, 3, 4, 7, 9, 12, 14, 16, 19,
547 24, 29, 36, 43, 45, 47, 50, 52, 54, 58,
548 64, 67, 72, 75, 79, 85, 88, 91, 94, 97,
552 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
553 static const yytype_int8 yyrhs[] =
555 16, 0, -1, -1, 16, 17, -1, 18, -1, 18,
556 19, -1, 21, -1, 22, -1, 10, 23, -1, 10,
557 12, 10, 23, -1, 10, 12, 10, 20, -1, 10,
558 12, 10, 12, 10, 23, -1, 10, 12, 10, 12,
559 10, 20, -1, 11, -1, 4, -1, 11, 20, -1,
560 20, -1, 9, -1, 10, 13, 10, -1, 10, 13,
561 10, 13, 10, -1, 6, 10, -1, 6, 10, 14,
562 10, -1, 10, 6, -1, 10, 6, 10, -1, 3,
563 14, 10, 6, 10, -1, 9, 8, -1, 10, 8,
564 -1, 9, 7, -1, 10, 7, -1, -1, 5, -1
567 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
568 static const yytype_uint16 yyrline[] =
570 0, 139, 139, 140, 143, 152, 156, 159, 164, 176,
571 182, 189, 195, 205, 209, 213, 221, 227, 248, 252,
572 264, 268, 273, 277, 282, 289, 292, 295, 298, 303,
577 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
578 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
579 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
580 static const char *const yytname[] =
582 "$end", "error", "$undefined", "tDAY", "tDAYZONE", "tMERIDIAN",
583 "tMONTH", "tMONTH_UNIT", "tSEC_UNIT", "tSNUMBER", "tUNUMBER", "tZONE",
584 "':'", "'/'", "','", "$accept", "spec", "item", "time", "zone",
585 "numzone", "date", "rel", "o_merid", 0
590 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
592 static const yytype_uint16 yytoknum[] =
594 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
599 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
600 static const yytype_uint8 yyr1[] =
602 0, 15, 16, 16, 17, 17, 17, 17, 18, 18,
603 18, 18, 18, 19, 19, 19, 19, 20, 21, 21,
604 21, 21, 21, 21, 21, 22, 22, 22, 22, 23,
608 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
609 static const yytype_uint8 yyr2[] =
611 0, 2, 0, 2, 1, 2, 1, 1, 2, 4,
612 4, 6, 6, 1, 1, 2, 1, 1, 3, 5,
613 2, 4, 2, 3, 5, 2, 2, 2, 2, 0,
617 /* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
618 Performed when YYTABLE doesn't specify something else to do. Zero
619 means the default is an error. */
620 static const yytype_uint8 yydefact[] =
622 2, 0, 1, 0, 0, 0, 29, 3, 4, 6,
623 7, 0, 20, 27, 25, 30, 22, 28, 26, 0,
624 0, 8, 14, 17, 13, 5, 16, 0, 0, 23,
625 29, 18, 15, 0, 21, 0, 10, 9, 0, 24,
629 /* YYDEFGOTO[NTERM-NUM]. */
630 static const yytype_int8 yydefgoto[] =
632 -1, 1, 7, 8, 25, 26, 9, 10, 21
635 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
637 #define YYPACT_NINF -29
638 static const yytype_int8 yypact[] =
640 -29, 1, -29, -11, 11, 20, 12, -29, 4, -29,
641 -29, 13, 16, -29, -29, -29, 21, -29, -29, 22,
642 23, -29, -29, -29, 5, -29, -29, 28, 25, -29,
643 17, 24, -29, 26, -29, 29, -29, -29, 30, -29,
647 /* YYPGOTO[NTERM-NUM]. */
648 static const yytype_int8 yypgoto[] =
650 -29, -29, -29, -29, -29, -24, -29, -29, -28
653 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
654 positive, shift that token. If negative, reduce the rule which
655 number is the opposite. If YYTABLE_NINF, syntax error. */
656 #define YYTABLE_NINF -1
657 static const yytype_uint8 yytable[] =
659 32, 2, 37, 11, 3, 15, 36, 4, 22, 23,
660 5, 6, 43, 23, 23, 24, 42, 15, 16, 17,
661 18, 12, 15, 27, 19, 20, 23, 13, 14, 35,
662 28, 29, 30, 31, 33, 34, 39, 38, 0, 40,
666 #define yypact_value_is_default(yystate) \
669 #define yytable_value_is_error(yytable_value) \
672 static const yytype_int8 yycheck[] =
674 24, 0, 30, 14, 3, 5, 30, 6, 4, 9,
675 9, 10, 40, 9, 9, 11, 40, 5, 6, 7,
676 8, 10, 5, 10, 12, 13, 9, 7, 8, 12,
677 14, 10, 10, 10, 6, 10, 10, 13, -1, 10,
681 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
682 symbol of state STATE-NUM. */
683 static const yytype_uint8 yystos[] =
685 0, 16, 0, 3, 6, 9, 10, 17, 18, 21,
686 22, 14, 10, 7, 8, 5, 6, 7, 8, 12,
687 13, 23, 4, 9, 11, 19, 20, 10, 14, 10,
688 10, 10, 20, 6, 10, 12, 20, 23, 13, 10,
692 #define yyerrok (yyerrstatus = 0)
693 #define yyclearin (yychar = YYEMPTY)
697 #define YYACCEPT goto yyacceptlab
698 #define YYABORT goto yyabortlab
699 #define YYERROR goto yyerrorlab
702 /* Like YYERROR except do call yyerror. This remains here temporarily
703 to ease the transition to the new meaning of YYERROR, for GCC.
704 Once GCC version 2 has supplanted version 1, this can go. However,
705 YYFAIL appears to be in use. Nevertheless, it is formally deprecated
706 in Bison 2.4.2's NEWS entry, where a plan to phase it out is
709 #define YYFAIL goto yyerrlab
711 /* This is here to suppress warnings from the GCC cpp's
712 -Wunused-macros. Normally we don't worry about that warning, but
713 some users do, and we want to make it easy for users to remove
714 YYFAIL uses, which will produce warnings from Bison 2.5. */
717 #define YYRECOVERING() (!!yyerrstatus)
719 #define YYBACKUP(Token, Value) \
721 if (yychar == YYEMPTY && yylen == 1) \
730 yyerror (YY_("syntax error: cannot back up")); \
737 #define YYERRCODE 256
740 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
741 If N is 0, then set CURRENT to the empty location which ends
742 the previous symbol: RHS[0] (always defined). */
744 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
745 #ifndef YYLLOC_DEFAULT
746 # define YYLLOC_DEFAULT(Current, Rhs, N) \
750 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
751 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
752 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
753 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
757 (Current).first_line = (Current).last_line = \
758 YYRHSLOC (Rhs, 0).last_line; \
759 (Current).first_column = (Current).last_column = \
760 YYRHSLOC (Rhs, 0).last_column; \
766 /* This macro is provided for backward compatibility. */
768 #ifndef YY_LOCATION_PRINT
769 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
773 /* YYLEX -- calling `yylex' with the right arguments. */
776 # define YYLEX yylex (YYLEX_PARAM)
778 # define YYLEX yylex ()
781 /* Enable debugging if requested. */
785 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
786 # define YYFPRINTF fprintf
789 # define YYDPRINTF(Args) \
795 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
799 YYFPRINTF (stderr, "%s ", Title); \
800 yy_symbol_print (stderr, \
802 YYFPRINTF (stderr, "\n"); \
807 /*--------------------------------.
808 | Print this symbol on YYOUTPUT. |
809 `--------------------------------*/
812 #if (defined __STDC__ || defined __C99__FUNC__ \
813 || defined __cplusplus || defined _MSC_VER)
815 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
818 yy_symbol_value_print (yyoutput, yytype, yyvaluep)
821 YYSTYPE const * const yyvaluep;
827 if (yytype < YYNTOKENS)
828 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
840 /*--------------------------------.
841 | Print this symbol on YYOUTPUT. |
842 `--------------------------------*/
844 #if (defined __STDC__ || defined __C99__FUNC__ \
845 || defined __cplusplus || defined _MSC_VER)
847 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
850 yy_symbol_print (yyoutput, yytype, yyvaluep)
853 YYSTYPE const * const yyvaluep;
856 if (yytype < YYNTOKENS)
857 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
859 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
861 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
862 YYFPRINTF (yyoutput, ")");
865 /*------------------------------------------------------------------.
866 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
868 `------------------------------------------------------------------*/
870 #if (defined __STDC__ || defined __C99__FUNC__ \
871 || defined __cplusplus || defined _MSC_VER)
873 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
876 yy_stack_print (yybottom, yytop)
877 yytype_int16 *yybottom;
881 YYFPRINTF (stderr, "Stack now");
882 for (; yybottom <= yytop; yybottom++)
884 int yybot = *yybottom;
885 YYFPRINTF (stderr, " %d", yybot);
887 YYFPRINTF (stderr, "\n");
890 # define YY_STACK_PRINT(Bottom, Top) \
893 yy_stack_print ((Bottom), (Top)); \
897 /*------------------------------------------------.
898 | Report that the YYRULE is going to be reduced. |
899 `------------------------------------------------*/
901 #if (defined __STDC__ || defined __C99__FUNC__ \
902 || defined __cplusplus || defined _MSC_VER)
904 yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
907 yy_reduce_print (yyvsp, yyrule)
912 int yynrhs = yyr2[yyrule];
914 unsigned long int yylno = yyrline[yyrule];
915 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
917 /* The symbols being reduced. */
918 for (yyi = 0; yyi < yynrhs; yyi++)
920 YYFPRINTF (stderr, " $%d = ", yyi + 1);
921 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
922 &(yyvsp[(yyi + 1) - (yynrhs)])
924 YYFPRINTF (stderr, "\n");
928 # define YY_REDUCE_PRINT(Rule) \
931 yy_reduce_print (yyvsp, Rule); \
934 /* Nonzero means print parse trace. It is left uninitialized so that
935 multiple parsers can coexist. */
938 # define YYDPRINTF(Args)
939 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
940 # define YY_STACK_PRINT(Bottom, Top)
941 # define YY_REDUCE_PRINT(Rule)
942 #endif /* !YYDEBUG */
945 /* YYINITDEPTH -- initial size of the parser's stacks. */
947 # define YYINITDEPTH 200
950 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
951 if the built-in stack extension method is used).
953 Do not make this value too large; the results are undefined if
954 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
955 evaluated with infinite-precision integer arithmetic. */
958 # define YYMAXDEPTH 10000
965 # if defined __GLIBC__ && defined _STRING_H
966 # define yystrlen strlen
968 /* Return the length of YYSTR. */
969 #if (defined __STDC__ || defined __C99__FUNC__ \
970 || defined __cplusplus || defined _MSC_VER)
972 yystrlen (const char *yystr)
980 for (yylen = 0; yystr[yylen]; yylen++)
988 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
989 # define yystpcpy stpcpy
991 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
993 #if (defined __STDC__ || defined __C99__FUNC__ \
994 || defined __cplusplus || defined _MSC_VER)
996 yystpcpy (char *yydest, const char *yysrc)
999 yystpcpy (yydest, yysrc)
1005 const char *yys = yysrc;
1007 while ((*yyd++ = *yys++) != '\0')
1016 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1017 quotes and backslashes, so that it's suitable for yyerror. The
1018 heuristic is that double-quoting is unnecessary unless the string
1019 contains an apostrophe, a comma, or backslash (other than
1020 backslash-backslash). YYSTR is taken from yytname. If YYRES is
1021 null, do not copy; instead, return the length of what the result
1024 yytnamerr (char *yyres, const char *yystr)
1029 char const *yyp = yystr;
1036 goto do_not_strip_quotes;
1040 goto do_not_strip_quotes;
1053 do_not_strip_quotes: ;
1057 return yystrlen (yystr);
1059 return yystpcpy (yyres, yystr) - yyres;
1063 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
1064 about the unexpected token YYTOKEN for the state stack whose top is
1067 Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
1068 not large enough to hold the message. In that case, also set
1069 *YYMSG_ALLOC to the required number of bytes. Return 2 if the
1070 required number of bytes is too large to store. */
1072 yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
1073 yytype_int16 *yyssp, int yytoken)
1075 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytoken]);
1076 YYSIZE_T yysize = yysize0;
1078 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1079 /* Internationalized format string. */
1080 const char *yyformat = 0;
1081 /* Arguments of yyformat. */
1082 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1083 /* Number of reported tokens (one for the "unexpected", one per
1087 /* There are many possibilities here to consider:
1088 - Assume YYFAIL is not used. It's too flawed to consider. See
1089 <http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html>
1090 for details. YYERROR is fine as it does not invoke this
1092 - If this state is a consistent state with a default action, then
1093 the only way this function was invoked is if the default action
1094 is an error action. In that case, don't check for expected
1095 tokens because there are none.
1096 - The only way there can be no lookahead present (in yychar) is if
1097 this state is a consistent state with a default action. Thus,
1098 detecting the absence of a lookahead is sufficient to determine
1099 that there is no unexpected or expected token to report. In that
1100 case, just report a simple "syntax error".
1101 - Don't assume there isn't a lookahead just because this state is a
1102 consistent state with a default action. There might have been a
1103 previous inconsistent state, consistent state with a non-default
1104 action, or user semantic action that manipulated yychar.
1105 - Of course, the expected token list depends on states to have
1106 correct lookahead information, and it depends on the parser not
1107 to perform extra reductions after fetching a lookahead from the
1108 scanner and before detecting a syntax error. Thus, state merging
1109 (from LALR or IELR) and default reductions corrupt the expected
1110 token list. However, the list is correct for canonical LR with
1111 one exception: it will still contain any token that will not be
1112 accepted due to an error action in a later state.
1114 if (yytoken != YYEMPTY)
1116 int yyn = yypact[*yyssp];
1117 yyarg[yycount++] = yytname[yytoken];
1118 if (!yypact_value_is_default (yyn))
1120 /* Start YYX at -YYN if negative to avoid negative indexes in
1121 YYCHECK. In other words, skip the first -YYN actions for
1122 this state because they are default actions. */
1123 int yyxbegin = yyn < 0 ? -yyn : 0;
1124 /* Stay within bounds of both yycheck and yytname. */
1125 int yychecklim = YYLAST - yyn + 1;
1126 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1129 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1130 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
1131 && !yytable_value_is_error (yytable[yyx + yyn]))
1133 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1139 yyarg[yycount++] = yytname[yyx];
1140 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1141 if (! (yysize <= yysize1
1142 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1151 # define YYCASE_(N, S) \
1155 YYCASE_(0, YY_("syntax error"));
1156 YYCASE_(1, YY_("syntax error, unexpected %s"));
1157 YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1158 YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1159 YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1160 YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1164 yysize1 = yysize + yystrlen (yyformat);
1165 if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1169 if (*yymsg_alloc < yysize)
1171 *yymsg_alloc = 2 * yysize;
1172 if (! (yysize <= *yymsg_alloc
1173 && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1174 *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1178 /* Avoid sprintf, as that infringes on the user's name space.
1179 Don't have undefined behavior even if the translation
1180 produced a string with the wrong number of "%s"s. */
1184 while ((*yyp = *yyformat) != '\0')
1185 if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1187 yyp += yytnamerr (yyp, yyarg[yyi++]);
1198 #endif /* YYERROR_VERBOSE */
1200 /*-----------------------------------------------.
1201 | Release the memory associated to this symbol. |
1202 `-----------------------------------------------*/
1205 #if (defined __STDC__ || defined __C99__FUNC__ \
1206 || defined __cplusplus || defined _MSC_VER)
1208 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1211 yydestruct (yymsg, yytype, yyvaluep)
1221 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1232 /* Prevent warnings from -Wmissing-prototypes. */
1233 #ifdef YYPARSE_PARAM
1234 #if defined __STDC__ || defined __cplusplus
1235 int yyparse (void *YYPARSE_PARAM);
1239 #else /* ! YYPARSE_PARAM */
1240 #if defined __STDC__ || defined __cplusplus
1245 #endif /* ! YYPARSE_PARAM */
1248 /* The lookahead symbol. */
1251 /* The semantic value of the lookahead symbol. */
1254 /* Number of syntax errors so far. */
1262 #ifdef YYPARSE_PARAM
1263 #if (defined __STDC__ || defined __C99__FUNC__ \
1264 || defined __cplusplus || defined _MSC_VER)
1266 yyparse (void *YYPARSE_PARAM)
1269 yyparse (YYPARSE_PARAM)
1270 void *YYPARSE_PARAM;
1272 #else /* ! YYPARSE_PARAM */
1273 #if (defined __STDC__ || defined __C99__FUNC__ \
1274 || defined __cplusplus || defined _MSC_VER)
1285 /* Number of tokens to shift before error messages enabled. */
1288 /* The stacks and their tools:
1289 `yyss': related to states.
1290 `yyvs': related to semantic values.
1292 Refer to the stacks thru separate pointers, to allow yyoverflow
1293 to reallocate them elsewhere. */
1295 /* The state stack. */
1296 yytype_int16 yyssa[YYINITDEPTH];
1298 yytype_int16 *yyssp;
1300 /* The semantic value stack. */
1301 YYSTYPE yyvsa[YYINITDEPTH];
1305 YYSIZE_T yystacksize;
1309 /* Lookahead token as an internal (translated) token number. */
1311 /* The variables used to return semantic value and location from the
1316 /* Buffer for error messages, and its allocated size. */
1318 char *yymsg = yymsgbuf;
1319 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1322 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1324 /* The number of symbols on the RHS of the reduced rule.
1325 Keep to zero when no symbol should be popped. */
1331 yystacksize = YYINITDEPTH;
1333 YYDPRINTF ((stderr, "Starting parse\n"));
1338 yychar = YYEMPTY; /* Cause a token to be read. */
1340 /* Initialize stack pointers.
1341 Waste one element of value and location stack
1342 so that they stay on the same level as the state stack.
1343 The wasted elements are never initialized. */
1349 /*------------------------------------------------------------.
1350 | yynewstate -- Push a new state, which is found in yystate. |
1351 `------------------------------------------------------------*/
1353 /* In all cases, when you get here, the value and location stacks
1354 have just been pushed. So pushing a state here evens the stacks. */
1360 if (yyss + yystacksize - 1 <= yyssp)
1362 /* Get the current used size of the three stacks, in elements. */
1363 YYSIZE_T yysize = yyssp - yyss + 1;
1367 /* Give user a chance to reallocate the stack. Use copies of
1368 these so that the &'s don't force the real ones into
1370 YYSTYPE *yyvs1 = yyvs;
1371 yytype_int16 *yyss1 = yyss;
1373 /* Each stack pointer address is followed by the size of the
1374 data in use in that stack, in bytes. This used to be a
1375 conditional around just the two extra args, but that might
1376 be undefined if yyoverflow is a macro. */
1377 yyoverflow (YY_("memory exhausted"),
1378 &yyss1, yysize * sizeof (*yyssp),
1379 &yyvs1, yysize * sizeof (*yyvsp),
1385 #else /* no yyoverflow */
1386 # ifndef YYSTACK_RELOCATE
1387 goto yyexhaustedlab;
1389 /* Extend the stack our own way. */
1390 if (YYMAXDEPTH <= yystacksize)
1391 goto yyexhaustedlab;
1393 if (YYMAXDEPTH < yystacksize)
1394 yystacksize = YYMAXDEPTH;
1397 yytype_int16 *yyss1 = yyss;
1398 union yyalloc *yyptr =
1399 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1401 goto yyexhaustedlab;
1402 YYSTACK_RELOCATE (yyss_alloc, yyss);
1403 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1404 # undef YYSTACK_RELOCATE
1406 YYSTACK_FREE (yyss1);
1409 #endif /* no yyoverflow */
1411 yyssp = yyss + yysize - 1;
1412 yyvsp = yyvs + yysize - 1;
1414 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1415 (unsigned long int) yystacksize));
1417 if (yyss + yystacksize - 1 <= yyssp)
1421 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1423 if (yystate == YYFINAL)
1433 /* Do appropriate processing given the current state. Read a
1434 lookahead token if we need one and don't already have one. */
1436 /* First try to decide what to do without reference to lookahead token. */
1437 yyn = yypact[yystate];
1438 if (yypact_value_is_default (yyn))
1441 /* Not known => get a lookahead token if don't already have one. */
1443 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1444 if (yychar == YYEMPTY)
1446 YYDPRINTF ((stderr, "Reading a token: "));
1450 if (yychar <= YYEOF)
1452 yychar = yytoken = YYEOF;
1453 YYDPRINTF ((stderr, "Now at end of input.\n"));
1457 yytoken = YYTRANSLATE (yychar);
1458 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1461 /* If the proper action on seeing token YYTOKEN is to reduce or to
1462 detect an error, take that action. */
1464 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1469 if (yytable_value_is_error (yyn))
1475 /* Count tokens shifted since error; after three, turn off error
1480 /* Shift the lookahead token. */
1481 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1483 /* Discard the shifted token. */
1492 /*-----------------------------------------------------------.
1493 | yydefault -- do the default action for the current state. |
1494 `-----------------------------------------------------------*/
1496 yyn = yydefact[yystate];
1502 /*-----------------------------.
1503 | yyreduce -- Do a reduction. |
1504 `-----------------------------*/
1506 /* yyn is the number of a rule to reduce with. */
1509 /* If YYLEN is nonzero, implement the default value of the action:
1512 Otherwise, the following line sets YYVAL to garbage.
1513 This behavior is undocumented and Bison
1514 users should not rely upon it. Assigning to YYVAL
1515 unconditionally makes the parser a bit smaller, and it avoids a
1516 GCC warning that YYVAL may be used uninitialized. */
1517 yyval = yyvsp[1-yylen];
1520 YY_REDUCE_PRINT (yyn);
1525 /* Line 1806 of yacc.c */
1526 #line 143 "parsedate.y"
1530 /* I am compulsive about lint natterings... */
1531 if (yyHaveTime == -1) {
1540 /* Line 1806 of yacc.c */
1541 #line 152 "parsedate.y"
1544 yyTimezone = (yyvsp[(2) - (2)].Number);
1550 /* Line 1806 of yacc.c */
1551 #line 156 "parsedate.y"
1559 /* Line 1806 of yacc.c */
1560 #line 159 "parsedate.y"
1568 /* Line 1806 of yacc.c */
1569 #line 164 "parsedate.y"
1571 if ((yyvsp[(1) - (2)].Number) < 100) {
1572 yyHour = (yyvsp[(1) - (2)].Number);
1576 yyHour = (yyvsp[(1) - (2)].Number) / 100;
1577 yyMinutes = (yyvsp[(1) - (2)].Number) % 100;
1580 yyMeridian = (yyvsp[(2) - (2)].Meridian);
1586 /* Line 1806 of yacc.c */
1587 #line 176 "parsedate.y"
1589 yyHour = (yyvsp[(1) - (4)].Number);
1590 yyMinutes = (yyvsp[(3) - (4)].Number);
1592 yyMeridian = (yyvsp[(4) - (4)].Meridian);
1598 /* Line 1806 of yacc.c */
1599 #line 182 "parsedate.y"
1601 yyHour = (yyvsp[(1) - (4)].Number);
1602 yyMinutes = (yyvsp[(3) - (4)].Number);
1603 yyTimezone = (yyvsp[(4) - (4)].Number);
1611 /* Line 1806 of yacc.c */
1612 #line 189 "parsedate.y"
1614 yyHour = (yyvsp[(1) - (6)].Number);
1615 yyMinutes = (yyvsp[(3) - (6)].Number);
1616 yySeconds = (yyvsp[(5) - (6)].Number);
1617 yyMeridian = (yyvsp[(6) - (6)].Meridian);
1623 /* Line 1806 of yacc.c */
1624 #line 195 "parsedate.y"
1626 yyHour = (yyvsp[(1) - (6)].Number);
1627 yyMinutes = (yyvsp[(3) - (6)].Number);
1628 yySeconds = (yyvsp[(5) - (6)].Number);
1629 yyTimezone = (yyvsp[(6) - (6)].Number);
1637 /* Line 1806 of yacc.c */
1638 #line 205 "parsedate.y"
1640 (yyval.Number) = (yyvsp[(1) - (1)].Number);
1647 /* Line 1806 of yacc.c */
1648 #line 209 "parsedate.y"
1650 (yyval.Number) = (yyvsp[(1) - (1)].Number);
1657 /* Line 1806 of yacc.c */
1658 #line 213 "parsedate.y"
1660 /* Only allow "GMT+300" and "GMT-0800" */
1661 if ((yyvsp[(1) - (2)].Number) != 0) {
1664 (yyval.Number) = (yyvsp[(2) - (2)].Number);
1671 /* Line 1806 of yacc.c */
1672 #line 221 "parsedate.y"
1674 (yyval.Number) = (yyvsp[(1) - (1)].Number);
1681 /* Line 1806 of yacc.c */
1682 #line 227 "parsedate.y"
1686 /* Unix and GMT and numeric timezones -- a little confusing. */
1687 if ((yyvsp[(1) - (1)].Number) < 0) {
1688 /* Don't work with negative modulus. */
1689 (yyvsp[(1) - (1)].Number) = -(yyvsp[(1) - (1)].Number);
1690 if ((yyvsp[(1) - (1)].Number) > 9999 || (i = (yyvsp[(1) - (1)].Number) % 100) >= 60) {
1693 (yyval.Number) = ((yyvsp[(1) - (1)].Number) / 100) * 60 + i;
1696 if ((yyvsp[(1) - (1)].Number) > 9999 || (i = (yyvsp[(1) - (1)].Number) % 100) >= 60) {
1699 (yyval.Number) = -(((yyvsp[(1) - (1)].Number) / 100) * 60 + i);
1706 /* Line 1806 of yacc.c */
1707 #line 248 "parsedate.y"
1709 yyMonth = (yyvsp[(1) - (3)].Number);
1710 yyDay = (yyvsp[(3) - (3)].Number);
1716 /* Line 1806 of yacc.c */
1717 #line 252 "parsedate.y"
1719 if ((yyvsp[(1) - (5)].Number) > 100) {
1720 yyYear = (yyvsp[(1) - (5)].Number);
1721 yyMonth = (yyvsp[(3) - (5)].Number);
1722 yyDay = (yyvsp[(5) - (5)].Number);
1725 yyMonth = (yyvsp[(1) - (5)].Number);
1726 yyDay = (yyvsp[(3) - (5)].Number);
1727 yyYear = (yyvsp[(5) - (5)].Number);
1734 /* Line 1806 of yacc.c */
1735 #line 264 "parsedate.y"
1737 yyMonth = (yyvsp[(1) - (2)].Number);
1738 yyDay = (yyvsp[(2) - (2)].Number);
1744 /* Line 1806 of yacc.c */
1745 #line 268 "parsedate.y"
1747 yyMonth = (yyvsp[(1) - (4)].Number);
1748 yyDay = (yyvsp[(2) - (4)].Number);
1749 yyYear = (yyvsp[(4) - (4)].Number);
1755 /* Line 1806 of yacc.c */
1756 #line 273 "parsedate.y"
1758 yyDay = (yyvsp[(1) - (2)].Number);
1759 yyMonth = (yyvsp[(2) - (2)].Number);
1765 /* Line 1806 of yacc.c */
1766 #line 277 "parsedate.y"
1768 yyDay = (yyvsp[(1) - (3)].Number);
1769 yyMonth = (yyvsp[(2) - (3)].Number);
1770 yyYear = (yyvsp[(3) - (3)].Number);
1776 /* Line 1806 of yacc.c */
1777 #line 282 "parsedate.y"
1779 yyDay = (yyvsp[(3) - (5)].Number);
1780 yyMonth = (yyvsp[(4) - (5)].Number);
1781 yyYear = (yyvsp[(5) - (5)].Number);
1787 /* Line 1806 of yacc.c */
1788 #line 289 "parsedate.y"
1790 yyRelSeconds += (yyvsp[(1) - (2)].Number) * (yyvsp[(2) - (2)].Number);
1796 /* Line 1806 of yacc.c */
1797 #line 292 "parsedate.y"
1799 yyRelSeconds += (yyvsp[(1) - (2)].Number) * (yyvsp[(2) - (2)].Number);
1805 /* Line 1806 of yacc.c */
1806 #line 295 "parsedate.y"
1808 yyRelMonth += (yyvsp[(1) - (2)].Number) * (yyvsp[(2) - (2)].Number);
1814 /* Line 1806 of yacc.c */
1815 #line 298 "parsedate.y"
1817 yyRelMonth += (yyvsp[(1) - (2)].Number) * (yyvsp[(2) - (2)].Number);
1823 /* Line 1806 of yacc.c */
1824 #line 303 "parsedate.y"
1826 (yyval.Meridian) = MER24;
1832 /* Line 1806 of yacc.c */
1833 #line 306 "parsedate.y"
1835 (yyval.Meridian) = (yyvsp[(1) - (1)].Meridian);
1841 /* Line 1806 of yacc.c */
1842 #line 1843 "y.tab.c"
1845 /* User semantic actions sometimes alter yychar, and that requires
1846 that yytoken be updated with the new translation. We take the
1847 approach of translating immediately before every use of yytoken.
1848 One alternative is translating here after every semantic action,
1849 but that translation would be missed if the semantic action invokes
1850 YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1851 if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
1852 incorrect destructor might then be invoked immediately. In the
1853 case of YYERROR or YYBACKUP, subsequent parser actions might lead
1854 to an incorrect destructor call or verbose syntax error message
1855 before the lookahead is translated. */
1856 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1860 YY_STACK_PRINT (yyss, yyssp);
1864 /* Now `shift' the result of the reduction. Determine what state
1865 that goes to, based on the state we popped back to and the rule
1866 number reduced by. */
1870 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1871 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1872 yystate = yytable[yystate];
1874 yystate = yydefgoto[yyn - YYNTOKENS];
1879 /*------------------------------------.
1880 | yyerrlab -- here on detecting error |
1881 `------------------------------------*/
1883 /* Make sure we have latest lookahead translation. See comments at
1884 user semantic actions for why this is necessary. */
1885 yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
1887 /* If not already recovering from an error, report this error. */
1891 #if ! YYERROR_VERBOSE
1892 yyerror (YY_("syntax error"));
1894 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
1897 char const *yymsgp = YY_("syntax error");
1898 int yysyntax_error_status;
1899 yysyntax_error_status = YYSYNTAX_ERROR;
1900 if (yysyntax_error_status == 0)
1902 else if (yysyntax_error_status == 1)
1904 if (yymsg != yymsgbuf)
1905 YYSTACK_FREE (yymsg);
1906 yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
1910 yymsg_alloc = sizeof yymsgbuf;
1911 yysyntax_error_status = 2;
1915 yysyntax_error_status = YYSYNTAX_ERROR;
1920 if (yysyntax_error_status == 2)
1921 goto yyexhaustedlab;
1923 # undef YYSYNTAX_ERROR
1929 if (yyerrstatus == 3)
1931 /* If just tried and failed to reuse lookahead token after an
1932 error, discard it. */
1934 if (yychar <= YYEOF)
1936 /* Return failure if at end of input. */
1937 if (yychar == YYEOF)
1942 yydestruct ("Error: discarding",
1948 /* Else will try to reuse lookahead token after shifting the error
1953 /*---------------------------------------------------.
1954 | yyerrorlab -- error raised explicitly by YYERROR. |
1955 `---------------------------------------------------*/
1958 /* Pacify compilers like GCC when the user code never invokes
1959 YYERROR and the label yyerrorlab therefore never appears in user
1961 if (/*CONSTCOND*/ 0)
1964 /* Do not reclaim the symbols of the rule which action triggered
1968 YY_STACK_PRINT (yyss, yyssp);
1973 /*-------------------------------------------------------------.
1974 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1975 `-------------------------------------------------------------*/
1977 yyerrstatus = 3; /* Each real token shifted decrements this. */
1981 yyn = yypact[yystate];
1982 if (!yypact_value_is_default (yyn))
1985 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1993 /* Pop the current state because it cannot handle the error token. */
1998 yydestruct ("Error: popping",
1999 yystos[yystate], yyvsp);
2002 YY_STACK_PRINT (yyss, yyssp);
2008 /* Shift the error token. */
2009 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
2015 /*-------------------------------------.
2016 | yyacceptlab -- YYACCEPT comes here. |
2017 `-------------------------------------*/
2022 /*-----------------------------------.
2023 | yyabortlab -- YYABORT comes here. |
2024 `-----------------------------------*/
2029 #if !defined(yyoverflow) || YYERROR_VERBOSE
2030 /*-------------------------------------------------.
2031 | yyexhaustedlab -- memory exhaustion comes here. |
2032 `-------------------------------------------------*/
2034 yyerror (YY_("memory exhausted"));
2040 if (yychar != YYEMPTY)
2042 /* Make sure we have latest lookahead translation. See comments at
2043 user semantic actions for why this is necessary. */
2044 yytoken = YYTRANSLATE (yychar);
2045 yydestruct ("Cleanup: discarding lookahead",
2048 /* Do not reclaim the symbols of the rule which action triggered
2049 this YYABORT or YYACCEPT. */
2051 YY_STACK_PRINT (yyss, yyssp);
2052 while (yyssp != yyss)
2054 yydestruct ("Cleanup: popping",
2055 yystos[*yyssp], yyvsp);
2060 YYSTACK_FREE (yyss);
2063 if (yymsg != yymsgbuf)
2064 YYSTACK_FREE (yymsg);
2066 /* Make sure YYID is used. */
2067 return YYID (yyresult);
2072 /* Line 2067 of yacc.c */
2073 #line 311 "parsedate.y"
2076 /* Month and day table. */
2077 static TABLE MonthDayTable[] = {
2078 { "january", tMONTH, 1 },
2079 { "february", tMONTH, 2 },
2080 { "march", tMONTH, 3 },
2081 { "april", tMONTH, 4 },
2082 { "may", tMONTH, 5 },
2083 { "june", tMONTH, 6 },
2084 { "july", tMONTH, 7 },
2085 { "august", tMONTH, 8 },
2086 { "september", tMONTH, 9 },
2087 { "october", tMONTH, 10 },
2088 { "november", tMONTH, 11 },
2089 { "december", tMONTH, 12 },
2090 /* The value of the day isn't used... */
2091 { "sunday", tDAY, 0 },
2092 { "monday", tDAY, 0 },
2093 { "tuesday", tDAY, 0 },
2094 { "wednesday", tDAY, 0 },
2095 { "thursday", tDAY, 0 },
2096 { "friday", tDAY, 0 },
2097 { "saturday", tDAY, 0 },
2100 /* Time units table. */
2101 static TABLE UnitsTable[] = {
2102 { "year", tMONTH_UNIT, 12 },
2103 { "month", tMONTH_UNIT, 1 },
2104 { "week", tSEC_UNIT, 7L * 24 * 60 * 60 },
2105 { "day", tSEC_UNIT, 1L * 24 * 60 * 60 },
2106 { "hour", tSEC_UNIT, 60 * 60 },
2107 { "minute", tSEC_UNIT, 60 },
2108 { "min", tSEC_UNIT, 60 },
2109 { "second", tSEC_UNIT, 1 },
2110 { "sec", tSEC_UNIT, 1 },
2113 /* Timezone table. */
2114 static TABLE TimezoneTable[] = {
2115 { "gmt", tZONE, HOUR( 0) }, /* Greenwich Mean */
2116 { "ut", tZONE, HOUR( 0) }, /* Universal */
2117 { "utc", tZONE, HOUR( 0) }, /* Universal Coordinated */
2118 { "cut", tZONE, HOUR( 0) }, /* Coordinated Universal */
2119 { "z", tZONE, HOUR( 0) }, /* Greenwich Mean */
2120 { "wet", tZONE, HOUR( 0) }, /* Western European */
2121 { "bst", tDAYZONE, HOUR( 0) }, /* British Summer */
2122 { "nst", tZONE, HOUR(3)+30 }, /* Newfoundland Standard */
2123 { "ndt", tDAYZONE, HOUR(3)+30 }, /* Newfoundland Daylight */
2124 { "ast", tZONE, HOUR( 4) }, /* Atlantic Standard */
2125 { "adt", tDAYZONE, HOUR( 4) }, /* Atlantic Daylight */
2126 { "est", tZONE, HOUR( 5) }, /* Eastern Standard */
2127 { "edt", tDAYZONE, HOUR( 5) }, /* Eastern Daylight */
2128 { "cst", tZONE, HOUR( 6) }, /* Central Standard */
2129 { "cdt", tDAYZONE, HOUR( 6) }, /* Central Daylight */
2130 { "mst", tZONE, HOUR( 7) }, /* Mountain Standard */
2131 { "mdt", tDAYZONE, HOUR( 7) }, /* Mountain Daylight */
2132 { "pst", tZONE, HOUR( 8) }, /* Pacific Standard */
2133 { "pdt", tDAYZONE, HOUR( 8) }, /* Pacific Daylight */
2134 { "yst", tZONE, HOUR( 9) }, /* Yukon Standard */
2135 { "ydt", tDAYZONE, HOUR( 9) }, /* Yukon Daylight */
2136 { "akst", tZONE, HOUR( 9) }, /* Alaska Standard */
2137 { "akdt", tDAYZONE, HOUR( 9) }, /* Alaska Daylight */
2138 { "hst", tZONE, HOUR(10) }, /* Hawaii Standard */
2139 { "hast", tZONE, HOUR(10) }, /* Hawaii-Aleutian Standard */
2140 { "hadt", tDAYZONE, HOUR(10) }, /* Hawaii-Aleutian Daylight */
2141 { "ces", tDAYZONE, -HOUR(1) }, /* Central European Summer */
2142 { "cest", tDAYZONE, -HOUR(1) }, /* Central European Summer */
2143 { "mez", tZONE, -HOUR(1) }, /* Middle European */
2144 { "mezt", tDAYZONE, -HOUR(1) }, /* Middle European Summer */
2145 { "cet", tZONE, -HOUR(1) }, /* Central European */
2146 { "met", tZONE, -HOUR(1) }, /* Middle European */
2147 { "eet", tZONE, -HOUR(2) }, /* Eastern Europe */
2148 { "msk", tZONE, -HOUR(3) }, /* Moscow Winter */
2149 { "msd", tDAYZONE, -HOUR(3) }, /* Moscow Summer */
2150 { "wast", tZONE, -HOUR(8) }, /* West Australian Standard */
2151 { "wadt", tDAYZONE, -HOUR(8) }, /* West Australian Daylight */
2152 { "hkt", tZONE, -HOUR(8) }, /* Hong Kong */
2153 { "cct", tZONE, -HOUR(8) }, /* China Coast */
2154 { "jst", tZONE, -HOUR(9) }, /* Japan Standard */
2155 { "kst", tZONE, -HOUR(9) }, /* Korean Standard */
2156 { "kdt", tZONE, -HOUR(9) }, /* Korean Daylight */
2157 { "cast", tZONE, -(HOUR(9)+30) }, /* Central Australian Standard */
2158 { "cadt", tDAYZONE, -(HOUR(9)+30) }, /* Central Australian Daylight */
2159 { "east", tZONE, -HOUR(10) }, /* Eastern Australian Standard */
2160 { "eadt", tDAYZONE, -HOUR(10) }, /* Eastern Australian Daylight */
2161 { "nzst", tZONE, -HOUR(12) }, /* New Zealand Standard */
2162 { "nzdt", tDAYZONE, -HOUR(12) }, /* New Zealand Daylight */
2164 /* For completeness we include the following entries. */
2167 /* Duplicate names. Either they conflict with a zone listed above
2168 * (which is either more likely to be seen or just been in circulation
2169 * longer), or they conflict with another zone in this section and
2170 * we could not reasonably choose one over the other. */
2171 { "fst", tZONE, HOUR( 2) }, /* Fernando De Noronha Standard */
2172 { "fdt", tDAYZONE, HOUR( 2) }, /* Fernando De Noronha Daylight */
2173 { "bst", tZONE, HOUR( 3) }, /* Brazil Standard */
2174 { "est", tZONE, HOUR( 3) }, /* Eastern Standard (Brazil) */
2175 { "edt", tDAYZONE, HOUR( 3) }, /* Eastern Daylight (Brazil) */
2176 { "wst", tZONE, HOUR( 4) }, /* Western Standard (Brazil) */
2177 { "wdt", tDAYZONE, HOUR( 4) }, /* Western Daylight (Brazil) */
2178 { "cst", tZONE, HOUR( 5) }, /* Chile Standard */
2179 { "cdt", tDAYZONE, HOUR( 5) }, /* Chile Daylight */
2180 { "ast", tZONE, HOUR( 5) }, /* Acre Standard */
2181 { "adt", tDAYZONE, HOUR( 5) }, /* Acre Daylight */
2182 { "cst", tZONE, HOUR( 5) }, /* Cuba Standard */
2183 { "cdt", tDAYZONE, HOUR( 5) }, /* Cuba Daylight */
2184 { "est", tZONE, HOUR( 6) }, /* Easter Island Standard */
2185 { "edt", tDAYZONE, HOUR( 6) }, /* Easter Island Daylight */
2186 { "sst", tZONE, HOUR(11) }, /* Samoa Standard */
2187 { "ist", tZONE, -HOUR(2) }, /* Israel Standard */
2188 { "idt", tDAYZONE, -HOUR(2) }, /* Israel Daylight */
2189 { "idt", tDAYZONE, -(HOUR(3)+30) }, /* Iran Daylight */
2190 { "ist", tZONE, -(HOUR(3)+30) }, /* Iran Standard */
2191 { "cst", tZONE, -HOUR(8) }, /* China Standard */
2192 { "cdt", tDAYZONE, -HOUR(8) }, /* China Daylight */
2193 { "sst", tZONE, -HOUR(8) }, /* Singapore Standard */
2195 /* Dubious (e.g., not in Olson's TIMEZONE package) or obsolete. */
2196 { "gst", tZONE, HOUR( 3) }, /* Greenland Standard */
2197 { "wat", tZONE, -HOUR(1) }, /* West Africa */
2198 { "at", tZONE, HOUR( 2) }, /* Azores */
2199 { "gst", tZONE, -HOUR(10) }, /* Guam Standard */
2200 { "nft", tZONE, HOUR(3)+30 }, /* Newfoundland */
2201 { "idlw", tZONE, HOUR(12) }, /* International Date Line West */
2202 { "mewt", tZONE, -HOUR(1) }, /* Middle European Winter */
2203 { "mest", tDAYZONE, -HOUR(1) }, /* Middle European Summer */
2204 { "swt", tZONE, -HOUR(1) }, /* Swedish Winter */
2205 { "sst", tDAYZONE, -HOUR(1) }, /* Swedish Summer */
2206 { "fwt", tZONE, -HOUR(1) }, /* French Winter */
2207 { "fst", tDAYZONE, -HOUR(1) }, /* French Summer */
2208 { "bt", tZONE, -HOUR(3) }, /* Baghdad */
2209 { "it", tZONE, -(HOUR(3)+30) }, /* Iran */
2210 { "zp4", tZONE, -HOUR(4) }, /* USSR Zone 3 */
2211 { "zp5", tZONE, -HOUR(5) }, /* USSR Zone 4 */
2212 { "ist", tZONE, -(HOUR(5)+30) }, /* Indian Standard */
2213 { "zp6", tZONE, -HOUR(6) }, /* USSR Zone 5 */
2214 { "nst", tZONE, -HOUR(7) }, /* North Sumatra */
2215 { "sst", tZONE, -HOUR(7) }, /* South Sumatra */
2216 { "jt", tZONE, -(HOUR(7)+30) }, /* Java (3pm in Cronusland!) */
2217 { "nzt", tZONE, -HOUR(12) }, /* New Zealand */
2218 { "idle", tZONE, -HOUR(12) }, /* International Date Line East */
2219 { "cat", tZONE, HOUR(10) }, /* -- expired 1967 */
2220 { "nt", tZONE, HOUR(11) }, /* -- expired 1967 */
2221 { "ahst", tZONE, HOUR(10) }, /* -- expired 1983 */
2222 { "hdt", tDAYZONE, HOUR(10) }, /* -- expired 1986 */
2236 ToSeconds(time_t Hours, time_t Minutes, time_t Seconds, MERIDIAN Meridian)
2238 if (Minutes < 0 || Minutes > 59 || Seconds < 0 || Seconds > 61)
2240 if (Meridian == MER24) {
2241 if (Hours < 0 || Hours > 23)
2245 if (Hours < 1 || Hours > 12)
2249 if (Meridian == MERpm)
2252 return (Hours * 60L + Minutes) * 60L + Seconds;
2257 Convert(time_t Month, time_t Day, time_t Year,
2258 time_t Hours, time_t Minutes, time_t Seconds,
2259 MERIDIAN Meridian, DSTMODE dst)
2261 static int DaysNormal[13] = {
2262 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
2264 static int DaysLeap[13] = {
2265 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
2267 static int LeapYears[] = {
2268 1972, 1976, 1980, 1984, 1988, 1992, 1996,
2269 2000, 2004, 2008, 2012, 2016, 2020, 2024, 2028, 2032, 2036
2273 register time_t Julian;
2283 for (mp = DaysNormal, yp = LeapYears; yp < ENDOF(LeapYears); yp++)
2288 if (Year < EPOCH || Year > END_OF_TIME
2289 || Month < 1 || Month > 12
2290 /* NOSTRICT *//* conversion from long may lose accuracy */
2291 || Day < 1 || Day > mp[(int)Month])
2294 Julian = Day - 1 + (Year - EPOCH) * 365;
2295 for (yp = LeapYears; yp < ENDOF(LeapYears); yp++, Julian++)
2298 for (i = 1; i < Month; i++)
2300 Julian *= SECSPERDAY;
2301 Julian += yyTimezone * 60L;
2302 if ((tod = ToSeconds(Hours, Minutes, Seconds, Meridian)) < 0)
2306 if (dst == DSTon || (dst == DSTmaybe && localtime(&tod)->tm_isdst))
2307 Julian -= DST_OFFSET * 60L * 60L;
2313 DSTcorrect(time_t Start, time_t Future)
2318 StartDay = (localtime(&Start)->tm_hour + 1) % 24;
2319 FutureDay = (localtime(&Future)->tm_hour + 1) % 24;
2320 return (Future - Start) + (StartDay - FutureDay) * DST_OFFSET * 60L * 60L;
2325 RelativeMonth(time_t Start, time_t RelMonth)
2331 tm = localtime(&Start);
2332 Month = 12 * tm->tm_year + tm->tm_mon + RelMonth;
2334 Month = Month % 12 + 1;
2335 return DSTcorrect(Start,
2336 Convert(Month, (time_t)tm->tm_mday, Year,
2337 (time_t)tm->tm_hour, (time_t)tm->tm_min, (time_t)tm->tm_sec,
2343 LookupWord(char *buff, register int length)
2353 /* See if we have an abbreviation for a month. */
2354 if (length == 3 || (length == 4 && p[3] == '.'))
2355 for (tp = MonthDayTable; tp < ENDOF(MonthDayTable); tp++) {
2357 if (c == q[0] && p[1] == q[1] && p[2] == q[2]) {
2358 yylval.Number = tp->value;
2363 for (tp = MonthDayTable; tp < ENDOF(MonthDayTable); tp++)
2364 if (c == tp->name[0] && strcmp(p, tp->name) == 0) {
2365 yylval.Number = tp->value;
2369 /* Try for a timezone. */
2370 for (tp = TimezoneTable; tp < ENDOF(TimezoneTable); tp++)
2371 if (c == tp->name[0] && p[1] == tp->name[1]
2372 && strcmp(p, tp->name) == 0) {
2373 yylval.Number = tp->value;
2377 /* Try the units table. */
2378 for (tp = UnitsTable; tp < ENDOF(UnitsTable); tp++)
2379 if (c == tp->name[0] && strcmp(p, tp->name) == 0) {
2380 yylval.Number = tp->value;
2384 /* Strip off any plural and try the units table again. */
2385 if (--length > 0 && p[length] == 's') {
2387 for (tp = UnitsTable; tp < ENDOF(UnitsTable); tp++)
2388 if (c == tp->name[0] && strcmp(p, tp->name) == 0) {
2390 yylval.Number = tp->value;
2397 /* Drop out any periods. */
2398 for (p = buff, q = (char*)buff; *q; q++)
2403 /* Try the meridians. */
2404 if (buff[1] == 'm' && buff[2] == '\0') {
2405 if (buff[0] == 'a') {
2406 yylval.Meridian = MERam;
2409 if (buff[0] == 'p') {
2410 yylval.Meridian = MERpm;
2415 /* If we saw any periods, try the timezones again. */
2416 if (p - buff != length) {
2418 for (p = buff, tp = TimezoneTable; tp < ENDOF(TimezoneTable); tp++)
2419 if (c == tp->name[0] && p[1] == tp->name[1]
2420 && strcmp(p, tp->name) == 0) {
2421 yylval.Number = tp->value;
2426 /* Unknown word -- assume GMT timezone. */
2440 register int nesting;
2443 /* Get first character after the whitespace. */
2445 while (isspace(*yyInput))
2449 /* Ignore RFC 822 comments, typically time zone names. */
2452 for (nesting = 1; (c = *++yyInput) != RPAREN || --nesting; )
2455 else if (!IS7BIT(c) || c == '\0' || c == '\r'
2456 || (c == '\\' && ((c = *++yyInput) == '\0' || !IS7BIT(c))))
2457 /* Lexical error: bad comment. */
2463 if (isdigit(c) || c == '-' || c == '+') {
2464 if (c == '-' || c == '+') {
2465 sign = c == '-' ? -1 : 1;
2467 if (!isdigit(*yyInput))
2468 /* Skip the plus or minus sign. */
2473 for (i = 0; (c = *yyInput++) != '\0' && isdigit(c); )
2474 i = 10 * i + c - '0';
2476 yylval.Number = sign < 0 ? -i : i;
2477 return sign ? tSNUMBER : tUNUMBER;
2482 for (p = buff; (c = *yyInput++) == '.' || isalpha(c); )
2483 if (p < &buff[sizeof buff - 1])
2484 *p++ = isupper(c) ? tolower(c) : c;
2487 return LookupWord(buff, p - buff);
2496 parsedate(const char *p)
2498 extern int date_parse(void);
2501 yyInput = p; /* well, its supposed to be const... */
2507 yyDSTmode = DSTmaybe;
2518 if (date_parse() || yyHaveTime > 1 || yyHaveDate > 1)
2521 if (yyHaveDate || yyHaveTime) {
2522 Start = Convert(yyMonth, yyDay, yyYear, yyHour, yyMinutes, yySeconds,
2523 yyMeridian, yyDSTmode);
2530 Start += yyRelSeconds;
2532 Start += RelativeMonth(Start, yyRelMonth);
2534 /* Have to do *something* with a legitimate -1 so it's distinguishable
2535 * from the error return value. (Alternately could set errno on error.) */
2536 return Start == -1 ? 0 : Start;
2544 #endif /* YYDEBUG */
2548 main(int ac, char *av[])
2555 #endif /* YYDEBUG */
2557 (void)printf("Enter date, or blank line to exit.\n\t> ");
2559 (void)printf("\t> ");
2560 (void)fflush(stdout);
2561 if (fgets(buff, sizeof buff, stdin) == NULL || buff[0] == '\n')
2564 if (strcmp(buff, "yydebug") == 0) {
2566 printf("yydebug = %s\n", yydebug ? "on" : "off");
2569 #endif /* YYDEBUG */
2570 d = parsedate(buff, (TIMEINFO *)NULL);
2572 (void)printf("Bad format - couldn't convert.\n");
2574 (void)printf("%s", ctime(&d));