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;
259 /* Line 193 of yacc.c. */
262 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
263 # define YYSTYPE_IS_DECLARED 1
267 /* Copy the second part of user declarations. */
270 /* Line 264 of yacc.c */
278 typedef YYTYPE_UINT8 yytype_uint8;
280 typedef unsigned char yytype_uint8;
284 typedef YYTYPE_INT8 yytype_int8;
285 #elif (defined __STDC__ || defined __C99__FUNC__ \
286 || defined __cplusplus || defined _MSC_VER)
287 typedef signed char yytype_int8;
289 typedef short int yytype_int8;
293 typedef YYTYPE_UINT16 yytype_uint16;
295 typedef unsigned short int yytype_uint16;
299 typedef YYTYPE_INT16 yytype_int16;
301 typedef short int yytype_int16;
305 # ifdef __SIZE_TYPE__
306 # define YYSIZE_T __SIZE_TYPE__
307 # elif defined size_t
308 # define YYSIZE_T size_t
309 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
310 || defined __cplusplus || defined _MSC_VER)
311 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
312 # define YYSIZE_T size_t
314 # define YYSIZE_T unsigned int
318 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
323 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
324 # define YY_(msgid) dgettext ("bison-runtime", msgid)
328 # define YY_(msgid) msgid
332 /* Suppress unused-variable warnings by "using" E. */
333 #if ! defined lint || defined __GNUC__
334 # define YYUSE(e) ((void) (e))
336 # define YYUSE(e) /* empty */
339 /* Identity function, used to suppress warnings about constant conditions. */
343 #if (defined __STDC__ || defined __C99__FUNC__ \
344 || defined __cplusplus || defined _MSC_VER)
357 #if ! defined yyoverflow || YYERROR_VERBOSE
359 /* The parser invokes alloca or malloc; define the necessary symbols. */
361 # ifdef YYSTACK_USE_ALLOCA
362 # if YYSTACK_USE_ALLOCA
364 # define YYSTACK_ALLOC __builtin_alloca
365 # elif defined __BUILTIN_VA_ARG_INCR
366 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
368 # define YYSTACK_ALLOC __alloca
369 # elif defined _MSC_VER
370 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
371 # define alloca _alloca
373 # define YYSTACK_ALLOC alloca
374 # if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
375 || defined __cplusplus || defined _MSC_VER)
376 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
385 # ifdef YYSTACK_ALLOC
386 /* Pacify GCC's `empty if-body' warning. */
387 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
388 # ifndef YYSTACK_ALLOC_MAXIMUM
389 /* The OS might guarantee only one guard page at the bottom of the stack,
390 and a page size can be as small as 4096 bytes. So we cannot safely
391 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
392 to allow for a few compiler-allocated temporary stack slots. */
393 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
396 # define YYSTACK_ALLOC YYMALLOC
397 # define YYSTACK_FREE YYFREE
398 # ifndef YYSTACK_ALLOC_MAXIMUM
399 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
401 # if (defined __cplusplus && ! defined _STDLIB_H \
402 && ! ((defined YYMALLOC || defined malloc) \
403 && (defined YYFREE || defined free)))
404 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
410 # define YYMALLOC malloc
411 # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
412 || defined __cplusplus || defined _MSC_VER)
413 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
418 # if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
419 || defined __cplusplus || defined _MSC_VER)
420 void free (void *); /* INFRINGES ON USER NAME SPACE */
424 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
427 #if (! defined yyoverflow \
428 && (! defined __cplusplus \
429 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
431 /* A type that is properly aligned for any stack member. */
434 yytype_int16 yyss_alloc;
438 /* The size of the maximum gap between one aligned stack and the next. */
439 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
441 /* The size of an array large to enough to hold all stacks, each with
443 # define YYSTACK_BYTES(N) \
444 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
445 + YYSTACK_GAP_MAXIMUM)
447 /* Copy COUNT objects from FROM to TO. The source and destination do
450 # if defined __GNUC__ && 1 < __GNUC__
451 # define YYCOPY(To, From, Count) \
452 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
454 # define YYCOPY(To, From, Count) \
458 for (yyi = 0; yyi < (Count); yyi++) \
459 (To)[yyi] = (From)[yyi]; \
465 /* Relocate STACK from its old location to the new one. The
466 local variables YYSIZE and YYSTACKSIZE give the old and new number of
467 elements in the stack, and YYPTR gives the new location of the
468 stack. Advance YYPTR to a properly aligned location for the next
470 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
473 YYSIZE_T yynewbytes; \
474 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
475 Stack = &yyptr->Stack_alloc; \
476 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
477 yyptr += yynewbytes / sizeof (*yyptr); \
483 /* YYFINAL -- State number of the termination state. */
485 /* YYLAST -- Last index in YYTABLE. */
488 /* YYNTOKENS -- Number of terminals. */
490 /* YYNNTS -- Number of nonterminals. */
492 /* YYNRULES -- Number of rules. */
494 /* YYNRULES -- Number of states. */
497 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
499 #define YYMAXUTOK 266
501 #define YYTRANSLATE(YYX) \
502 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
504 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
505 static const yytype_uint8 yytranslate[] =
507 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
508 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
509 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
510 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
511 2, 2, 2, 2, 14, 2, 2, 13, 2, 2,
512 2, 2, 2, 2, 2, 2, 2, 2, 12, 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, 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, 1, 2, 3, 4,
533 5, 6, 7, 8, 9, 10, 11
537 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
539 static const yytype_uint8 yyprhs[] =
541 0, 0, 3, 4, 7, 9, 12, 14, 16, 19,
542 24, 29, 36, 43, 45, 47, 50, 52, 54, 58,
543 64, 67, 72, 75, 79, 85, 88, 91, 94, 97,
547 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
548 static const yytype_int8 yyrhs[] =
550 16, 0, -1, -1, 16, 17, -1, 18, -1, 18,
551 19, -1, 21, -1, 22, -1, 10, 23, -1, 10,
552 12, 10, 23, -1, 10, 12, 10, 20, -1, 10,
553 12, 10, 12, 10, 23, -1, 10, 12, 10, 12,
554 10, 20, -1, 11, -1, 4, -1, 11, 20, -1,
555 20, -1, 9, -1, 10, 13, 10, -1, 10, 13,
556 10, 13, 10, -1, 6, 10, -1, 6, 10, 14,
557 10, -1, 10, 6, -1, 10, 6, 10, -1, 3,
558 14, 10, 6, 10, -1, 9, 8, -1, 10, 8,
559 -1, 9, 7, -1, 10, 7, -1, -1, 5, -1
562 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
563 static const yytype_uint16 yyrline[] =
565 0, 139, 139, 140, 143, 152, 156, 159, 164, 176,
566 182, 189, 195, 205, 209, 213, 221, 227, 248, 252,
567 264, 268, 273, 277, 282, 289, 292, 295, 298, 303,
572 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
573 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
574 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
575 static const char *const yytname[] =
577 "$end", "error", "$undefined", "tDAY", "tDAYZONE", "tMERIDIAN",
578 "tMONTH", "tMONTH_UNIT", "tSEC_UNIT", "tSNUMBER", "tUNUMBER", "tZONE",
579 "':'", "'/'", "','", "$accept", "spec", "item", "time", "zone",
580 "numzone", "date", "rel", "o_merid", 0
585 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
587 static const yytype_uint16 yytoknum[] =
589 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
594 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
595 static const yytype_uint8 yyr1[] =
597 0, 15, 16, 16, 17, 17, 17, 17, 18, 18,
598 18, 18, 18, 19, 19, 19, 19, 20, 21, 21,
599 21, 21, 21, 21, 21, 22, 22, 22, 22, 23,
603 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
604 static const yytype_uint8 yyr2[] =
606 0, 2, 0, 2, 1, 2, 1, 1, 2, 4,
607 4, 6, 6, 1, 1, 2, 1, 1, 3, 5,
608 2, 4, 2, 3, 5, 2, 2, 2, 2, 0,
612 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
613 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
614 means the default is an error. */
615 static const yytype_uint8 yydefact[] =
617 2, 0, 1, 0, 0, 0, 29, 3, 4, 6,
618 7, 0, 20, 27, 25, 30, 22, 28, 26, 0,
619 0, 8, 14, 17, 13, 5, 16, 0, 0, 23,
620 29, 18, 15, 0, 21, 0, 10, 9, 0, 24,
624 /* YYDEFGOTO[NTERM-NUM]. */
625 static const yytype_int8 yydefgoto[] =
627 -1, 1, 7, 8, 25, 26, 9, 10, 21
630 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
632 #define YYPACT_NINF -29
633 static const yytype_int8 yypact[] =
635 -29, 1, -29, -11, 11, 20, 12, -29, 4, -29,
636 -29, 13, 16, -29, -29, -29, 21, -29, -29, 22,
637 23, -29, -29, -29, 5, -29, -29, 28, 25, -29,
638 17, 24, -29, 26, -29, 29, -29, -29, 30, -29,
642 /* YYPGOTO[NTERM-NUM]. */
643 static const yytype_int8 yypgoto[] =
645 -29, -29, -29, -29, -29, -24, -29, -29, -28
648 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
649 positive, shift that token. If negative, reduce the rule which
650 number is the opposite. If zero, do what YYDEFACT says.
651 If YYTABLE_NINF, syntax error. */
652 #define YYTABLE_NINF -1
653 static const yytype_uint8 yytable[] =
655 32, 2, 37, 11, 3, 15, 36, 4, 22, 23,
656 5, 6, 43, 23, 23, 24, 42, 15, 16, 17,
657 18, 12, 15, 27, 19, 20, 23, 13, 14, 35,
658 28, 29, 30, 31, 33, 34, 39, 38, 0, 40,
662 static const yytype_int8 yycheck[] =
664 24, 0, 30, 14, 3, 5, 30, 6, 4, 9,
665 9, 10, 40, 9, 9, 11, 40, 5, 6, 7,
666 8, 10, 5, 10, 12, 13, 9, 7, 8, 12,
667 14, 10, 10, 10, 6, 10, 10, 13, -1, 10,
671 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
672 symbol of state STATE-NUM. */
673 static const yytype_uint8 yystos[] =
675 0, 16, 0, 3, 6, 9, 10, 17, 18, 21,
676 22, 14, 10, 7, 8, 5, 6, 7, 8, 12,
677 13, 23, 4, 9, 11, 19, 20, 10, 14, 10,
678 10, 10, 20, 6, 10, 12, 20, 23, 13, 10,
682 #define yyerrok (yyerrstatus = 0)
683 #define yyclearin (yychar = YYEMPTY)
687 #define YYACCEPT goto yyacceptlab
688 #define YYABORT goto yyabortlab
689 #define YYERROR goto yyerrorlab
692 /* Like YYERROR except do call yyerror. This remains here temporarily
693 to ease the transition to the new meaning of YYERROR, for GCC.
694 Once GCC version 2 has supplanted version 1, this can go. */
696 #define YYFAIL goto yyerrlab
698 #define YYRECOVERING() (!!yyerrstatus)
700 #define YYBACKUP(Token, Value) \
702 if (yychar == YYEMPTY && yylen == 1) \
706 yytoken = YYTRANSLATE (yychar); \
712 yyerror (YY_("syntax error: cannot back up")); \
719 #define YYERRCODE 256
722 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
723 If N is 0, then set CURRENT to the empty location which ends
724 the previous symbol: RHS[0] (always defined). */
726 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
727 #ifndef YYLLOC_DEFAULT
728 # define YYLLOC_DEFAULT(Current, Rhs, N) \
732 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
733 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
734 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
735 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
739 (Current).first_line = (Current).last_line = \
740 YYRHSLOC (Rhs, 0).last_line; \
741 (Current).first_column = (Current).last_column = \
742 YYRHSLOC (Rhs, 0).last_column; \
748 /* YY_LOCATION_PRINT -- Print the location on the stream.
749 This macro was not mandated originally: define only if we know
750 we won't break user code: when these are the locations we know. */
752 #ifndef YY_LOCATION_PRINT
753 # if YYLTYPE_IS_TRIVIAL
754 # define YY_LOCATION_PRINT(File, Loc) \
755 fprintf (File, "%d.%d-%d.%d", \
756 (Loc).first_line, (Loc).first_column, \
757 (Loc).last_line, (Loc).last_column)
759 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
764 /* YYLEX -- calling `yylex' with the right arguments. */
767 # define YYLEX yylex (YYLEX_PARAM)
769 # define YYLEX yylex ()
772 /* Enable debugging if requested. */
776 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
777 # define YYFPRINTF fprintf
780 # define YYDPRINTF(Args) \
786 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
790 YYFPRINTF (stderr, "%s ", Title); \
791 yy_symbol_print (stderr, \
793 YYFPRINTF (stderr, "\n"); \
798 /*--------------------------------.
799 | Print this symbol on YYOUTPUT. |
800 `--------------------------------*/
803 #if (defined __STDC__ || defined __C99__FUNC__ \
804 || defined __cplusplus || defined _MSC_VER)
806 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
809 yy_symbol_value_print (yyoutput, yytype, yyvaluep)
812 YYSTYPE const * const yyvaluep;
818 if (yytype < YYNTOKENS)
819 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
831 /*--------------------------------.
832 | Print this symbol on YYOUTPUT. |
833 `--------------------------------*/
835 #if (defined __STDC__ || defined __C99__FUNC__ \
836 || defined __cplusplus || defined _MSC_VER)
838 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
841 yy_symbol_print (yyoutput, yytype, yyvaluep)
844 YYSTYPE const * const yyvaluep;
847 if (yytype < YYNTOKENS)
848 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
850 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
852 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
853 YYFPRINTF (yyoutput, ")");
856 /*------------------------------------------------------------------.
857 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
859 `------------------------------------------------------------------*/
861 #if (defined __STDC__ || defined __C99__FUNC__ \
862 || defined __cplusplus || defined _MSC_VER)
864 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
867 yy_stack_print (yybottom, yytop)
868 yytype_int16 *yybottom;
872 YYFPRINTF (stderr, "Stack now");
873 for (; yybottom <= yytop; yybottom++)
875 int yybot = *yybottom;
876 YYFPRINTF (stderr, " %d", yybot);
878 YYFPRINTF (stderr, "\n");
881 # define YY_STACK_PRINT(Bottom, Top) \
884 yy_stack_print ((Bottom), (Top)); \
888 /*------------------------------------------------.
889 | Report that the YYRULE is going to be reduced. |
890 `------------------------------------------------*/
892 #if (defined __STDC__ || defined __C99__FUNC__ \
893 || defined __cplusplus || defined _MSC_VER)
895 yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
898 yy_reduce_print (yyvsp, yyrule)
903 int yynrhs = yyr2[yyrule];
905 unsigned long int yylno = yyrline[yyrule];
906 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
908 /* The symbols being reduced. */
909 for (yyi = 0; yyi < yynrhs; yyi++)
911 YYFPRINTF (stderr, " $%d = ", yyi + 1);
912 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
913 &(yyvsp[(yyi + 1) - (yynrhs)])
915 YYFPRINTF (stderr, "\n");
919 # define YY_REDUCE_PRINT(Rule) \
922 yy_reduce_print (yyvsp, Rule); \
925 /* Nonzero means print parse trace. It is left uninitialized so that
926 multiple parsers can coexist. */
929 # define YYDPRINTF(Args)
930 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
931 # define YY_STACK_PRINT(Bottom, Top)
932 # define YY_REDUCE_PRINT(Rule)
933 #endif /* !YYDEBUG */
936 /* YYINITDEPTH -- initial size of the parser's stacks. */
938 # define YYINITDEPTH 200
941 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
942 if the built-in stack extension method is used).
944 Do not make this value too large; the results are undefined if
945 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
946 evaluated with infinite-precision integer arithmetic. */
949 # define YYMAXDEPTH 10000
957 # if defined __GLIBC__ && defined _STRING_H
958 # define yystrlen strlen
960 /* Return the length of YYSTR. */
961 #if (defined __STDC__ || defined __C99__FUNC__ \
962 || defined __cplusplus || defined _MSC_VER)
964 yystrlen (const char *yystr)
972 for (yylen = 0; yystr[yylen]; yylen++)
980 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
981 # define yystpcpy stpcpy
983 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
985 #if (defined __STDC__ || defined __C99__FUNC__ \
986 || defined __cplusplus || defined _MSC_VER)
988 yystpcpy (char *yydest, const char *yysrc)
991 yystpcpy (yydest, yysrc)
997 const char *yys = yysrc;
999 while ((*yyd++ = *yys++) != '\0')
1008 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1009 quotes and backslashes, so that it's suitable for yyerror. The
1010 heuristic is that double-quoting is unnecessary unless the string
1011 contains an apostrophe, a comma, or backslash (other than
1012 backslash-backslash). YYSTR is taken from yytname. If YYRES is
1013 null, do not copy; instead, return the length of what the result
1016 yytnamerr (char *yyres, const char *yystr)
1021 char const *yyp = yystr;
1028 goto do_not_strip_quotes;
1032 goto do_not_strip_quotes;
1045 do_not_strip_quotes: ;
1049 return yystrlen (yystr);
1051 return yystpcpy (yyres, yystr) - yyres;
1055 /* Copy into YYRESULT an error message about the unexpected token
1056 YYCHAR while in state YYSTATE. Return the number of bytes copied,
1057 including the terminating null byte. If YYRESULT is null, do not
1058 copy anything; just return the number of bytes that would be
1059 copied. As a special case, return 0 if an ordinary "syntax error"
1060 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
1061 size calculation. */
1063 yysyntax_error (char *yyresult, int yystate, int yychar)
1065 int yyn = yypact[yystate];
1067 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
1071 int yytype = YYTRANSLATE (yychar);
1072 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
1073 YYSIZE_T yysize = yysize0;
1075 int yysize_overflow = 0;
1076 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1077 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1081 /* This is so xgettext sees the translatable formats that are
1082 constructed on the fly. */
1083 YY_("syntax error, unexpected %s");
1084 YY_("syntax error, unexpected %s, expecting %s");
1085 YY_("syntax error, unexpected %s, expecting %s or %s");
1086 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
1087 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
1091 static char const yyunexpected[] = "syntax error, unexpected %s";
1092 static char const yyexpecting[] = ", expecting %s";
1093 static char const yyor[] = " or %s";
1094 char yyformat[sizeof yyunexpected
1095 + sizeof yyexpecting - 1
1096 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
1097 * (sizeof yyor - 1))];
1098 char const *yyprefix = yyexpecting;
1100 /* Start YYX at -YYN if negative to avoid negative indexes in
1102 int yyxbegin = yyn < 0 ? -yyn : 0;
1104 /* Stay within bounds of both yycheck and yytname. */
1105 int yychecklim = YYLAST - yyn + 1;
1106 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1109 yyarg[0] = yytname[yytype];
1110 yyfmt = yystpcpy (yyformat, yyunexpected);
1112 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1113 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1115 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1119 yyformat[sizeof yyunexpected - 1] = '\0';
1122 yyarg[yycount++] = yytname[yyx];
1123 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1124 yysize_overflow |= (yysize1 < yysize);
1126 yyfmt = yystpcpy (yyfmt, yyprefix);
1130 yyf = YY_(yyformat);
1131 yysize1 = yysize + yystrlen (yyf);
1132 yysize_overflow |= (yysize1 < yysize);
1135 if (yysize_overflow)
1136 return YYSIZE_MAXIMUM;
1140 /* Avoid sprintf, as that infringes on the user's name space.
1141 Don't have undefined behavior even if the translation
1142 produced a string with the wrong number of "%s"s. */
1143 char *yyp = yyresult;
1145 while ((*yyp = *yyf) != '\0')
1147 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
1149 yyp += yytnamerr (yyp, yyarg[yyi++]);
1162 #endif /* YYERROR_VERBOSE */
1165 /*-----------------------------------------------.
1166 | Release the memory associated to this symbol. |
1167 `-----------------------------------------------*/
1170 #if (defined __STDC__ || defined __C99__FUNC__ \
1171 || defined __cplusplus || defined _MSC_VER)
1173 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1176 yydestruct (yymsg, yytype, yyvaluep)
1186 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1196 /* Prevent warnings from -Wmissing-prototypes. */
1197 #ifdef YYPARSE_PARAM
1198 #if defined __STDC__ || defined __cplusplus
1199 int yyparse (void *YYPARSE_PARAM);
1203 #else /* ! YYPARSE_PARAM */
1204 #if defined __STDC__ || defined __cplusplus
1209 #endif /* ! YYPARSE_PARAM */
1212 /* The lookahead symbol. */
1215 /* The semantic value of the lookahead symbol. */
1218 /* Number of syntax errors so far. */
1223 /*-------------------------.
1224 | yyparse or yypush_parse. |
1225 `-------------------------*/
1227 #ifdef YYPARSE_PARAM
1228 #if (defined __STDC__ || defined __C99__FUNC__ \
1229 || defined __cplusplus || defined _MSC_VER)
1231 yyparse (void *YYPARSE_PARAM)
1234 yyparse (YYPARSE_PARAM)
1235 void *YYPARSE_PARAM;
1237 #else /* ! YYPARSE_PARAM */
1238 #if (defined __STDC__ || defined __C99__FUNC__ \
1239 || defined __cplusplus || defined _MSC_VER)
1252 /* Number of tokens to shift before error messages enabled. */
1255 /* The stacks and their tools:
1256 `yyss': related to states.
1257 `yyvs': related to semantic values.
1259 Refer to the stacks thru separate pointers, to allow yyoverflow
1260 to reallocate them elsewhere. */
1262 /* The state stack. */
1263 yytype_int16 yyssa[YYINITDEPTH];
1265 yytype_int16 *yyssp;
1267 /* The semantic value stack. */
1268 YYSTYPE yyvsa[YYINITDEPTH];
1272 YYSIZE_T yystacksize;
1276 /* Lookahead token as an internal (translated) token number. */
1278 /* The variables used to return semantic value and location from the
1283 /* Buffer for error messages, and its allocated size. */
1285 char *yymsg = yymsgbuf;
1286 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1289 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1291 /* The number of symbols on the RHS of the reduced rule.
1292 Keep to zero when no symbol should be popped. */
1298 yystacksize = YYINITDEPTH;
1300 YYDPRINTF ((stderr, "Starting parse\n"));
1305 yychar = YYEMPTY; /* Cause a token to be read. */
1307 /* Initialize stack pointers.
1308 Waste one element of value and location stack
1309 so that they stay on the same level as the state stack.
1310 The wasted elements are never initialized. */
1316 /*------------------------------------------------------------.
1317 | yynewstate -- Push a new state, which is found in yystate. |
1318 `------------------------------------------------------------*/
1320 /* In all cases, when you get here, the value and location stacks
1321 have just been pushed. So pushing a state here evens the stacks. */
1327 if (yyss + yystacksize - 1 <= yyssp)
1329 /* Get the current used size of the three stacks, in elements. */
1330 YYSIZE_T yysize = yyssp - yyss + 1;
1334 /* Give user a chance to reallocate the stack. Use copies of
1335 these so that the &'s don't force the real ones into
1337 YYSTYPE *yyvs1 = yyvs;
1338 yytype_int16 *yyss1 = yyss;
1340 /* Each stack pointer address is followed by the size of the
1341 data in use in that stack, in bytes. This used to be a
1342 conditional around just the two extra args, but that might
1343 be undefined if yyoverflow is a macro. */
1344 yyoverflow (YY_("memory exhausted"),
1345 &yyss1, yysize * sizeof (*yyssp),
1346 &yyvs1, yysize * sizeof (*yyvsp),
1352 #else /* no yyoverflow */
1353 # ifndef YYSTACK_RELOCATE
1354 goto yyexhaustedlab;
1356 /* Extend the stack our own way. */
1357 if (YYMAXDEPTH <= yystacksize)
1358 goto yyexhaustedlab;
1360 if (YYMAXDEPTH < yystacksize)
1361 yystacksize = YYMAXDEPTH;
1364 yytype_int16 *yyss1 = yyss;
1365 union yyalloc *yyptr =
1366 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1368 goto yyexhaustedlab;
1369 YYSTACK_RELOCATE (yyss_alloc, yyss);
1370 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1371 # undef YYSTACK_RELOCATE
1373 YYSTACK_FREE (yyss1);
1376 #endif /* no yyoverflow */
1378 yyssp = yyss + yysize - 1;
1379 yyvsp = yyvs + yysize - 1;
1381 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1382 (unsigned long int) yystacksize));
1384 if (yyss + yystacksize - 1 <= yyssp)
1388 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1390 if (yystate == YYFINAL)
1400 /* Do appropriate processing given the current state. Read a
1401 lookahead token if we need one and don't already have one. */
1403 /* First try to decide what to do without reference to lookahead token. */
1404 yyn = yypact[yystate];
1405 if (yyn == YYPACT_NINF)
1408 /* Not known => get a lookahead token if don't already have one. */
1410 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1411 if (yychar == YYEMPTY)
1413 YYDPRINTF ((stderr, "Reading a token: "));
1417 if (yychar <= YYEOF)
1419 yychar = yytoken = YYEOF;
1420 YYDPRINTF ((stderr, "Now at end of input.\n"));
1424 yytoken = YYTRANSLATE (yychar);
1425 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1428 /* If the proper action on seeing token YYTOKEN is to reduce or to
1429 detect an error, take that action. */
1431 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1436 if (yyn == 0 || yyn == YYTABLE_NINF)
1442 /* Count tokens shifted since error; after three, turn off error
1447 /* Shift the lookahead token. */
1448 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1450 /* Discard the shifted token. */
1459 /*-----------------------------------------------------------.
1460 | yydefault -- do the default action for the current state. |
1461 `-----------------------------------------------------------*/
1463 yyn = yydefact[yystate];
1469 /*-----------------------------.
1470 | yyreduce -- Do a reduction. |
1471 `-----------------------------*/
1473 /* yyn is the number of a rule to reduce with. */
1476 /* If YYLEN is nonzero, implement the default value of the action:
1479 Otherwise, the following line sets YYVAL to garbage.
1480 This behavior is undocumented and Bison
1481 users should not rely upon it. Assigning to YYVAL
1482 unconditionally makes the parser a bit smaller, and it avoids a
1483 GCC warning that YYVAL may be used uninitialized. */
1484 yyval = yyvsp[1-yylen];
1487 YY_REDUCE_PRINT (yyn);
1492 /* Line 1455 of yacc.c */
1493 #line 143 "parsedate.y"
1497 /* I am compulsive about lint natterings... */
1498 if (yyHaveTime == -1) {
1507 /* Line 1455 of yacc.c */
1508 #line 152 "parsedate.y"
1511 yyTimezone = (yyvsp[(2) - (2)].Number);
1517 /* Line 1455 of yacc.c */
1518 #line 156 "parsedate.y"
1526 /* Line 1455 of yacc.c */
1527 #line 159 "parsedate.y"
1535 /* Line 1455 of yacc.c */
1536 #line 164 "parsedate.y"
1538 if ((yyvsp[(1) - (2)].Number) < 100) {
1539 yyHour = (yyvsp[(1) - (2)].Number);
1543 yyHour = (yyvsp[(1) - (2)].Number) / 100;
1544 yyMinutes = (yyvsp[(1) - (2)].Number) % 100;
1547 yyMeridian = (yyvsp[(2) - (2)].Meridian);
1553 /* Line 1455 of yacc.c */
1554 #line 176 "parsedate.y"
1556 yyHour = (yyvsp[(1) - (4)].Number);
1557 yyMinutes = (yyvsp[(3) - (4)].Number);
1559 yyMeridian = (yyvsp[(4) - (4)].Meridian);
1565 /* Line 1455 of yacc.c */
1566 #line 182 "parsedate.y"
1568 yyHour = (yyvsp[(1) - (4)].Number);
1569 yyMinutes = (yyvsp[(3) - (4)].Number);
1570 yyTimezone = (yyvsp[(4) - (4)].Number);
1578 /* Line 1455 of yacc.c */
1579 #line 189 "parsedate.y"
1581 yyHour = (yyvsp[(1) - (6)].Number);
1582 yyMinutes = (yyvsp[(3) - (6)].Number);
1583 yySeconds = (yyvsp[(5) - (6)].Number);
1584 yyMeridian = (yyvsp[(6) - (6)].Meridian);
1590 /* Line 1455 of yacc.c */
1591 #line 195 "parsedate.y"
1593 yyHour = (yyvsp[(1) - (6)].Number);
1594 yyMinutes = (yyvsp[(3) - (6)].Number);
1595 yySeconds = (yyvsp[(5) - (6)].Number);
1596 yyTimezone = (yyvsp[(6) - (6)].Number);
1604 /* Line 1455 of yacc.c */
1605 #line 205 "parsedate.y"
1607 (yyval.Number) = (yyvsp[(1) - (1)].Number);
1614 /* Line 1455 of yacc.c */
1615 #line 209 "parsedate.y"
1617 (yyval.Number) = (yyvsp[(1) - (1)].Number);
1624 /* Line 1455 of yacc.c */
1625 #line 213 "parsedate.y"
1627 /* Only allow "GMT+300" and "GMT-0800" */
1628 if ((yyvsp[(1) - (2)].Number) != 0) {
1631 (yyval.Number) = (yyvsp[(2) - (2)].Number);
1638 /* Line 1455 of yacc.c */
1639 #line 221 "parsedate.y"
1641 (yyval.Number) = (yyvsp[(1) - (1)].Number);
1648 /* Line 1455 of yacc.c */
1649 #line 227 "parsedate.y"
1653 /* Unix and GMT and numeric timezones -- a little confusing. */
1654 if ((yyvsp[(1) - (1)].Number) < 0) {
1655 /* Don't work with negative modulus. */
1656 (yyvsp[(1) - (1)].Number) = -(yyvsp[(1) - (1)].Number);
1657 if ((yyvsp[(1) - (1)].Number) > 9999 || (i = (yyvsp[(1) - (1)].Number) % 100) >= 60) {
1660 (yyval.Number) = ((yyvsp[(1) - (1)].Number) / 100) * 60 + i;
1663 if ((yyvsp[(1) - (1)].Number) > 9999 || (i = (yyvsp[(1) - (1)].Number) % 100) >= 60) {
1666 (yyval.Number) = -(((yyvsp[(1) - (1)].Number) / 100) * 60 + i);
1673 /* Line 1455 of yacc.c */
1674 #line 248 "parsedate.y"
1676 yyMonth = (yyvsp[(1) - (3)].Number);
1677 yyDay = (yyvsp[(3) - (3)].Number);
1683 /* Line 1455 of yacc.c */
1684 #line 252 "parsedate.y"
1686 if ((yyvsp[(1) - (5)].Number) > 100) {
1687 yyYear = (yyvsp[(1) - (5)].Number);
1688 yyMonth = (yyvsp[(3) - (5)].Number);
1689 yyDay = (yyvsp[(5) - (5)].Number);
1692 yyMonth = (yyvsp[(1) - (5)].Number);
1693 yyDay = (yyvsp[(3) - (5)].Number);
1694 yyYear = (yyvsp[(5) - (5)].Number);
1701 /* Line 1455 of yacc.c */
1702 #line 264 "parsedate.y"
1704 yyMonth = (yyvsp[(1) - (2)].Number);
1705 yyDay = (yyvsp[(2) - (2)].Number);
1711 /* Line 1455 of yacc.c */
1712 #line 268 "parsedate.y"
1714 yyMonth = (yyvsp[(1) - (4)].Number);
1715 yyDay = (yyvsp[(2) - (4)].Number);
1716 yyYear = (yyvsp[(4) - (4)].Number);
1722 /* Line 1455 of yacc.c */
1723 #line 273 "parsedate.y"
1725 yyDay = (yyvsp[(1) - (2)].Number);
1726 yyMonth = (yyvsp[(2) - (2)].Number);
1732 /* Line 1455 of yacc.c */
1733 #line 277 "parsedate.y"
1735 yyDay = (yyvsp[(1) - (3)].Number);
1736 yyMonth = (yyvsp[(2) - (3)].Number);
1737 yyYear = (yyvsp[(3) - (3)].Number);
1743 /* Line 1455 of yacc.c */
1744 #line 282 "parsedate.y"
1746 yyDay = (yyvsp[(3) - (5)].Number);
1747 yyMonth = (yyvsp[(4) - (5)].Number);
1748 yyYear = (yyvsp[(5) - (5)].Number);
1754 /* Line 1455 of yacc.c */
1755 #line 289 "parsedate.y"
1757 yyRelSeconds += (yyvsp[(1) - (2)].Number) * (yyvsp[(2) - (2)].Number);
1763 /* Line 1455 of yacc.c */
1764 #line 292 "parsedate.y"
1766 yyRelSeconds += (yyvsp[(1) - (2)].Number) * (yyvsp[(2) - (2)].Number);
1772 /* Line 1455 of yacc.c */
1773 #line 295 "parsedate.y"
1775 yyRelMonth += (yyvsp[(1) - (2)].Number) * (yyvsp[(2) - (2)].Number);
1781 /* Line 1455 of yacc.c */
1782 #line 298 "parsedate.y"
1784 yyRelMonth += (yyvsp[(1) - (2)].Number) * (yyvsp[(2) - (2)].Number);
1790 /* Line 1455 of yacc.c */
1791 #line 303 "parsedate.y"
1793 (yyval.Meridian) = MER24;
1799 /* Line 1455 of yacc.c */
1800 #line 306 "parsedate.y"
1802 (yyval.Meridian) = (yyvsp[(1) - (1)].Meridian);
1808 /* Line 1455 of yacc.c */
1809 #line 1813 "y.tab.c"
1812 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1816 YY_STACK_PRINT (yyss, yyssp);
1820 /* Now `shift' the result of the reduction. Determine what state
1821 that goes to, based on the state we popped back to and the rule
1822 number reduced by. */
1826 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1827 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1828 yystate = yytable[yystate];
1830 yystate = yydefgoto[yyn - YYNTOKENS];
1835 /*------------------------------------.
1836 | yyerrlab -- here on detecting error |
1837 `------------------------------------*/
1839 /* If not already recovering from an error, report this error. */
1843 #if ! YYERROR_VERBOSE
1844 yyerror (YY_("syntax error"));
1847 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
1848 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
1850 YYSIZE_T yyalloc = 2 * yysize;
1851 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
1852 yyalloc = YYSTACK_ALLOC_MAXIMUM;
1853 if (yymsg != yymsgbuf)
1854 YYSTACK_FREE (yymsg);
1855 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
1857 yymsg_alloc = yyalloc;
1861 yymsg_alloc = sizeof yymsgbuf;
1865 if (0 < yysize && yysize <= yymsg_alloc)
1867 (void) yysyntax_error (yymsg, yystate, yychar);
1872 yyerror (YY_("syntax error"));
1874 goto yyexhaustedlab;
1882 if (yyerrstatus == 3)
1884 /* If just tried and failed to reuse lookahead token after an
1885 error, discard it. */
1887 if (yychar <= YYEOF)
1889 /* Return failure if at end of input. */
1890 if (yychar == YYEOF)
1895 yydestruct ("Error: discarding",
1901 /* Else will try to reuse lookahead token after shifting the error
1906 /*---------------------------------------------------.
1907 | yyerrorlab -- error raised explicitly by YYERROR. |
1908 `---------------------------------------------------*/
1911 /* Pacify compilers like GCC when the user code never invokes
1912 YYERROR and the label yyerrorlab therefore never appears in user
1914 if (/*CONSTCOND*/ 0)
1917 /* Do not reclaim the symbols of the rule which action triggered
1921 YY_STACK_PRINT (yyss, yyssp);
1926 /*-------------------------------------------------------------.
1927 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1928 `-------------------------------------------------------------*/
1930 yyerrstatus = 3; /* Each real token shifted decrements this. */
1934 yyn = yypact[yystate];
1935 if (yyn != YYPACT_NINF)
1938 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1946 /* Pop the current state because it cannot handle the error token. */
1951 yydestruct ("Error: popping",
1952 yystos[yystate], yyvsp);
1955 YY_STACK_PRINT (yyss, yyssp);
1961 /* Shift the error token. */
1962 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1968 /*-------------------------------------.
1969 | yyacceptlab -- YYACCEPT comes here. |
1970 `-------------------------------------*/
1975 /*-----------------------------------.
1976 | yyabortlab -- YYABORT comes here. |
1977 `-----------------------------------*/
1982 #if !defined(yyoverflow) || YYERROR_VERBOSE
1983 /*-------------------------------------------------.
1984 | yyexhaustedlab -- memory exhaustion comes here. |
1985 `-------------------------------------------------*/
1987 yyerror (YY_("memory exhausted"));
1993 if (yychar != YYEMPTY)
1994 yydestruct ("Cleanup: discarding lookahead",
1996 /* Do not reclaim the symbols of the rule which action triggered
1997 this YYABORT or YYACCEPT. */
1999 YY_STACK_PRINT (yyss, yyssp);
2000 while (yyssp != yyss)
2002 yydestruct ("Cleanup: popping",
2003 yystos[*yyssp], yyvsp);
2008 YYSTACK_FREE (yyss);
2011 if (yymsg != yymsgbuf)
2012 YYSTACK_FREE (yymsg);
2014 /* Make sure YYID is used. */
2015 return YYID (yyresult);
2020 /* Line 1675 of yacc.c */
2021 #line 311 "parsedate.y"
2024 /* Month and day table. */
2025 static TABLE MonthDayTable[] = {
2026 { "january", tMONTH, 1 },
2027 { "february", tMONTH, 2 },
2028 { "march", tMONTH, 3 },
2029 { "april", tMONTH, 4 },
2030 { "may", tMONTH, 5 },
2031 { "june", tMONTH, 6 },
2032 { "july", tMONTH, 7 },
2033 { "august", tMONTH, 8 },
2034 { "september", tMONTH, 9 },
2035 { "october", tMONTH, 10 },
2036 { "november", tMONTH, 11 },
2037 { "december", tMONTH, 12 },
2038 /* The value of the day isn't used... */
2039 { "sunday", tDAY, 0 },
2040 { "monday", tDAY, 0 },
2041 { "tuesday", tDAY, 0 },
2042 { "wednesday", tDAY, 0 },
2043 { "thursday", tDAY, 0 },
2044 { "friday", tDAY, 0 },
2045 { "saturday", tDAY, 0 },
2048 /* Time units table. */
2049 static TABLE UnitsTable[] = {
2050 { "year", tMONTH_UNIT, 12 },
2051 { "month", tMONTH_UNIT, 1 },
2052 { "week", tSEC_UNIT, 7L * 24 * 60 * 60 },
2053 { "day", tSEC_UNIT, 1L * 24 * 60 * 60 },
2054 { "hour", tSEC_UNIT, 60 * 60 },
2055 { "minute", tSEC_UNIT, 60 },
2056 { "min", tSEC_UNIT, 60 },
2057 { "second", tSEC_UNIT, 1 },
2058 { "sec", tSEC_UNIT, 1 },
2061 /* Timezone table. */
2062 static TABLE TimezoneTable[] = {
2063 { "gmt", tZONE, HOUR( 0) }, /* Greenwich Mean */
2064 { "ut", tZONE, HOUR( 0) }, /* Universal */
2065 { "utc", tZONE, HOUR( 0) }, /* Universal Coordinated */
2066 { "cut", tZONE, HOUR( 0) }, /* Coordinated Universal */
2067 { "z", tZONE, HOUR( 0) }, /* Greenwich Mean */
2068 { "wet", tZONE, HOUR( 0) }, /* Western European */
2069 { "bst", tDAYZONE, HOUR( 0) }, /* British Summer */
2070 { "nst", tZONE, HOUR(3)+30 }, /* Newfoundland Standard */
2071 { "ndt", tDAYZONE, HOUR(3)+30 }, /* Newfoundland Daylight */
2072 { "ast", tZONE, HOUR( 4) }, /* Atlantic Standard */
2073 { "adt", tDAYZONE, HOUR( 4) }, /* Atlantic Daylight */
2074 { "est", tZONE, HOUR( 5) }, /* Eastern Standard */
2075 { "edt", tDAYZONE, HOUR( 5) }, /* Eastern Daylight */
2076 { "cst", tZONE, HOUR( 6) }, /* Central Standard */
2077 { "cdt", tDAYZONE, HOUR( 6) }, /* Central Daylight */
2078 { "mst", tZONE, HOUR( 7) }, /* Mountain Standard */
2079 { "mdt", tDAYZONE, HOUR( 7) }, /* Mountain Daylight */
2080 { "pst", tZONE, HOUR( 8) }, /* Pacific Standard */
2081 { "pdt", tDAYZONE, HOUR( 8) }, /* Pacific Daylight */
2082 { "yst", tZONE, HOUR( 9) }, /* Yukon Standard */
2083 { "ydt", tDAYZONE, HOUR( 9) }, /* Yukon Daylight */
2084 { "akst", tZONE, HOUR( 9) }, /* Alaska Standard */
2085 { "akdt", tDAYZONE, HOUR( 9) }, /* Alaska Daylight */
2086 { "hst", tZONE, HOUR(10) }, /* Hawaii Standard */
2087 { "hast", tZONE, HOUR(10) }, /* Hawaii-Aleutian Standard */
2088 { "hadt", tDAYZONE, HOUR(10) }, /* Hawaii-Aleutian Daylight */
2089 { "ces", tDAYZONE, -HOUR(1) }, /* Central European Summer */
2090 { "cest", tDAYZONE, -HOUR(1) }, /* Central European Summer */
2091 { "mez", tZONE, -HOUR(1) }, /* Middle European */
2092 { "mezt", tDAYZONE, -HOUR(1) }, /* Middle European Summer */
2093 { "cet", tZONE, -HOUR(1) }, /* Central European */
2094 { "met", tZONE, -HOUR(1) }, /* Middle European */
2095 { "eet", tZONE, -HOUR(2) }, /* Eastern Europe */
2096 { "msk", tZONE, -HOUR(3) }, /* Moscow Winter */
2097 { "msd", tDAYZONE, -HOUR(3) }, /* Moscow Summer */
2098 { "wast", tZONE, -HOUR(8) }, /* West Australian Standard */
2099 { "wadt", tDAYZONE, -HOUR(8) }, /* West Australian Daylight */
2100 { "hkt", tZONE, -HOUR(8) }, /* Hong Kong */
2101 { "cct", tZONE, -HOUR(8) }, /* China Coast */
2102 { "jst", tZONE, -HOUR(9) }, /* Japan Standard */
2103 { "kst", tZONE, -HOUR(9) }, /* Korean Standard */
2104 { "kdt", tZONE, -HOUR(9) }, /* Korean Daylight */
2105 { "cast", tZONE, -(HOUR(9)+30) }, /* Central Australian Standard */
2106 { "cadt", tDAYZONE, -(HOUR(9)+30) }, /* Central Australian Daylight */
2107 { "east", tZONE, -HOUR(10) }, /* Eastern Australian Standard */
2108 { "eadt", tDAYZONE, -HOUR(10) }, /* Eastern Australian Daylight */
2109 { "nzst", tZONE, -HOUR(12) }, /* New Zealand Standard */
2110 { "nzdt", tDAYZONE, -HOUR(12) }, /* New Zealand Daylight */
2112 /* For completeness we include the following entries. */
2115 /* Duplicate names. Either they conflict with a zone listed above
2116 * (which is either more likely to be seen or just been in circulation
2117 * longer), or they conflict with another zone in this section and
2118 * we could not reasonably choose one over the other. */
2119 { "fst", tZONE, HOUR( 2) }, /* Fernando De Noronha Standard */
2120 { "fdt", tDAYZONE, HOUR( 2) }, /* Fernando De Noronha Daylight */
2121 { "bst", tZONE, HOUR( 3) }, /* Brazil Standard */
2122 { "est", tZONE, HOUR( 3) }, /* Eastern Standard (Brazil) */
2123 { "edt", tDAYZONE, HOUR( 3) }, /* Eastern Daylight (Brazil) */
2124 { "wst", tZONE, HOUR( 4) }, /* Western Standard (Brazil) */
2125 { "wdt", tDAYZONE, HOUR( 4) }, /* Western Daylight (Brazil) */
2126 { "cst", tZONE, HOUR( 5) }, /* Chile Standard */
2127 { "cdt", tDAYZONE, HOUR( 5) }, /* Chile Daylight */
2128 { "ast", tZONE, HOUR( 5) }, /* Acre Standard */
2129 { "adt", tDAYZONE, HOUR( 5) }, /* Acre Daylight */
2130 { "cst", tZONE, HOUR( 5) }, /* Cuba Standard */
2131 { "cdt", tDAYZONE, HOUR( 5) }, /* Cuba Daylight */
2132 { "est", tZONE, HOUR( 6) }, /* Easter Island Standard */
2133 { "edt", tDAYZONE, HOUR( 6) }, /* Easter Island Daylight */
2134 { "sst", tZONE, HOUR(11) }, /* Samoa Standard */
2135 { "ist", tZONE, -HOUR(2) }, /* Israel Standard */
2136 { "idt", tDAYZONE, -HOUR(2) }, /* Israel Daylight */
2137 { "idt", tDAYZONE, -(HOUR(3)+30) }, /* Iran Daylight */
2138 { "ist", tZONE, -(HOUR(3)+30) }, /* Iran Standard */
2139 { "cst", tZONE, -HOUR(8) }, /* China Standard */
2140 { "cdt", tDAYZONE, -HOUR(8) }, /* China Daylight */
2141 { "sst", tZONE, -HOUR(8) }, /* Singapore Standard */
2143 /* Dubious (e.g., not in Olson's TIMEZONE package) or obsolete. */
2144 { "gst", tZONE, HOUR( 3) }, /* Greenland Standard */
2145 { "wat", tZONE, -HOUR(1) }, /* West Africa */
2146 { "at", tZONE, HOUR( 2) }, /* Azores */
2147 { "gst", tZONE, -HOUR(10) }, /* Guam Standard */
2148 { "nft", tZONE, HOUR(3)+30 }, /* Newfoundland */
2149 { "idlw", tZONE, HOUR(12) }, /* International Date Line West */
2150 { "mewt", tZONE, -HOUR(1) }, /* Middle European Winter */
2151 { "mest", tDAYZONE, -HOUR(1) }, /* Middle European Summer */
2152 { "swt", tZONE, -HOUR(1) }, /* Swedish Winter */
2153 { "sst", tDAYZONE, -HOUR(1) }, /* Swedish Summer */
2154 { "fwt", tZONE, -HOUR(1) }, /* French Winter */
2155 { "fst", tDAYZONE, -HOUR(1) }, /* French Summer */
2156 { "bt", tZONE, -HOUR(3) }, /* Baghdad */
2157 { "it", tZONE, -(HOUR(3)+30) }, /* Iran */
2158 { "zp4", tZONE, -HOUR(4) }, /* USSR Zone 3 */
2159 { "zp5", tZONE, -HOUR(5) }, /* USSR Zone 4 */
2160 { "ist", tZONE, -(HOUR(5)+30) }, /* Indian Standard */
2161 { "zp6", tZONE, -HOUR(6) }, /* USSR Zone 5 */
2162 { "nst", tZONE, -HOUR(7) }, /* North Sumatra */
2163 { "sst", tZONE, -HOUR(7) }, /* South Sumatra */
2164 { "jt", tZONE, -(HOUR(7)+30) }, /* Java (3pm in Cronusland!) */
2165 { "nzt", tZONE, -HOUR(12) }, /* New Zealand */
2166 { "idle", tZONE, -HOUR(12) }, /* International Date Line East */
2167 { "cat", tZONE, HOUR(10) }, /* -- expired 1967 */
2168 { "nt", tZONE, HOUR(11) }, /* -- expired 1967 */
2169 { "ahst", tZONE, HOUR(10) }, /* -- expired 1983 */
2170 { "hdt", tDAYZONE, HOUR(10) }, /* -- expired 1986 */
2184 ToSeconds(time_t Hours, time_t Minutes, time_t Seconds, MERIDIAN Meridian)
2186 if (Minutes < 0 || Minutes > 59 || Seconds < 0 || Seconds > 61)
2188 if (Meridian == MER24) {
2189 if (Hours < 0 || Hours > 23)
2193 if (Hours < 1 || Hours > 12)
2197 if (Meridian == MERpm)
2200 return (Hours * 60L + Minutes) * 60L + Seconds;
2205 Convert(time_t Month, time_t Day, time_t Year,
2206 time_t Hours, time_t Minutes, time_t Seconds,
2207 MERIDIAN Meridian, DSTMODE dst)
2209 static int DaysNormal[13] = {
2210 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
2212 static int DaysLeap[13] = {
2213 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
2215 static int LeapYears[] = {
2216 1972, 1976, 1980, 1984, 1988, 1992, 1996,
2217 2000, 2004, 2008, 2012, 2016, 2020, 2024, 2028, 2032, 2036
2221 register time_t Julian;
2231 for (mp = DaysNormal, yp = LeapYears; yp < ENDOF(LeapYears); yp++)
2236 if (Year < EPOCH || Year > END_OF_TIME
2237 || Month < 1 || Month > 12
2238 /* NOSTRICT *//* conversion from long may lose accuracy */
2239 || Day < 1 || Day > mp[(int)Month])
2242 Julian = Day - 1 + (Year - EPOCH) * 365;
2243 for (yp = LeapYears; yp < ENDOF(LeapYears); yp++, Julian++)
2246 for (i = 1; i < Month; i++)
2248 Julian *= SECSPERDAY;
2249 Julian += yyTimezone * 60L;
2250 if ((tod = ToSeconds(Hours, Minutes, Seconds, Meridian)) < 0)
2254 if (dst == DSTon || (dst == DSTmaybe && localtime(&tod)->tm_isdst))
2255 Julian -= DST_OFFSET * 60L * 60L;
2261 DSTcorrect(time_t Start, time_t Future)
2266 StartDay = (localtime(&Start)->tm_hour + 1) % 24;
2267 FutureDay = (localtime(&Future)->tm_hour + 1) % 24;
2268 return (Future - Start) + (StartDay - FutureDay) * DST_OFFSET * 60L * 60L;
2273 RelativeMonth(time_t Start, time_t RelMonth)
2279 tm = localtime(&Start);
2280 Month = 12 * tm->tm_year + tm->tm_mon + RelMonth;
2282 Month = Month % 12 + 1;
2283 return DSTcorrect(Start,
2284 Convert(Month, (time_t)tm->tm_mday, Year,
2285 (time_t)tm->tm_hour, (time_t)tm->tm_min, (time_t)tm->tm_sec,
2291 LookupWord(char *buff, register int length)
2301 /* See if we have an abbreviation for a month. */
2302 if (length == 3 || (length == 4 && p[3] == '.'))
2303 for (tp = MonthDayTable; tp < ENDOF(MonthDayTable); tp++) {
2305 if (c == q[0] && p[1] == q[1] && p[2] == q[2]) {
2306 yylval.Number = tp->value;
2311 for (tp = MonthDayTable; tp < ENDOF(MonthDayTable); tp++)
2312 if (c == tp->name[0] && strcmp(p, tp->name) == 0) {
2313 yylval.Number = tp->value;
2317 /* Try for a timezone. */
2318 for (tp = TimezoneTable; tp < ENDOF(TimezoneTable); tp++)
2319 if (c == tp->name[0] && p[1] == tp->name[1]
2320 && strcmp(p, tp->name) == 0) {
2321 yylval.Number = tp->value;
2325 /* Try the units table. */
2326 for (tp = UnitsTable; tp < ENDOF(UnitsTable); tp++)
2327 if (c == tp->name[0] && strcmp(p, tp->name) == 0) {
2328 yylval.Number = tp->value;
2332 /* Strip off any plural and try the units table again. */
2333 if (--length > 0 && p[length] == 's') {
2335 for (tp = UnitsTable; tp < ENDOF(UnitsTable); tp++)
2336 if (c == tp->name[0] && strcmp(p, tp->name) == 0) {
2338 yylval.Number = tp->value;
2345 /* Drop out any periods. */
2346 for (p = buff, q = (char*)buff; *q; q++)
2351 /* Try the meridians. */
2352 if (buff[1] == 'm' && buff[2] == '\0') {
2353 if (buff[0] == 'a') {
2354 yylval.Meridian = MERam;
2357 if (buff[0] == 'p') {
2358 yylval.Meridian = MERpm;
2363 /* If we saw any periods, try the timezones again. */
2364 if (p - buff != length) {
2366 for (p = buff, tp = TimezoneTable; tp < ENDOF(TimezoneTable); tp++)
2367 if (c == tp->name[0] && p[1] == tp->name[1]
2368 && strcmp(p, tp->name) == 0) {
2369 yylval.Number = tp->value;
2374 /* Unknown word -- assume GMT timezone. */
2388 register int nesting;
2391 /* Get first character after the whitespace. */
2393 while (isspace(*yyInput))
2397 /* Ignore RFC 822 comments, typically time zone names. */
2400 for (nesting = 1; (c = *++yyInput) != RPAREN || --nesting; )
2403 else if (!IS7BIT(c) || c == '\0' || c == '\r'
2404 || (c == '\\' && ((c = *++yyInput) == '\0' || !IS7BIT(c))))
2405 /* Lexical error: bad comment. */
2411 if (isdigit(c) || c == '-' || c == '+') {
2412 if (c == '-' || c == '+') {
2413 sign = c == '-' ? -1 : 1;
2415 if (!isdigit(*yyInput))
2416 /* Skip the plus or minus sign. */
2421 for (i = 0; (c = *yyInput++) != '\0' && isdigit(c); )
2422 i = 10 * i + c - '0';
2424 yylval.Number = sign < 0 ? -i : i;
2425 return sign ? tSNUMBER : tUNUMBER;
2430 for (p = buff; (c = *yyInput++) == '.' || isalpha(c); )
2431 if (p < &buff[sizeof buff - 1])
2432 *p++ = isupper(c) ? tolower(c) : c;
2435 return LookupWord(buff, p - buff);
2444 parsedate(const char *p)
2446 extern int date_parse(void);
2449 yyInput = p; /* well, its supposed to be const... */
2455 yyDSTmode = DSTmaybe;
2466 if (date_parse() || yyHaveTime > 1 || yyHaveDate > 1)
2469 if (yyHaveDate || yyHaveTime) {
2470 Start = Convert(yyMonth, yyDay, yyYear, yyHour, yyMinutes, yySeconds,
2471 yyMeridian, yyDSTmode);
2478 Start += yyRelSeconds;
2480 Start += RelativeMonth(Start, yyRelMonth);
2482 /* Have to do *something* with a legitimate -1 so it's distinguishable
2483 * from the error return value. (Alternately could set errno on error.) */
2484 return Start == -1 ? 0 : Start;
2492 #endif /* YYDEBUG */
2496 main(int ac, char *av[])
2503 #endif /* YYDEBUG */
2505 (void)printf("Enter date, or blank line to exit.\n\t> ");
2507 (void)printf("\t> ");
2508 (void)fflush(stdout);
2509 if (fgets(buff, sizeof buff, stdin) == NULL || buff[0] == '\n')
2512 if (strcmp(buff, "yydebug") == 0) {
2514 printf("yydebug = %s\n", yydebug ? "on" : "off");
2517 #endif /* YYDEBUG */
2518 d = parsedate(buff, (TIMEINFO *)NULL);
2520 (void)printf("Bad format - couldn't convert.\n");
2522 (void)printf("%s", ctime(&d));