1 /* A Bison parser, made by GNU Bison 2.5. */
3 /* Bison implementation for Yacc-like parsers in C
5 Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc.
7 This program is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 /* As a special exception, you may create a larger work that contains
21 part or all of the Bison parser skeleton and distribute that work
22 under terms of your choice, so long as that work isn't itself a
23 parser generator using the skeleton or a modified version thereof
24 as a parser skeleton. Alternatively, if you modify or redistribute
25 the parser skeleton itself, you may (at your option) remove this
26 special exception, which will cause the skeleton and the resulting
27 Bison output files to be licensed under the GNU General Public
28 License without this special exception.
30 This special exception was added by the Free Software Foundation in
31 version 2.2 of Bison. */
33 /* C LALR(1) parser skeleton written by Richard Stallman, by
34 simplifying the original so-called "semantic" parser. */
36 /* All symbols defined below should begin with yy or YY, to avoid
37 infringing on user name space. This should be done even for local
38 variables, as they might otherwise be expanded by user macros.
39 There are some unavoidable exceptions within include files to
40 define necessary library symbols; they are noted "INFRINGES ON
41 USER NAME SPACE" below. */
43 /* Identify Bison output. */
47 #define YYBISON_VERSION "2.5"
50 #define YYSKELETON_NAME "yacc.c"
61 /* Using locations. */
62 #define YYLSP_NEEDED 0
66 /* Copy the first part of user declarations. */
68 /* Line 268 of yacc.c */
73 ** Originally written by Steven M. Bellovin <smb@research.att.com> while
74 ** at the University of North Carolina at Chapel Hill. Later tweaked by
75 ** a couple of people on Usenet. Completely overhauled by Rich $alz
76 ** <rsalz@osf.org> and Jim Berets <jberets@bbn.com> in August, 1990.
77 ** Further revised (removed obsolete constructs and cleaned up timezone
78 ** names) in August, 1991, by Rich. Paul Eggert <eggert@twinsun.com>
79 ** helped in September, 1992. Art Cancro <ajc@citadel.org> cleaned
80 ** it up for ANSI C in December, 1999.
82 ** This grammar has six shift/reduce conflicts.
84 ** This code is in the public domain and has no copyright.
86 /* SUPPRESS 530 *//* Empty body for statement */
87 /* SUPPRESS 593 on yyerrlab *//* Label was not used */
88 /* SUPPRESS 593 on yynewstate *//* Label was not used */
89 /* SUPPRESS 595 on yypvt *//* Automatic variable may be used before set */
95 #include <sys/types.h>
99 # if !STDC_HEADERS && HAVE_MEMORY_H
105 # include <strings.h>
108 #include "parsedate.h"
112 #define yyparse date_parse
113 #define yylex date_lex
114 #define yyerror date_error
117 /* See the LeapYears table in Convert. */
119 #define END_OF_TIME 2038
120 /* Constants for general time calculations. */
122 #define SECSPERDAY (24L * 60L * 60L)
123 /* Readability for TABLE stuff. */
124 #define HOUR(x) (x * 60)
128 #define IS7BIT(x) ((unsigned int)(x) < 0200)
130 #define SIZEOF(array) ((int)(sizeof array / sizeof array[0]))
131 #define ENDOF(array) (&array[SIZEOF(array)])
135 ** An entry in the lexical lookup table.
137 typedef struct _TABLE {
144 ** Daylight-savings mode: on, off, or not yet known.
146 typedef enum _DSTMODE {
147 DSTon, DSToff, DSTmaybe
151 ** Meridian: am, pm, or 24-hour style.
153 typedef enum _MERIDIAN {
159 ** Global variables. We could get rid of most of them by using a yacc
160 ** union, but this is more efficient. (This routine predates the
161 ** yacc %union construct.)
163 static const char *yyInput;
164 static DSTMODE yyDSTmode;
165 static int yyHaveDate;
166 static int yyHaveRel;
167 static int yyHaveTime;
168 static time_t yyTimezone;
170 static time_t yyHour;
171 static time_t yyMinutes;
172 static time_t yyMonth;
173 static time_t yySeconds;
174 static time_t yyYear;
175 static MERIDIAN yyMeridian;
176 static time_t yyRelMonth;
177 static time_t yyRelSeconds;
180 static void date_error(char *);
183 /* Line 268 of yacc.c */
186 /* Enabling traces. */
191 /* Enabling verbose error messages. */
192 #ifdef YYERROR_VERBOSE
193 # undef YYERROR_VERBOSE
194 # define YYERROR_VERBOSE 1
196 # define YYERROR_VERBOSE 0
199 /* Enabling the token table. */
200 #ifndef YYTOKEN_TABLE
201 # define YYTOKEN_TABLE 0
208 /* Put the tokens into the symbol table, so that GDB and other debuggers
225 #define tMERIDIAN 260
227 #define tMONTH_UNIT 262
228 #define tSEC_UNIT 263
236 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
237 typedef union YYSTYPE
240 /* Line 293 of yacc.c */
241 #line 114 "parsedate.y"
244 enum _MERIDIAN Meridian;
248 /* Line 293 of yacc.c */
251 # define YYSTYPE_IS_TRIVIAL 1
252 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
253 # define YYSTYPE_IS_DECLARED 1
257 /* Copy the second part of user declarations. */
260 /* Line 343 of yacc.c */
268 typedef YYTYPE_UINT8 yytype_uint8;
270 typedef unsigned char yytype_uint8;
274 typedef YYTYPE_INT8 yytype_int8;
275 #elif (defined __STDC__ || defined __C99__FUNC__ \
276 || defined __cplusplus || defined _MSC_VER)
277 typedef signed char yytype_int8;
279 typedef short int yytype_int8;
283 typedef YYTYPE_UINT16 yytype_uint16;
285 typedef unsigned short int yytype_uint16;
289 typedef YYTYPE_INT16 yytype_int16;
291 typedef short int yytype_int16;
295 # ifdef __SIZE_TYPE__
296 # define YYSIZE_T __SIZE_TYPE__
297 # elif defined size_t
298 # define YYSIZE_T size_t
299 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
300 || defined __cplusplus || defined _MSC_VER)
301 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
302 # define YYSIZE_T size_t
304 # define YYSIZE_T unsigned int
308 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
311 # if defined YYENABLE_NLS && YYENABLE_NLS
313 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
314 # define YY_(msgid) dgettext ("bison-runtime", msgid)
318 # define YY_(msgid) msgid
322 /* Suppress unused-variable warnings by "using" E. */
323 #if ! defined lint || defined __GNUC__
324 # define YYUSE(e) ((void) (e))
326 # define YYUSE(e) /* empty */
329 /* Identity function, used to suppress warnings about constant conditions. */
333 #if (defined __STDC__ || defined __C99__FUNC__ \
334 || defined __cplusplus || defined _MSC_VER)
347 #if ! defined yyoverflow || YYERROR_VERBOSE
349 /* The parser invokes alloca or malloc; define the necessary symbols. */
351 # ifdef YYSTACK_USE_ALLOCA
352 # if YYSTACK_USE_ALLOCA
354 # define YYSTACK_ALLOC __builtin_alloca
355 # elif defined __BUILTIN_VA_ARG_INCR
356 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
358 # define YYSTACK_ALLOC __alloca
359 # elif defined _MSC_VER
360 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
361 # define alloca _alloca
363 # define YYSTACK_ALLOC alloca
364 # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
365 || defined __cplusplus || defined _MSC_VER)
366 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
367 # ifndef EXIT_SUCCESS
368 # define EXIT_SUCCESS 0
375 # ifdef YYSTACK_ALLOC
376 /* Pacify GCC's `empty if-body' warning. */
377 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
378 # ifndef YYSTACK_ALLOC_MAXIMUM
379 /* The OS might guarantee only one guard page at the bottom of the stack,
380 and a page size can be as small as 4096 bytes. So we cannot safely
381 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
382 to allow for a few compiler-allocated temporary stack slots. */
383 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
386 # define YYSTACK_ALLOC YYMALLOC
387 # define YYSTACK_FREE YYFREE
388 # ifndef YYSTACK_ALLOC_MAXIMUM
389 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
391 # if (defined __cplusplus && ! defined EXIT_SUCCESS \
392 && ! ((defined YYMALLOC || defined malloc) \
393 && (defined YYFREE || defined free)))
394 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
395 # ifndef EXIT_SUCCESS
396 # define EXIT_SUCCESS 0
400 # define YYMALLOC malloc
401 # if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
402 || defined __cplusplus || defined _MSC_VER)
403 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
408 # if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
409 || defined __cplusplus || defined _MSC_VER)
410 void free (void *); /* INFRINGES ON USER NAME SPACE */
414 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
417 #if (! defined yyoverflow \
418 && (! defined __cplusplus \
419 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
421 /* A type that is properly aligned for any stack member. */
424 yytype_int16 yyss_alloc;
428 /* The size of the maximum gap between one aligned stack and the next. */
429 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
431 /* The size of an array large to enough to hold all stacks, each with
433 # define YYSTACK_BYTES(N) \
434 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
435 + YYSTACK_GAP_MAXIMUM)
437 # define YYCOPY_NEEDED 1
439 /* Relocate STACK from its old location to the new one. The
440 local variables YYSIZE and YYSTACKSIZE give the old and new number of
441 elements in the stack, and YYPTR gives the new location of the
442 stack. Advance YYPTR to a properly aligned location for the next
444 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
447 YYSIZE_T yynewbytes; \
448 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
449 Stack = &yyptr->Stack_alloc; \
450 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
451 yyptr += yynewbytes / sizeof (*yyptr); \
457 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
458 /* Copy COUNT objects from FROM to TO. The source and destination do
461 # if defined __GNUC__ && 1 < __GNUC__
462 # define YYCOPY(To, From, Count) \
463 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
465 # define YYCOPY(To, From, Count) \
469 for (yyi = 0; yyi < (Count); yyi++) \
470 (To)[yyi] = (From)[yyi]; \
475 #endif /* !YYCOPY_NEEDED */
477 /* YYFINAL -- State number of the termination state. */
479 /* YYLAST -- Last index in YYTABLE. */
482 /* YYNTOKENS -- Number of terminals. */
484 /* YYNNTS -- Number of nonterminals. */
486 /* YYNRULES -- Number of rules. */
488 /* YYNRULES -- Number of states. */
491 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
493 #define YYMAXUTOK 266
495 #define YYTRANSLATE(YYX) \
496 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
498 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
499 static const yytype_uint8 yytranslate[] =
501 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
502 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
503 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
504 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
505 2, 2, 2, 2, 14, 2, 2, 13, 2, 2,
506 2, 2, 2, 2, 2, 2, 2, 2, 12, 2,
507 2, 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, 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, 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, 1, 2, 3, 4,
527 5, 6, 7, 8, 9, 10, 11
531 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
533 static const yytype_uint8 yyprhs[] =
535 0, 0, 3, 4, 7, 9, 12, 14, 16, 19,
536 24, 29, 36, 43, 45, 47, 50, 52, 54, 58,
537 64, 67, 72, 75, 79, 85, 88, 91, 94, 97,
541 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
542 static const yytype_int8 yyrhs[] =
544 16, 0, -1, -1, 16, 17, -1, 18, -1, 18,
545 19, -1, 21, -1, 22, -1, 10, 23, -1, 10,
546 12, 10, 23, -1, 10, 12, 10, 20, -1, 10,
547 12, 10, 12, 10, 23, -1, 10, 12, 10, 12,
548 10, 20, -1, 11, -1, 4, -1, 11, 20, -1,
549 20, -1, 9, -1, 10, 13, 10, -1, 10, 13,
550 10, 13, 10, -1, 6, 10, -1, 6, 10, 14,
551 10, -1, 10, 6, -1, 10, 6, 10, -1, 3,
552 14, 10, 6, 10, -1, 9, 8, -1, 10, 8,
553 -1, 9, 7, -1, 10, 7, -1, -1, 5, -1
556 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
557 static const yytype_uint16 yyrline[] =
559 0, 128, 128, 129, 132, 141, 145, 148, 153, 165,
560 171, 178, 184, 194, 198, 202, 210, 216, 237, 241,
561 253, 257, 262, 266, 271, 278, 281, 284, 287, 292,
566 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
567 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
568 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
569 static const char *const yytname[] =
571 "$end", "error", "$undefined", "tDAY", "tDAYZONE", "tMERIDIAN",
572 "tMONTH", "tMONTH_UNIT", "tSEC_UNIT", "tSNUMBER", "tUNUMBER", "tZONE",
573 "':'", "'/'", "','", "$accept", "spec", "item", "time", "zone",
574 "numzone", "date", "rel", "o_merid", 0
579 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
581 static const yytype_uint16 yytoknum[] =
583 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
588 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
589 static const yytype_uint8 yyr1[] =
591 0, 15, 16, 16, 17, 17, 17, 17, 18, 18,
592 18, 18, 18, 19, 19, 19, 19, 20, 21, 21,
593 21, 21, 21, 21, 21, 22, 22, 22, 22, 23,
597 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
598 static const yytype_uint8 yyr2[] =
600 0, 2, 0, 2, 1, 2, 1, 1, 2, 4,
601 4, 6, 6, 1, 1, 2, 1, 1, 3, 5,
602 2, 4, 2, 3, 5, 2, 2, 2, 2, 0,
606 /* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
607 Performed when YYTABLE doesn't specify something else to do. Zero
608 means the default is an error. */
609 static const yytype_uint8 yydefact[] =
611 2, 0, 1, 0, 0, 0, 29, 3, 4, 6,
612 7, 0, 20, 27, 25, 30, 22, 28, 26, 0,
613 0, 8, 14, 17, 13, 5, 16, 0, 0, 23,
614 29, 18, 15, 0, 21, 0, 10, 9, 0, 24,
618 /* YYDEFGOTO[NTERM-NUM]. */
619 static const yytype_int8 yydefgoto[] =
621 -1, 1, 7, 8, 25, 26, 9, 10, 21
624 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
626 #define YYPACT_NINF -29
627 static const yytype_int8 yypact[] =
629 -29, 1, -29, -11, 11, 20, 12, -29, 4, -29,
630 -29, 13, 16, -29, -29, -29, 21, -29, -29, 22,
631 23, -29, -29, -29, 5, -29, -29, 28, 25, -29,
632 17, 24, -29, 26, -29, 29, -29, -29, 30, -29,
636 /* YYPGOTO[NTERM-NUM]. */
637 static const yytype_int8 yypgoto[] =
639 -29, -29, -29, -29, -29, -24, -29, -29, -28
642 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
643 positive, shift that token. If negative, reduce the rule which
644 number is the opposite. If YYTABLE_NINF, syntax error. */
645 #define YYTABLE_NINF -1
646 static const yytype_uint8 yytable[] =
648 32, 2, 37, 11, 3, 15, 36, 4, 22, 23,
649 5, 6, 43, 23, 23, 24, 42, 15, 16, 17,
650 18, 12, 15, 27, 19, 20, 23, 13, 14, 35,
651 28, 29, 30, 31, 33, 34, 39, 38, 0, 40,
655 #define yypact_value_is_default(yystate) \
658 #define yytable_value_is_error(yytable_value) \
661 static const yytype_int8 yycheck[] =
663 24, 0, 30, 14, 3, 5, 30, 6, 4, 9,
664 9, 10, 40, 9, 9, 11, 40, 5, 6, 7,
665 8, 10, 5, 10, 12, 13, 9, 7, 8, 12,
666 14, 10, 10, 10, 6, 10, 10, 13, -1, 10,
670 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
671 symbol of state STATE-NUM. */
672 static const yytype_uint8 yystos[] =
674 0, 16, 0, 3, 6, 9, 10, 17, 18, 21,
675 22, 14, 10, 7, 8, 5, 6, 7, 8, 12,
676 13, 23, 4, 9, 11, 19, 20, 10, 14, 10,
677 10, 10, 20, 6, 10, 12, 20, 23, 13, 10,
681 #define yyerrok (yyerrstatus = 0)
682 #define yyclearin (yychar = YYEMPTY)
686 #define YYACCEPT goto yyacceptlab
687 #define YYABORT goto yyabortlab
688 #define YYERROR goto yyerrorlab
691 /* Like YYERROR except do call yyerror. This remains here temporarily
692 to ease the transition to the new meaning of YYERROR, for GCC.
693 Once GCC version 2 has supplanted version 1, this can go. However,
694 YYFAIL appears to be in use. Nevertheless, it is formally deprecated
695 in Bison 2.4.2's NEWS entry, where a plan to phase it out is
698 #define YYFAIL goto yyerrlab
700 /* This is here to suppress warnings from the GCC cpp's
701 -Wunused-macros. Normally we don't worry about that warning, but
702 some users do, and we want to make it easy for users to remove
703 YYFAIL uses, which will produce warnings from Bison 2.5. */
706 #define YYRECOVERING() (!!yyerrstatus)
708 #define YYBACKUP(Token, Value) \
710 if (yychar == YYEMPTY && yylen == 1) \
719 yyerror (YY_("syntax error: cannot back up")); \
726 #define YYERRCODE 256
729 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
730 If N is 0, then set CURRENT to the empty location which ends
731 the previous symbol: RHS[0] (always defined). */
733 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
734 #ifndef YYLLOC_DEFAULT
735 # define YYLLOC_DEFAULT(Current, Rhs, N) \
739 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
740 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
741 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
742 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
746 (Current).first_line = (Current).last_line = \
747 YYRHSLOC (Rhs, 0).last_line; \
748 (Current).first_column = (Current).last_column = \
749 YYRHSLOC (Rhs, 0).last_column; \
755 /* This macro is provided for backward compatibility. */
757 #ifndef YY_LOCATION_PRINT
758 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
762 /* YYLEX -- calling `yylex' with the right arguments. */
765 # define YYLEX yylex (YYLEX_PARAM)
767 # define YYLEX yylex ()
770 /* Enable debugging if requested. */
774 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
775 # define YYFPRINTF fprintf
778 # define YYDPRINTF(Args) \
784 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
788 YYFPRINTF (stderr, "%s ", Title); \
789 yy_symbol_print (stderr, \
791 YYFPRINTF (stderr, "\n"); \
796 /*--------------------------------.
797 | Print this symbol on YYOUTPUT. |
798 `--------------------------------*/
801 #if (defined __STDC__ || defined __C99__FUNC__ \
802 || defined __cplusplus || defined _MSC_VER)
804 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
807 yy_symbol_value_print (yyoutput, yytype, yyvaluep)
810 YYSTYPE const * const yyvaluep;
816 if (yytype < YYNTOKENS)
817 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
829 /*--------------------------------.
830 | Print this symbol on YYOUTPUT. |
831 `--------------------------------*/
833 #if (defined __STDC__ || defined __C99__FUNC__ \
834 || defined __cplusplus || defined _MSC_VER)
836 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
839 yy_symbol_print (yyoutput, yytype, yyvaluep)
842 YYSTYPE const * const yyvaluep;
845 if (yytype < YYNTOKENS)
846 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
848 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
850 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
851 YYFPRINTF (yyoutput, ")");
854 /*------------------------------------------------------------------.
855 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
857 `------------------------------------------------------------------*/
859 #if (defined __STDC__ || defined __C99__FUNC__ \
860 || defined __cplusplus || defined _MSC_VER)
862 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
865 yy_stack_print (yybottom, yytop)
866 yytype_int16 *yybottom;
870 YYFPRINTF (stderr, "Stack now");
871 for (; yybottom <= yytop; yybottom++)
873 int yybot = *yybottom;
874 YYFPRINTF (stderr, " %d", yybot);
876 YYFPRINTF (stderr, "\n");
879 # define YY_STACK_PRINT(Bottom, Top) \
882 yy_stack_print ((Bottom), (Top)); \
886 /*------------------------------------------------.
887 | Report that the YYRULE is going to be reduced. |
888 `------------------------------------------------*/
890 #if (defined __STDC__ || defined __C99__FUNC__ \
891 || defined __cplusplus || defined _MSC_VER)
893 yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
896 yy_reduce_print (yyvsp, yyrule)
901 int yynrhs = yyr2[yyrule];
903 unsigned long int yylno = yyrline[yyrule];
904 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
906 /* The symbols being reduced. */
907 for (yyi = 0; yyi < yynrhs; yyi++)
909 YYFPRINTF (stderr, " $%d = ", yyi + 1);
910 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
911 &(yyvsp[(yyi + 1) - (yynrhs)])
913 YYFPRINTF (stderr, "\n");
917 # define YY_REDUCE_PRINT(Rule) \
920 yy_reduce_print (yyvsp, Rule); \
923 /* Nonzero means print parse trace. It is left uninitialized so that
924 multiple parsers can coexist. */
927 # define YYDPRINTF(Args)
928 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
929 # define YY_STACK_PRINT(Bottom, Top)
930 # define YY_REDUCE_PRINT(Rule)
931 #endif /* !YYDEBUG */
934 /* YYINITDEPTH -- initial size of the parser's stacks. */
936 # define YYINITDEPTH 200
939 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
940 if the built-in stack extension method is used).
942 Do not make this value too large; the results are undefined if
943 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
944 evaluated with infinite-precision integer arithmetic. */
947 # define YYMAXDEPTH 10000
954 # if defined __GLIBC__ && defined _STRING_H
955 # define yystrlen strlen
957 /* Return the length of YYSTR. */
958 #if (defined __STDC__ || defined __C99__FUNC__ \
959 || defined __cplusplus || defined _MSC_VER)
961 yystrlen (const char *yystr)
969 for (yylen = 0; yystr[yylen]; yylen++)
977 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
978 # define yystpcpy stpcpy
980 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
982 #if (defined __STDC__ || defined __C99__FUNC__ \
983 || defined __cplusplus || defined _MSC_VER)
985 yystpcpy (char *yydest, const char *yysrc)
988 yystpcpy (yydest, yysrc)
994 const char *yys = yysrc;
996 while ((*yyd++ = *yys++) != '\0')
1005 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1006 quotes and backslashes, so that it's suitable for yyerror. The
1007 heuristic is that double-quoting is unnecessary unless the string
1008 contains an apostrophe, a comma, or backslash (other than
1009 backslash-backslash). YYSTR is taken from yytname. If YYRES is
1010 null, do not copy; instead, return the length of what the result
1013 yytnamerr (char *yyres, const char *yystr)
1018 char const *yyp = yystr;
1025 goto do_not_strip_quotes;
1029 goto do_not_strip_quotes;
1042 do_not_strip_quotes: ;
1046 return yystrlen (yystr);
1048 return yystpcpy (yyres, yystr) - yyres;
1052 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
1053 about the unexpected token YYTOKEN for the state stack whose top is
1056 Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
1057 not large enough to hold the message. In that case, also set
1058 *YYMSG_ALLOC to the required number of bytes. Return 2 if the
1059 required number of bytes is too large to store. */
1061 yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
1062 yytype_int16 *yyssp, int yytoken)
1064 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytoken]);
1065 YYSIZE_T yysize = yysize0;
1067 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1068 /* Internationalized format string. */
1069 const char *yyformat = 0;
1070 /* Arguments of yyformat. */
1071 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1072 /* Number of reported tokens (one for the "unexpected", one per
1076 /* There are many possibilities here to consider:
1077 - Assume YYFAIL is not used. It's too flawed to consider. See
1078 <http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html>
1079 for details. YYERROR is fine as it does not invoke this
1081 - If this state is a consistent state with a default action, then
1082 the only way this function was invoked is if the default action
1083 is an error action. In that case, don't check for expected
1084 tokens because there are none.
1085 - The only way there can be no lookahead present (in yychar) is if
1086 this state is a consistent state with a default action. Thus,
1087 detecting the absence of a lookahead is sufficient to determine
1088 that there is no unexpected or expected token to report. In that
1089 case, just report a simple "syntax error".
1090 - Don't assume there isn't a lookahead just because this state is a
1091 consistent state with a default action. There might have been a
1092 previous inconsistent state, consistent state with a non-default
1093 action, or user semantic action that manipulated yychar.
1094 - Of course, the expected token list depends on states to have
1095 correct lookahead information, and it depends on the parser not
1096 to perform extra reductions after fetching a lookahead from the
1097 scanner and before detecting a syntax error. Thus, state merging
1098 (from LALR or IELR) and default reductions corrupt the expected
1099 token list. However, the list is correct for canonical LR with
1100 one exception: it will still contain any token that will not be
1101 accepted due to an error action in a later state.
1103 if (yytoken != YYEMPTY)
1105 int yyn = yypact[*yyssp];
1106 yyarg[yycount++] = yytname[yytoken];
1107 if (!yypact_value_is_default (yyn))
1109 /* Start YYX at -YYN if negative to avoid negative indexes in
1110 YYCHECK. In other words, skip the first -YYN actions for
1111 this state because they are default actions. */
1112 int yyxbegin = yyn < 0 ? -yyn : 0;
1113 /* Stay within bounds of both yycheck and yytname. */
1114 int yychecklim = YYLAST - yyn + 1;
1115 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1118 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1119 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
1120 && !yytable_value_is_error (yytable[yyx + yyn]))
1122 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1128 yyarg[yycount++] = yytname[yyx];
1129 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1130 if (! (yysize <= yysize1
1131 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1140 # define YYCASE_(N, S) \
1144 YYCASE_(0, YY_("syntax error"));
1145 YYCASE_(1, YY_("syntax error, unexpected %s"));
1146 YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1147 YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1148 YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1149 YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1153 yysize1 = yysize + yystrlen (yyformat);
1154 if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1158 if (*yymsg_alloc < yysize)
1160 *yymsg_alloc = 2 * yysize;
1161 if (! (yysize <= *yymsg_alloc
1162 && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1163 *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1167 /* Avoid sprintf, as that infringes on the user's name space.
1168 Don't have undefined behavior even if the translation
1169 produced a string with the wrong number of "%s"s. */
1173 while ((*yyp = *yyformat) != '\0')
1174 if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1176 yyp += yytnamerr (yyp, yyarg[yyi++]);
1187 #endif /* YYERROR_VERBOSE */
1189 /*-----------------------------------------------.
1190 | Release the memory associated to this symbol. |
1191 `-----------------------------------------------*/
1194 #if (defined __STDC__ || defined __C99__FUNC__ \
1195 || defined __cplusplus || defined _MSC_VER)
1197 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1200 yydestruct (yymsg, yytype, yyvaluep)
1210 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1221 /* Prevent warnings from -Wmissing-prototypes. */
1222 #ifdef YYPARSE_PARAM
1223 #if defined __STDC__ || defined __cplusplus
1224 int yyparse (void *YYPARSE_PARAM);
1228 #else /* ! YYPARSE_PARAM */
1229 #if defined __STDC__ || defined __cplusplus
1234 #endif /* ! YYPARSE_PARAM */
1237 /* The lookahead symbol. */
1240 /* The semantic value of the lookahead symbol. */
1243 /* Number of syntax errors so far. */
1251 #ifdef YYPARSE_PARAM
1252 #if (defined __STDC__ || defined __C99__FUNC__ \
1253 || defined __cplusplus || defined _MSC_VER)
1255 yyparse (void *YYPARSE_PARAM)
1258 yyparse (YYPARSE_PARAM)
1259 void *YYPARSE_PARAM;
1261 #else /* ! YYPARSE_PARAM */
1262 #if (defined __STDC__ || defined __C99__FUNC__ \
1263 || defined __cplusplus || defined _MSC_VER)
1274 /* Number of tokens to shift before error messages enabled. */
1277 /* The stacks and their tools:
1278 `yyss': related to states.
1279 `yyvs': related to semantic values.
1281 Refer to the stacks thru separate pointers, to allow yyoverflow
1282 to reallocate them elsewhere. */
1284 /* The state stack. */
1285 yytype_int16 yyssa[YYINITDEPTH];
1287 yytype_int16 *yyssp;
1289 /* The semantic value stack. */
1290 YYSTYPE yyvsa[YYINITDEPTH];
1294 YYSIZE_T yystacksize;
1298 /* Lookahead token as an internal (translated) token number. */
1300 /* The variables used to return semantic value and location from the
1305 /* Buffer for error messages, and its allocated size. */
1307 char *yymsg = yymsgbuf;
1308 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1311 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1313 /* The number of symbols on the RHS of the reduced rule.
1314 Keep to zero when no symbol should be popped. */
1320 yystacksize = YYINITDEPTH;
1322 YYDPRINTF ((stderr, "Starting parse\n"));
1327 yychar = YYEMPTY; /* Cause a token to be read. */
1329 /* Initialize stack pointers.
1330 Waste one element of value and location stack
1331 so that they stay on the same level as the state stack.
1332 The wasted elements are never initialized. */
1338 /*------------------------------------------------------------.
1339 | yynewstate -- Push a new state, which is found in yystate. |
1340 `------------------------------------------------------------*/
1342 /* In all cases, when you get here, the value and location stacks
1343 have just been pushed. So pushing a state here evens the stacks. */
1349 if (yyss + yystacksize - 1 <= yyssp)
1351 /* Get the current used size of the three stacks, in elements. */
1352 YYSIZE_T yysize = yyssp - yyss + 1;
1356 /* Give user a chance to reallocate the stack. Use copies of
1357 these so that the &'s don't force the real ones into
1359 YYSTYPE *yyvs1 = yyvs;
1360 yytype_int16 *yyss1 = yyss;
1362 /* Each stack pointer address is followed by the size of the
1363 data in use in that stack, in bytes. This used to be a
1364 conditional around just the two extra args, but that might
1365 be undefined if yyoverflow is a macro. */
1366 yyoverflow (YY_("memory exhausted"),
1367 &yyss1, yysize * sizeof (*yyssp),
1368 &yyvs1, yysize * sizeof (*yyvsp),
1374 #else /* no yyoverflow */
1375 # ifndef YYSTACK_RELOCATE
1376 goto yyexhaustedlab;
1378 /* Extend the stack our own way. */
1379 if (YYMAXDEPTH <= yystacksize)
1380 goto yyexhaustedlab;
1382 if (YYMAXDEPTH < yystacksize)
1383 yystacksize = YYMAXDEPTH;
1386 yytype_int16 *yyss1 = yyss;
1387 union yyalloc *yyptr =
1388 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1390 goto yyexhaustedlab;
1391 YYSTACK_RELOCATE (yyss_alloc, yyss);
1392 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1393 # undef YYSTACK_RELOCATE
1395 YYSTACK_FREE (yyss1);
1398 #endif /* no yyoverflow */
1400 yyssp = yyss + yysize - 1;
1401 yyvsp = yyvs + yysize - 1;
1403 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1404 (unsigned long int) yystacksize));
1406 if (yyss + yystacksize - 1 <= yyssp)
1410 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1412 if (yystate == YYFINAL)
1422 /* Do appropriate processing given the current state. Read a
1423 lookahead token if we need one and don't already have one. */
1425 /* First try to decide what to do without reference to lookahead token. */
1426 yyn = yypact[yystate];
1427 if (yypact_value_is_default (yyn))
1430 /* Not known => get a lookahead token if don't already have one. */
1432 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1433 if (yychar == YYEMPTY)
1435 YYDPRINTF ((stderr, "Reading a token: "));
1439 if (yychar <= YYEOF)
1441 yychar = yytoken = YYEOF;
1442 YYDPRINTF ((stderr, "Now at end of input.\n"));
1446 yytoken = YYTRANSLATE (yychar);
1447 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1450 /* If the proper action on seeing token YYTOKEN is to reduce or to
1451 detect an error, take that action. */
1453 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1458 if (yytable_value_is_error (yyn))
1464 /* Count tokens shifted since error; after three, turn off error
1469 /* Shift the lookahead token. */
1470 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1472 /* Discard the shifted token. */
1481 /*-----------------------------------------------------------.
1482 | yydefault -- do the default action for the current state. |
1483 `-----------------------------------------------------------*/
1485 yyn = yydefact[yystate];
1491 /*-----------------------------.
1492 | yyreduce -- Do a reduction. |
1493 `-----------------------------*/
1495 /* yyn is the number of a rule to reduce with. */
1498 /* If YYLEN is nonzero, implement the default value of the action:
1501 Otherwise, the following line sets YYVAL to garbage.
1502 This behavior is undocumented and Bison
1503 users should not rely upon it. Assigning to YYVAL
1504 unconditionally makes the parser a bit smaller, and it avoids a
1505 GCC warning that YYVAL may be used uninitialized. */
1506 yyval = yyvsp[1-yylen];
1509 YY_REDUCE_PRINT (yyn);
1514 /* Line 1806 of yacc.c */
1515 #line 132 "parsedate.y"
1519 /* I am compulsive about lint natterings... */
1520 if (yyHaveTime == -1) {
1529 /* Line 1806 of yacc.c */
1530 #line 141 "parsedate.y"
1533 yyTimezone = (yyvsp[(2) - (2)].Number);
1539 /* Line 1806 of yacc.c */
1540 #line 145 "parsedate.y"
1548 /* Line 1806 of yacc.c */
1549 #line 148 "parsedate.y"
1557 /* Line 1806 of yacc.c */
1558 #line 153 "parsedate.y"
1560 if ((yyvsp[(1) - (2)].Number) < 100) {
1561 yyHour = (yyvsp[(1) - (2)].Number);
1565 yyHour = (yyvsp[(1) - (2)].Number) / 100;
1566 yyMinutes = (yyvsp[(1) - (2)].Number) % 100;
1569 yyMeridian = (yyvsp[(2) - (2)].Meridian);
1575 /* Line 1806 of yacc.c */
1576 #line 165 "parsedate.y"
1578 yyHour = (yyvsp[(1) - (4)].Number);
1579 yyMinutes = (yyvsp[(3) - (4)].Number);
1581 yyMeridian = (yyvsp[(4) - (4)].Meridian);
1587 /* Line 1806 of yacc.c */
1588 #line 171 "parsedate.y"
1590 yyHour = (yyvsp[(1) - (4)].Number);
1591 yyMinutes = (yyvsp[(3) - (4)].Number);
1592 yyTimezone = (yyvsp[(4) - (4)].Number);
1600 /* Line 1806 of yacc.c */
1601 #line 178 "parsedate.y"
1603 yyHour = (yyvsp[(1) - (6)].Number);
1604 yyMinutes = (yyvsp[(3) - (6)].Number);
1605 yySeconds = (yyvsp[(5) - (6)].Number);
1606 yyMeridian = (yyvsp[(6) - (6)].Meridian);
1612 /* Line 1806 of yacc.c */
1613 #line 184 "parsedate.y"
1615 yyHour = (yyvsp[(1) - (6)].Number);
1616 yyMinutes = (yyvsp[(3) - (6)].Number);
1617 yySeconds = (yyvsp[(5) - (6)].Number);
1618 yyTimezone = (yyvsp[(6) - (6)].Number);
1626 /* Line 1806 of yacc.c */
1627 #line 194 "parsedate.y"
1629 (yyval.Number) = (yyvsp[(1) - (1)].Number);
1636 /* Line 1806 of yacc.c */
1637 #line 198 "parsedate.y"
1639 (yyval.Number) = (yyvsp[(1) - (1)].Number);
1646 /* Line 1806 of yacc.c */
1647 #line 202 "parsedate.y"
1649 /* Only allow "GMT+300" and "GMT-0800" */
1650 if ((yyvsp[(1) - (2)].Number) != 0) {
1653 (yyval.Number) = (yyvsp[(2) - (2)].Number);
1660 /* Line 1806 of yacc.c */
1661 #line 210 "parsedate.y"
1663 (yyval.Number) = (yyvsp[(1) - (1)].Number);
1670 /* Line 1806 of yacc.c */
1671 #line 216 "parsedate.y"
1675 /* Unix and GMT and numeric timezones -- a little confusing. */
1676 if ((yyvsp[(1) - (1)].Number) < 0) {
1677 /* Don't work with negative modulus. */
1678 (yyvsp[(1) - (1)].Number) = -(yyvsp[(1) - (1)].Number);
1679 if ((yyvsp[(1) - (1)].Number) > 9999 || (i = (yyvsp[(1) - (1)].Number) % 100) >= 60) {
1682 (yyval.Number) = ((yyvsp[(1) - (1)].Number) / 100) * 60 + i;
1685 if ((yyvsp[(1) - (1)].Number) > 9999 || (i = (yyvsp[(1) - (1)].Number) % 100) >= 60) {
1688 (yyval.Number) = -(((yyvsp[(1) - (1)].Number) / 100) * 60 + i);
1695 /* Line 1806 of yacc.c */
1696 #line 237 "parsedate.y"
1698 yyMonth = (yyvsp[(1) - (3)].Number);
1699 yyDay = (yyvsp[(3) - (3)].Number);
1705 /* Line 1806 of yacc.c */
1706 #line 241 "parsedate.y"
1708 if ((yyvsp[(1) - (5)].Number) > 100) {
1709 yyYear = (yyvsp[(1) - (5)].Number);
1710 yyMonth = (yyvsp[(3) - (5)].Number);
1711 yyDay = (yyvsp[(5) - (5)].Number);
1714 yyMonth = (yyvsp[(1) - (5)].Number);
1715 yyDay = (yyvsp[(3) - (5)].Number);
1716 yyYear = (yyvsp[(5) - (5)].Number);
1723 /* Line 1806 of yacc.c */
1724 #line 253 "parsedate.y"
1726 yyMonth = (yyvsp[(1) - (2)].Number);
1727 yyDay = (yyvsp[(2) - (2)].Number);
1733 /* Line 1806 of yacc.c */
1734 #line 257 "parsedate.y"
1736 yyMonth = (yyvsp[(1) - (4)].Number);
1737 yyDay = (yyvsp[(2) - (4)].Number);
1738 yyYear = (yyvsp[(4) - (4)].Number);
1744 /* Line 1806 of yacc.c */
1745 #line 262 "parsedate.y"
1747 yyDay = (yyvsp[(1) - (2)].Number);
1748 yyMonth = (yyvsp[(2) - (2)].Number);
1754 /* Line 1806 of yacc.c */
1755 #line 266 "parsedate.y"
1757 yyDay = (yyvsp[(1) - (3)].Number);
1758 yyMonth = (yyvsp[(2) - (3)].Number);
1759 yyYear = (yyvsp[(3) - (3)].Number);
1765 /* Line 1806 of yacc.c */
1766 #line 271 "parsedate.y"
1768 yyDay = (yyvsp[(3) - (5)].Number);
1769 yyMonth = (yyvsp[(4) - (5)].Number);
1770 yyYear = (yyvsp[(5) - (5)].Number);
1776 /* Line 1806 of yacc.c */
1777 #line 278 "parsedate.y"
1779 yyRelSeconds += (yyvsp[(1) - (2)].Number) * (yyvsp[(2) - (2)].Number);
1785 /* Line 1806 of yacc.c */
1786 #line 281 "parsedate.y"
1788 yyRelSeconds += (yyvsp[(1) - (2)].Number) * (yyvsp[(2) - (2)].Number);
1794 /* Line 1806 of yacc.c */
1795 #line 284 "parsedate.y"
1797 yyRelMonth += (yyvsp[(1) - (2)].Number) * (yyvsp[(2) - (2)].Number);
1803 /* Line 1806 of yacc.c */
1804 #line 287 "parsedate.y"
1806 yyRelMonth += (yyvsp[(1) - (2)].Number) * (yyvsp[(2) - (2)].Number);
1812 /* Line 1806 of yacc.c */
1813 #line 292 "parsedate.y"
1815 (yyval.Meridian) = MER24;
1821 /* Line 1806 of yacc.c */
1822 #line 295 "parsedate.y"
1824 (yyval.Meridian) = (yyvsp[(1) - (1)].Meridian);
1830 /* Line 1806 of yacc.c */
1831 #line 1832 "y.tab.c"
1834 /* User semantic actions sometimes alter yychar, and that requires
1835 that yytoken be updated with the new translation. We take the
1836 approach of translating immediately before every use of yytoken.
1837 One alternative is translating here after every semantic action,
1838 but that translation would be missed if the semantic action invokes
1839 YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1840 if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
1841 incorrect destructor might then be invoked immediately. In the
1842 case of YYERROR or YYBACKUP, subsequent parser actions might lead
1843 to an incorrect destructor call or verbose syntax error message
1844 before the lookahead is translated. */
1845 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1849 YY_STACK_PRINT (yyss, yyssp);
1853 /* Now `shift' the result of the reduction. Determine what state
1854 that goes to, based on the state we popped back to and the rule
1855 number reduced by. */
1859 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1860 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1861 yystate = yytable[yystate];
1863 yystate = yydefgoto[yyn - YYNTOKENS];
1868 /*------------------------------------.
1869 | yyerrlab -- here on detecting error |
1870 `------------------------------------*/
1872 /* Make sure we have latest lookahead translation. See comments at
1873 user semantic actions for why this is necessary. */
1874 yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
1876 /* If not already recovering from an error, report this error. */
1880 #if ! YYERROR_VERBOSE
1881 yyerror (YY_("syntax error"));
1883 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
1886 char const *yymsgp = YY_("syntax error");
1887 int yysyntax_error_status;
1888 yysyntax_error_status = YYSYNTAX_ERROR;
1889 if (yysyntax_error_status == 0)
1891 else if (yysyntax_error_status == 1)
1893 if (yymsg != yymsgbuf)
1894 YYSTACK_FREE (yymsg);
1895 yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
1899 yymsg_alloc = sizeof yymsgbuf;
1900 yysyntax_error_status = 2;
1904 yysyntax_error_status = YYSYNTAX_ERROR;
1909 if (yysyntax_error_status == 2)
1910 goto yyexhaustedlab;
1912 # undef YYSYNTAX_ERROR
1918 if (yyerrstatus == 3)
1920 /* If just tried and failed to reuse lookahead token after an
1921 error, discard it. */
1923 if (yychar <= YYEOF)
1925 /* Return failure if at end of input. */
1926 if (yychar == YYEOF)
1931 yydestruct ("Error: discarding",
1937 /* Else will try to reuse lookahead token after shifting the error
1942 /*---------------------------------------------------.
1943 | yyerrorlab -- error raised explicitly by YYERROR. |
1944 `---------------------------------------------------*/
1947 /* Pacify compilers like GCC when the user code never invokes
1948 YYERROR and the label yyerrorlab therefore never appears in user
1950 if (/*CONSTCOND*/ 0)
1953 /* Do not reclaim the symbols of the rule which action triggered
1957 YY_STACK_PRINT (yyss, yyssp);
1962 /*-------------------------------------------------------------.
1963 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1964 `-------------------------------------------------------------*/
1966 yyerrstatus = 3; /* Each real token shifted decrements this. */
1970 yyn = yypact[yystate];
1971 if (!yypact_value_is_default (yyn))
1974 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1982 /* Pop the current state because it cannot handle the error token. */
1987 yydestruct ("Error: popping",
1988 yystos[yystate], yyvsp);
1991 YY_STACK_PRINT (yyss, yyssp);
1997 /* Shift the error token. */
1998 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
2004 /*-------------------------------------.
2005 | yyacceptlab -- YYACCEPT comes here. |
2006 `-------------------------------------*/
2011 /*-----------------------------------.
2012 | yyabortlab -- YYABORT comes here. |
2013 `-----------------------------------*/
2018 #if !defined(yyoverflow) || YYERROR_VERBOSE
2019 /*-------------------------------------------------.
2020 | yyexhaustedlab -- memory exhaustion comes here. |
2021 `-------------------------------------------------*/
2023 yyerror (YY_("memory exhausted"));
2029 if (yychar != YYEMPTY)
2031 /* Make sure we have latest lookahead translation. See comments at
2032 user semantic actions for why this is necessary. */
2033 yytoken = YYTRANSLATE (yychar);
2034 yydestruct ("Cleanup: discarding lookahead",
2037 /* Do not reclaim the symbols of the rule which action triggered
2038 this YYABORT or YYACCEPT. */
2040 YY_STACK_PRINT (yyss, yyssp);
2041 while (yyssp != yyss)
2043 yydestruct ("Cleanup: popping",
2044 yystos[*yyssp], yyvsp);
2049 YYSTACK_FREE (yyss);
2052 if (yymsg != yymsgbuf)
2053 YYSTACK_FREE (yymsg);
2055 /* Make sure YYID is used. */
2056 return YYID (yyresult);
2061 /* Line 2067 of yacc.c */
2062 #line 300 "parsedate.y"
2065 /* Month and day table. */
2066 static TABLE MonthDayTable[] = {
2067 { "january", tMONTH, 1 },
2068 { "february", tMONTH, 2 },
2069 { "march", tMONTH, 3 },
2070 { "april", tMONTH, 4 },
2071 { "may", tMONTH, 5 },
2072 { "june", tMONTH, 6 },
2073 { "july", tMONTH, 7 },
2074 { "august", tMONTH, 8 },
2075 { "september", tMONTH, 9 },
2076 { "october", tMONTH, 10 },
2077 { "november", tMONTH, 11 },
2078 { "december", tMONTH, 12 },
2079 /* The value of the day isn't used... */
2080 { "sunday", tDAY, 0 },
2081 { "monday", tDAY, 0 },
2082 { "tuesday", tDAY, 0 },
2083 { "wednesday", tDAY, 0 },
2084 { "thursday", tDAY, 0 },
2085 { "friday", tDAY, 0 },
2086 { "saturday", tDAY, 0 },
2089 /* Time units table. */
2090 static TABLE UnitsTable[] = {
2091 { "year", tMONTH_UNIT, 12 },
2092 { "month", tMONTH_UNIT, 1 },
2093 { "week", tSEC_UNIT, 7L * 24 * 60 * 60 },
2094 { "day", tSEC_UNIT, 1L * 24 * 60 * 60 },
2095 { "hour", tSEC_UNIT, 60 * 60 },
2096 { "minute", tSEC_UNIT, 60 },
2097 { "min", tSEC_UNIT, 60 },
2098 { "second", tSEC_UNIT, 1 },
2099 { "sec", tSEC_UNIT, 1 },
2102 /* Timezone table. */
2103 static TABLE TimezoneTable[] = {
2104 { "gmt", tZONE, HOUR( 0) }, /* Greenwich Mean */
2105 { "ut", tZONE, HOUR( 0) }, /* Universal */
2106 { "utc", tZONE, HOUR( 0) }, /* Universal Coordinated */
2107 { "cut", tZONE, HOUR( 0) }, /* Coordinated Universal */
2108 { "z", tZONE, HOUR( 0) }, /* Greenwich Mean */
2109 { "wet", tZONE, HOUR( 0) }, /* Western European */
2110 { "bst", tDAYZONE, HOUR( 0) }, /* British Summer */
2111 { "nst", tZONE, HOUR(3)+30 }, /* Newfoundland Standard */
2112 { "ndt", tDAYZONE, HOUR(3)+30 }, /* Newfoundland Daylight */
2113 { "ast", tZONE, HOUR( 4) }, /* Atlantic Standard */
2114 { "adt", tDAYZONE, HOUR( 4) }, /* Atlantic Daylight */
2115 { "est", tZONE, HOUR( 5) }, /* Eastern Standard */
2116 { "edt", tDAYZONE, HOUR( 5) }, /* Eastern Daylight */
2117 { "cst", tZONE, HOUR( 6) }, /* Central Standard */
2118 { "cdt", tDAYZONE, HOUR( 6) }, /* Central Daylight */
2119 { "mst", tZONE, HOUR( 7) }, /* Mountain Standard */
2120 { "mdt", tDAYZONE, HOUR( 7) }, /* Mountain Daylight */
2121 { "pst", tZONE, HOUR( 8) }, /* Pacific Standard */
2122 { "pdt", tDAYZONE, HOUR( 8) }, /* Pacific Daylight */
2123 { "yst", tZONE, HOUR( 9) }, /* Yukon Standard */
2124 { "ydt", tDAYZONE, HOUR( 9) }, /* Yukon Daylight */
2125 { "akst", tZONE, HOUR( 9) }, /* Alaska Standard */
2126 { "akdt", tDAYZONE, HOUR( 9) }, /* Alaska Daylight */
2127 { "hst", tZONE, HOUR(10) }, /* Hawaii Standard */
2128 { "hast", tZONE, HOUR(10) }, /* Hawaii-Aleutian Standard */
2129 { "hadt", tDAYZONE, HOUR(10) }, /* Hawaii-Aleutian Daylight */
2130 { "ces", tDAYZONE, -HOUR(1) }, /* Central European Summer */
2131 { "cest", tDAYZONE, -HOUR(1) }, /* Central European Summer */
2132 { "mez", tZONE, -HOUR(1) }, /* Middle European */
2133 { "mezt", tDAYZONE, -HOUR(1) }, /* Middle European Summer */
2134 { "cet", tZONE, -HOUR(1) }, /* Central European */
2135 { "met", tZONE, -HOUR(1) }, /* Middle European */
2136 { "eet", tZONE, -HOUR(2) }, /* Eastern Europe */
2137 { "msk", tZONE, -HOUR(3) }, /* Moscow Winter */
2138 { "msd", tDAYZONE, -HOUR(3) }, /* Moscow Summer */
2139 { "wast", tZONE, -HOUR(8) }, /* West Australian Standard */
2140 { "wadt", tDAYZONE, -HOUR(8) }, /* West Australian Daylight */
2141 { "hkt", tZONE, -HOUR(8) }, /* Hong Kong */
2142 { "cct", tZONE, -HOUR(8) }, /* China Coast */
2143 { "jst", tZONE, -HOUR(9) }, /* Japan Standard */
2144 { "kst", tZONE, -HOUR(9) }, /* Korean Standard */
2145 { "kdt", tZONE, -HOUR(9) }, /* Korean Daylight */
2146 { "cast", tZONE, -(HOUR(9)+30) }, /* Central Australian Standard */
2147 { "cadt", tDAYZONE, -(HOUR(9)+30) }, /* Central Australian Daylight */
2148 { "east", tZONE, -HOUR(10) }, /* Eastern Australian Standard */
2149 { "eadt", tDAYZONE, -HOUR(10) }, /* Eastern Australian Daylight */
2150 { "nzst", tZONE, -HOUR(12) }, /* New Zealand Standard */
2151 { "nzdt", tDAYZONE, -HOUR(12) }, /* New Zealand Daylight */
2153 /* For completeness we include the following entries. */
2156 /* Duplicate names. Either they conflict with a zone listed above
2157 * (which is either more likely to be seen or just been in circulation
2158 * longer), or they conflict with another zone in this section and
2159 * we could not reasonably choose one over the other. */
2160 { "fst", tZONE, HOUR( 2) }, /* Fernando De Noronha Standard */
2161 { "fdt", tDAYZONE, HOUR( 2) }, /* Fernando De Noronha Daylight */
2162 { "bst", tZONE, HOUR( 3) }, /* Brazil Standard */
2163 { "est", tZONE, HOUR( 3) }, /* Eastern Standard (Brazil) */
2164 { "edt", tDAYZONE, HOUR( 3) }, /* Eastern Daylight (Brazil) */
2165 { "wst", tZONE, HOUR( 4) }, /* Western Standard (Brazil) */
2166 { "wdt", tDAYZONE, HOUR( 4) }, /* Western Daylight (Brazil) */
2167 { "cst", tZONE, HOUR( 5) }, /* Chile Standard */
2168 { "cdt", tDAYZONE, HOUR( 5) }, /* Chile Daylight */
2169 { "ast", tZONE, HOUR( 5) }, /* Acre Standard */
2170 { "adt", tDAYZONE, HOUR( 5) }, /* Acre Daylight */
2171 { "cst", tZONE, HOUR( 5) }, /* Cuba Standard */
2172 { "cdt", tDAYZONE, HOUR( 5) }, /* Cuba Daylight */
2173 { "est", tZONE, HOUR( 6) }, /* Easter Island Standard */
2174 { "edt", tDAYZONE, HOUR( 6) }, /* Easter Island Daylight */
2175 { "sst", tZONE, HOUR(11) }, /* Samoa Standard */
2176 { "ist", tZONE, -HOUR(2) }, /* Israel Standard */
2177 { "idt", tDAYZONE, -HOUR(2) }, /* Israel Daylight */
2178 { "idt", tDAYZONE, -(HOUR(3)+30) }, /* Iran Daylight */
2179 { "ist", tZONE, -(HOUR(3)+30) }, /* Iran Standard */
2180 { "cst", tZONE, -HOUR(8) }, /* China Standard */
2181 { "cdt", tDAYZONE, -HOUR(8) }, /* China Daylight */
2182 { "sst", tZONE, -HOUR(8) }, /* Singapore Standard */
2184 /* Dubious (e.g., not in Olson's TIMEZONE package) or obsolete. */
2185 { "gst", tZONE, HOUR( 3) }, /* Greenland Standard */
2186 { "wat", tZONE, -HOUR(1) }, /* West Africa */
2187 { "at", tZONE, HOUR( 2) }, /* Azores */
2188 { "gst", tZONE, -HOUR(10) }, /* Guam Standard */
2189 { "nft", tZONE, HOUR(3)+30 }, /* Newfoundland */
2190 { "idlw", tZONE, HOUR(12) }, /* International Date Line West */
2191 { "mewt", tZONE, -HOUR(1) }, /* Middle European Winter */
2192 { "mest", tDAYZONE, -HOUR(1) }, /* Middle European Summer */
2193 { "swt", tZONE, -HOUR(1) }, /* Swedish Winter */
2194 { "sst", tDAYZONE, -HOUR(1) }, /* Swedish Summer */
2195 { "fwt", tZONE, -HOUR(1) }, /* French Winter */
2196 { "fst", tDAYZONE, -HOUR(1) }, /* French Summer */
2197 { "bt", tZONE, -HOUR(3) }, /* Baghdad */
2198 { "it", tZONE, -(HOUR(3)+30) }, /* Iran */
2199 { "zp4", tZONE, -HOUR(4) }, /* USSR Zone 3 */
2200 { "zp5", tZONE, -HOUR(5) }, /* USSR Zone 4 */
2201 { "ist", tZONE, -(HOUR(5)+30) }, /* Indian Standard */
2202 { "zp6", tZONE, -HOUR(6) }, /* USSR Zone 5 */
2203 { "nst", tZONE, -HOUR(7) }, /* North Sumatra */
2204 { "sst", tZONE, -HOUR(7) }, /* South Sumatra */
2205 { "jt", tZONE, -(HOUR(7)+30) }, /* Java (3pm in Cronusland!) */
2206 { "nzt", tZONE, -HOUR(12) }, /* New Zealand */
2207 { "idle", tZONE, -HOUR(12) }, /* International Date Line East */
2208 { "cat", tZONE, HOUR(10) }, /* -- expired 1967 */
2209 { "nt", tZONE, HOUR(11) }, /* -- expired 1967 */
2210 { "ahst", tZONE, HOUR(10) }, /* -- expired 1983 */
2211 { "hdt", tDAYZONE, HOUR(10) }, /* -- expired 1986 */
2225 ToSeconds(time_t Hours, time_t Minutes, time_t Seconds, MERIDIAN Meridian)
2227 if (Minutes < 0 || Minutes > 59 || Seconds < 0 || Seconds > 61)
2229 if (Meridian == MER24) {
2230 if (Hours < 0 || Hours > 23)
2234 if (Hours < 1 || Hours > 12)
2238 if (Meridian == MERpm)
2241 return (Hours * 60L + Minutes) * 60L + Seconds;
2246 Convert(time_t Month, time_t Day, time_t Year,
2247 time_t Hours, time_t Minutes, time_t Seconds,
2248 MERIDIAN Meridian, DSTMODE dst)
2250 static int DaysNormal[13] = {
2251 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
2253 static int DaysLeap[13] = {
2254 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
2256 static int LeapYears[] = {
2257 1972, 1976, 1980, 1984, 1988, 1992, 1996,
2258 2000, 2004, 2008, 2012, 2016, 2020, 2024, 2028, 2032, 2036
2262 register time_t Julian;
2272 for (mp = DaysNormal, yp = LeapYears; yp < ENDOF(LeapYears); yp++)
2277 if (Year < EPOCH || Year > END_OF_TIME
2278 || Month < 1 || Month > 12
2279 /* NOSTRICT *//* conversion from long may lose accuracy */
2280 || Day < 1 || Day > mp[(int)Month])
2283 Julian = Day - 1 + (Year - EPOCH) * 365;
2284 for (yp = LeapYears; yp < ENDOF(LeapYears); yp++, Julian++)
2287 for (i = 1; i < Month; i++)
2289 Julian *= SECSPERDAY;
2290 Julian += yyTimezone * 60L;
2291 if ((tod = ToSeconds(Hours, Minutes, Seconds, Meridian)) < 0)
2295 if (dst == DSTon || (dst == DSTmaybe && localtime(&tod)->tm_isdst))
2296 Julian -= DST_OFFSET * 60L * 60L;
2302 DSTcorrect(time_t Start, time_t Future)
2307 StartDay = (localtime(&Start)->tm_hour + 1) % 24;
2308 FutureDay = (localtime(&Future)->tm_hour + 1) % 24;
2309 return (Future - Start) + (StartDay - FutureDay) * DST_OFFSET * 60L * 60L;
2314 RelativeMonth(time_t Start, time_t RelMonth)
2320 tm = localtime(&Start);
2321 Month = 12 * tm->tm_year + tm->tm_mon + RelMonth;
2323 Month = Month % 12 + 1;
2324 return DSTcorrect(Start,
2325 Convert(Month, (time_t)tm->tm_mday, Year,
2326 (time_t)tm->tm_hour, (time_t)tm->tm_min, (time_t)tm->tm_sec,
2332 LookupWord(char *buff, register int length)
2342 /* See if we have an abbreviation for a month. */
2343 if (length == 3 || (length == 4 && p[3] == '.'))
2344 for (tp = MonthDayTable; tp < ENDOF(MonthDayTable); tp++) {
2346 if (c == q[0] && p[1] == q[1] && p[2] == q[2]) {
2347 yylval.Number = tp->value;
2352 for (tp = MonthDayTable; tp < ENDOF(MonthDayTable); tp++)
2353 if (c == tp->name[0] && strcmp(p, tp->name) == 0) {
2354 yylval.Number = tp->value;
2358 /* Try for a timezone. */
2359 for (tp = TimezoneTable; tp < ENDOF(TimezoneTable); tp++)
2360 if (c == tp->name[0] && p[1] == tp->name[1]
2361 && strcmp(p, tp->name) == 0) {
2362 yylval.Number = tp->value;
2366 /* Try the units table. */
2367 for (tp = UnitsTable; tp < ENDOF(UnitsTable); tp++)
2368 if (c == tp->name[0] && strcmp(p, tp->name) == 0) {
2369 yylval.Number = tp->value;
2373 /* Strip off any plural and try the units table again. */
2374 if (--length > 0 && p[length] == 's') {
2376 for (tp = UnitsTable; tp < ENDOF(UnitsTable); tp++)
2377 if (c == tp->name[0] && strcmp(p, tp->name) == 0) {
2379 yylval.Number = tp->value;
2386 /* Drop out any periods. */
2387 for (p = buff, q = (char*)buff; *q; q++)
2392 /* Try the meridians. */
2393 if (buff[1] == 'm' && buff[2] == '\0') {
2394 if (buff[0] == 'a') {
2395 yylval.Meridian = MERam;
2398 if (buff[0] == 'p') {
2399 yylval.Meridian = MERpm;
2404 /* If we saw any periods, try the timezones again. */
2405 if (p - buff != length) {
2407 for (p = buff, tp = TimezoneTable; tp < ENDOF(TimezoneTable); tp++)
2408 if (c == tp->name[0] && p[1] == tp->name[1]
2409 && strcmp(p, tp->name) == 0) {
2410 yylval.Number = tp->value;
2415 /* Unknown word -- assume GMT timezone. */
2429 register int nesting;
2432 /* Get first character after the whitespace. */
2434 while (isspace(*yyInput))
2438 /* Ignore RFC 822 comments, typically time zone names. */
2441 for (nesting = 1; (c = *++yyInput) != RPAREN || --nesting; )
2444 else if (!IS7BIT(c) || c == '\0' || c == '\r'
2445 || (c == '\\' && ((c = *++yyInput) == '\0' || !IS7BIT(c))))
2446 /* Lexical error: bad comment. */
2452 if (isdigit(c) || c == '-' || c == '+') {
2453 if (c == '-' || c == '+') {
2454 sign = c == '-' ? -1 : 1;
2456 if (!isdigit(*yyInput))
2457 /* Skip the plus or minus sign. */
2462 for (i = 0; (c = *yyInput++) != '\0' && isdigit(c); )
2463 i = 10 * i + c - '0';
2465 yylval.Number = sign < 0 ? -i : i;
2466 return sign ? tSNUMBER : tUNUMBER;
2471 for (p = buff; (c = *yyInput++) == '.' || isalpha(c); )
2472 if (p < &buff[sizeof buff - 1])
2473 *p++ = isupper(c) ? tolower(c) : c;
2476 return LookupWord(buff, p - buff);
2485 parsedate(const char *p)
2487 extern int date_parse(void);
2490 yyInput = p; /* well, its supposed to be const... */
2496 yyDSTmode = DSTmaybe;
2507 if (date_parse() || yyHaveTime > 1 || yyHaveDate > 1)
2510 if (yyHaveDate || yyHaveTime) {
2511 Start = Convert(yyMonth, yyDay, yyYear, yyHour, yyMinutes, yySeconds,
2512 yyMeridian, yyDSTmode);
2519 Start += yyRelSeconds;
2521 Start += RelativeMonth(Start, yyRelMonth);
2523 /* Have to do *something* with a legitimate -1 so it's distinguishable
2524 * from the error return value. (Alternately could set errno on error.) */
2525 return Start == -1 ? 0 : Start;
2533 #endif /* YYDEBUG */
2537 main(int ac, char *av[])
2544 #endif /* YYDEBUG */
2546 (void)printf("Enter date, or blank line to exit.\n\t> ");
2548 (void)printf("\t> ");
2549 (void)fflush(stdout);
2550 if (fgets(buff, sizeof buff, stdin) == NULL || buff[0] == '\n')
2553 if (strcmp(buff, "yydebug") == 0) {
2555 printf("yydebug = %s\n", yydebug ? "on" : "off");
2558 #endif /* YYDEBUG */
2559 d = parsedate(buff, (TIMEINFO *)NULL);
2561 (void)printf("Bad format - couldn't convert.\n");
2563 (void)printf("%s", ctime(&d));