2 /* A Bison parser, made by GNU Bison 2.4.1. */
4 /* Skeleton implementation for Bison's Yacc-like parsers in C
6 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
7 Free Software Foundation, Inc.
9 This program is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
22 /* As a special exception, you may create a larger work that contains
23 part or all of the Bison parser skeleton and distribute that work
24 under terms of your choice, so long as that work isn't itself a
25 parser generator using the skeleton or a modified version thereof
26 as a parser skeleton. Alternatively, if you modify or redistribute
27 the parser skeleton itself, you may (at your option) remove this
28 special exception, which will cause the skeleton and the resulting
29 Bison output files to be licensed under the GNU General Public
30 License without this special exception.
32 This special exception was added by the Free Software Foundation in
33 version 2.2 of Bison. */
35 /* C LALR(1) parser skeleton written by Richard Stallman, by
36 simplifying the original so-called "semantic" parser. */
38 /* All symbols defined below should begin with yy or YY, to avoid
39 infringing on user name space. This should be done even for local
40 variables, as they might otherwise be expanded by user macros.
41 There are some unavoidable exceptions within include files to
42 define necessary library symbols; they are noted "INFRINGES ON
43 USER NAME SPACE" below. */
45 /* Identify Bison output. */
49 #define YYBISON_VERSION "2.4.1"
52 #define YYSKELETON_NAME "yacc.c"
63 /* Using locations. */
64 #define YYLSP_NEEDED 0
68 /* Copy the first part of user declarations. */
70 /* Line 189 of yacc.c */
75 ** Originally written by Steven M. Bellovin <smb@research.att.com> while
76 ** at the University of North Carolina at Chapel Hill. Later tweaked by
77 ** a couple of people on Usenet. Completely overhauled by Rich $alz
78 ** <rsalz@osf.org> and Jim Berets <jberets@bbn.com> in August, 1990.
79 ** Further revised (removed obsolete constructs and cleaned up timezone
80 ** names) in August, 1991, by Rich. Paul Eggert <eggert@twinsun.com>
81 ** helped in September, 1992. Art Cancro <ajc@uncensored.citadel.org> cleaned
82 ** it up for ANSI C in December, 1999.
84 ** This grammar has six shift/reduce conflicts.
86 ** This code is in the public domain and has no copyright.
88 /* SUPPRESS 530 *//* Empty body for statement */
89 /* SUPPRESS 593 on yyerrlab *//* Label was not used */
90 /* SUPPRESS 593 on yynewstate *//* Label was not used */
91 /* SUPPRESS 595 on yypvt *//* Automatic variable may be used before set */
97 #include <sys/types.h>
100 #if TIME_WITH_SYS_TIME
101 # include <sys/time.h>
105 # include <sys/time.h>
112 # if !STDC_HEADERS && HAVE_MEMORY_H
118 # include <strings.h>
121 #include "parsedate.h"
125 #define yyparse date_parse
126 #define yylex date_lex
127 #define yyerror date_error
130 /* See the LeapYears table in Convert. */
132 #define END_OF_TIME 2038
133 /* Constants for general time calculations. */
135 #define SECSPERDAY (24L * 60L * 60L)
136 /* Readability for TABLE stuff. */
137 #define HOUR(x) (x * 60)
141 #define IS7BIT(x) ((unsigned int)(x) < 0200)
143 #define SIZEOF(array) ((int)(sizeof array / sizeof array[0]))
144 #define ENDOF(array) (&array[SIZEOF(array)])
148 ** An entry in the lexical lookup table.
150 typedef struct _TABLE {
157 ** Daylight-savings mode: on, off, or not yet known.
159 typedef enum _DSTMODE {
160 DSTon, DSToff, DSTmaybe
164 ** Meridian: am, pm, or 24-hour style.
166 typedef enum _MERIDIAN {
172 ** Global variables. We could get rid of most of them by using a yacc
173 ** union, but this is more efficient. (This routine predates the
174 ** yacc %union construct.)
176 static const char *yyInput;
177 static DSTMODE yyDSTmode;
178 static int yyHaveDate;
179 static int yyHaveRel;
180 static int yyHaveTime;
181 static time_t yyTimezone;
183 static time_t yyHour;
184 static time_t yyMinutes;
185 static time_t yyMonth;
186 static time_t yySeconds;
187 static time_t yyYear;
188 static MERIDIAN yyMeridian;
189 static time_t yyRelMonth;
190 static time_t yyRelSeconds;
193 static void date_error(char *);
196 /* Line 189 of yacc.c */
199 /* Enabling traces. */
204 /* Enabling verbose error messages. */
205 #ifdef YYERROR_VERBOSE
206 # undef YYERROR_VERBOSE
207 # define YYERROR_VERBOSE 1
209 # define YYERROR_VERBOSE 0
212 /* Enabling the token table. */
213 #ifndef YYTOKEN_TABLE
214 # define YYTOKEN_TABLE 0
221 /* Put the tokens into the symbol table, so that GDB and other debuggers
238 #define tMERIDIAN 260
240 #define tMONTH_UNIT 262
241 #define tSEC_UNIT 263
249 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
250 typedef union YYSTYPE
253 /* Line 214 of yacc.c */
254 #line 125 "parsedate.y"
257 enum _MERIDIAN Meridian;
261 /* Line 214 of yacc.c */
264 # define YYSTYPE_IS_TRIVIAL 1
265 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
266 # define YYSTYPE_IS_DECLARED 1
270 /* Copy the second part of user declarations. */
273 /* Line 264 of yacc.c */
281 typedef YYTYPE_UINT8 yytype_uint8;
283 typedef unsigned char yytype_uint8;
287 typedef YYTYPE_INT8 yytype_int8;
288 #elif (defined __STDC__ || defined __C99__FUNC__ \
289 || defined __cplusplus || defined _MSC_VER)
290 typedef signed char yytype_int8;
292 typedef short int yytype_int8;
296 typedef YYTYPE_UINT16 yytype_uint16;
298 typedef unsigned short int yytype_uint16;
302 typedef YYTYPE_INT16 yytype_int16;
304 typedef short int yytype_int16;
308 # ifdef __SIZE_TYPE__
309 # define YYSIZE_T __SIZE_TYPE__
310 # elif defined size_t
311 # define YYSIZE_T size_t
312 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
313 || defined __cplusplus || defined _MSC_VER)
314 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
315 # define YYSIZE_T size_t
317 # define YYSIZE_T unsigned int
321 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
326 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
327 # define YY_(msgid) dgettext ("bison-runtime", msgid)
331 # define YY_(msgid) msgid
335 /* Suppress unused-variable warnings by "using" E. */
336 #if ! defined lint || defined __GNUC__
337 # define YYUSE(e) ((void) (e))
339 # define YYUSE(e) /* empty */
342 /* Identity function, used to suppress warnings about constant conditions. */
346 #if (defined __STDC__ || defined __C99__FUNC__ \
347 || defined __cplusplus || defined _MSC_VER)
360 #if ! defined yyoverflow || YYERROR_VERBOSE
362 /* The parser invokes alloca or malloc; define the necessary symbols. */
364 # ifdef YYSTACK_USE_ALLOCA
365 # if YYSTACK_USE_ALLOCA
367 # define YYSTACK_ALLOC __builtin_alloca
368 # elif defined __BUILTIN_VA_ARG_INCR
369 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
371 # define YYSTACK_ALLOC __alloca
372 # elif defined _MSC_VER
373 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
374 # define alloca _alloca
376 # define YYSTACK_ALLOC alloca
377 # if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
378 || defined __cplusplus || defined _MSC_VER)
379 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
388 # ifdef YYSTACK_ALLOC
389 /* Pacify GCC's `empty if-body' warning. */
390 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
391 # ifndef YYSTACK_ALLOC_MAXIMUM
392 /* The OS might guarantee only one guard page at the bottom of the stack,
393 and a page size can be as small as 4096 bytes. So we cannot safely
394 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
395 to allow for a few compiler-allocated temporary stack slots. */
396 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
399 # define YYSTACK_ALLOC YYMALLOC
400 # define YYSTACK_FREE YYFREE
401 # ifndef YYSTACK_ALLOC_MAXIMUM
402 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
404 # if (defined __cplusplus && ! defined _STDLIB_H \
405 && ! ((defined YYMALLOC || defined malloc) \
406 && (defined YYFREE || defined free)))
407 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
413 # define YYMALLOC malloc
414 # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
415 || defined __cplusplus || defined _MSC_VER)
416 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
421 # if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
422 || defined __cplusplus || defined _MSC_VER)
423 void free (void *); /* INFRINGES ON USER NAME SPACE */
427 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
430 #if (! defined yyoverflow \
431 && (! defined __cplusplus \
432 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
434 /* A type that is properly aligned for any stack member. */
437 yytype_int16 yyss_alloc;
441 /* The size of the maximum gap between one aligned stack and the next. */
442 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
444 /* The size of an array large to enough to hold all stacks, each with
446 # define YYSTACK_BYTES(N) \
447 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
448 + YYSTACK_GAP_MAXIMUM)
450 /* Copy COUNT objects from FROM to TO. The source and destination do
453 # if defined __GNUC__ && 1 < __GNUC__
454 # define YYCOPY(To, From, Count) \
455 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
457 # define YYCOPY(To, From, Count) \
461 for (yyi = 0; yyi < (Count); yyi++) \
462 (To)[yyi] = (From)[yyi]; \
468 /* Relocate STACK from its old location to the new one. The
469 local variables YYSIZE and YYSTACKSIZE give the old and new number of
470 elements in the stack, and YYPTR gives the new location of the
471 stack. Advance YYPTR to a properly aligned location for the next
473 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
476 YYSIZE_T yynewbytes; \
477 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
478 Stack = &yyptr->Stack_alloc; \
479 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
480 yyptr += yynewbytes / sizeof (*yyptr); \
486 /* YYFINAL -- State number of the termination state. */
488 /* YYLAST -- Last index in YYTABLE. */
491 /* YYNTOKENS -- Number of terminals. */
493 /* YYNNTS -- Number of nonterminals. */
495 /* YYNRULES -- Number of rules. */
497 /* YYNRULES -- Number of states. */
500 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
502 #define YYMAXUTOK 266
504 #define YYTRANSLATE(YYX) \
505 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
507 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
508 static const yytype_uint8 yytranslate[] =
510 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
511 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
512 2, 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, 14, 2, 2, 13, 2, 2,
515 2, 2, 2, 2, 2, 2, 2, 2, 12, 2,
516 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
517 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 1, 2, 3, 4,
536 5, 6, 7, 8, 9, 10, 11
540 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
542 static const yytype_uint8 yyprhs[] =
544 0, 0, 3, 4, 7, 9, 12, 14, 16, 19,
545 24, 29, 36, 43, 45, 47, 50, 52, 54, 58,
546 64, 67, 72, 75, 79, 85, 88, 91, 94, 97,
550 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
551 static const yytype_int8 yyrhs[] =
553 16, 0, -1, -1, 16, 17, -1, 18, -1, 18,
554 19, -1, 21, -1, 22, -1, 10, 23, -1, 10,
555 12, 10, 23, -1, 10, 12, 10, 20, -1, 10,
556 12, 10, 12, 10, 23, -1, 10, 12, 10, 12,
557 10, 20, -1, 11, -1, 4, -1, 11, 20, -1,
558 20, -1, 9, -1, 10, 13, 10, -1, 10, 13,
559 10, 13, 10, -1, 6, 10, -1, 6, 10, 14,
560 10, -1, 10, 6, -1, 10, 6, 10, -1, 3,
561 14, 10, 6, 10, -1, 9, 8, -1, 10, 8,
562 -1, 9, 7, -1, 10, 7, -1, -1, 5, -1
565 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
566 static const yytype_uint16 yyrline[] =
568 0, 139, 139, 140, 143, 152, 156, 159, 164, 176,
569 182, 189, 195, 205, 209, 213, 221, 227, 248, 252,
570 264, 268, 273, 277, 282, 289, 292, 295, 298, 303,
575 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
576 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
577 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
578 static const char *const yytname[] =
580 "$end", "error", "$undefined", "tDAY", "tDAYZONE", "tMERIDIAN",
581 "tMONTH", "tMONTH_UNIT", "tSEC_UNIT", "tSNUMBER", "tUNUMBER", "tZONE",
582 "':'", "'/'", "','", "$accept", "spec", "item", "time", "zone",
583 "numzone", "date", "rel", "o_merid", 0
588 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
590 static const yytype_uint16 yytoknum[] =
592 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
597 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
598 static const yytype_uint8 yyr1[] =
600 0, 15, 16, 16, 17, 17, 17, 17, 18, 18,
601 18, 18, 18, 19, 19, 19, 19, 20, 21, 21,
602 21, 21, 21, 21, 21, 22, 22, 22, 22, 23,
606 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
607 static const yytype_uint8 yyr2[] =
609 0, 2, 0, 2, 1, 2, 1, 1, 2, 4,
610 4, 6, 6, 1, 1, 2, 1, 1, 3, 5,
611 2, 4, 2, 3, 5, 2, 2, 2, 2, 0,
615 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
616 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
617 means the default is an error. */
618 static const yytype_uint8 yydefact[] =
620 2, 0, 1, 0, 0, 0, 29, 3, 4, 6,
621 7, 0, 20, 27, 25, 30, 22, 28, 26, 0,
622 0, 8, 14, 17, 13, 5, 16, 0, 0, 23,
623 29, 18, 15, 0, 21, 0, 10, 9, 0, 24,
627 /* YYDEFGOTO[NTERM-NUM]. */
628 static const yytype_int8 yydefgoto[] =
630 -1, 1, 7, 8, 25, 26, 9, 10, 21
633 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
635 #define YYPACT_NINF -29
636 static const yytype_int8 yypact[] =
638 -29, 1, -29, -11, 11, 20, 12, -29, 4, -29,
639 -29, 13, 16, -29, -29, -29, 21, -29, -29, 22,
640 23, -29, -29, -29, 5, -29, -29, 28, 25, -29,
641 17, 24, -29, 26, -29, 29, -29, -29, 30, -29,
645 /* YYPGOTO[NTERM-NUM]. */
646 static const yytype_int8 yypgoto[] =
648 -29, -29, -29, -29, -29, -24, -29, -29, -28
651 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
652 positive, shift that token. If negative, reduce the rule which
653 number is the opposite. If zero, do what YYDEFACT says.
654 If YYTABLE_NINF, syntax error. */
655 #define YYTABLE_NINF -1
656 static const yytype_uint8 yytable[] =
658 32, 2, 37, 11, 3, 15, 36, 4, 22, 23,
659 5, 6, 43, 23, 23, 24, 42, 15, 16, 17,
660 18, 12, 15, 27, 19, 20, 23, 13, 14, 35,
661 28, 29, 30, 31, 33, 34, 39, 38, 0, 40,
665 static const yytype_int8 yycheck[] =
667 24, 0, 30, 14, 3, 5, 30, 6, 4, 9,
668 9, 10, 40, 9, 9, 11, 40, 5, 6, 7,
669 8, 10, 5, 10, 12, 13, 9, 7, 8, 12,
670 14, 10, 10, 10, 6, 10, 10, 13, -1, 10,
674 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
675 symbol of state STATE-NUM. */
676 static const yytype_uint8 yystos[] =
678 0, 16, 0, 3, 6, 9, 10, 17, 18, 21,
679 22, 14, 10, 7, 8, 5, 6, 7, 8, 12,
680 13, 23, 4, 9, 11, 19, 20, 10, 14, 10,
681 10, 10, 20, 6, 10, 12, 20, 23, 13, 10,
685 #define yyerrok (yyerrstatus = 0)
686 #define yyclearin (yychar = YYEMPTY)
690 #define YYACCEPT goto yyacceptlab
691 #define YYABORT goto yyabortlab
692 #define YYERROR goto yyerrorlab
695 /* Like YYERROR except do call yyerror. This remains here temporarily
696 to ease the transition to the new meaning of YYERROR, for GCC.
697 Once GCC version 2 has supplanted version 1, this can go. */
699 #define YYFAIL goto yyerrlab
701 #define YYRECOVERING() (!!yyerrstatus)
703 #define YYBACKUP(Token, Value) \
705 if (yychar == YYEMPTY && yylen == 1) \
709 yytoken = YYTRANSLATE (yychar); \
715 yyerror (YY_("syntax error: cannot back up")); \
722 #define YYERRCODE 256
725 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
726 If N is 0, then set CURRENT to the empty location which ends
727 the previous symbol: RHS[0] (always defined). */
729 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
730 #ifndef YYLLOC_DEFAULT
731 # define YYLLOC_DEFAULT(Current, Rhs, N) \
735 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
736 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
737 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
738 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
742 (Current).first_line = (Current).last_line = \
743 YYRHSLOC (Rhs, 0).last_line; \
744 (Current).first_column = (Current).last_column = \
745 YYRHSLOC (Rhs, 0).last_column; \
751 /* YY_LOCATION_PRINT -- Print the location on the stream.
752 This macro was not mandated originally: define only if we know
753 we won't break user code: when these are the locations we know. */
755 #ifndef YY_LOCATION_PRINT
756 # if YYLTYPE_IS_TRIVIAL
757 # define YY_LOCATION_PRINT(File, Loc) \
758 fprintf (File, "%d.%d-%d.%d", \
759 (Loc).first_line, (Loc).first_column, \
760 (Loc).last_line, (Loc).last_column)
762 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
767 /* YYLEX -- calling `yylex' with the right arguments. */
770 # define YYLEX yylex (YYLEX_PARAM)
772 # define YYLEX yylex ()
775 /* Enable debugging if requested. */
779 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
780 # define YYFPRINTF fprintf
783 # define YYDPRINTF(Args) \
789 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
793 YYFPRINTF (stderr, "%s ", Title); \
794 yy_symbol_print (stderr, \
796 YYFPRINTF (stderr, "\n"); \
801 /*--------------------------------.
802 | Print this symbol on YYOUTPUT. |
803 `--------------------------------*/
806 #if (defined __STDC__ || defined __C99__FUNC__ \
807 || defined __cplusplus || defined _MSC_VER)
809 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
812 yy_symbol_value_print (yyoutput, yytype, yyvaluep)
815 YYSTYPE const * const yyvaluep;
821 if (yytype < YYNTOKENS)
822 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
834 /*--------------------------------.
835 | Print this symbol on YYOUTPUT. |
836 `--------------------------------*/
838 #if (defined __STDC__ || defined __C99__FUNC__ \
839 || defined __cplusplus || defined _MSC_VER)
841 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
844 yy_symbol_print (yyoutput, yytype, yyvaluep)
847 YYSTYPE const * const yyvaluep;
850 if (yytype < YYNTOKENS)
851 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
853 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
855 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
856 YYFPRINTF (yyoutput, ")");
859 /*------------------------------------------------------------------.
860 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
862 `------------------------------------------------------------------*/
864 #if (defined __STDC__ || defined __C99__FUNC__ \
865 || defined __cplusplus || defined _MSC_VER)
867 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
870 yy_stack_print (yybottom, yytop)
871 yytype_int16 *yybottom;
875 YYFPRINTF (stderr, "Stack now");
876 for (; yybottom <= yytop; yybottom++)
878 int yybot = *yybottom;
879 YYFPRINTF (stderr, " %d", yybot);
881 YYFPRINTF (stderr, "\n");
884 # define YY_STACK_PRINT(Bottom, Top) \
887 yy_stack_print ((Bottom), (Top)); \
891 /*------------------------------------------------.
892 | Report that the YYRULE is going to be reduced. |
893 `------------------------------------------------*/
895 #if (defined __STDC__ || defined __C99__FUNC__ \
896 || defined __cplusplus || defined _MSC_VER)
898 yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
901 yy_reduce_print (yyvsp, yyrule)
906 int yynrhs = yyr2[yyrule];
908 unsigned long int yylno = yyrline[yyrule];
909 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
911 /* The symbols being reduced. */
912 for (yyi = 0; yyi < yynrhs; yyi++)
914 YYFPRINTF (stderr, " $%d = ", yyi + 1);
915 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
916 &(yyvsp[(yyi + 1) - (yynrhs)])
918 YYFPRINTF (stderr, "\n");
922 # define YY_REDUCE_PRINT(Rule) \
925 yy_reduce_print (yyvsp, Rule); \
928 /* Nonzero means print parse trace. It is left uninitialized so that
929 multiple parsers can coexist. */
932 # define YYDPRINTF(Args)
933 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
934 # define YY_STACK_PRINT(Bottom, Top)
935 # define YY_REDUCE_PRINT(Rule)
936 #endif /* !YYDEBUG */
939 /* YYINITDEPTH -- initial size of the parser's stacks. */
941 # define YYINITDEPTH 200
944 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
945 if the built-in stack extension method is used).
947 Do not make this value too large; the results are undefined if
948 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
949 evaluated with infinite-precision integer arithmetic. */
952 # define YYMAXDEPTH 10000
960 # if defined __GLIBC__ && defined _STRING_H
961 # define yystrlen strlen
963 /* Return the length of YYSTR. */
964 #if (defined __STDC__ || defined __C99__FUNC__ \
965 || defined __cplusplus || defined _MSC_VER)
967 yystrlen (const char *yystr)
975 for (yylen = 0; yystr[yylen]; yylen++)
983 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
984 # define yystpcpy stpcpy
986 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
988 #if (defined __STDC__ || defined __C99__FUNC__ \
989 || defined __cplusplus || defined _MSC_VER)
991 yystpcpy (char *yydest, const char *yysrc)
994 yystpcpy (yydest, yysrc)
1000 const char *yys = yysrc;
1002 while ((*yyd++ = *yys++) != '\0')
1011 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1012 quotes and backslashes, so that it's suitable for yyerror. The
1013 heuristic is that double-quoting is unnecessary unless the string
1014 contains an apostrophe, a comma, or backslash (other than
1015 backslash-backslash). YYSTR is taken from yytname. If YYRES is
1016 null, do not copy; instead, return the length of what the result
1019 yytnamerr (char *yyres, const char *yystr)
1024 char const *yyp = yystr;
1031 goto do_not_strip_quotes;
1035 goto do_not_strip_quotes;
1048 do_not_strip_quotes: ;
1052 return yystrlen (yystr);
1054 return yystpcpy (yyres, yystr) - yyres;
1058 /* Copy into YYRESULT an error message about the unexpected token
1059 YYCHAR while in state YYSTATE. Return the number of bytes copied,
1060 including the terminating null byte. If YYRESULT is null, do not
1061 copy anything; just return the number of bytes that would be
1062 copied. As a special case, return 0 if an ordinary "syntax error"
1063 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
1064 size calculation. */
1066 yysyntax_error (char *yyresult, int yystate, int yychar)
1068 int yyn = yypact[yystate];
1070 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
1074 int yytype = YYTRANSLATE (yychar);
1075 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
1076 YYSIZE_T yysize = yysize0;
1078 int yysize_overflow = 0;
1079 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1080 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1084 /* This is so xgettext sees the translatable formats that are
1085 constructed on the fly. */
1086 YY_("syntax error, unexpected %s");
1087 YY_("syntax error, unexpected %s, expecting %s");
1088 YY_("syntax error, unexpected %s, expecting %s or %s");
1089 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
1090 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
1094 static char const yyunexpected[] = "syntax error, unexpected %s";
1095 static char const yyexpecting[] = ", expecting %s";
1096 static char const yyor[] = " or %s";
1097 char yyformat[sizeof yyunexpected
1098 + sizeof yyexpecting - 1
1099 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
1100 * (sizeof yyor - 1))];
1101 char const *yyprefix = yyexpecting;
1103 /* Start YYX at -YYN if negative to avoid negative indexes in
1105 int yyxbegin = yyn < 0 ? -yyn : 0;
1107 /* Stay within bounds of both yycheck and yytname. */
1108 int yychecklim = YYLAST - yyn + 1;
1109 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1112 yyarg[0] = yytname[yytype];
1113 yyfmt = yystpcpy (yyformat, yyunexpected);
1115 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1116 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1118 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1122 yyformat[sizeof yyunexpected - 1] = '\0';
1125 yyarg[yycount++] = yytname[yyx];
1126 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1127 yysize_overflow |= (yysize1 < yysize);
1129 yyfmt = yystpcpy (yyfmt, yyprefix);
1133 yyf = YY_(yyformat);
1134 yysize1 = yysize + yystrlen (yyf);
1135 yysize_overflow |= (yysize1 < yysize);
1138 if (yysize_overflow)
1139 return YYSIZE_MAXIMUM;
1143 /* Avoid sprintf, as that infringes on the user's name space.
1144 Don't have undefined behavior even if the translation
1145 produced a string with the wrong number of "%s"s. */
1146 char *yyp = yyresult;
1148 while ((*yyp = *yyf) != '\0')
1150 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
1152 yyp += yytnamerr (yyp, yyarg[yyi++]);
1165 #endif /* YYERROR_VERBOSE */
1168 /*-----------------------------------------------.
1169 | Release the memory associated to this symbol. |
1170 `-----------------------------------------------*/
1173 #if (defined __STDC__ || defined __C99__FUNC__ \
1174 || defined __cplusplus || defined _MSC_VER)
1176 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1179 yydestruct (yymsg, yytype, yyvaluep)
1189 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1199 /* Prevent warnings from -Wmissing-prototypes. */
1200 #ifdef YYPARSE_PARAM
1201 #if defined __STDC__ || defined __cplusplus
1202 int yyparse (void *YYPARSE_PARAM);
1206 #else /* ! YYPARSE_PARAM */
1207 #if defined __STDC__ || defined __cplusplus
1212 #endif /* ! YYPARSE_PARAM */
1215 /* The lookahead symbol. */
1218 /* The semantic value of the lookahead symbol. */
1221 /* Number of syntax errors so far. */
1226 /*-------------------------.
1227 | yyparse or yypush_parse. |
1228 `-------------------------*/
1230 #ifdef YYPARSE_PARAM
1231 #if (defined __STDC__ || defined __C99__FUNC__ \
1232 || defined __cplusplus || defined _MSC_VER)
1234 yyparse (void *YYPARSE_PARAM)
1237 yyparse (YYPARSE_PARAM)
1238 void *YYPARSE_PARAM;
1240 #else /* ! YYPARSE_PARAM */
1241 #if (defined __STDC__ || defined __C99__FUNC__ \
1242 || defined __cplusplus || defined _MSC_VER)
1255 /* Number of tokens to shift before error messages enabled. */
1258 /* The stacks and their tools:
1259 `yyss': related to states.
1260 `yyvs': related to semantic values.
1262 Refer to the stacks thru separate pointers, to allow yyoverflow
1263 to reallocate them elsewhere. */
1265 /* The state stack. */
1266 yytype_int16 yyssa[YYINITDEPTH];
1268 yytype_int16 *yyssp;
1270 /* The semantic value stack. */
1271 YYSTYPE yyvsa[YYINITDEPTH];
1275 YYSIZE_T yystacksize;
1279 /* Lookahead token as an internal (translated) token number. */
1281 /* The variables used to return semantic value and location from the
1286 /* Buffer for error messages, and its allocated size. */
1288 char *yymsg = yymsgbuf;
1289 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1292 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1294 /* The number of symbols on the RHS of the reduced rule.
1295 Keep to zero when no symbol should be popped. */
1301 yystacksize = YYINITDEPTH;
1303 YYDPRINTF ((stderr, "Starting parse\n"));
1308 yychar = YYEMPTY; /* Cause a token to be read. */
1310 /* Initialize stack pointers.
1311 Waste one element of value and location stack
1312 so that they stay on the same level as the state stack.
1313 The wasted elements are never initialized. */
1319 /*------------------------------------------------------------.
1320 | yynewstate -- Push a new state, which is found in yystate. |
1321 `------------------------------------------------------------*/
1323 /* In all cases, when you get here, the value and location stacks
1324 have just been pushed. So pushing a state here evens the stacks. */
1330 if (yyss + yystacksize - 1 <= yyssp)
1332 /* Get the current used size of the three stacks, in elements. */
1333 YYSIZE_T yysize = yyssp - yyss + 1;
1337 /* Give user a chance to reallocate the stack. Use copies of
1338 these so that the &'s don't force the real ones into
1340 YYSTYPE *yyvs1 = yyvs;
1341 yytype_int16 *yyss1 = yyss;
1343 /* Each stack pointer address is followed by the size of the
1344 data in use in that stack, in bytes. This used to be a
1345 conditional around just the two extra args, but that might
1346 be undefined if yyoverflow is a macro. */
1347 yyoverflow (YY_("memory exhausted"),
1348 &yyss1, yysize * sizeof (*yyssp),
1349 &yyvs1, yysize * sizeof (*yyvsp),
1355 #else /* no yyoverflow */
1356 # ifndef YYSTACK_RELOCATE
1357 goto yyexhaustedlab;
1359 /* Extend the stack our own way. */
1360 if (YYMAXDEPTH <= yystacksize)
1361 goto yyexhaustedlab;
1363 if (YYMAXDEPTH < yystacksize)
1364 yystacksize = YYMAXDEPTH;
1367 yytype_int16 *yyss1 = yyss;
1368 union yyalloc *yyptr =
1369 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1371 goto yyexhaustedlab;
1372 YYSTACK_RELOCATE (yyss_alloc, yyss);
1373 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1374 # undef YYSTACK_RELOCATE
1376 YYSTACK_FREE (yyss1);
1379 #endif /* no yyoverflow */
1381 yyssp = yyss + yysize - 1;
1382 yyvsp = yyvs + yysize - 1;
1384 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1385 (unsigned long int) yystacksize));
1387 if (yyss + yystacksize - 1 <= yyssp)
1391 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1393 if (yystate == YYFINAL)
1403 /* Do appropriate processing given the current state. Read a
1404 lookahead token if we need one and don't already have one. */
1406 /* First try to decide what to do without reference to lookahead token. */
1407 yyn = yypact[yystate];
1408 if (yyn == YYPACT_NINF)
1411 /* Not known => get a lookahead token if don't already have one. */
1413 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1414 if (yychar == YYEMPTY)
1416 YYDPRINTF ((stderr, "Reading a token: "));
1420 if (yychar <= YYEOF)
1422 yychar = yytoken = YYEOF;
1423 YYDPRINTF ((stderr, "Now at end of input.\n"));
1427 yytoken = YYTRANSLATE (yychar);
1428 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1431 /* If the proper action on seeing token YYTOKEN is to reduce or to
1432 detect an error, take that action. */
1434 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1439 if (yyn == 0 || yyn == YYTABLE_NINF)
1445 /* Count tokens shifted since error; after three, turn off error
1450 /* Shift the lookahead token. */
1451 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1453 /* Discard the shifted token. */
1462 /*-----------------------------------------------------------.
1463 | yydefault -- do the default action for the current state. |
1464 `-----------------------------------------------------------*/
1466 yyn = yydefact[yystate];
1472 /*-----------------------------.
1473 | yyreduce -- Do a reduction. |
1474 `-----------------------------*/
1476 /* yyn is the number of a rule to reduce with. */
1479 /* If YYLEN is nonzero, implement the default value of the action:
1482 Otherwise, the following line sets YYVAL to garbage.
1483 This behavior is undocumented and Bison
1484 users should not rely upon it. Assigning to YYVAL
1485 unconditionally makes the parser a bit smaller, and it avoids a
1486 GCC warning that YYVAL may be used uninitialized. */
1487 yyval = yyvsp[1-yylen];
1490 YY_REDUCE_PRINT (yyn);
1495 /* Line 1455 of yacc.c */
1496 #line 143 "parsedate.y"
1500 /* I am compulsive about lint natterings... */
1501 if (yyHaveTime == -1) {
1510 /* Line 1455 of yacc.c */
1511 #line 152 "parsedate.y"
1514 yyTimezone = (yyvsp[(2) - (2)].Number);
1520 /* Line 1455 of yacc.c */
1521 #line 156 "parsedate.y"
1529 /* Line 1455 of yacc.c */
1530 #line 159 "parsedate.y"
1538 /* Line 1455 of yacc.c */
1539 #line 164 "parsedate.y"
1541 if ((yyvsp[(1) - (2)].Number) < 100) {
1542 yyHour = (yyvsp[(1) - (2)].Number);
1546 yyHour = (yyvsp[(1) - (2)].Number) / 100;
1547 yyMinutes = (yyvsp[(1) - (2)].Number) % 100;
1550 yyMeridian = (yyvsp[(2) - (2)].Meridian);
1556 /* Line 1455 of yacc.c */
1557 #line 176 "parsedate.y"
1559 yyHour = (yyvsp[(1) - (4)].Number);
1560 yyMinutes = (yyvsp[(3) - (4)].Number);
1562 yyMeridian = (yyvsp[(4) - (4)].Meridian);
1568 /* Line 1455 of yacc.c */
1569 #line 182 "parsedate.y"
1571 yyHour = (yyvsp[(1) - (4)].Number);
1572 yyMinutes = (yyvsp[(3) - (4)].Number);
1573 yyTimezone = (yyvsp[(4) - (4)].Number);
1581 /* Line 1455 of yacc.c */
1582 #line 189 "parsedate.y"
1584 yyHour = (yyvsp[(1) - (6)].Number);
1585 yyMinutes = (yyvsp[(3) - (6)].Number);
1586 yySeconds = (yyvsp[(5) - (6)].Number);
1587 yyMeridian = (yyvsp[(6) - (6)].Meridian);
1593 /* Line 1455 of yacc.c */
1594 #line 195 "parsedate.y"
1596 yyHour = (yyvsp[(1) - (6)].Number);
1597 yyMinutes = (yyvsp[(3) - (6)].Number);
1598 yySeconds = (yyvsp[(5) - (6)].Number);
1599 yyTimezone = (yyvsp[(6) - (6)].Number);
1607 /* Line 1455 of yacc.c */
1608 #line 205 "parsedate.y"
1610 (yyval.Number) = (yyvsp[(1) - (1)].Number);
1617 /* Line 1455 of yacc.c */
1618 #line 209 "parsedate.y"
1620 (yyval.Number) = (yyvsp[(1) - (1)].Number);
1627 /* Line 1455 of yacc.c */
1628 #line 213 "parsedate.y"
1630 /* Only allow "GMT+300" and "GMT-0800" */
1631 if ((yyvsp[(1) - (2)].Number) != 0) {
1634 (yyval.Number) = (yyvsp[(2) - (2)].Number);
1641 /* Line 1455 of yacc.c */
1642 #line 221 "parsedate.y"
1644 (yyval.Number) = (yyvsp[(1) - (1)].Number);
1651 /* Line 1455 of yacc.c */
1652 #line 227 "parsedate.y"
1656 /* Unix and GMT and numeric timezones -- a little confusing. */
1657 if ((yyvsp[(1) - (1)].Number) < 0) {
1658 /* Don't work with negative modulus. */
1659 (yyvsp[(1) - (1)].Number) = -(yyvsp[(1) - (1)].Number);
1660 if ((yyvsp[(1) - (1)].Number) > 9999 || (i = (yyvsp[(1) - (1)].Number) % 100) >= 60) {
1663 (yyval.Number) = ((yyvsp[(1) - (1)].Number) / 100) * 60 + i;
1666 if ((yyvsp[(1) - (1)].Number) > 9999 || (i = (yyvsp[(1) - (1)].Number) % 100) >= 60) {
1669 (yyval.Number) = -(((yyvsp[(1) - (1)].Number) / 100) * 60 + i);
1676 /* Line 1455 of yacc.c */
1677 #line 248 "parsedate.y"
1679 yyMonth = (yyvsp[(1) - (3)].Number);
1680 yyDay = (yyvsp[(3) - (3)].Number);
1686 /* Line 1455 of yacc.c */
1687 #line 252 "parsedate.y"
1689 if ((yyvsp[(1) - (5)].Number) > 100) {
1690 yyYear = (yyvsp[(1) - (5)].Number);
1691 yyMonth = (yyvsp[(3) - (5)].Number);
1692 yyDay = (yyvsp[(5) - (5)].Number);
1695 yyMonth = (yyvsp[(1) - (5)].Number);
1696 yyDay = (yyvsp[(3) - (5)].Number);
1697 yyYear = (yyvsp[(5) - (5)].Number);
1704 /* Line 1455 of yacc.c */
1705 #line 264 "parsedate.y"
1707 yyMonth = (yyvsp[(1) - (2)].Number);
1708 yyDay = (yyvsp[(2) - (2)].Number);
1714 /* Line 1455 of yacc.c */
1715 #line 268 "parsedate.y"
1717 yyMonth = (yyvsp[(1) - (4)].Number);
1718 yyDay = (yyvsp[(2) - (4)].Number);
1719 yyYear = (yyvsp[(4) - (4)].Number);
1725 /* Line 1455 of yacc.c */
1726 #line 273 "parsedate.y"
1728 yyDay = (yyvsp[(1) - (2)].Number);
1729 yyMonth = (yyvsp[(2) - (2)].Number);
1735 /* Line 1455 of yacc.c */
1736 #line 277 "parsedate.y"
1738 yyDay = (yyvsp[(1) - (3)].Number);
1739 yyMonth = (yyvsp[(2) - (3)].Number);
1740 yyYear = (yyvsp[(3) - (3)].Number);
1746 /* Line 1455 of yacc.c */
1747 #line 282 "parsedate.y"
1749 yyDay = (yyvsp[(3) - (5)].Number);
1750 yyMonth = (yyvsp[(4) - (5)].Number);
1751 yyYear = (yyvsp[(5) - (5)].Number);
1757 /* Line 1455 of yacc.c */
1758 #line 289 "parsedate.y"
1760 yyRelSeconds += (yyvsp[(1) - (2)].Number) * (yyvsp[(2) - (2)].Number);
1766 /* Line 1455 of yacc.c */
1767 #line 292 "parsedate.y"
1769 yyRelSeconds += (yyvsp[(1) - (2)].Number) * (yyvsp[(2) - (2)].Number);
1775 /* Line 1455 of yacc.c */
1776 #line 295 "parsedate.y"
1778 yyRelMonth += (yyvsp[(1) - (2)].Number) * (yyvsp[(2) - (2)].Number);
1784 /* Line 1455 of yacc.c */
1785 #line 298 "parsedate.y"
1787 yyRelMonth += (yyvsp[(1) - (2)].Number) * (yyvsp[(2) - (2)].Number);
1793 /* Line 1455 of yacc.c */
1794 #line 303 "parsedate.y"
1796 (yyval.Meridian) = MER24;
1802 /* Line 1455 of yacc.c */
1803 #line 306 "parsedate.y"
1805 (yyval.Meridian) = (yyvsp[(1) - (1)].Meridian);
1811 /* Line 1455 of yacc.c */
1812 #line 1813 "y.tab.c"
1815 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1819 YY_STACK_PRINT (yyss, yyssp);
1823 /* Now `shift' the result of the reduction. Determine what state
1824 that goes to, based on the state we popped back to and the rule
1825 number reduced by. */
1829 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1830 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1831 yystate = yytable[yystate];
1833 yystate = yydefgoto[yyn - YYNTOKENS];
1838 /*------------------------------------.
1839 | yyerrlab -- here on detecting error |
1840 `------------------------------------*/
1842 /* If not already recovering from an error, report this error. */
1846 #if ! YYERROR_VERBOSE
1847 yyerror (YY_("syntax error"));
1850 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
1851 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
1853 YYSIZE_T yyalloc = 2 * yysize;
1854 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
1855 yyalloc = YYSTACK_ALLOC_MAXIMUM;
1856 if (yymsg != yymsgbuf)
1857 YYSTACK_FREE (yymsg);
1858 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
1860 yymsg_alloc = yyalloc;
1864 yymsg_alloc = sizeof yymsgbuf;
1868 if (0 < yysize && yysize <= yymsg_alloc)
1870 (void) yysyntax_error (yymsg, yystate, yychar);
1875 yyerror (YY_("syntax error"));
1877 goto yyexhaustedlab;
1885 if (yyerrstatus == 3)
1887 /* If just tried and failed to reuse lookahead token after an
1888 error, discard it. */
1890 if (yychar <= YYEOF)
1892 /* Return failure if at end of input. */
1893 if (yychar == YYEOF)
1898 yydestruct ("Error: discarding",
1904 /* Else will try to reuse lookahead token after shifting the error
1909 /*---------------------------------------------------.
1910 | yyerrorlab -- error raised explicitly by YYERROR. |
1911 `---------------------------------------------------*/
1914 /* Pacify compilers like GCC when the user code never invokes
1915 YYERROR and the label yyerrorlab therefore never appears in user
1917 if (/*CONSTCOND*/ 0)
1920 /* Do not reclaim the symbols of the rule which action triggered
1924 YY_STACK_PRINT (yyss, yyssp);
1929 /*-------------------------------------------------------------.
1930 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1931 `-------------------------------------------------------------*/
1933 yyerrstatus = 3; /* Each real token shifted decrements this. */
1937 yyn = yypact[yystate];
1938 if (yyn != YYPACT_NINF)
1941 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1949 /* Pop the current state because it cannot handle the error token. */
1954 yydestruct ("Error: popping",
1955 yystos[yystate], yyvsp);
1958 YY_STACK_PRINT (yyss, yyssp);
1964 /* Shift the error token. */
1965 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1971 /*-------------------------------------.
1972 | yyacceptlab -- YYACCEPT comes here. |
1973 `-------------------------------------*/
1978 /*-----------------------------------.
1979 | yyabortlab -- YYABORT comes here. |
1980 `-----------------------------------*/
1985 #if !defined(yyoverflow) || YYERROR_VERBOSE
1986 /*-------------------------------------------------.
1987 | yyexhaustedlab -- memory exhaustion comes here. |
1988 `-------------------------------------------------*/
1990 yyerror (YY_("memory exhausted"));
1996 if (yychar != YYEMPTY)
1997 yydestruct ("Cleanup: discarding lookahead",
1999 /* Do not reclaim the symbols of the rule which action triggered
2000 this YYABORT or YYACCEPT. */
2002 YY_STACK_PRINT (yyss, yyssp);
2003 while (yyssp != yyss)
2005 yydestruct ("Cleanup: popping",
2006 yystos[*yyssp], yyvsp);
2011 YYSTACK_FREE (yyss);
2014 if (yymsg != yymsgbuf)
2015 YYSTACK_FREE (yymsg);
2017 /* Make sure YYID is used. */
2018 return YYID (yyresult);
2023 /* Line 1675 of yacc.c */
2024 #line 311 "parsedate.y"
2027 /* Month and day table. */
2028 static TABLE MonthDayTable[] = {
2029 { "january", tMONTH, 1 },
2030 { "february", tMONTH, 2 },
2031 { "march", tMONTH, 3 },
2032 { "april", tMONTH, 4 },
2033 { "may", tMONTH, 5 },
2034 { "june", tMONTH, 6 },
2035 { "july", tMONTH, 7 },
2036 { "august", tMONTH, 8 },
2037 { "september", tMONTH, 9 },
2038 { "october", tMONTH, 10 },
2039 { "november", tMONTH, 11 },
2040 { "december", tMONTH, 12 },
2041 /* The value of the day isn't used... */
2042 { "sunday", tDAY, 0 },
2043 { "monday", tDAY, 0 },
2044 { "tuesday", tDAY, 0 },
2045 { "wednesday", tDAY, 0 },
2046 { "thursday", tDAY, 0 },
2047 { "friday", tDAY, 0 },
2048 { "saturday", tDAY, 0 },
2051 /* Time units table. */
2052 static TABLE UnitsTable[] = {
2053 { "year", tMONTH_UNIT, 12 },
2054 { "month", tMONTH_UNIT, 1 },
2055 { "week", tSEC_UNIT, 7L * 24 * 60 * 60 },
2056 { "day", tSEC_UNIT, 1L * 24 * 60 * 60 },
2057 { "hour", tSEC_UNIT, 60 * 60 },
2058 { "minute", tSEC_UNIT, 60 },
2059 { "min", tSEC_UNIT, 60 },
2060 { "second", tSEC_UNIT, 1 },
2061 { "sec", tSEC_UNIT, 1 },
2064 /* Timezone table. */
2065 static TABLE TimezoneTable[] = {
2066 { "gmt", tZONE, HOUR( 0) }, /* Greenwich Mean */
2067 { "ut", tZONE, HOUR( 0) }, /* Universal */
2068 { "utc", tZONE, HOUR( 0) }, /* Universal Coordinated */
2069 { "cut", tZONE, HOUR( 0) }, /* Coordinated Universal */
2070 { "z", tZONE, HOUR( 0) }, /* Greenwich Mean */
2071 { "wet", tZONE, HOUR( 0) }, /* Western European */
2072 { "bst", tDAYZONE, HOUR( 0) }, /* British Summer */
2073 { "nst", tZONE, HOUR(3)+30 }, /* Newfoundland Standard */
2074 { "ndt", tDAYZONE, HOUR(3)+30 }, /* Newfoundland Daylight */
2075 { "ast", tZONE, HOUR( 4) }, /* Atlantic Standard */
2076 { "adt", tDAYZONE, HOUR( 4) }, /* Atlantic Daylight */
2077 { "est", tZONE, HOUR( 5) }, /* Eastern Standard */
2078 { "edt", tDAYZONE, HOUR( 5) }, /* Eastern Daylight */
2079 { "cst", tZONE, HOUR( 6) }, /* Central Standard */
2080 { "cdt", tDAYZONE, HOUR( 6) }, /* Central Daylight */
2081 { "mst", tZONE, HOUR( 7) }, /* Mountain Standard */
2082 { "mdt", tDAYZONE, HOUR( 7) }, /* Mountain Daylight */
2083 { "pst", tZONE, HOUR( 8) }, /* Pacific Standard */
2084 { "pdt", tDAYZONE, HOUR( 8) }, /* Pacific Daylight */
2085 { "yst", tZONE, HOUR( 9) }, /* Yukon Standard */
2086 { "ydt", tDAYZONE, HOUR( 9) }, /* Yukon Daylight */
2087 { "akst", tZONE, HOUR( 9) }, /* Alaska Standard */
2088 { "akdt", tDAYZONE, HOUR( 9) }, /* Alaska Daylight */
2089 { "hst", tZONE, HOUR(10) }, /* Hawaii Standard */
2090 { "hast", tZONE, HOUR(10) }, /* Hawaii-Aleutian Standard */
2091 { "hadt", tDAYZONE, HOUR(10) }, /* Hawaii-Aleutian Daylight */
2092 { "ces", tDAYZONE, -HOUR(1) }, /* Central European Summer */
2093 { "cest", tDAYZONE, -HOUR(1) }, /* Central European Summer */
2094 { "mez", tZONE, -HOUR(1) }, /* Middle European */
2095 { "mezt", tDAYZONE, -HOUR(1) }, /* Middle European Summer */
2096 { "cet", tZONE, -HOUR(1) }, /* Central European */
2097 { "met", tZONE, -HOUR(1) }, /* Middle European */
2098 { "eet", tZONE, -HOUR(2) }, /* Eastern Europe */
2099 { "msk", tZONE, -HOUR(3) }, /* Moscow Winter */
2100 { "msd", tDAYZONE, -HOUR(3) }, /* Moscow Summer */
2101 { "wast", tZONE, -HOUR(8) }, /* West Australian Standard */
2102 { "wadt", tDAYZONE, -HOUR(8) }, /* West Australian Daylight */
2103 { "hkt", tZONE, -HOUR(8) }, /* Hong Kong */
2104 { "cct", tZONE, -HOUR(8) }, /* China Coast */
2105 { "jst", tZONE, -HOUR(9) }, /* Japan Standard */
2106 { "kst", tZONE, -HOUR(9) }, /* Korean Standard */
2107 { "kdt", tZONE, -HOUR(9) }, /* Korean Daylight */
2108 { "cast", tZONE, -(HOUR(9)+30) }, /* Central Australian Standard */
2109 { "cadt", tDAYZONE, -(HOUR(9)+30) }, /* Central Australian Daylight */
2110 { "east", tZONE, -HOUR(10) }, /* Eastern Australian Standard */
2111 { "eadt", tDAYZONE, -HOUR(10) }, /* Eastern Australian Daylight */
2112 { "nzst", tZONE, -HOUR(12) }, /* New Zealand Standard */
2113 { "nzdt", tDAYZONE, -HOUR(12) }, /* New Zealand Daylight */
2115 /* For completeness we include the following entries. */
2118 /* Duplicate names. Either they conflict with a zone listed above
2119 * (which is either more likely to be seen or just been in circulation
2120 * longer), or they conflict with another zone in this section and
2121 * we could not reasonably choose one over the other. */
2122 { "fst", tZONE, HOUR( 2) }, /* Fernando De Noronha Standard */
2123 { "fdt", tDAYZONE, HOUR( 2) }, /* Fernando De Noronha Daylight */
2124 { "bst", tZONE, HOUR( 3) }, /* Brazil Standard */
2125 { "est", tZONE, HOUR( 3) }, /* Eastern Standard (Brazil) */
2126 { "edt", tDAYZONE, HOUR( 3) }, /* Eastern Daylight (Brazil) */
2127 { "wst", tZONE, HOUR( 4) }, /* Western Standard (Brazil) */
2128 { "wdt", tDAYZONE, HOUR( 4) }, /* Western Daylight (Brazil) */
2129 { "cst", tZONE, HOUR( 5) }, /* Chile Standard */
2130 { "cdt", tDAYZONE, HOUR( 5) }, /* Chile Daylight */
2131 { "ast", tZONE, HOUR( 5) }, /* Acre Standard */
2132 { "adt", tDAYZONE, HOUR( 5) }, /* Acre Daylight */
2133 { "cst", tZONE, HOUR( 5) }, /* Cuba Standard */
2134 { "cdt", tDAYZONE, HOUR( 5) }, /* Cuba Daylight */
2135 { "est", tZONE, HOUR( 6) }, /* Easter Island Standard */
2136 { "edt", tDAYZONE, HOUR( 6) }, /* Easter Island Daylight */
2137 { "sst", tZONE, HOUR(11) }, /* Samoa Standard */
2138 { "ist", tZONE, -HOUR(2) }, /* Israel Standard */
2139 { "idt", tDAYZONE, -HOUR(2) }, /* Israel Daylight */
2140 { "idt", tDAYZONE, -(HOUR(3)+30) }, /* Iran Daylight */
2141 { "ist", tZONE, -(HOUR(3)+30) }, /* Iran Standard */
2142 { "cst", tZONE, -HOUR(8) }, /* China Standard */
2143 { "cdt", tDAYZONE, -HOUR(8) }, /* China Daylight */
2144 { "sst", tZONE, -HOUR(8) }, /* Singapore Standard */
2146 /* Dubious (e.g., not in Olson's TIMEZONE package) or obsolete. */
2147 { "gst", tZONE, HOUR( 3) }, /* Greenland Standard */
2148 { "wat", tZONE, -HOUR(1) }, /* West Africa */
2149 { "at", tZONE, HOUR( 2) }, /* Azores */
2150 { "gst", tZONE, -HOUR(10) }, /* Guam Standard */
2151 { "nft", tZONE, HOUR(3)+30 }, /* Newfoundland */
2152 { "idlw", tZONE, HOUR(12) }, /* International Date Line West */
2153 { "mewt", tZONE, -HOUR(1) }, /* Middle European Winter */
2154 { "mest", tDAYZONE, -HOUR(1) }, /* Middle European Summer */
2155 { "swt", tZONE, -HOUR(1) }, /* Swedish Winter */
2156 { "sst", tDAYZONE, -HOUR(1) }, /* Swedish Summer */
2157 { "fwt", tZONE, -HOUR(1) }, /* French Winter */
2158 { "fst", tDAYZONE, -HOUR(1) }, /* French Summer */
2159 { "bt", tZONE, -HOUR(3) }, /* Baghdad */
2160 { "it", tZONE, -(HOUR(3)+30) }, /* Iran */
2161 { "zp4", tZONE, -HOUR(4) }, /* USSR Zone 3 */
2162 { "zp5", tZONE, -HOUR(5) }, /* USSR Zone 4 */
2163 { "ist", tZONE, -(HOUR(5)+30) }, /* Indian Standard */
2164 { "zp6", tZONE, -HOUR(6) }, /* USSR Zone 5 */
2165 { "nst", tZONE, -HOUR(7) }, /* North Sumatra */
2166 { "sst", tZONE, -HOUR(7) }, /* South Sumatra */
2167 { "jt", tZONE, -(HOUR(7)+30) }, /* Java (3pm in Cronusland!) */
2168 { "nzt", tZONE, -HOUR(12) }, /* New Zealand */
2169 { "idle", tZONE, -HOUR(12) }, /* International Date Line East */
2170 { "cat", tZONE, HOUR(10) }, /* -- expired 1967 */
2171 { "nt", tZONE, HOUR(11) }, /* -- expired 1967 */
2172 { "ahst", tZONE, HOUR(10) }, /* -- expired 1983 */
2173 { "hdt", tDAYZONE, HOUR(10) }, /* -- expired 1986 */
2187 ToSeconds(time_t Hours, time_t Minutes, time_t Seconds, MERIDIAN Meridian)
2189 if (Minutes < 0 || Minutes > 59 || Seconds < 0 || Seconds > 61)
2191 if (Meridian == MER24) {
2192 if (Hours < 0 || Hours > 23)
2196 if (Hours < 1 || Hours > 12)
2200 if (Meridian == MERpm)
2203 return (Hours * 60L + Minutes) * 60L + Seconds;
2208 Convert(time_t Month, time_t Day, time_t Year,
2209 time_t Hours, time_t Minutes, time_t Seconds,
2210 MERIDIAN Meridian, DSTMODE dst)
2212 static int DaysNormal[13] = {
2213 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
2215 static int DaysLeap[13] = {
2216 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
2218 static int LeapYears[] = {
2219 1972, 1976, 1980, 1984, 1988, 1992, 1996,
2220 2000, 2004, 2008, 2012, 2016, 2020, 2024, 2028, 2032, 2036
2224 register time_t Julian;
2234 for (mp = DaysNormal, yp = LeapYears; yp < ENDOF(LeapYears); yp++)
2239 if (Year < EPOCH || Year > END_OF_TIME
2240 || Month < 1 || Month > 12
2241 /* NOSTRICT *//* conversion from long may lose accuracy */
2242 || Day < 1 || Day > mp[(int)Month])
2245 Julian = Day - 1 + (Year - EPOCH) * 365;
2246 for (yp = LeapYears; yp < ENDOF(LeapYears); yp++, Julian++)
2249 for (i = 1; i < Month; i++)
2251 Julian *= SECSPERDAY;
2252 Julian += yyTimezone * 60L;
2253 if ((tod = ToSeconds(Hours, Minutes, Seconds, Meridian)) < 0)
2257 if (dst == DSTon || (dst == DSTmaybe && localtime(&tod)->tm_isdst))
2258 Julian -= DST_OFFSET * 60L * 60L;
2264 DSTcorrect(time_t Start, time_t Future)
2269 StartDay = (localtime(&Start)->tm_hour + 1) % 24;
2270 FutureDay = (localtime(&Future)->tm_hour + 1) % 24;
2271 return (Future - Start) + (StartDay - FutureDay) * DST_OFFSET * 60L * 60L;
2276 RelativeMonth(time_t Start, time_t RelMonth)
2282 tm = localtime(&Start);
2283 Month = 12 * tm->tm_year + tm->tm_mon + RelMonth;
2285 Month = Month % 12 + 1;
2286 return DSTcorrect(Start,
2287 Convert(Month, (time_t)tm->tm_mday, Year,
2288 (time_t)tm->tm_hour, (time_t)tm->tm_min, (time_t)tm->tm_sec,
2294 LookupWord(char *buff, register int length)
2304 /* See if we have an abbreviation for a month. */
2305 if (length == 3 || (length == 4 && p[3] == '.'))
2306 for (tp = MonthDayTable; tp < ENDOF(MonthDayTable); tp++) {
2308 if (c == q[0] && p[1] == q[1] && p[2] == q[2]) {
2309 yylval.Number = tp->value;
2314 for (tp = MonthDayTable; tp < ENDOF(MonthDayTable); tp++)
2315 if (c == tp->name[0] && strcmp(p, tp->name) == 0) {
2316 yylval.Number = tp->value;
2320 /* Try for a timezone. */
2321 for (tp = TimezoneTable; tp < ENDOF(TimezoneTable); tp++)
2322 if (c == tp->name[0] && p[1] == tp->name[1]
2323 && strcmp(p, tp->name) == 0) {
2324 yylval.Number = tp->value;
2328 /* Try the units table. */
2329 for (tp = UnitsTable; tp < ENDOF(UnitsTable); tp++)
2330 if (c == tp->name[0] && strcmp(p, tp->name) == 0) {
2331 yylval.Number = tp->value;
2335 /* Strip off any plural and try the units table again. */
2336 if (--length > 0 && p[length] == 's') {
2338 for (tp = UnitsTable; tp < ENDOF(UnitsTable); tp++)
2339 if (c == tp->name[0] && strcmp(p, tp->name) == 0) {
2341 yylval.Number = tp->value;
2348 /* Drop out any periods. */
2349 for (p = buff, q = (char*)buff; *q; q++)
2354 /* Try the meridians. */
2355 if (buff[1] == 'm' && buff[2] == '\0') {
2356 if (buff[0] == 'a') {
2357 yylval.Meridian = MERam;
2360 if (buff[0] == 'p') {
2361 yylval.Meridian = MERpm;
2366 /* If we saw any periods, try the timezones again. */
2367 if (p - buff != length) {
2369 for (p = buff, tp = TimezoneTable; tp < ENDOF(TimezoneTable); tp++)
2370 if (c == tp->name[0] && p[1] == tp->name[1]
2371 && strcmp(p, tp->name) == 0) {
2372 yylval.Number = tp->value;
2377 /* Unknown word -- assume GMT timezone. */
2391 register int nesting;
2394 /* Get first character after the whitespace. */
2396 while (isspace(*yyInput))
2400 /* Ignore RFC 822 comments, typically time zone names. */
2403 for (nesting = 1; (c = *++yyInput) != RPAREN || --nesting; )
2406 else if (!IS7BIT(c) || c == '\0' || c == '\r'
2407 || (c == '\\' && ((c = *++yyInput) == '\0' || !IS7BIT(c))))
2408 /* Lexical error: bad comment. */
2414 if (isdigit(c) || c == '-' || c == '+') {
2415 if (c == '-' || c == '+') {
2416 sign = c == '-' ? -1 : 1;
2418 if (!isdigit(*yyInput))
2419 /* Skip the plus or minus sign. */
2424 for (i = 0; (c = *yyInput++) != '\0' && isdigit(c); )
2425 i = 10 * i + c - '0';
2427 yylval.Number = sign < 0 ? -i : i;
2428 return sign ? tSNUMBER : tUNUMBER;
2433 for (p = buff; (c = *yyInput++) == '.' || isalpha(c); )
2434 if (p < &buff[sizeof buff - 1])
2435 *p++ = isupper(c) ? tolower(c) : c;
2438 return LookupWord(buff, p - buff);
2447 parsedate(const char *p)
2449 extern int date_parse(void);
2452 yyInput = p; /* well, its supposed to be const... */
2458 yyDSTmode = DSTmaybe;
2469 if (date_parse() || yyHaveTime > 1 || yyHaveDate > 1)
2472 if (yyHaveDate || yyHaveTime) {
2473 Start = Convert(yyMonth, yyDay, yyYear, yyHour, yyMinutes, yySeconds,
2474 yyMeridian, yyDSTmode);
2481 Start += yyRelSeconds;
2483 Start += RelativeMonth(Start, yyRelMonth);
2485 /* Have to do *something* with a legitimate -1 so it's distinguishable
2486 * from the error return value. (Alternately could set errno on error.) */
2487 return Start == -1 ? 0 : Start;
2495 #endif /* YYDEBUG */
2499 main(int ac, char *av[])
2506 #endif /* YYDEBUG */
2508 (void)printf("Enter date, or blank line to exit.\n\t> ");
2510 (void)printf("\t> ");
2511 (void)fflush(stdout);
2512 if (fgets(buff, sizeof buff, stdin) == NULL || buff[0] == '\n')
2515 if (strcmp(buff, "yydebug") == 0) {
2517 printf("yydebug = %s\n", yydebug ? "on" : "off");
2520 #endif /* YYDEBUG */
2521 d = parsedate(buff, (TIMEINFO *)NULL);
2523 (void)printf("Bad format - couldn't convert.\n");
2525 (void)printf("%s", ctime(&d));