1 /* A Bison parser, made by GNU Bison 3.7. */
3 /* Bison implementation for Yacc-like parsers in C
5 Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2020 Free Software Foundation,
8 This program is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21 /* As a special exception, you may create a larger work that contains
22 part or all of the Bison parser skeleton and distribute that work
23 under terms of your choice, so long as that work isn't itself a
24 parser generator using the skeleton or a modified version thereof
25 as a parser skeleton. Alternatively, if you modify or redistribute
26 the parser skeleton itself, you may (at your option) remove this
27 special exception, which will cause the skeleton and the resulting
28 Bison output files to be licensed under the GNU General Public
29 License without this special exception.
31 This special exception was added by the Free Software Foundation in
32 version 2.2 of Bison. */
34 /* C LALR(1) parser skeleton written by Richard Stallman, by
35 simplifying the original so-called "semantic" parser. */
37 /* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,
38 especially those whose name start with YY_ or yy_. They are
39 private implementation details that can be changed or removed. */
41 /* All symbols defined below should begin with yy or YY, to avoid
42 infringing on user name space. This should be done even for local
43 variables, as they might otherwise be expanded by user macros.
44 There are some unavoidable exceptions within include files to
45 define necessary library symbols; they are noted "INFRINGES ON
46 USER NAME SPACE" below. */
48 /* Identify Bison output. */
52 #define YYBISON_VERSION "3.7"
55 #define YYSKELETON_NAME "yacc.c"
69 /* First part of user prologue. */
70 #line 1 "server/parsedate.y"
74 ** Originally written by Steven M. Bellovin <smb@research.att.com> while
75 ** at the University of North Carolina at Chapel Hill. Later tweaked by
76 ** a couple of people on Usenet. Completely overhauled by Rich $alz
77 ** <rsalz@osf.org> and Jim Berets <jberets@bbn.com> in August, 1990.
78 ** Further revised (removed obsolete constructs and cleaned up timezone
79 ** names) in August, 1991, by Rich. Paul Eggert <eggert@twinsun.com>
80 ** helped in September, 1992. Art Cancro <ajc@citadel.org> cleaned
81 ** it up for ANSI C in December, 1999.
83 ** This grammar has six shift/reduce conflicts.
85 ** This code is in the public domain and has no copyright.
87 /* SUPPRESS 530 *//* Empty body for statement */
88 /* SUPPRESS 593 on yyerrlab *//* Label was not used */
89 /* SUPPRESS 593 on yynewstate *//* Label was not used */
90 /* SUPPRESS 595 on yypvt *//* Automatic variable may be used before set */
96 #include <sys/types.h>
100 # if !STDC_HEADERS && HAVE_MEMORY_H
106 # include <strings.h>
109 #include "parsedate.h"
113 #define yyparse date_parse
114 #define yylex date_lex
115 #define yyerror date_error
118 /* See the LeapYears table in Convert. */
120 #define END_OF_TIME 2038
121 /* Constants for general time calculations. */
123 #define SECSPERDAY (24L * 60L * 60L)
124 /* Readability for TABLE stuff. */
125 #define HOUR(x) (x * 60)
129 #define IS7BIT(x) ((unsigned int)(x) < 0200)
131 #define SIZEOF(array) ((int)(sizeof array / sizeof array[0]))
132 #define ENDOF(array) (&array[SIZEOF(array)])
136 ** An entry in the lexical lookup table.
138 typedef struct _TABLE {
145 ** Daylight-savings mode: on, off, or not yet known.
147 typedef enum _DSTMODE {
148 DSTon, DSToff, DSTmaybe
152 ** Meridian: am, pm, or 24-hour style.
154 typedef enum _MERIDIAN {
160 ** Global variables. We could get rid of most of them by using a yacc
161 ** union, but this is more efficient. (This routine predates the
162 ** yacc %union construct.)
164 static const char *yyInput;
165 static DSTMODE yyDSTmode;
166 static int yyHaveDate;
167 static int yyHaveRel;
168 static int yyHaveTime;
169 static time_t yyTimezone;
171 static time_t yyHour;
172 static time_t yyMinutes;
173 static time_t yyMonth;
174 static time_t yySeconds;
175 static time_t yyYear;
176 static MERIDIAN yyMeridian;
177 static time_t yyRelMonth;
178 static time_t yyRelSeconds;
181 static void date_error(char *);
187 # define YY_CAST(Type, Val) static_cast<Type> (Val)
188 # define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type> (Val)
190 # define YY_CAST(Type, Val) ((Type) (Val))
191 # define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val))
195 # if defined __cplusplus
196 # if 201103L <= __cplusplus
197 # define YY_NULLPTR nullptr
199 # define YY_NULLPTR 0
202 # define YY_NULLPTR ((void*)0)
221 YYEOF = 0, /* "end of file" */
222 YYerror = 256, /* error */
223 YYUNDEF = 257, /* "invalid token" */
224 tDAY = 258, /* tDAY */
225 tDAYZONE = 259, /* tDAYZONE */
226 tMERIDIAN = 260, /* tMERIDIAN */
227 tMONTH = 261, /* tMONTH */
228 tMONTH_UNIT = 262, /* tMONTH_UNIT */
229 tSEC_UNIT = 263, /* tSEC_UNIT */
230 tSNUMBER = 264, /* tSNUMBER */
231 tUNUMBER = 265, /* tUNUMBER */
232 tZONE = 266 /* tZONE */
234 typedef enum yytokentype yytoken_kind_t;
242 #define tMERIDIAN 260
244 #define tMONTH_UNIT 262
245 #define tSEC_UNIT 263
251 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
254 #line 114 "server/parsedate.y"
257 enum _MERIDIAN Meridian;
262 typedef union YYSTYPE YYSTYPE;
263 # define YYSTYPE_IS_TRIVIAL 1
264 # define YYSTYPE_IS_DECLARED 1
268 extern YYSTYPE yylval;
276 YYSYMBOL_YYEMPTY = -2,
277 YYSYMBOL_YYEOF = 0, /* "end of file" */
278 YYSYMBOL_YYerror = 1, /* error */
279 YYSYMBOL_YYUNDEF = 2, /* "invalid token" */
280 YYSYMBOL_tDAY = 3, /* tDAY */
281 YYSYMBOL_tDAYZONE = 4, /* tDAYZONE */
282 YYSYMBOL_tMERIDIAN = 5, /* tMERIDIAN */
283 YYSYMBOL_tMONTH = 6, /* tMONTH */
284 YYSYMBOL_tMONTH_UNIT = 7, /* tMONTH_UNIT */
285 YYSYMBOL_tSEC_UNIT = 8, /* tSEC_UNIT */
286 YYSYMBOL_tSNUMBER = 9, /* tSNUMBER */
287 YYSYMBOL_tUNUMBER = 10, /* tUNUMBER */
288 YYSYMBOL_tZONE = 11, /* tZONE */
289 YYSYMBOL_12_ = 12, /* ':' */
290 YYSYMBOL_13_ = 13, /* '/' */
291 YYSYMBOL_14_ = 14, /* ',' */
292 YYSYMBOL_YYACCEPT = 15, /* $accept */
293 YYSYMBOL_spec = 16, /* spec */
294 YYSYMBOL_item = 17, /* item */
295 YYSYMBOL_time = 18, /* time */
296 YYSYMBOL_zone = 19, /* zone */
297 YYSYMBOL_numzone = 20, /* numzone */
298 YYSYMBOL_date = 21, /* date */
299 YYSYMBOL_rel = 22, /* rel */
300 YYSYMBOL_o_merid = 23 /* o_merid */
302 typedef enum yysymbol_kind_t yysymbol_kind_t;
311 /* On compilers that do not define __PTRDIFF_MAX__ etc., make sure
312 <limits.h> and (if available) <stdint.h> are included
313 so that the code can choose integer types of a good width. */
315 #ifndef __PTRDIFF_MAX__
316 # include <limits.h> /* INFRINGES ON USER NAME SPACE */
317 # if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
318 # include <stdint.h> /* INFRINGES ON USER NAME SPACE */
323 /* Narrow types that promote to a signed type and that can represent a
324 signed or unsigned integer of at least N bits. In tables they can
325 save space and decrease cache pressure. Promoting to a signed type
326 helps avoid bugs in integer arithmetic. */
328 #ifdef __INT_LEAST8_MAX__
329 typedef __INT_LEAST8_TYPE__ yytype_int8;
330 #elif defined YY_STDINT_H
331 typedef int_least8_t yytype_int8;
333 typedef signed char yytype_int8;
336 #ifdef __INT_LEAST16_MAX__
337 typedef __INT_LEAST16_TYPE__ yytype_int16;
338 #elif defined YY_STDINT_H
339 typedef int_least16_t yytype_int16;
341 typedef short yytype_int16;
344 #if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__
345 typedef __UINT_LEAST8_TYPE__ yytype_uint8;
346 #elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \
347 && UINT_LEAST8_MAX <= INT_MAX)
348 typedef uint_least8_t yytype_uint8;
349 #elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX
350 typedef unsigned char yytype_uint8;
352 typedef short yytype_uint8;
355 #if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__
356 typedef __UINT_LEAST16_TYPE__ yytype_uint16;
357 #elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \
358 && UINT_LEAST16_MAX <= INT_MAX)
359 typedef uint_least16_t yytype_uint16;
360 #elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX
361 typedef unsigned short yytype_uint16;
363 typedef int yytype_uint16;
367 # if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__
368 # define YYPTRDIFF_T __PTRDIFF_TYPE__
369 # define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__
370 # elif defined PTRDIFF_MAX
372 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
374 # define YYPTRDIFF_T ptrdiff_t
375 # define YYPTRDIFF_MAXIMUM PTRDIFF_MAX
377 # define YYPTRDIFF_T long
378 # define YYPTRDIFF_MAXIMUM LONG_MAX
383 # ifdef __SIZE_TYPE__
384 # define YYSIZE_T __SIZE_TYPE__
385 # elif defined size_t
386 # define YYSIZE_T size_t
387 # elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
388 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
389 # define YYSIZE_T size_t
391 # define YYSIZE_T unsigned
395 #define YYSIZE_MAXIMUM \
396 YY_CAST (YYPTRDIFF_T, \
397 (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1) \
398 ? YYPTRDIFF_MAXIMUM \
399 : YY_CAST (YYSIZE_T, -1)))
401 #define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X))
404 /* Stored state numbers (used for stacks). */
405 typedef yytype_int8 yy_state_t;
407 /* State numbers in computations. */
408 typedef int yy_state_fast_t;
411 # if defined YYENABLE_NLS && YYENABLE_NLS
413 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
414 # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
418 # define YY_(Msgid) Msgid
423 #ifndef YY_ATTRIBUTE_PURE
424 # if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__)
425 # define YY_ATTRIBUTE_PURE __attribute__ ((__pure__))
427 # define YY_ATTRIBUTE_PURE
431 #ifndef YY_ATTRIBUTE_UNUSED
432 # if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__)
433 # define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
435 # define YY_ATTRIBUTE_UNUSED
439 /* Suppress unused-variable warnings by "using" E. */
440 #if ! defined lint || defined __GNUC__
441 # define YYUSE(E) ((void) (E))
443 # define YYUSE(E) /* empty */
446 #if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
447 /* Suppress an incorrect diagnostic about yylval being uninitialized. */
448 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
449 _Pragma ("GCC diagnostic push") \
450 _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \
451 _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
452 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
453 _Pragma ("GCC diagnostic pop")
455 # define YY_INITIAL_VALUE(Value) Value
457 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
458 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
459 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
461 #ifndef YY_INITIAL_VALUE
462 # define YY_INITIAL_VALUE(Value) /* Nothing. */
465 #if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__
466 # define YY_IGNORE_USELESS_CAST_BEGIN \
467 _Pragma ("GCC diagnostic push") \
468 _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"")
469 # define YY_IGNORE_USELESS_CAST_END \
470 _Pragma ("GCC diagnostic pop")
472 #ifndef YY_IGNORE_USELESS_CAST_BEGIN
473 # define YY_IGNORE_USELESS_CAST_BEGIN
474 # define YY_IGNORE_USELESS_CAST_END
478 #define YY_ASSERT(E) ((void) (0 && (E)))
480 #if !defined yyoverflow
482 /* The parser invokes alloca or malloc; define the necessary symbols. */
484 # ifdef YYSTACK_USE_ALLOCA
485 # if YYSTACK_USE_ALLOCA
487 # define YYSTACK_ALLOC __builtin_alloca
488 # elif defined __BUILTIN_VA_ARG_INCR
489 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
491 # define YYSTACK_ALLOC __alloca
492 # elif defined _MSC_VER
493 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
494 # define alloca _alloca
496 # define YYSTACK_ALLOC alloca
497 # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
498 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
499 /* Use EXIT_SUCCESS as a witness for stdlib.h. */
500 # ifndef EXIT_SUCCESS
501 # define EXIT_SUCCESS 0
508 # ifdef YYSTACK_ALLOC
509 /* Pacify GCC's 'empty if-body' warning. */
510 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
511 # ifndef YYSTACK_ALLOC_MAXIMUM
512 /* The OS might guarantee only one guard page at the bottom of the stack,
513 and a page size can be as small as 4096 bytes. So we cannot safely
514 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
515 to allow for a few compiler-allocated temporary stack slots. */
516 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
519 # define YYSTACK_ALLOC YYMALLOC
520 # define YYSTACK_FREE YYFREE
521 # ifndef YYSTACK_ALLOC_MAXIMUM
522 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
524 # if (defined __cplusplus && ! defined EXIT_SUCCESS \
525 && ! ((defined YYMALLOC || defined malloc) \
526 && (defined YYFREE || defined free)))
527 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
528 # ifndef EXIT_SUCCESS
529 # define EXIT_SUCCESS 0
533 # define YYMALLOC malloc
534 # if ! defined malloc && ! defined EXIT_SUCCESS
535 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
540 # if ! defined free && ! defined EXIT_SUCCESS
541 void free (void *); /* INFRINGES ON USER NAME SPACE */
545 #endif /* !defined yyoverflow */
547 #if (! defined yyoverflow \
548 && (! defined __cplusplus \
549 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
551 /* A type that is properly aligned for any stack member. */
554 yy_state_t yyss_alloc;
558 /* The size of the maximum gap between one aligned stack and the next. */
559 # define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1)
561 /* The size of an array large to enough to hold all stacks, each with
563 # define YYSTACK_BYTES(N) \
564 ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE)) \
565 + YYSTACK_GAP_MAXIMUM)
567 # define YYCOPY_NEEDED 1
569 /* Relocate STACK from its old location to the new one. The
570 local variables YYSIZE and YYSTACKSIZE give the old and new number of
571 elements in the stack, and YYPTR gives the new location of the
572 stack. Advance YYPTR to a properly aligned location for the next
574 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
577 YYPTRDIFF_T yynewbytes; \
578 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
579 Stack = &yyptr->Stack_alloc; \
580 yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \
581 yyptr += yynewbytes / YYSIZEOF (*yyptr); \
587 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
588 /* Copy COUNT objects from SRC to DST. The source and destination do
591 # if defined __GNUC__ && 1 < __GNUC__
592 # define YYCOPY(Dst, Src, Count) \
593 __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src)))
595 # define YYCOPY(Dst, Src, Count) \
599 for (yyi = 0; yyi < (Count); yyi++) \
600 (Dst)[yyi] = (Src)[yyi]; \
605 #endif /* !YYCOPY_NEEDED */
607 /* YYFINAL -- State number of the termination state. */
609 /* YYLAST -- Last index in YYTABLE. */
612 /* YYNTOKENS -- Number of terminals. */
614 /* YYNNTS -- Number of nonterminals. */
616 /* YYNRULES -- Number of rules. */
618 /* YYNSTATES -- Number of states. */
621 /* YYMAXUTOK -- Last valid token kind. */
622 #define YYMAXUTOK 266
625 /* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
626 as returned by yylex, with out-of-bounds checking. */
627 #define YYTRANSLATE(YYX) \
628 (0 <= (YYX) && (YYX) <= YYMAXUTOK \
629 ? YY_CAST (yysymbol_kind_t, yytranslate[YYX]) \
632 /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
633 as returned by yylex. */
634 static const yytype_int8 yytranslate[] =
636 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
637 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
638 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
639 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
640 2, 2, 2, 2, 14, 2, 2, 13, 2, 2,
641 2, 2, 2, 2, 2, 2, 2, 2, 12, 2,
642 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
643 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
644 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
645 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
646 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
647 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
648 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
649 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
650 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
651 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
652 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
653 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
654 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
655 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
656 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
657 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
658 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
659 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
660 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
661 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
662 5, 6, 7, 8, 9, 10, 11
666 /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
667 static const yytype_int16 yyrline[] =
669 0, 128, 128, 129, 132, 141, 145, 148, 153, 165,
670 171, 178, 184, 194, 198, 202, 210, 216, 237, 241,
671 253, 257, 262, 266, 271, 278, 281, 284, 287, 292,
676 /** Accessing symbol of state STATE. */
677 #define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State])
680 /* The user-facing name of the symbol whose (internal) number is
681 YYSYMBOL. No bounds checking. */
682 static const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED;
684 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
685 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
686 static const char *const yytname[] =
688 "\"end of file\"", "error", "\"invalid token\"", "tDAY", "tDAYZONE",
689 "tMERIDIAN", "tMONTH", "tMONTH_UNIT", "tSEC_UNIT", "tSNUMBER",
690 "tUNUMBER", "tZONE", "':'", "'/'", "','", "$accept", "spec", "item",
691 "time", "zone", "numzone", "date", "rel", "o_merid", YY_NULLPTR
695 yysymbol_name (yysymbol_kind_t yysymbol)
697 return yytname[yysymbol];
702 /* YYTOKNUM[NUM] -- (External) token number corresponding to the
703 (internal) symbol number NUM (which must be that of a token). */
704 static const yytype_int16 yytoknum[] =
706 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
711 #define YYPACT_NINF (-29)
713 #define yypact_value_is_default(Yyn) \
714 ((Yyn) == YYPACT_NINF)
716 #define YYTABLE_NINF (-1)
718 #define yytable_value_is_error(Yyn) \
721 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
723 static const yytype_int8 yypact[] =
725 -29, 1, -29, -11, 11, 20, 12, -29, 4, -29,
726 -29, 13, 16, -29, -29, -29, 21, -29, -29, 22,
727 23, -29, -29, -29, 5, -29, -29, 28, 25, -29,
728 17, 24, -29, 26, -29, 29, -29, -29, 30, -29,
732 /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
733 Performed when YYTABLE does not specify something else to do. Zero
734 means the default is an error. */
735 static const yytype_int8 yydefact[] =
737 2, 0, 1, 0, 0, 0, 29, 3, 4, 6,
738 7, 0, 20, 27, 25, 30, 22, 28, 26, 0,
739 0, 8, 14, 17, 13, 5, 16, 0, 0, 23,
740 29, 18, 15, 0, 21, 0, 10, 9, 0, 24,
744 /* YYPGOTO[NTERM-NUM]. */
745 static const yytype_int8 yypgoto[] =
747 -29, -29, -29, -29, -29, -24, -29, -29, -28
750 /* YYDEFGOTO[NTERM-NUM]. */
751 static const yytype_int8 yydefgoto[] =
753 -1, 1, 7, 8, 25, 26, 9, 10, 21
756 /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
757 positive, shift that token. If negative, reduce the rule whose
758 number is the opposite. If YYTABLE_NINF, syntax error. */
759 static const yytype_int8 yytable[] =
761 32, 2, 37, 11, 3, 15, 36, 4, 22, 23,
762 5, 6, 43, 23, 23, 24, 42, 15, 16, 17,
763 18, 12, 15, 27, 19, 20, 23, 13, 14, 35,
764 28, 29, 30, 31, 33, 34, 39, 38, 0, 40,
768 static const yytype_int8 yycheck[] =
770 24, 0, 30, 14, 3, 5, 30, 6, 4, 9,
771 9, 10, 40, 9, 9, 11, 40, 5, 6, 7,
772 8, 10, 5, 10, 12, 13, 9, 7, 8, 12,
773 14, 10, 10, 10, 6, 10, 10, 13, -1, 10,
777 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
778 symbol of state STATE-NUM. */
779 static const yytype_int8 yystos[] =
781 0, 16, 0, 3, 6, 9, 10, 17, 18, 21,
782 22, 14, 10, 7, 8, 5, 6, 7, 8, 12,
783 13, 23, 4, 9, 11, 19, 20, 10, 14, 10,
784 10, 10, 20, 6, 10, 12, 20, 23, 13, 10,
788 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
789 static const yytype_int8 yyr1[] =
791 0, 15, 16, 16, 17, 17, 17, 17, 18, 18,
792 18, 18, 18, 19, 19, 19, 19, 20, 21, 21,
793 21, 21, 21, 21, 21, 22, 22, 22, 22, 23,
797 /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
798 static const yytype_int8 yyr2[] =
800 0, 2, 0, 2, 1, 2, 1, 1, 2, 4,
801 4, 6, 6, 1, 1, 2, 1, 1, 3, 5,
802 2, 4, 2, 3, 5, 2, 2, 2, 2, 0,
807 enum { YYENOMEM = -2 };
809 #define yyerrok (yyerrstatus = 0)
810 #define yyclearin (yychar = YYEMPTY)
812 #define YYACCEPT goto yyacceptlab
813 #define YYABORT goto yyabortlab
814 #define YYERROR goto yyerrorlab
817 #define YYRECOVERING() (!!yyerrstatus)
819 #define YYBACKUP(Token, Value) \
821 if (yychar == YYEMPTY) \
825 YYPOPSTACK (yylen); \
831 yyerror (YY_("syntax error: cannot back up")); \
836 /* Backward compatibility with an undocumented macro.
837 Use YYerror or YYUNDEF. */
838 #define YYERRCODE YYUNDEF
841 /* Enable debugging if requested. */
845 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
846 # define YYFPRINTF fprintf
849 # define YYDPRINTF(Args) \
855 /* This macro is provided for backward compatibility. */
856 # ifndef YY_LOCATION_PRINT
857 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
861 # define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \
865 YYFPRINTF (stderr, "%s ", Title); \
866 yy_symbol_print (stderr, \
868 YYFPRINTF (stderr, "\n"); \
873 /*-----------------------------------.
874 | Print this symbol's value on YYO. |
875 `-----------------------------------*/
878 yy_symbol_value_print (FILE *yyo,
879 yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep)
881 FILE *yyoutput = yyo;
886 if (yykind < YYNTOKENS)
887 YYPRINT (yyo, yytoknum[yykind], *yyvaluep);
889 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
891 YY_IGNORE_MAYBE_UNINITIALIZED_END
895 /*---------------------------.
896 | Print this symbol on YYO. |
897 `---------------------------*/
900 yy_symbol_print (FILE *yyo,
901 yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep)
903 YYFPRINTF (yyo, "%s %s (",
904 yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind));
906 yy_symbol_value_print (yyo, yykind, yyvaluep);
907 YYFPRINTF (yyo, ")");
910 /*------------------------------------------------------------------.
911 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
913 `------------------------------------------------------------------*/
916 yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop)
918 YYFPRINTF (stderr, "Stack now");
919 for (; yybottom <= yytop; yybottom++)
921 int yybot = *yybottom;
922 YYFPRINTF (stderr, " %d", yybot);
924 YYFPRINTF (stderr, "\n");
927 # define YY_STACK_PRINT(Bottom, Top) \
930 yy_stack_print ((Bottom), (Top)); \
934 /*------------------------------------------------.
935 | Report that the YYRULE is going to be reduced. |
936 `------------------------------------------------*/
939 yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp,
942 int yylno = yyrline[yyrule];
943 int yynrhs = yyr2[yyrule];
945 YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n",
947 /* The symbols being reduced. */
948 for (yyi = 0; yyi < yynrhs; yyi++)
950 YYFPRINTF (stderr, " $%d = ", yyi + 1);
951 yy_symbol_print (stderr,
952 YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]),
953 &yyvsp[(yyi + 1) - (yynrhs)]);
954 YYFPRINTF (stderr, "\n");
958 # define YY_REDUCE_PRINT(Rule) \
961 yy_reduce_print (yyssp, yyvsp, Rule); \
964 /* Nonzero means print parse trace. It is left uninitialized so that
965 multiple parsers can coexist. */
968 # define YYDPRINTF(Args) ((void) 0)
969 # define YY_SYMBOL_PRINT(Title, Kind, Value, Location)
970 # define YY_STACK_PRINT(Bottom, Top)
971 # define YY_REDUCE_PRINT(Rule)
972 #endif /* !YYDEBUG */
975 /* YYINITDEPTH -- initial size of the parser's stacks. */
977 # define YYINITDEPTH 200
980 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
981 if the built-in stack extension method is used).
983 Do not make this value too large; the results are undefined if
984 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
985 evaluated with infinite-precision integer arithmetic. */
988 # define YYMAXDEPTH 10000
996 /*-----------------------------------------------.
997 | Release the memory associated to this symbol. |
998 `-----------------------------------------------*/
1001 yydestruct (const char *yymsg,
1002 yysymbol_kind_t yykind, YYSTYPE *yyvaluep)
1007 YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp);
1009 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1011 YY_IGNORE_MAYBE_UNINITIALIZED_END
1015 /* Lookahead token kind. */
1018 /* The semantic value of the lookahead symbol. */
1020 /* Number of syntax errors so far. */
1033 yy_state_fast_t yystate = 0;
1034 /* Number of tokens to shift before error messages enabled. */
1035 int yyerrstatus = 0;
1037 /* Refer to the stacks through separate pointers, to allow yyoverflow
1038 to reallocate them elsewhere. */
1041 YYPTRDIFF_T yystacksize = YYINITDEPTH;
1043 /* The state stack: array, bottom, top. */
1044 yy_state_t yyssa[YYINITDEPTH];
1045 yy_state_t *yyss = yyssa;
1046 yy_state_t *yyssp = yyss;
1048 /* The semantic value stack: array, bottom, top. */
1049 YYSTYPE yyvsa[YYINITDEPTH];
1050 YYSTYPE *yyvs = yyvsa;
1051 YYSTYPE *yyvsp = yyvs;
1054 /* The return value of yyparse. */
1056 /* Lookahead symbol kind. */
1057 yysymbol_kind_t yytoken = YYSYMBOL_YYEMPTY;
1058 /* The variables used to return semantic value and location from the
1064 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1066 /* The number of symbols on the RHS of the reduced rule.
1067 Keep to zero when no symbol should be popped. */
1070 YYDPRINTF ((stderr, "Starting parse\n"));
1072 yychar = YYEMPTY; /* Cause a token to be read. */
1076 /*------------------------------------------------------------.
1077 | yynewstate -- push a new state, which is found in yystate. |
1078 `------------------------------------------------------------*/
1080 /* In all cases, when you get here, the value and location stacks
1081 have just been pushed. So pushing a state here evens the stacks. */
1085 /*--------------------------------------------------------------------.
1086 | yysetstate -- set current state (the top of the stack) to yystate. |
1087 `--------------------------------------------------------------------*/
1089 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1090 YY_ASSERT (0 <= yystate && yystate < YYNSTATES);
1091 YY_IGNORE_USELESS_CAST_BEGIN
1092 *yyssp = YY_CAST (yy_state_t, yystate);
1093 YY_IGNORE_USELESS_CAST_END
1094 YY_STACK_PRINT (yyss, yyssp);
1096 if (yyss + yystacksize - 1 <= yyssp)
1097 #if !defined yyoverflow && !defined YYSTACK_RELOCATE
1098 goto yyexhaustedlab;
1101 /* Get the current used size of the three stacks, in elements. */
1102 YYPTRDIFF_T yysize = yyssp - yyss + 1;
1104 # if defined yyoverflow
1106 /* Give user a chance to reallocate the stack. Use copies of
1107 these so that the &'s don't force the real ones into
1109 yy_state_t *yyss1 = yyss;
1110 YYSTYPE *yyvs1 = yyvs;
1112 /* Each stack pointer address is followed by the size of the
1113 data in use in that stack, in bytes. This used to be a
1114 conditional around just the two extra args, but that might
1115 be undefined if yyoverflow is a macro. */
1116 yyoverflow (YY_("memory exhausted"),
1117 &yyss1, yysize * YYSIZEOF (*yyssp),
1118 &yyvs1, yysize * YYSIZEOF (*yyvsp),
1123 # else /* defined YYSTACK_RELOCATE */
1124 /* Extend the stack our own way. */
1125 if (YYMAXDEPTH <= yystacksize)
1126 goto yyexhaustedlab;
1128 if (YYMAXDEPTH < yystacksize)
1129 yystacksize = YYMAXDEPTH;
1132 yy_state_t *yyss1 = yyss;
1133 union yyalloc *yyptr =
1134 YY_CAST (union yyalloc *,
1135 YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize))));
1137 goto yyexhaustedlab;
1138 YYSTACK_RELOCATE (yyss_alloc, yyss);
1139 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1140 # undef YYSTACK_RELOCATE
1142 YYSTACK_FREE (yyss1);
1146 yyssp = yyss + yysize - 1;
1147 yyvsp = yyvs + yysize - 1;
1149 YY_IGNORE_USELESS_CAST_BEGIN
1150 YYDPRINTF ((stderr, "Stack size increased to %ld\n",
1151 YY_CAST (long, yystacksize)));
1152 YY_IGNORE_USELESS_CAST_END
1154 if (yyss + yystacksize - 1 <= yyssp)
1157 #endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
1159 if (yystate == YYFINAL)
1169 /* Do appropriate processing given the current state. Read a
1170 lookahead token if we need one and don't already have one. */
1172 /* First try to decide what to do without reference to lookahead token. */
1173 yyn = yypact[yystate];
1174 if (yypact_value_is_default (yyn))
1177 /* Not known => get a lookahead token if don't already have one. */
1179 /* YYCHAR is either empty, or end-of-input, or a valid lookahead. */
1180 if (yychar == YYEMPTY)
1182 YYDPRINTF ((stderr, "Reading a token\n"));
1186 if (yychar <= YYEOF)
1189 yytoken = YYSYMBOL_YYEOF;
1190 YYDPRINTF ((stderr, "Now at end of input.\n"));
1192 else if (yychar == YYerror)
1194 /* The scanner already issued an error message, process directly
1195 to error recovery. But do not keep the error token as
1196 lookahead, it is too special and may lead us to an endless
1197 loop in error recovery. */
1199 yytoken = YYSYMBOL_YYerror;
1204 yytoken = YYTRANSLATE (yychar);
1205 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1208 /* If the proper action on seeing token YYTOKEN is to reduce or to
1209 detect an error, take that action. */
1211 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1216 if (yytable_value_is_error (yyn))
1222 /* Count tokens shifted since error; after three, turn off error
1227 /* Shift the lookahead token. */
1228 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1230 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1232 YY_IGNORE_MAYBE_UNINITIALIZED_END
1234 /* Discard the shifted token. */
1239 /*-----------------------------------------------------------.
1240 | yydefault -- do the default action for the current state. |
1241 `-----------------------------------------------------------*/
1243 yyn = yydefact[yystate];
1249 /*-----------------------------.
1250 | yyreduce -- do a reduction. |
1251 `-----------------------------*/
1253 /* yyn is the number of a rule to reduce with. */
1256 /* If YYLEN is nonzero, implement the default value of the action:
1259 Otherwise, the following line sets YYVAL to garbage.
1260 This behavior is undocumented and Bison
1261 users should not rely upon it. Assigning to YYVAL
1262 unconditionally makes the parser a bit smaller, and it avoids a
1263 GCC warning that YYVAL may be used uninitialized. */
1264 yyval = yyvsp[1-yylen];
1267 YY_REDUCE_PRINT (yyn);
1270 case 4: /* item: time */
1271 #line 132 "server/parsedate.y"
1275 /* I am compulsive about lint natterings... */
1276 if (yyHaveTime == -1) {
1281 #line 1282 "y.tab.c"
1284 case 5: /* item: time zone */
1285 #line 141 "server/parsedate.y"
1288 yyTimezone = (yyvsp[0].Number);
1290 #line 1291 "y.tab.c"
1293 case 6: /* item: date */
1294 #line 145 "server/parsedate.y"
1298 #line 1299 "y.tab.c"
1301 case 7: /* item: rel */
1302 #line 148 "server/parsedate.y"
1306 #line 1307 "y.tab.c"
1309 case 8: /* time: tUNUMBER o_merid */
1310 #line 153 "server/parsedate.y"
1312 if ((yyvsp[-1].Number) < 100) {
1313 yyHour = (yyvsp[-1].Number);
1317 yyHour = (yyvsp[-1].Number) / 100;
1318 yyMinutes = (yyvsp[-1].Number) % 100;
1321 yyMeridian = (yyvsp[0].Meridian);
1323 #line 1324 "y.tab.c"
1326 case 9: /* time: tUNUMBER ':' tUNUMBER o_merid */
1327 #line 165 "server/parsedate.y"
1329 yyHour = (yyvsp[-3].Number);
1330 yyMinutes = (yyvsp[-1].Number);
1332 yyMeridian = (yyvsp[0].Meridian);
1334 #line 1335 "y.tab.c"
1337 case 10: /* time: tUNUMBER ':' tUNUMBER numzone */
1338 #line 171 "server/parsedate.y"
1340 yyHour = (yyvsp[-3].Number);
1341 yyMinutes = (yyvsp[-1].Number);
1342 yyTimezone = (yyvsp[0].Number);
1346 #line 1347 "y.tab.c"
1349 case 11: /* time: tUNUMBER ':' tUNUMBER ':' tUNUMBER o_merid */
1350 #line 178 "server/parsedate.y"
1352 yyHour = (yyvsp[-5].Number);
1353 yyMinutes = (yyvsp[-3].Number);
1354 yySeconds = (yyvsp[-1].Number);
1355 yyMeridian = (yyvsp[0].Meridian);
1357 #line 1358 "y.tab.c"
1360 case 12: /* time: tUNUMBER ':' tUNUMBER ':' tUNUMBER numzone */
1361 #line 184 "server/parsedate.y"
1363 yyHour = (yyvsp[-5].Number);
1364 yyMinutes = (yyvsp[-3].Number);
1365 yySeconds = (yyvsp[-1].Number);
1366 yyTimezone = (yyvsp[0].Number);
1370 #line 1371 "y.tab.c"
1373 case 13: /* zone: tZONE */
1374 #line 194 "server/parsedate.y"
1376 (yyval.Number) = (yyvsp[0].Number);
1379 #line 1380 "y.tab.c"
1382 case 14: /* zone: tDAYZONE */
1383 #line 198 "server/parsedate.y"
1385 (yyval.Number) = (yyvsp[0].Number);
1388 #line 1389 "y.tab.c"
1391 case 15: /* zone: tZONE numzone */
1392 #line 202 "server/parsedate.y"
1394 /* Only allow "GMT+300" and "GMT-0800" */
1395 if ((yyvsp[-1].Number) != 0) {
1398 (yyval.Number) = (yyvsp[0].Number);
1401 #line 1402 "y.tab.c"
1404 case 16: /* zone: numzone */
1405 #line 210 "server/parsedate.y"
1407 (yyval.Number) = (yyvsp[0].Number);
1410 #line 1411 "y.tab.c"
1413 case 17: /* numzone: tSNUMBER */
1414 #line 216 "server/parsedate.y"
1418 /* Unix and GMT and numeric timezones -- a little confusing. */
1419 if ((yyvsp[0].Number) < 0) {
1420 /* Don't work with negative modulus. */
1421 (yyvsp[0].Number) = -(yyvsp[0].Number);
1422 if ((yyvsp[0].Number) > 9999 || (i = (yyvsp[0].Number) % 100) >= 60) {
1425 (yyval.Number) = ((yyvsp[0].Number) / 100) * 60 + i;
1428 if ((yyvsp[0].Number) > 9999 || (i = (yyvsp[0].Number) % 100) >= 60) {
1431 (yyval.Number) = -(((yyvsp[0].Number) / 100) * 60 + i);
1434 #line 1435 "y.tab.c"
1437 case 18: /* date: tUNUMBER '/' tUNUMBER */
1438 #line 237 "server/parsedate.y"
1440 yyMonth = (yyvsp[-2].Number);
1441 yyDay = (yyvsp[0].Number);
1443 #line 1444 "y.tab.c"
1446 case 19: /* date: tUNUMBER '/' tUNUMBER '/' tUNUMBER */
1447 #line 241 "server/parsedate.y"
1449 if ((yyvsp[-4].Number) > 100) {
1450 yyYear = (yyvsp[-4].Number);
1451 yyMonth = (yyvsp[-2].Number);
1452 yyDay = (yyvsp[0].Number);
1455 yyMonth = (yyvsp[-4].Number);
1456 yyDay = (yyvsp[-2].Number);
1457 yyYear = (yyvsp[0].Number);
1460 #line 1461 "y.tab.c"
1463 case 20: /* date: tMONTH tUNUMBER */
1464 #line 253 "server/parsedate.y"
1466 yyMonth = (yyvsp[-1].Number);
1467 yyDay = (yyvsp[0].Number);
1469 #line 1470 "y.tab.c"
1472 case 21: /* date: tMONTH tUNUMBER ',' tUNUMBER */
1473 #line 257 "server/parsedate.y"
1475 yyMonth = (yyvsp[-3].Number);
1476 yyDay = (yyvsp[-2].Number);
1477 yyYear = (yyvsp[0].Number);
1479 #line 1480 "y.tab.c"
1482 case 22: /* date: tUNUMBER tMONTH */
1483 #line 262 "server/parsedate.y"
1485 yyDay = (yyvsp[-1].Number);
1486 yyMonth = (yyvsp[0].Number);
1488 #line 1489 "y.tab.c"
1491 case 23: /* date: tUNUMBER tMONTH tUNUMBER */
1492 #line 266 "server/parsedate.y"
1494 yyDay = (yyvsp[-2].Number);
1495 yyMonth = (yyvsp[-1].Number);
1496 yyYear = (yyvsp[0].Number);
1498 #line 1499 "y.tab.c"
1501 case 24: /* date: tDAY ',' tUNUMBER tMONTH tUNUMBER */
1502 #line 271 "server/parsedate.y"
1504 yyDay = (yyvsp[-2].Number);
1505 yyMonth = (yyvsp[-1].Number);
1506 yyYear = (yyvsp[0].Number);
1508 #line 1509 "y.tab.c"
1511 case 25: /* rel: tSNUMBER tSEC_UNIT */
1512 #line 278 "server/parsedate.y"
1514 yyRelSeconds += (yyvsp[-1].Number) * (yyvsp[0].Number);
1516 #line 1517 "y.tab.c"
1519 case 26: /* rel: tUNUMBER tSEC_UNIT */
1520 #line 281 "server/parsedate.y"
1522 yyRelSeconds += (yyvsp[-1].Number) * (yyvsp[0].Number);
1524 #line 1525 "y.tab.c"
1527 case 27: /* rel: tSNUMBER tMONTH_UNIT */
1528 #line 284 "server/parsedate.y"
1530 yyRelMonth += (yyvsp[-1].Number) * (yyvsp[0].Number);
1532 #line 1533 "y.tab.c"
1535 case 28: /* rel: tUNUMBER tMONTH_UNIT */
1536 #line 287 "server/parsedate.y"
1538 yyRelMonth += (yyvsp[-1].Number) * (yyvsp[0].Number);
1540 #line 1541 "y.tab.c"
1543 case 29: /* o_merid: %empty */
1544 #line 292 "server/parsedate.y"
1546 (yyval.Meridian) = MER24;
1548 #line 1549 "y.tab.c"
1551 case 30: /* o_merid: tMERIDIAN */
1552 #line 295 "server/parsedate.y"
1554 (yyval.Meridian) = (yyvsp[0].Meridian);
1556 #line 1557 "y.tab.c"
1560 #line 1561 "y.tab.c"
1564 /* User semantic actions sometimes alter yychar, and that requires
1565 that yytoken be updated with the new translation. We take the
1566 approach of translating immediately before every use of yytoken.
1567 One alternative is translating here after every semantic action,
1568 but that translation would be missed if the semantic action invokes
1569 YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1570 if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
1571 incorrect destructor might then be invoked immediately. In the
1572 case of YYERROR or YYBACKUP, subsequent parser actions might lead
1573 to an incorrect destructor call or verbose syntax error message
1574 before the lookahead is translated. */
1575 YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc);
1582 /* Now 'shift' the result of the reduction. Determine what state
1583 that goes to, based on the state we popped back to and the rule
1584 number reduced by. */
1586 const int yylhs = yyr1[yyn] - YYNTOKENS;
1587 const int yyi = yypgoto[yylhs] + *yyssp;
1588 yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
1590 : yydefgoto[yylhs]);
1596 /*--------------------------------------.
1597 | yyerrlab -- here on detecting error. |
1598 `--------------------------------------*/
1600 /* Make sure we have latest lookahead translation. See comments at
1601 user semantic actions for why this is necessary. */
1602 yytoken = yychar == YYEMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE (yychar);
1603 /* If not already recovering from an error, report this error. */
1607 yyerror (YY_("syntax error"));
1610 if (yyerrstatus == 3)
1612 /* If just tried and failed to reuse lookahead token after an
1613 error, discard it. */
1615 if (yychar <= YYEOF)
1617 /* Return failure if at end of input. */
1618 if (yychar == YYEOF)
1623 yydestruct ("Error: discarding",
1629 /* Else will try to reuse lookahead token after shifting the error
1634 /*---------------------------------------------------.
1635 | yyerrorlab -- error raised explicitly by YYERROR. |
1636 `---------------------------------------------------*/
1638 /* Pacify compilers when the user code never invokes YYERROR and the
1639 label yyerrorlab therefore never appears in user code. */
1643 /* Do not reclaim the symbols of the rule whose action triggered
1647 YY_STACK_PRINT (yyss, yyssp);
1652 /*-------------------------------------------------------------.
1653 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1654 `-------------------------------------------------------------*/
1656 yyerrstatus = 3; /* Each real token shifted decrements this. */
1658 /* Pop stack until we find a state that shifts the error token. */
1661 yyn = yypact[yystate];
1662 if (!yypact_value_is_default (yyn))
1664 yyn += YYSYMBOL_YYerror;
1665 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYerror)
1673 /* Pop the current state because it cannot handle the error token. */
1678 yydestruct ("Error: popping",
1679 YY_ACCESSING_SYMBOL (yystate), yyvsp);
1682 YY_STACK_PRINT (yyss, yyssp);
1685 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1687 YY_IGNORE_MAYBE_UNINITIALIZED_END
1690 /* Shift the error token. */
1691 YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp);
1697 /*-------------------------------------.
1698 | yyacceptlab -- YYACCEPT comes here. |
1699 `-------------------------------------*/
1705 /*-----------------------------------.
1706 | yyabortlab -- YYABORT comes here. |
1707 `-----------------------------------*/
1713 #if !defined yyoverflow
1714 /*-------------------------------------------------.
1715 | yyexhaustedlab -- memory exhaustion comes here. |
1716 `-------------------------------------------------*/
1718 yyerror (YY_("memory exhausted"));
1724 /*-------------------------------------------------------.
1725 | yyreturn -- parsing is finished, clean up and return. |
1726 `-------------------------------------------------------*/
1728 if (yychar != YYEMPTY)
1730 /* Make sure we have latest lookahead translation. See comments at
1731 user semantic actions for why this is necessary. */
1732 yytoken = YYTRANSLATE (yychar);
1733 yydestruct ("Cleanup: discarding lookahead",
1736 /* Do not reclaim the symbols of the rule whose action triggered
1737 this YYABORT or YYACCEPT. */
1739 YY_STACK_PRINT (yyss, yyssp);
1740 while (yyssp != yyss)
1742 yydestruct ("Cleanup: popping",
1743 YY_ACCESSING_SYMBOL (+*yyssp), yyvsp);
1748 YYSTACK_FREE (yyss);
1754 #line 300 "server/parsedate.y"
1757 /* Month and day table. */
1758 static TABLE MonthDayTable[] = {
1759 { "january", tMONTH, 1 },
1760 { "february", tMONTH, 2 },
1761 { "march", tMONTH, 3 },
1762 { "april", tMONTH, 4 },
1763 { "may", tMONTH, 5 },
1764 { "june", tMONTH, 6 },
1765 { "july", tMONTH, 7 },
1766 { "august", tMONTH, 8 },
1767 { "september", tMONTH, 9 },
1768 { "october", tMONTH, 10 },
1769 { "november", tMONTH, 11 },
1770 { "december", tMONTH, 12 },
1771 /* The value of the day isn't used... */
1772 { "sunday", tDAY, 0 },
1773 { "monday", tDAY, 0 },
1774 { "tuesday", tDAY, 0 },
1775 { "wednesday", tDAY, 0 },
1776 { "thursday", tDAY, 0 },
1777 { "friday", tDAY, 0 },
1778 { "saturday", tDAY, 0 },
1781 /* Time units table. */
1782 static TABLE UnitsTable[] = {
1783 { "year", tMONTH_UNIT, 12 },
1784 { "month", tMONTH_UNIT, 1 },
1785 { "week", tSEC_UNIT, 7L * 24 * 60 * 60 },
1786 { "day", tSEC_UNIT, 1L * 24 * 60 * 60 },
1787 { "hour", tSEC_UNIT, 60 * 60 },
1788 { "minute", tSEC_UNIT, 60 },
1789 { "min", tSEC_UNIT, 60 },
1790 { "second", tSEC_UNIT, 1 },
1791 { "sec", tSEC_UNIT, 1 },
1794 /* Timezone table. */
1795 static TABLE TimezoneTable[] = {
1796 { "gmt", tZONE, HOUR( 0) }, /* Greenwich Mean */
1797 { "ut", tZONE, HOUR( 0) }, /* Universal */
1798 { "utc", tZONE, HOUR( 0) }, /* Universal Coordinated */
1799 { "cut", tZONE, HOUR( 0) }, /* Coordinated Universal */
1800 { "z", tZONE, HOUR( 0) }, /* Greenwich Mean */
1801 { "wet", tZONE, HOUR( 0) }, /* Western European */
1802 { "bst", tDAYZONE, HOUR( 0) }, /* British Summer */
1803 { "nst", tZONE, HOUR(3)+30 }, /* Newfoundland Standard */
1804 { "ndt", tDAYZONE, HOUR(3)+30 }, /* Newfoundland Daylight */
1805 { "ast", tZONE, HOUR( 4) }, /* Atlantic Standard */
1806 { "adt", tDAYZONE, HOUR( 4) }, /* Atlantic Daylight */
1807 { "est", tZONE, HOUR( 5) }, /* Eastern Standard */
1808 { "edt", tDAYZONE, HOUR( 5) }, /* Eastern Daylight */
1809 { "cst", tZONE, HOUR( 6) }, /* Central Standard */
1810 { "cdt", tDAYZONE, HOUR( 6) }, /* Central Daylight */
1811 { "mst", tZONE, HOUR( 7) }, /* Mountain Standard */
1812 { "mdt", tDAYZONE, HOUR( 7) }, /* Mountain Daylight */
1813 { "pst", tZONE, HOUR( 8) }, /* Pacific Standard */
1814 { "pdt", tDAYZONE, HOUR( 8) }, /* Pacific Daylight */
1815 { "yst", tZONE, HOUR( 9) }, /* Yukon Standard */
1816 { "ydt", tDAYZONE, HOUR( 9) }, /* Yukon Daylight */
1817 { "akst", tZONE, HOUR( 9) }, /* Alaska Standard */
1818 { "akdt", tDAYZONE, HOUR( 9) }, /* Alaska Daylight */
1819 { "hst", tZONE, HOUR(10) }, /* Hawaii Standard */
1820 { "hast", tZONE, HOUR(10) }, /* Hawaii-Aleutian Standard */
1821 { "hadt", tDAYZONE, HOUR(10) }, /* Hawaii-Aleutian Daylight */
1822 { "ces", tDAYZONE, -HOUR(1) }, /* Central European Summer */
1823 { "cest", tDAYZONE, -HOUR(1) }, /* Central European Summer */
1824 { "mez", tZONE, -HOUR(1) }, /* Middle European */
1825 { "mezt", tDAYZONE, -HOUR(1) }, /* Middle European Summer */
1826 { "cet", tZONE, -HOUR(1) }, /* Central European */
1827 { "met", tZONE, -HOUR(1) }, /* Middle European */
1828 { "eet", tZONE, -HOUR(2) }, /* Eastern Europe */
1829 { "msk", tZONE, -HOUR(3) }, /* Moscow Winter */
1830 { "msd", tDAYZONE, -HOUR(3) }, /* Moscow Summer */
1831 { "wast", tZONE, -HOUR(8) }, /* West Australian Standard */
1832 { "wadt", tDAYZONE, -HOUR(8) }, /* West Australian Daylight */
1833 { "hkt", tZONE, -HOUR(8) }, /* Hong Kong */
1834 { "cct", tZONE, -HOUR(8) }, /* China Coast */
1835 { "jst", tZONE, -HOUR(9) }, /* Japan Standard */
1836 { "kst", tZONE, -HOUR(9) }, /* Korean Standard */
1837 { "kdt", tZONE, -HOUR(9) }, /* Korean Daylight */
1838 { "cast", tZONE, -(HOUR(9)+30) }, /* Central Australian Standard */
1839 { "cadt", tDAYZONE, -(HOUR(9)+30) }, /* Central Australian Daylight */
1840 { "east", tZONE, -HOUR(10) }, /* Eastern Australian Standard */
1841 { "eadt", tDAYZONE, -HOUR(10) }, /* Eastern Australian Daylight */
1842 { "nzst", tZONE, -HOUR(12) }, /* New Zealand Standard */
1843 { "nzdt", tDAYZONE, -HOUR(12) }, /* New Zealand Daylight */
1845 /* For completeness we include the following entries. */
1848 /* Duplicate names. Either they conflict with a zone listed above
1849 * (which is either more likely to be seen or just been in circulation
1850 * longer), or they conflict with another zone in this section and
1851 * we could not reasonably choose one over the other. */
1852 { "fst", tZONE, HOUR( 2) }, /* Fernando De Noronha Standard */
1853 { "fdt", tDAYZONE, HOUR( 2) }, /* Fernando De Noronha Daylight */
1854 { "bst", tZONE, HOUR( 3) }, /* Brazil Standard */
1855 { "est", tZONE, HOUR( 3) }, /* Eastern Standard (Brazil) */
1856 { "edt", tDAYZONE, HOUR( 3) }, /* Eastern Daylight (Brazil) */
1857 { "wst", tZONE, HOUR( 4) }, /* Western Standard (Brazil) */
1858 { "wdt", tDAYZONE, HOUR( 4) }, /* Western Daylight (Brazil) */
1859 { "cst", tZONE, HOUR( 5) }, /* Chile Standard */
1860 { "cdt", tDAYZONE, HOUR( 5) }, /* Chile Daylight */
1861 { "ast", tZONE, HOUR( 5) }, /* Acre Standard */
1862 { "adt", tDAYZONE, HOUR( 5) }, /* Acre Daylight */
1863 { "cst", tZONE, HOUR( 5) }, /* Cuba Standard */
1864 { "cdt", tDAYZONE, HOUR( 5) }, /* Cuba Daylight */
1865 { "est", tZONE, HOUR( 6) }, /* Easter Island Standard */
1866 { "edt", tDAYZONE, HOUR( 6) }, /* Easter Island Daylight */
1867 { "sst", tZONE, HOUR(11) }, /* Samoa Standard */
1868 { "ist", tZONE, -HOUR(2) }, /* Israel Standard */
1869 { "idt", tDAYZONE, -HOUR(2) }, /* Israel Daylight */
1870 { "idt", tDAYZONE, -(HOUR(3)+30) }, /* Iran Daylight */
1871 { "ist", tZONE, -(HOUR(3)+30) }, /* Iran Standard */
1872 { "cst", tZONE, -HOUR(8) }, /* China Standard */
1873 { "cdt", tDAYZONE, -HOUR(8) }, /* China Daylight */
1874 { "sst", tZONE, -HOUR(8) }, /* Singapore Standard */
1876 /* Dubious (e.g., not in Olson's TIMEZONE package) or obsolete. */
1877 { "gst", tZONE, HOUR( 3) }, /* Greenland Standard */
1878 { "wat", tZONE, -HOUR(1) }, /* West Africa */
1879 { "at", tZONE, HOUR( 2) }, /* Azores */
1880 { "gst", tZONE, -HOUR(10) }, /* Guam Standard */
1881 { "nft", tZONE, HOUR(3)+30 }, /* Newfoundland */
1882 { "idlw", tZONE, HOUR(12) }, /* International Date Line West */
1883 { "mewt", tZONE, -HOUR(1) }, /* Middle European Winter */
1884 { "mest", tDAYZONE, -HOUR(1) }, /* Middle European Summer */
1885 { "swt", tZONE, -HOUR(1) }, /* Swedish Winter */
1886 { "sst", tDAYZONE, -HOUR(1) }, /* Swedish Summer */
1887 { "fwt", tZONE, -HOUR(1) }, /* French Winter */
1888 { "fst", tDAYZONE, -HOUR(1) }, /* French Summer */
1889 { "bt", tZONE, -HOUR(3) }, /* Baghdad */
1890 { "it", tZONE, -(HOUR(3)+30) }, /* Iran */
1891 { "zp4", tZONE, -HOUR(4) }, /* USSR Zone 3 */
1892 { "zp5", tZONE, -HOUR(5) }, /* USSR Zone 4 */
1893 { "ist", tZONE, -(HOUR(5)+30) }, /* Indian Standard */
1894 { "zp6", tZONE, -HOUR(6) }, /* USSR Zone 5 */
1895 { "nst", tZONE, -HOUR(7) }, /* North Sumatra */
1896 { "sst", tZONE, -HOUR(7) }, /* South Sumatra */
1897 { "jt", tZONE, -(HOUR(7)+30) }, /* Java (3pm in Cronusland!) */
1898 { "nzt", tZONE, -HOUR(12) }, /* New Zealand */
1899 { "idle", tZONE, -HOUR(12) }, /* International Date Line East */
1900 { "cat", tZONE, HOUR(10) }, /* -- expired 1967 */
1901 { "nt", tZONE, HOUR(11) }, /* -- expired 1967 */
1902 { "ahst", tZONE, HOUR(10) }, /* -- expired 1983 */
1903 { "hdt", tDAYZONE, HOUR(10) }, /* -- expired 1986 */
1917 ToSeconds(time_t Hours, time_t Minutes, time_t Seconds, MERIDIAN Meridian)
1919 if (Minutes < 0 || Minutes > 59 || Seconds < 0 || Seconds > 61)
1921 if (Meridian == MER24) {
1922 if (Hours < 0 || Hours > 23)
1926 if (Hours < 1 || Hours > 12)
1930 if (Meridian == MERpm)
1933 return (Hours * 60L + Minutes) * 60L + Seconds;
1938 Convert(time_t Month, time_t Day, time_t Year,
1939 time_t Hours, time_t Minutes, time_t Seconds,
1940 MERIDIAN Meridian, DSTMODE dst)
1942 static int DaysNormal[13] = {
1943 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
1945 static int DaysLeap[13] = {
1946 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
1948 static int LeapYears[] = {
1949 1972, 1976, 1980, 1984, 1988, 1992, 1996,
1950 2000, 2004, 2008, 2012, 2016, 2020, 2024, 2028, 2032, 2036
1954 register time_t Julian;
1964 for (mp = DaysNormal, yp = LeapYears; yp < ENDOF(LeapYears); yp++)
1969 if (Year < EPOCH || Year > END_OF_TIME
1970 || Month < 1 || Month > 12
1971 /* NOSTRICT *//* conversion from long may lose accuracy */
1972 || Day < 1 || Day > mp[(int)Month])
1975 Julian = Day - 1 + (Year - EPOCH) * 365;
1976 for (yp = LeapYears; yp < ENDOF(LeapYears); yp++, Julian++)
1979 for (i = 1; i < Month; i++)
1981 Julian *= SECSPERDAY;
1982 Julian += yyTimezone * 60L;
1983 if ((tod = ToSeconds(Hours, Minutes, Seconds, Meridian)) < 0)
1987 if (dst == DSTon || (dst == DSTmaybe && localtime(&tod)->tm_isdst))
1988 Julian -= DST_OFFSET * 60L * 60L;
1994 DSTcorrect(time_t Start, time_t Future)
1999 StartDay = (localtime(&Start)->tm_hour + 1) % 24;
2000 FutureDay = (localtime(&Future)->tm_hour + 1) % 24;
2001 return (Future - Start) + (StartDay - FutureDay) * DST_OFFSET * 60L * 60L;
2006 RelativeMonth(time_t Start, time_t RelMonth)
2012 tm = localtime(&Start);
2013 Month = 12 * tm->tm_year + tm->tm_mon + RelMonth;
2015 Month = Month % 12 + 1;
2016 return DSTcorrect(Start,
2017 Convert(Month, (time_t)tm->tm_mday, Year,
2018 (time_t)tm->tm_hour, (time_t)tm->tm_min, (time_t)tm->tm_sec,
2024 LookupWord(char *buff, register int length)
2034 /* See if we have an abbreviation for a month. */
2035 if (length == 3 || (length == 4 && p[3] == '.'))
2036 for (tp = MonthDayTable; tp < ENDOF(MonthDayTable); tp++) {
2038 if (c == q[0] && p[1] == q[1] && p[2] == q[2]) {
2039 yylval.Number = tp->value;
2044 for (tp = MonthDayTable; tp < ENDOF(MonthDayTable); tp++)
2045 if (c == tp->name[0] && strcmp(p, tp->name) == 0) {
2046 yylval.Number = tp->value;
2050 /* Try for a timezone. */
2051 for (tp = TimezoneTable; tp < ENDOF(TimezoneTable); tp++)
2052 if (c == tp->name[0] && p[1] == tp->name[1]
2053 && strcmp(p, tp->name) == 0) {
2054 yylval.Number = tp->value;
2058 /* Try the units table. */
2059 for (tp = UnitsTable; tp < ENDOF(UnitsTable); tp++)
2060 if (c == tp->name[0] && strcmp(p, tp->name) == 0) {
2061 yylval.Number = tp->value;
2065 /* Strip off any plural and try the units table again. */
2066 if (--length > 0 && p[length] == 's') {
2068 for (tp = UnitsTable; tp < ENDOF(UnitsTable); tp++)
2069 if (c == tp->name[0] && strcmp(p, tp->name) == 0) {
2071 yylval.Number = tp->value;
2078 /* Drop out any periods. */
2079 for (p = buff, q = (char*)buff; *q; q++)
2084 /* Try the meridians. */
2085 if (buff[1] == 'm' && buff[2] == '\0') {
2086 if (buff[0] == 'a') {
2087 yylval.Meridian = MERam;
2090 if (buff[0] == 'p') {
2091 yylval.Meridian = MERpm;
2096 /* If we saw any periods, try the timezones again. */
2097 if (p - buff != length) {
2099 for (p = buff, tp = TimezoneTable; tp < ENDOF(TimezoneTable); tp++)
2100 if (c == tp->name[0] && p[1] == tp->name[1]
2101 && strcmp(p, tp->name) == 0) {
2102 yylval.Number = tp->value;
2107 /* Unknown word -- assume GMT timezone. */
2121 register int nesting;
2124 /* Get first character after the whitespace. */
2126 while (isspace(*yyInput))
2130 /* Ignore RFC 822 comments, typically time zone names. */
2133 for (nesting = 1; (c = *++yyInput) != RPAREN || --nesting; )
2136 else if (!IS7BIT(c) || c == '\0' || c == '\r'
2137 || (c == '\\' && ((c = *++yyInput) == '\0' || !IS7BIT(c))))
2138 /* Lexical error: bad comment. */
2144 if (isdigit(c) || c == '-' || c == '+') {
2145 if (c == '-' || c == '+') {
2146 sign = c == '-' ? -1 : 1;
2148 if (!isdigit(*yyInput))
2149 /* Skip the plus or minus sign. */
2154 for (i = 0; (c = *yyInput++) != '\0' && isdigit(c); )
2155 i = 10 * i + c - '0';
2157 yylval.Number = sign < 0 ? -i : i;
2158 return sign ? tSNUMBER : tUNUMBER;
2163 for (p = buff; (c = *yyInput++) == '.' || isalpha(c); )
2164 if (p < &buff[sizeof buff - 1])
2165 *p++ = isupper(c) ? tolower(c) : c;
2168 return LookupWord(buff, p - buff);
2177 parsedate(const char *p)
2179 extern int date_parse(void);
2182 yyInput = p; /* well, its supposed to be const... */
2188 yyDSTmode = DSTmaybe;
2199 if (date_parse() || yyHaveTime > 1 || yyHaveDate > 1)
2202 if (yyHaveDate || yyHaveTime) {
2203 Start = Convert(yyMonth, yyDay, yyYear, yyHour, yyMinutes, yySeconds,
2204 yyMeridian, yyDSTmode);
2211 Start += yyRelSeconds;
2213 Start += RelativeMonth(Start, yyRelMonth);
2215 /* Have to do *something* with a legitimate -1 so it's distinguishable
2216 * from the error return value. (Alternately could set errno on error.) */
2217 return Start == -1 ? 0 : Start;
2225 #endif /* YYDEBUG */
2229 main(int ac, char *av[])
2236 #endif /* YYDEBUG */
2238 (void)printf("Enter date, or blank line to exit.\n\t> ");
2240 (void)printf("\t> ");
2241 (void)fflush(stdout);
2242 if (fgets(buff, sizeof buff, stdin) == NULL || buff[0] == '\n')
2245 if (strcmp(buff, "yydebug") == 0) {
2247 printf("yydebug = %s\n", yydebug ? "on" : "off");
2250 #endif /* YYDEBUG */
2251 d = parsedate(buff, (TIMEINFO *)NULL);
2253 (void)printf("Bad format - couldn't convert.\n");
2255 (void)printf("%s", ctime(&d));