Back to index

citadel  8.12
parsedate.c
Go to the documentation of this file.
00001 /* A Bison parser, made by GNU Bison 2.5.  */
00002 
00003 /* Bison implementation for Yacc-like parsers in C
00004    
00005       Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc.
00006    
00007    This program is free software: you can redistribute it and/or modify
00008    it under the terms of the GNU General Public License as published by
00009    the Free Software Foundation, either version 3 of the License, or
00010    (at your option) any later version.
00011    
00012    This program is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015    GNU General Public License for more details.
00016    
00017    You should have received a copy of the GNU General Public License
00018    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
00019 
00020 /* As a special exception, you may create a larger work that contains
00021    part or all of the Bison parser skeleton and distribute that work
00022    under terms of your choice, so long as that work isn't itself a
00023    parser generator using the skeleton or a modified version thereof
00024    as a parser skeleton.  Alternatively, if you modify or redistribute
00025    the parser skeleton itself, you may (at your option) remove this
00026    special exception, which will cause the skeleton and the resulting
00027    Bison output files to be licensed under the GNU General Public
00028    License without this special exception.
00029    
00030    This special exception was added by the Free Software Foundation in
00031    version 2.2 of Bison.  */
00032 
00033 /* C LALR(1) parser skeleton written by Richard Stallman, by
00034    simplifying the original so-called "semantic" parser.  */
00035 
00036 /* All symbols defined below should begin with yy or YY, to avoid
00037    infringing on user name space.  This should be done even for local
00038    variables, as they might otherwise be expanded by user macros.
00039    There are some unavoidable exceptions within include files to
00040    define necessary library symbols; they are noted "INFRINGES ON
00041    USER NAME SPACE" below.  */
00042 
00043 /* Identify Bison output.  */
00044 #define YYBISON 1
00045 
00046 /* Bison version.  */
00047 #define YYBISON_VERSION "2.5"
00048 
00049 /* Skeleton name.  */
00050 #define YYSKELETON_NAME "yacc.c"
00051 
00052 /* Pure parsers.  */
00053 #define YYPURE 0
00054 
00055 /* Push parsers.  */
00056 #define YYPUSH 0
00057 
00058 /* Pull parsers.  */
00059 #define YYPULL 1
00060 
00061 /* Using locations.  */
00062 #define YYLSP_NEEDED 0
00063 
00064 
00065 
00066 /* Copy the first part of user declarations.  */
00067 
00068 /* Line 268 of yacc.c  */
00069 #line 1 "parsedate.y"
00070 
00071 /* $Revision$
00072 **
00073 **  Originally written by Steven M. Bellovin <smb@research.att.com> while
00074 **  at the University of North Carolina at Chapel Hill.  Later tweaked by
00075 **  a couple of people on Usenet.  Completely overhauled by Rich $alz
00076 **  <rsalz@osf.org> and Jim Berets <jberets@bbn.com> in August, 1990.
00077 **  Further revised (removed obsolete constructs and cleaned up timezone
00078 **  names) in August, 1991, by Rich.  Paul Eggert <eggert@twinsun.com>
00079 **  helped in September, 1992.  Art Cancro <ajc@uncensored.citadel.org> cleaned
00080 **  it up for ANSI C in December, 1999.
00081 **
00082 **  This grammar has six shift/reduce conflicts.
00083 **
00084 **  This code is in the public domain and has no copyright.
00085 */
00086 /* SUPPRESS 530 *//* Empty body for statement */
00087 /* SUPPRESS 593 on yyerrlab *//* Label was not used */
00088 /* SUPPRESS 593 on yynewstate *//* Label was not used */
00089 /* SUPPRESS 595 on yypvt *//* Automatic variable may be used before set */
00090 
00091 #include "sysdep.h"
00092 
00093 #include <stdio.h>
00094 #include <stdlib.h>
00095 #include <sys/types.h>
00096 #include <ctype.h>
00097 
00098 #if TIME_WITH_SYS_TIME
00099 # include <sys/time.h>
00100 # include <time.h>
00101 #else
00102 # if HAVE_SYS_TIME_H
00103 #  include <sys/time.h>
00104 # else
00105 #  include <time.h>
00106 # endif
00107 #endif
00108 
00109 #if HAVE_STRING_H
00110 # if !STDC_HEADERS && HAVE_MEMORY_H
00111 #  include <memory.h>
00112 # endif
00113 # include <string.h>
00114 #endif
00115 #if HAVE_STRINGS_H
00116 # include <strings.h>
00117 #endif
00118 
00119 #include "parsedate.h"
00120 
00121 int date_lex(void);
00122 
00123 #define yyparse             date_parse
00124 #define yylex        date_lex
00125 #define yyerror             date_error
00126 
00127 
00128     /* See the LeapYears table in Convert. */
00129 #define EPOCH        1970
00130 #define END_OF_TIME  2038
00131     /* Constants for general time calculations. */
00132 #define DST_OFFSET   1
00133 #define SECSPERDAY   (24L * 60L * 60L)
00134     /* Readability for TABLE stuff. */
00135 #define HOUR(x)             (x * 60)
00136 
00137 #define LPAREN              '('
00138 #define RPAREN              ')'
00139 #define IS7BIT(x)    ((unsigned int)(x) < 0200)
00140 
00141 #define SIZEOF(array)       ((int)(sizeof array / sizeof array[0]))
00142 #define ENDOF(array) (&array[SIZEOF(array)])
00143 
00144 
00145 /*
00146 **  An entry in the lexical lookup table.
00147 */
00148 typedef struct _TABLE {
00149     char      *name;
00150     int              type;
00151     time_t    value;
00152 } TABLE;
00153 
00154 /*
00155 **  Daylight-savings mode:  on, off, or not yet known.
00156 */
00157 typedef enum _DSTMODE {
00158     DSTon, DSToff, DSTmaybe
00159 } DSTMODE;
00160 
00161 /*
00162 **  Meridian:  am, pm, or 24-hour style.
00163 */
00164 typedef enum _MERIDIAN {
00165     MERam, MERpm, MER24
00166 } MERIDIAN;
00167 
00168 
00169 /*
00170 **  Global variables.  We could get rid of most of them by using a yacc
00171 **  union, but this is more efficient.  (This routine predates the
00172 **  yacc %union construct.)
00173 */
00174 static const char    *yyInput;
00175 static DSTMODE       yyDSTmode;
00176 static int    yyHaveDate;
00177 static int    yyHaveRel;
00178 static int    yyHaveTime;
00179 static time_t yyTimezone;
00180 static time_t yyDay;
00181 static time_t yyHour;
00182 static time_t yyMinutes;
00183 static time_t yyMonth;
00184 static time_t yySeconds;
00185 static time_t yyYear;
00186 static MERIDIAN      yyMeridian;
00187 static time_t yyRelMonth;
00188 static time_t yyRelSeconds;
00189 
00190 
00191 static void          date_error(char *);
00192 
00193 
00194 /* Line 268 of yacc.c  */
00195 #line 196 "y.tab.c"
00196 
00197 /* Enabling traces.  */
00198 #ifndef YYDEBUG
00199 # define YYDEBUG 0
00200 #endif
00201 
00202 /* Enabling verbose error messages.  */
00203 #ifdef YYERROR_VERBOSE
00204 # undef YYERROR_VERBOSE
00205 # define YYERROR_VERBOSE 1
00206 #else
00207 # define YYERROR_VERBOSE 0
00208 #endif
00209 
00210 /* Enabling the token table.  */
00211 #ifndef YYTOKEN_TABLE
00212 # define YYTOKEN_TABLE 0
00213 #endif
00214 
00215 
00216 /* Tokens.  */
00217 #ifndef YYTOKENTYPE
00218 # define YYTOKENTYPE
00219    /* Put the tokens into the symbol table, so that GDB and other debuggers
00220       know about them.  */
00221    enum yytokentype {
00222      tDAY = 258,
00223      tDAYZONE = 259,
00224      tMERIDIAN = 260,
00225      tMONTH = 261,
00226      tMONTH_UNIT = 262,
00227      tSEC_UNIT = 263,
00228      tSNUMBER = 264,
00229      tUNUMBER = 265,
00230      tZONE = 266
00231    };
00232 #endif
00233 /* Tokens.  */
00234 #define tDAY 258
00235 #define tDAYZONE 259
00236 #define tMERIDIAN 260
00237 #define tMONTH 261
00238 #define tMONTH_UNIT 262
00239 #define tSEC_UNIT 263
00240 #define tSNUMBER 264
00241 #define tUNUMBER 265
00242 #define tZONE 266
00243 
00244 
00245 
00246 
00247 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
00248 typedef union YYSTYPE
00249 {
00250 
00251 /* Line 293 of yacc.c  */
00252 #line 125 "parsedate.y"
00253 
00254     time_t           Number;
00255     enum _MERIDIAN   Meridian;
00256 
00257 
00258 
00259 /* Line 293 of yacc.c  */
00260 #line 261 "y.tab.c"
00261 } YYSTYPE;
00262 # define YYSTYPE_IS_TRIVIAL 1
00263 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
00264 # define YYSTYPE_IS_DECLARED 1
00265 #endif
00266 
00267 
00268 /* Copy the second part of user declarations.  */
00269 
00270 
00271 /* Line 343 of yacc.c  */
00272 #line 273 "y.tab.c"
00273 
00274 #ifdef short
00275 # undef short
00276 #endif
00277 
00278 #ifdef YYTYPE_UINT8
00279 typedef YYTYPE_UINT8 yytype_uint8;
00280 #else
00281 typedef unsigned char yytype_uint8;
00282 #endif
00283 
00284 #ifdef YYTYPE_INT8
00285 typedef YYTYPE_INT8 yytype_int8;
00286 #elif (defined __STDC__ || defined __C99__FUNC__ \
00287      || defined __cplusplus || defined _MSC_VER)
00288 typedef signed char yytype_int8;
00289 #else
00290 typedef short int yytype_int8;
00291 #endif
00292 
00293 #ifdef YYTYPE_UINT16
00294 typedef YYTYPE_UINT16 yytype_uint16;
00295 #else
00296 typedef unsigned short int yytype_uint16;
00297 #endif
00298 
00299 #ifdef YYTYPE_INT16
00300 typedef YYTYPE_INT16 yytype_int16;
00301 #else
00302 typedef short int yytype_int16;
00303 #endif
00304 
00305 #ifndef YYSIZE_T
00306 # ifdef __SIZE_TYPE__
00307 #  define YYSIZE_T __SIZE_TYPE__
00308 # elif defined size_t
00309 #  define YYSIZE_T size_t
00310 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
00311      || defined __cplusplus || defined _MSC_VER)
00312 #  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
00313 #  define YYSIZE_T size_t
00314 # else
00315 #  define YYSIZE_T unsigned int
00316 # endif
00317 #endif
00318 
00319 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
00320 
00321 #ifndef YY_
00322 # if defined YYENABLE_NLS && YYENABLE_NLS
00323 #  if ENABLE_NLS
00324 #   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
00325 #   define YY_(msgid) dgettext ("bison-runtime", msgid)
00326 #  endif
00327 # endif
00328 # ifndef YY_
00329 #  define YY_(msgid) msgid
00330 # endif
00331 #endif
00332 
00333 /* Suppress unused-variable warnings by "using" E.  */
00334 #if ! defined lint || defined __GNUC__
00335 # define YYUSE(e) ((void) (e))
00336 #else
00337 # define YYUSE(e) /* empty */
00338 #endif
00339 
00340 /* Identity function, used to suppress warnings about constant conditions.  */
00341 #ifndef lint
00342 # define YYID(n) (n)
00343 #else
00344 #if (defined __STDC__ || defined __C99__FUNC__ \
00345      || defined __cplusplus || defined _MSC_VER)
00346 static int
00347 YYID (int yyi)
00348 #else
00349 static int
00350 YYID (yyi)
00351     int yyi;
00352 #endif
00353 {
00354   return yyi;
00355 }
00356 #endif
00357 
00358 #if ! defined yyoverflow || YYERROR_VERBOSE
00359 
00360 /* The parser invokes alloca or malloc; define the necessary symbols.  */
00361 
00362 # ifdef YYSTACK_USE_ALLOCA
00363 #  if YYSTACK_USE_ALLOCA
00364 #   ifdef __GNUC__
00365 #    define YYSTACK_ALLOC __builtin_alloca
00366 #   elif defined __BUILTIN_VA_ARG_INCR
00367 #    include <alloca.h> /* INFRINGES ON USER NAME SPACE */
00368 #   elif defined _AIX
00369 #    define YYSTACK_ALLOC __alloca
00370 #   elif defined _MSC_VER
00371 #    include <malloc.h> /* INFRINGES ON USER NAME SPACE */
00372 #    define alloca _alloca
00373 #   else
00374 #    define YYSTACK_ALLOC alloca
00375 #    if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
00376      || defined __cplusplus || defined _MSC_VER)
00377 #     include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
00378 #     ifndef EXIT_SUCCESS
00379 #      define EXIT_SUCCESS 0
00380 #     endif
00381 #    endif
00382 #   endif
00383 #  endif
00384 # endif
00385 
00386 # ifdef YYSTACK_ALLOC
00387    /* Pacify GCC's `empty if-body' warning.  */
00388 #  define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
00389 #  ifndef YYSTACK_ALLOC_MAXIMUM
00390     /* The OS might guarantee only one guard page at the bottom of the stack,
00391        and a page size can be as small as 4096 bytes.  So we cannot safely
00392        invoke alloca (N) if N exceeds 4096.  Use a slightly smaller number
00393        to allow for a few compiler-allocated temporary stack slots.  */
00394 #   define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
00395 #  endif
00396 # else
00397 #  define YYSTACK_ALLOC YYMALLOC
00398 #  define YYSTACK_FREE YYFREE
00399 #  ifndef YYSTACK_ALLOC_MAXIMUM
00400 #   define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
00401 #  endif
00402 #  if (defined __cplusplus && ! defined EXIT_SUCCESS \
00403        && ! ((defined YYMALLOC || defined malloc) \
00404             && (defined YYFREE || defined free)))
00405 #   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
00406 #   ifndef EXIT_SUCCESS
00407 #    define EXIT_SUCCESS 0
00408 #   endif
00409 #  endif
00410 #  ifndef YYMALLOC
00411 #   define YYMALLOC malloc
00412 #   if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
00413      || defined __cplusplus || defined _MSC_VER)
00414 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
00415 #   endif
00416 #  endif
00417 #  ifndef YYFREE
00418 #   define YYFREE free
00419 #   if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
00420      || defined __cplusplus || defined _MSC_VER)
00421 void free (void *); /* INFRINGES ON USER NAME SPACE */
00422 #   endif
00423 #  endif
00424 # endif
00425 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
00426 
00427 
00428 #if (! defined yyoverflow \
00429      && (! defined __cplusplus \
00430         || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
00431 
00432 /* A type that is properly aligned for any stack member.  */
00433 union yyalloc
00434 {
00435   yytype_int16 yyss_alloc;
00436   YYSTYPE yyvs_alloc;
00437 };
00438 
00439 /* The size of the maximum gap between one aligned stack and the next.  */
00440 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
00441 
00442 /* The size of an array large to enough to hold all stacks, each with
00443    N elements.  */
00444 # define YYSTACK_BYTES(N) \
00445      ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
00446       + YYSTACK_GAP_MAXIMUM)
00447 
00448 # define YYCOPY_NEEDED 1
00449 
00450 /* Relocate STACK from its old location to the new one.  The
00451    local variables YYSIZE and YYSTACKSIZE give the old and new number of
00452    elements in the stack, and YYPTR gives the new location of the
00453    stack.  Advance YYPTR to a properly aligned location for the next
00454    stack.  */
00455 # define YYSTACK_RELOCATE(Stack_alloc, Stack)                         \
00456     do                                                         \
00457       {                                                               \
00458        YYSIZE_T yynewbytes;                                    \
00459        YYCOPY (&yyptr->Stack_alloc, Stack, yysize);                   \
00460        Stack = &yyptr->Stack_alloc;                                   \
00461        yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
00462        yyptr += yynewbytes / sizeof (*yyptr);                         \
00463       }                                                               \
00464     while (YYID (0))
00465 
00466 #endif
00467 
00468 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
00469 /* Copy COUNT objects from FROM to TO.  The source and destination do
00470    not overlap.  */
00471 # ifndef YYCOPY
00472 #  if defined __GNUC__ && 1 < __GNUC__
00473 #   define YYCOPY(To, From, Count) \
00474       __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
00475 #  else
00476 #   define YYCOPY(To, From, Count)        \
00477       do                                  \
00478        {                                  \
00479          YYSIZE_T yyi;                           \
00480          for (yyi = 0; yyi < (Count); yyi++)     \
00481            (To)[yyi] = (From)[yyi];              \
00482        }                                  \
00483       while (YYID (0))
00484 #  endif
00485 # endif
00486 #endif /* !YYCOPY_NEEDED */
00487 
00488 /* YYFINAL -- State number of the termination state.  */
00489 #define YYFINAL  2
00490 /* YYLAST -- Last index in YYTABLE.  */
00491 #define YYLAST   40
00492 
00493 /* YYNTOKENS -- Number of terminals.  */
00494 #define YYNTOKENS  15
00495 /* YYNNTS -- Number of nonterminals.  */
00496 #define YYNNTS  9
00497 /* YYNRULES -- Number of rules.  */
00498 #define YYNRULES  30
00499 /* YYNRULES -- Number of states.  */
00500 #define YYNSTATES  44
00501 
00502 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
00503 #define YYUNDEFTOK  2
00504 #define YYMAXUTOK   266
00505 
00506 #define YYTRANSLATE(YYX)                                       \
00507   ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
00508 
00509 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX.  */
00510 static const yytype_uint8 yytranslate[] =
00511 {
00512        0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00513        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00514        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00515        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00516        2,     2,     2,     2,    14,     2,     2,    13,     2,     2,
00517        2,     2,     2,     2,     2,     2,     2,     2,    12,     2,
00518        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00519        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00520        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00521        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00522        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00523        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00524        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00525        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00526        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00527        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00528        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00529        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00530        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00531        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00532        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00533        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00534        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00535        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00536        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00537        2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
00538        5,     6,     7,     8,     9,    10,    11
00539 };
00540 
00541 #if YYDEBUG
00542 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
00543    YYRHS.  */
00544 static const yytype_uint8 yyprhs[] =
00545 {
00546        0,     0,     3,     4,     7,     9,    12,    14,    16,    19,
00547       24,    29,    36,    43,    45,    47,    50,    52,    54,    58,
00548       64,    67,    72,    75,    79,    85,    88,    91,    94,    97,
00549       98
00550 };
00551 
00552 /* YYRHS -- A `-1'-separated list of the rules' RHS.  */
00553 static const yytype_int8 yyrhs[] =
00554 {
00555       16,     0,    -1,    -1,    16,    17,    -1,    18,    -1,    18,
00556       19,    -1,    21,    -1,    22,    -1,    10,    23,    -1,    10,
00557       12,    10,    23,    -1,    10,    12,    10,    20,    -1,    10,
00558       12,    10,    12,    10,    23,    -1,    10,    12,    10,    12,
00559       10,    20,    -1,    11,    -1,     4,    -1,    11,    20,    -1,
00560       20,    -1,     9,    -1,    10,    13,    10,    -1,    10,    13,
00561       10,    13,    10,    -1,     6,    10,    -1,     6,    10,    14,
00562       10,    -1,    10,     6,    -1,    10,     6,    10,    -1,     3,
00563       14,    10,     6,    10,    -1,     9,     8,    -1,    10,     8,
00564       -1,     9,     7,    -1,    10,     7,    -1,    -1,     5,    -1
00565 };
00566 
00567 /* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
00568 static const yytype_uint16 yyrline[] =
00569 {
00570        0,   139,   139,   140,   143,   152,   156,   159,   164,   176,
00571      182,   189,   195,   205,   209,   213,   221,   227,   248,   252,
00572      264,   268,   273,   277,   282,   289,   292,   295,   298,   303,
00573      306
00574 };
00575 #endif
00576 
00577 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
00578 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
00579    First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
00580 static const char *const yytname[] =
00581 {
00582   "$end", "error", "$undefined", "tDAY", "tDAYZONE", "tMERIDIAN",
00583   "tMONTH", "tMONTH_UNIT", "tSEC_UNIT", "tSNUMBER", "tUNUMBER", "tZONE",
00584   "':'", "'/'", "','", "$accept", "spec", "item", "time", "zone",
00585   "numzone", "date", "rel", "o_merid", 0
00586 };
00587 #endif
00588 
00589 # ifdef YYPRINT
00590 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
00591    token YYLEX-NUM.  */
00592 static const yytype_uint16 yytoknum[] =
00593 {
00594        0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
00595      265,   266,    58,    47,    44
00596 };
00597 # endif
00598 
00599 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
00600 static const yytype_uint8 yyr1[] =
00601 {
00602        0,    15,    16,    16,    17,    17,    17,    17,    18,    18,
00603       18,    18,    18,    19,    19,    19,    19,    20,    21,    21,
00604       21,    21,    21,    21,    21,    22,    22,    22,    22,    23,
00605       23
00606 };
00607 
00608 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
00609 static const yytype_uint8 yyr2[] =
00610 {
00611        0,     2,     0,     2,     1,     2,     1,     1,     2,     4,
00612        4,     6,     6,     1,     1,     2,     1,     1,     3,     5,
00613        2,     4,     2,     3,     5,     2,     2,     2,     2,     0,
00614        1
00615 };
00616 
00617 /* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
00618    Performed when YYTABLE doesn't specify something else to do.  Zero
00619    means the default is an error.  */
00620 static const yytype_uint8 yydefact[] =
00621 {
00622        2,     0,     1,     0,     0,     0,    29,     3,     4,     6,
00623        7,     0,    20,    27,    25,    30,    22,    28,    26,     0,
00624        0,     8,    14,    17,    13,     5,    16,     0,     0,    23,
00625       29,    18,    15,     0,    21,     0,    10,     9,     0,    24,
00626       29,    19,    12,    11
00627 };
00628 
00629 /* YYDEFGOTO[NTERM-NUM].  */
00630 static const yytype_int8 yydefgoto[] =
00631 {
00632       -1,     1,     7,     8,    25,    26,     9,    10,    21
00633 };
00634 
00635 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
00636    STATE-NUM.  */
00637 #define YYPACT_NINF -29
00638 static const yytype_int8 yypact[] =
00639 {
00640      -29,     1,   -29,   -11,    11,    20,    12,   -29,     4,   -29,
00641      -29,    13,    16,   -29,   -29,   -29,    21,   -29,   -29,    22,
00642       23,   -29,   -29,   -29,     5,   -29,   -29,    28,    25,   -29,
00643       17,    24,   -29,    26,   -29,    29,   -29,   -29,    30,   -29,
00644        0,   -29,   -29,   -29
00645 };
00646 
00647 /* YYPGOTO[NTERM-NUM].  */
00648 static const yytype_int8 yypgoto[] =
00649 {
00650      -29,   -29,   -29,   -29,   -29,   -24,   -29,   -29,   -28
00651 };
00652 
00653 /* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
00654    positive, shift that token.  If negative, reduce the rule which
00655    number is the opposite.  If YYTABLE_NINF, syntax error.  */
00656 #define YYTABLE_NINF -1
00657 static const yytype_uint8 yytable[] =
00658 {
00659       32,     2,    37,    11,     3,    15,    36,     4,    22,    23,
00660        5,     6,    43,    23,    23,    24,    42,    15,    16,    17,
00661       18,    12,    15,    27,    19,    20,    23,    13,    14,    35,
00662       28,    29,    30,    31,    33,    34,    39,    38,     0,    40,
00663       41
00664 };
00665 
00666 #define yypact_value_is_default(yystate) \
00667   ((yystate) == (-29))
00668 
00669 #define yytable_value_is_error(yytable_value) \
00670   YYID (0)
00671 
00672 static const yytype_int8 yycheck[] =
00673 {
00674       24,     0,    30,    14,     3,     5,    30,     6,     4,     9,
00675        9,    10,    40,     9,     9,    11,    40,     5,     6,     7,
00676        8,    10,     5,    10,    12,    13,     9,     7,     8,    12,
00677       14,    10,    10,    10,     6,    10,    10,    13,    -1,    10,
00678       10
00679 };
00680 
00681 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
00682    symbol of state STATE-NUM.  */
00683 static const yytype_uint8 yystos[] =
00684 {
00685        0,    16,     0,     3,     6,     9,    10,    17,    18,    21,
00686       22,    14,    10,     7,     8,     5,     6,     7,     8,    12,
00687       13,    23,     4,     9,    11,    19,    20,    10,    14,    10,
00688       10,    10,    20,     6,    10,    12,    20,    23,    13,    10,
00689       10,    10,    20,    23
00690 };
00691 
00692 #define yyerrok             (yyerrstatus = 0)
00693 #define yyclearin    (yychar = YYEMPTY)
00694 #define YYEMPTY             (-2)
00695 #define YYEOF        0
00696 
00697 #define YYACCEPT     goto yyacceptlab
00698 #define YYABORT             goto yyabortlab
00699 #define YYERROR             goto yyerrorlab
00700 
00701 
00702 /* Like YYERROR except do call yyerror.  This remains here temporarily
00703    to ease the transition to the new meaning of YYERROR, for GCC.
00704    Once GCC version 2 has supplanted version 1, this can go.  However,
00705    YYFAIL appears to be in use.  Nevertheless, it is formally deprecated
00706    in Bison 2.4.2's NEWS entry, where a plan to phase it out is
00707    discussed.  */
00708 
00709 #define YYFAIL              goto yyerrlab
00710 #if defined YYFAIL
00711   /* This is here to suppress warnings from the GCC cpp's
00712      -Wunused-macros.  Normally we don't worry about that warning, but
00713      some users do, and we want to make it easy for users to remove
00714      YYFAIL uses, which will produce warnings from Bison 2.5.  */
00715 #endif
00716 
00717 #define YYRECOVERING()  (!!yyerrstatus)
00718 
00719 #define YYBACKUP(Token, Value)                                 \
00720 do                                                      \
00721   if (yychar == YYEMPTY && yylen == 1)                         \
00722     {                                                   \
00723       yychar = (Token);                                        \
00724       yylval = (Value);                                        \
00725       YYPOPSTACK (1);                                          \
00726       goto yybackup;                                    \
00727     }                                                   \
00728   else                                                  \
00729     {                                                   \
00730       yyerror (YY_("syntax error: cannot back up")); \
00731       YYERROR;                                                 \
00732     }                                                   \
00733 while (YYID (0))
00734 
00735 
00736 #define YYTERROR     1
00737 #define YYERRCODE    256
00738 
00739 
00740 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
00741    If N is 0, then set CURRENT to the empty location which ends
00742    the previous symbol: RHS[0] (always defined).  */
00743 
00744 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
00745 #ifndef YYLLOC_DEFAULT
00746 # define YYLLOC_DEFAULT(Current, Rhs, N)                       \
00747     do                                                         \
00748       if (YYID (N))                                                    \
00749        {                                                       \
00750          (Current).first_line   = YYRHSLOC (Rhs, 1).first_line;       \
00751          (Current).first_column = YYRHSLOC (Rhs, 1).first_column;     \
00752          (Current).last_line    = YYRHSLOC (Rhs, N).last_line;        \
00753          (Current).last_column  = YYRHSLOC (Rhs, N).last_column;      \
00754        }                                                       \
00755       else                                                     \
00756        {                                                       \
00757          (Current).first_line   = (Current).last_line   =             \
00758            YYRHSLOC (Rhs, 0).last_line;                        \
00759          (Current).first_column = (Current).last_column =             \
00760            YYRHSLOC (Rhs, 0).last_column;                      \
00761        }                                                       \
00762     while (YYID (0))
00763 #endif
00764 
00765 
00766 /* This macro is provided for backward compatibility. */
00767 
00768 #ifndef YY_LOCATION_PRINT
00769 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
00770 #endif
00771 
00772 
00773 /* YYLEX -- calling `yylex' with the right arguments.  */
00774 
00775 #ifdef YYLEX_PARAM
00776 # define YYLEX yylex (YYLEX_PARAM)
00777 #else
00778 # define YYLEX yylex ()
00779 #endif
00780 
00781 /* Enable debugging if requested.  */
00782 #if YYDEBUG
00783 
00784 # ifndef YYFPRINTF
00785 #  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
00786 #  define YYFPRINTF fprintf
00787 # endif
00788 
00789 # define YYDPRINTF(Args)                  \
00790 do {                                      \
00791   if (yydebug)                                   \
00792     YYFPRINTF Args;                       \
00793 } while (YYID (0))
00794 
00795 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)                  \
00796 do {                                                             \
00797   if (yydebug)                                                          \
00798     {                                                            \
00799       YYFPRINTF (stderr, "%s ", Title);                                 \
00800       yy_symbol_print (stderr,                                          \
00801                 Type, Value); \
00802       YYFPRINTF (stderr, "\n");                                         \
00803     }                                                            \
00804 } while (YYID (0))
00805 
00806 
00807 /*--------------------------------.
00808 | Print this symbol on YYOUTPUT.  |
00809 `--------------------------------*/
00810 
00811 /*ARGSUSED*/
00812 #if (defined __STDC__ || defined __C99__FUNC__ \
00813      || defined __cplusplus || defined _MSC_VER)
00814 static void
00815 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
00816 #else
00817 static void
00818 yy_symbol_value_print (yyoutput, yytype, yyvaluep)
00819     FILE *yyoutput;
00820     int yytype;
00821     YYSTYPE const * const yyvaluep;
00822 #endif
00823 {
00824   if (!yyvaluep)
00825     return;
00826 # ifdef YYPRINT
00827   if (yytype < YYNTOKENS)
00828     YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
00829 # else
00830   YYUSE (yyoutput);
00831 # endif
00832   switch (yytype)
00833     {
00834       default:
00835        break;
00836     }
00837 }
00838 
00839 
00840 /*--------------------------------.
00841 | Print this symbol on YYOUTPUT.  |
00842 `--------------------------------*/
00843 
00844 #if (defined __STDC__ || defined __C99__FUNC__ \
00845      || defined __cplusplus || defined _MSC_VER)
00846 static void
00847 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
00848 #else
00849 static void
00850 yy_symbol_print (yyoutput, yytype, yyvaluep)
00851     FILE *yyoutput;
00852     int yytype;
00853     YYSTYPE const * const yyvaluep;
00854 #endif
00855 {
00856   if (yytype < YYNTOKENS)
00857     YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
00858   else
00859     YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
00860 
00861   yy_symbol_value_print (yyoutput, yytype, yyvaluep);
00862   YYFPRINTF (yyoutput, ")");
00863 }
00864 
00865 /*------------------------------------------------------------------.
00866 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
00867 | TOP (included).                                                   |
00868 `------------------------------------------------------------------*/
00869 
00870 #if (defined __STDC__ || defined __C99__FUNC__ \
00871      || defined __cplusplus || defined _MSC_VER)
00872 static void
00873 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
00874 #else
00875 static void
00876 yy_stack_print (yybottom, yytop)
00877     yytype_int16 *yybottom;
00878     yytype_int16 *yytop;
00879 #endif
00880 {
00881   YYFPRINTF (stderr, "Stack now");
00882   for (; yybottom <= yytop; yybottom++)
00883     {
00884       int yybot = *yybottom;
00885       YYFPRINTF (stderr, " %d", yybot);
00886     }
00887   YYFPRINTF (stderr, "\n");
00888 }
00889 
00890 # define YY_STACK_PRINT(Bottom, Top)                           \
00891 do {                                                    \
00892   if (yydebug)                                                 \
00893     yy_stack_print ((Bottom), (Top));                          \
00894 } while (YYID (0))
00895 
00896 
00897 /*------------------------------------------------.
00898 | Report that the YYRULE is going to be reduced.  |
00899 `------------------------------------------------*/
00900 
00901 #if (defined __STDC__ || defined __C99__FUNC__ \
00902      || defined __cplusplus || defined _MSC_VER)
00903 static void
00904 yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
00905 #else
00906 static void
00907 yy_reduce_print (yyvsp, yyrule)
00908     YYSTYPE *yyvsp;
00909     int yyrule;
00910 #endif
00911 {
00912   int yynrhs = yyr2[yyrule];
00913   int yyi;
00914   unsigned long int yylno = yyrline[yyrule];
00915   YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
00916             yyrule - 1, yylno);
00917   /* The symbols being reduced.  */
00918   for (yyi = 0; yyi < yynrhs; yyi++)
00919     {
00920       YYFPRINTF (stderr, "   $%d = ", yyi + 1);
00921       yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
00922                      &(yyvsp[(yyi + 1) - (yynrhs)])
00923                                           );
00924       YYFPRINTF (stderr, "\n");
00925     }
00926 }
00927 
00928 # define YY_REDUCE_PRINT(Rule)            \
00929 do {                               \
00930   if (yydebug)                            \
00931     yy_reduce_print (yyvsp, Rule); \
00932 } while (YYID (0))
00933 
00934 /* Nonzero means print parse trace.  It is left uninitialized so that
00935    multiple parsers can coexist.  */
00936 int yydebug;
00937 #else /* !YYDEBUG */
00938 # define YYDPRINTF(Args)
00939 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
00940 # define YY_STACK_PRINT(Bottom, Top)
00941 # define YY_REDUCE_PRINT(Rule)
00942 #endif /* !YYDEBUG */
00943 
00944 
00945 /* YYINITDEPTH -- initial size of the parser's stacks.  */
00946 #ifndef       YYINITDEPTH
00947 # define YYINITDEPTH 200
00948 #endif
00949 
00950 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
00951    if the built-in stack extension method is used).
00952 
00953    Do not make this value too large; the results are undefined if
00954    YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
00955    evaluated with infinite-precision integer arithmetic.  */
00956 
00957 #ifndef YYMAXDEPTH
00958 # define YYMAXDEPTH 10000
00959 #endif
00960 
00961 
00962 #if YYERROR_VERBOSE
00963 
00964 # ifndef yystrlen
00965 #  if defined __GLIBC__ && defined _STRING_H
00966 #   define yystrlen strlen
00967 #  else
00968 /* Return the length of YYSTR.  */
00969 #if (defined __STDC__ || defined __C99__FUNC__ \
00970      || defined __cplusplus || defined _MSC_VER)
00971 static YYSIZE_T
00972 yystrlen (const char *yystr)
00973 #else
00974 static YYSIZE_T
00975 yystrlen (yystr)
00976     const char *yystr;
00977 #endif
00978 {
00979   YYSIZE_T yylen;
00980   for (yylen = 0; yystr[yylen]; yylen++)
00981     continue;
00982   return yylen;
00983 }
00984 #  endif
00985 # endif
00986 
00987 # ifndef yystpcpy
00988 #  if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
00989 #   define yystpcpy stpcpy
00990 #  else
00991 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
00992    YYDEST.  */
00993 #if (defined __STDC__ || defined __C99__FUNC__ \
00994      || defined __cplusplus || defined _MSC_VER)
00995 static char *
00996 yystpcpy (char *yydest, const char *yysrc)
00997 #else
00998 static char *
00999 yystpcpy (yydest, yysrc)
01000     char *yydest;
01001     const char *yysrc;
01002 #endif
01003 {
01004   char *yyd = yydest;
01005   const char *yys = yysrc;
01006 
01007   while ((*yyd++ = *yys++) != '\0')
01008     continue;
01009 
01010   return yyd - 1;
01011 }
01012 #  endif
01013 # endif
01014 
01015 # ifndef yytnamerr
01016 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
01017    quotes and backslashes, so that it's suitable for yyerror.  The
01018    heuristic is that double-quoting is unnecessary unless the string
01019    contains an apostrophe, a comma, or backslash (other than
01020    backslash-backslash).  YYSTR is taken from yytname.  If YYRES is
01021    null, do not copy; instead, return the length of what the result
01022    would have been.  */
01023 static YYSIZE_T
01024 yytnamerr (char *yyres, const char *yystr)
01025 {
01026   if (*yystr == '"')
01027     {
01028       YYSIZE_T yyn = 0;
01029       char const *yyp = yystr;
01030 
01031       for (;;)
01032        switch (*++yyp)
01033          {
01034          case '\'':
01035          case ',':
01036            goto do_not_strip_quotes;
01037 
01038          case '\\':
01039            if (*++yyp != '\\')
01040              goto do_not_strip_quotes;
01041            /* Fall through.  */
01042          default:
01043            if (yyres)
01044              yyres[yyn] = *yyp;
01045            yyn++;
01046            break;
01047 
01048          case '"':
01049            if (yyres)
01050              yyres[yyn] = '\0';
01051            return yyn;
01052          }
01053     do_not_strip_quotes: ;
01054     }
01055 
01056   if (! yyres)
01057     return yystrlen (yystr);
01058 
01059   return yystpcpy (yyres, yystr) - yyres;
01060 }
01061 # endif
01062 
01063 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
01064    about the unexpected token YYTOKEN for the state stack whose top is
01065    YYSSP.
01066 
01067    Return 0 if *YYMSG was successfully written.  Return 1 if *YYMSG is
01068    not large enough to hold the message.  In that case, also set
01069    *YYMSG_ALLOC to the required number of bytes.  Return 2 if the
01070    required number of bytes is too large to store.  */
01071 static int
01072 yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
01073                 yytype_int16 *yyssp, int yytoken)
01074 {
01075   YYSIZE_T yysize0 = yytnamerr (0, yytname[yytoken]);
01076   YYSIZE_T yysize = yysize0;
01077   YYSIZE_T yysize1;
01078   enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
01079   /* Internationalized format string. */
01080   const char *yyformat = 0;
01081   /* Arguments of yyformat. */
01082   char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
01083   /* Number of reported tokens (one for the "unexpected", one per
01084      "expected"). */
01085   int yycount = 0;
01086 
01087   /* There are many possibilities here to consider:
01088      - Assume YYFAIL is not used.  It's too flawed to consider.  See
01089        <http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html>
01090        for details.  YYERROR is fine as it does not invoke this
01091        function.
01092      - If this state is a consistent state with a default action, then
01093        the only way this function was invoked is if the default action
01094        is an error action.  In that case, don't check for expected
01095        tokens because there are none.
01096      - The only way there can be no lookahead present (in yychar) is if
01097        this state is a consistent state with a default action.  Thus,
01098        detecting the absence of a lookahead is sufficient to determine
01099        that there is no unexpected or expected token to report.  In that
01100        case, just report a simple "syntax error".
01101      - Don't assume there isn't a lookahead just because this state is a
01102        consistent state with a default action.  There might have been a
01103        previous inconsistent state, consistent state with a non-default
01104        action, or user semantic action that manipulated yychar.
01105      - Of course, the expected token list depends on states to have
01106        correct lookahead information, and it depends on the parser not
01107        to perform extra reductions after fetching a lookahead from the
01108        scanner and before detecting a syntax error.  Thus, state merging
01109        (from LALR or IELR) and default reductions corrupt the expected
01110        token list.  However, the list is correct for canonical LR with
01111        one exception: it will still contain any token that will not be
01112        accepted due to an error action in a later state.
01113   */
01114   if (yytoken != YYEMPTY)
01115     {
01116       int yyn = yypact[*yyssp];
01117       yyarg[yycount++] = yytname[yytoken];
01118       if (!yypact_value_is_default (yyn))
01119         {
01120           /* Start YYX at -YYN if negative to avoid negative indexes in
01121              YYCHECK.  In other words, skip the first -YYN actions for
01122              this state because they are default actions.  */
01123           int yyxbegin = yyn < 0 ? -yyn : 0;
01124           /* Stay within bounds of both yycheck and yytname.  */
01125           int yychecklim = YYLAST - yyn + 1;
01126           int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
01127           int yyx;
01128 
01129           for (yyx = yyxbegin; yyx < yyxend; ++yyx)
01130             if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
01131                 && !yytable_value_is_error (yytable[yyx + yyn]))
01132               {
01133                 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
01134                   {
01135                     yycount = 1;
01136                     yysize = yysize0;
01137                     break;
01138                   }
01139                 yyarg[yycount++] = yytname[yyx];
01140                 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
01141                 if (! (yysize <= yysize1
01142                        && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
01143                   return 2;
01144                 yysize = yysize1;
01145               }
01146         }
01147     }
01148 
01149   switch (yycount)
01150     {
01151 # define YYCASE_(N, S)                      \
01152       case N:                               \
01153         yyformat = S;                       \
01154       break
01155       YYCASE_(0, YY_("syntax error"));
01156       YYCASE_(1, YY_("syntax error, unexpected %s"));
01157       YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
01158       YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
01159       YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
01160       YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
01161 # undef YYCASE_
01162     }
01163 
01164   yysize1 = yysize + yystrlen (yyformat);
01165   if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
01166     return 2;
01167   yysize = yysize1;
01168 
01169   if (*yymsg_alloc < yysize)
01170     {
01171       *yymsg_alloc = 2 * yysize;
01172       if (! (yysize <= *yymsg_alloc
01173              && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
01174         *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
01175       return 1;
01176     }
01177 
01178   /* Avoid sprintf, as that infringes on the user's name space.
01179      Don't have undefined behavior even if the translation
01180      produced a string with the wrong number of "%s"s.  */
01181   {
01182     char *yyp = *yymsg;
01183     int yyi = 0;
01184     while ((*yyp = *yyformat) != '\0')
01185       if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
01186         {
01187           yyp += yytnamerr (yyp, yyarg[yyi++]);
01188           yyformat += 2;
01189         }
01190       else
01191         {
01192           yyp++;
01193           yyformat++;
01194         }
01195   }
01196   return 0;
01197 }
01198 #endif /* YYERROR_VERBOSE */
01199 
01200 /*-----------------------------------------------.
01201 | Release the memory associated to this symbol.  |
01202 `-----------------------------------------------*/
01203 
01204 /*ARGSUSED*/
01205 #if (defined __STDC__ || defined __C99__FUNC__ \
01206      || defined __cplusplus || defined _MSC_VER)
01207 static void
01208 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
01209 #else
01210 static void
01211 yydestruct (yymsg, yytype, yyvaluep)
01212     const char *yymsg;
01213     int yytype;
01214     YYSTYPE *yyvaluep;
01215 #endif
01216 {
01217   YYUSE (yyvaluep);
01218 
01219   if (!yymsg)
01220     yymsg = "Deleting";
01221   YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
01222 
01223   switch (yytype)
01224     {
01225 
01226       default:
01227        break;
01228     }
01229 }
01230 
01231 
01232 /* Prevent warnings from -Wmissing-prototypes.  */
01233 #ifdef YYPARSE_PARAM
01234 #if defined __STDC__ || defined __cplusplus
01235 int yyparse (void *YYPARSE_PARAM);
01236 #else
01237 int yyparse ();
01238 #endif
01239 #else /* ! YYPARSE_PARAM */
01240 #if defined __STDC__ || defined __cplusplus
01241 int yyparse (void);
01242 #else
01243 int yyparse ();
01244 #endif
01245 #endif /* ! YYPARSE_PARAM */
01246 
01247 
01248 /* The lookahead symbol.  */
01249 int yychar;
01250 
01251 /* The semantic value of the lookahead symbol.  */
01252 YYSTYPE yylval;
01253 
01254 /* Number of syntax errors so far.  */
01255 int yynerrs;
01256 
01257 
01258 /*----------.
01259 | yyparse.  |
01260 `----------*/
01261 
01262 #ifdef YYPARSE_PARAM
01263 #if (defined __STDC__ || defined __C99__FUNC__ \
01264      || defined __cplusplus || defined _MSC_VER)
01265 int
01266 yyparse (void *YYPARSE_PARAM)
01267 #else
01268 int
01269 yyparse (YYPARSE_PARAM)
01270     void *YYPARSE_PARAM;
01271 #endif
01272 #else /* ! YYPARSE_PARAM */
01273 #if (defined __STDC__ || defined __C99__FUNC__ \
01274      || defined __cplusplus || defined _MSC_VER)
01275 int
01276 yyparse (void)
01277 #else
01278 int
01279 yyparse ()
01280 
01281 #endif
01282 #endif
01283 {
01284     int yystate;
01285     /* Number of tokens to shift before error messages enabled.  */
01286     int yyerrstatus;
01287 
01288     /* The stacks and their tools:
01289        `yyss': related to states.
01290        `yyvs': related to semantic values.
01291 
01292        Refer to the stacks thru separate pointers, to allow yyoverflow
01293        to reallocate them elsewhere.  */
01294 
01295     /* The state stack.  */
01296     yytype_int16 yyssa[YYINITDEPTH];
01297     yytype_int16 *yyss;
01298     yytype_int16 *yyssp;
01299 
01300     /* The semantic value stack.  */
01301     YYSTYPE yyvsa[YYINITDEPTH];
01302     YYSTYPE *yyvs;
01303     YYSTYPE *yyvsp;
01304 
01305     YYSIZE_T yystacksize;
01306 
01307   int yyn;
01308   int yyresult;
01309   /* Lookahead token as an internal (translated) token number.  */
01310   int yytoken;
01311   /* The variables used to return semantic value and location from the
01312      action routines.  */
01313   YYSTYPE yyval;
01314 
01315 #if YYERROR_VERBOSE
01316   /* Buffer for error messages, and its allocated size.  */
01317   char yymsgbuf[128];
01318   char *yymsg = yymsgbuf;
01319   YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
01320 #endif
01321 
01322 #define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N))
01323 
01324   /* The number of symbols on the RHS of the reduced rule.
01325      Keep to zero when no symbol should be popped.  */
01326   int yylen = 0;
01327 
01328   yytoken = 0;
01329   yyss = yyssa;
01330   yyvs = yyvsa;
01331   yystacksize = YYINITDEPTH;
01332 
01333   YYDPRINTF ((stderr, "Starting parse\n"));
01334 
01335   yystate = 0;
01336   yyerrstatus = 0;
01337   yynerrs = 0;
01338   yychar = YYEMPTY; /* Cause a token to be read.  */
01339 
01340   /* Initialize stack pointers.
01341      Waste one element of value and location stack
01342      so that they stay on the same level as the state stack.
01343      The wasted elements are never initialized.  */
01344   yyssp = yyss;
01345   yyvsp = yyvs;
01346 
01347   goto yysetstate;
01348 
01349 /*------------------------------------------------------------.
01350 | yynewstate -- Push a new state, which is found in yystate.  |
01351 `------------------------------------------------------------*/
01352  yynewstate:
01353   /* In all cases, when you get here, the value and location stacks
01354      have just been pushed.  So pushing a state here evens the stacks.  */
01355   yyssp++;
01356 
01357  yysetstate:
01358   *yyssp = yystate;
01359 
01360   if (yyss + yystacksize - 1 <= yyssp)
01361     {
01362       /* Get the current used size of the three stacks, in elements.  */
01363       YYSIZE_T yysize = yyssp - yyss + 1;
01364 
01365 #ifdef yyoverflow
01366       {
01367        /* Give user a chance to reallocate the stack.  Use copies of
01368           these so that the &'s don't force the real ones into
01369           memory.  */
01370        YYSTYPE *yyvs1 = yyvs;
01371        yytype_int16 *yyss1 = yyss;
01372 
01373        /* Each stack pointer address is followed by the size of the
01374           data in use in that stack, in bytes.  This used to be a
01375           conditional around just the two extra args, but that might
01376           be undefined if yyoverflow is a macro.  */
01377        yyoverflow (YY_("memory exhausted"),
01378                   &yyss1, yysize * sizeof (*yyssp),
01379                   &yyvs1, yysize * sizeof (*yyvsp),
01380                   &yystacksize);
01381 
01382        yyss = yyss1;
01383        yyvs = yyvs1;
01384       }
01385 #else /* no yyoverflow */
01386 # ifndef YYSTACK_RELOCATE
01387       goto yyexhaustedlab;
01388 # else
01389       /* Extend the stack our own way.  */
01390       if (YYMAXDEPTH <= yystacksize)
01391        goto yyexhaustedlab;
01392       yystacksize *= 2;
01393       if (YYMAXDEPTH < yystacksize)
01394        yystacksize = YYMAXDEPTH;
01395 
01396       {
01397        yytype_int16 *yyss1 = yyss;
01398        union yyalloc *yyptr =
01399          (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
01400        if (! yyptr)
01401          goto yyexhaustedlab;
01402        YYSTACK_RELOCATE (yyss_alloc, yyss);
01403        YYSTACK_RELOCATE (yyvs_alloc, yyvs);
01404 #  undef YYSTACK_RELOCATE
01405        if (yyss1 != yyssa)
01406          YYSTACK_FREE (yyss1);
01407       }
01408 # endif
01409 #endif /* no yyoverflow */
01410 
01411       yyssp = yyss + yysize - 1;
01412       yyvsp = yyvs + yysize - 1;
01413 
01414       YYDPRINTF ((stderr, "Stack size increased to %lu\n",
01415                 (unsigned long int) yystacksize));
01416 
01417       if (yyss + yystacksize - 1 <= yyssp)
01418        YYABORT;
01419     }
01420 
01421   YYDPRINTF ((stderr, "Entering state %d\n", yystate));
01422 
01423   if (yystate == YYFINAL)
01424     YYACCEPT;
01425 
01426   goto yybackup;
01427 
01428 /*-----------.
01429 | yybackup.  |
01430 `-----------*/
01431 yybackup:
01432 
01433   /* Do appropriate processing given the current state.  Read a
01434      lookahead token if we need one and don't already have one.  */
01435 
01436   /* First try to decide what to do without reference to lookahead token.  */
01437   yyn = yypact[yystate];
01438   if (yypact_value_is_default (yyn))
01439     goto yydefault;
01440 
01441   /* Not known => get a lookahead token if don't already have one.  */
01442 
01443   /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol.  */
01444   if (yychar == YYEMPTY)
01445     {
01446       YYDPRINTF ((stderr, "Reading a token: "));
01447       yychar = YYLEX;
01448     }
01449 
01450   if (yychar <= YYEOF)
01451     {
01452       yychar = yytoken = YYEOF;
01453       YYDPRINTF ((stderr, "Now at end of input.\n"));
01454     }
01455   else
01456     {
01457       yytoken = YYTRANSLATE (yychar);
01458       YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
01459     }
01460 
01461   /* If the proper action on seeing token YYTOKEN is to reduce or to
01462      detect an error, take that action.  */
01463   yyn += yytoken;
01464   if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
01465     goto yydefault;
01466   yyn = yytable[yyn];
01467   if (yyn <= 0)
01468     {
01469       if (yytable_value_is_error (yyn))
01470         goto yyerrlab;
01471       yyn = -yyn;
01472       goto yyreduce;
01473     }
01474 
01475   /* Count tokens shifted since error; after three, turn off error
01476      status.  */
01477   if (yyerrstatus)
01478     yyerrstatus--;
01479 
01480   /* Shift the lookahead token.  */
01481   YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
01482 
01483   /* Discard the shifted token.  */
01484   yychar = YYEMPTY;
01485 
01486   yystate = yyn;
01487   *++yyvsp = yylval;
01488 
01489   goto yynewstate;
01490 
01491 
01492 /*-----------------------------------------------------------.
01493 | yydefault -- do the default action for the current state.  |
01494 `-----------------------------------------------------------*/
01495 yydefault:
01496   yyn = yydefact[yystate];
01497   if (yyn == 0)
01498     goto yyerrlab;
01499   goto yyreduce;
01500 
01501 
01502 /*-----------------------------.
01503 | yyreduce -- Do a reduction.  |
01504 `-----------------------------*/
01505 yyreduce:
01506   /* yyn is the number of a rule to reduce with.  */
01507   yylen = yyr2[yyn];
01508 
01509   /* If YYLEN is nonzero, implement the default value of the action:
01510      `$$ = $1'.
01511 
01512      Otherwise, the following line sets YYVAL to garbage.
01513      This behavior is undocumented and Bison
01514      users should not rely upon it.  Assigning to YYVAL
01515      unconditionally makes the parser a bit smaller, and it avoids a
01516      GCC warning that YYVAL may be used uninitialized.  */
01517   yyval = yyvsp[1-yylen];
01518 
01519 
01520   YY_REDUCE_PRINT (yyn);
01521   switch (yyn)
01522     {
01523         case 4:
01524 
01525 /* Line 1806 of yacc.c  */
01526 #line 143 "parsedate.y"
01527     {
01528            yyHaveTime++;
01529 #ifdef lint
01530            /* I am compulsive about lint natterings... */
01531            if (yyHaveTime == -1) {
01532               YYERROR;
01533            }
01534 #endif /* lint */
01535        }
01536     break;
01537 
01538   case 5:
01539 
01540 /* Line 1806 of yacc.c  */
01541 #line 152 "parsedate.y"
01542     {
01543            yyHaveTime++;
01544            yyTimezone = (yyvsp[(2) - (2)].Number);
01545        }
01546     break;
01547 
01548   case 6:
01549 
01550 /* Line 1806 of yacc.c  */
01551 #line 156 "parsedate.y"
01552     {
01553            yyHaveDate++;
01554        }
01555     break;
01556 
01557   case 7:
01558 
01559 /* Line 1806 of yacc.c  */
01560 #line 159 "parsedate.y"
01561     {
01562            yyHaveRel = 1;
01563        }
01564     break;
01565 
01566   case 8:
01567 
01568 /* Line 1806 of yacc.c  */
01569 #line 164 "parsedate.y"
01570     {
01571            if ((yyvsp[(1) - (2)].Number) < 100) {
01572               yyHour = (yyvsp[(1) - (2)].Number);
01573               yyMinutes = 0;
01574            }
01575            else {
01576               yyHour = (yyvsp[(1) - (2)].Number) / 100;
01577               yyMinutes = (yyvsp[(1) - (2)].Number) % 100;
01578            }
01579            yySeconds = 0;
01580            yyMeridian = (yyvsp[(2) - (2)].Meridian);
01581        }
01582     break;
01583 
01584   case 9:
01585 
01586 /* Line 1806 of yacc.c  */
01587 #line 176 "parsedate.y"
01588     {
01589            yyHour = (yyvsp[(1) - (4)].Number);
01590            yyMinutes = (yyvsp[(3) - (4)].Number);
01591            yySeconds = 0;
01592            yyMeridian = (yyvsp[(4) - (4)].Meridian);
01593        }
01594     break;
01595 
01596   case 10:
01597 
01598 /* Line 1806 of yacc.c  */
01599 #line 182 "parsedate.y"
01600     {
01601            yyHour = (yyvsp[(1) - (4)].Number);
01602            yyMinutes = (yyvsp[(3) - (4)].Number);
01603            yyTimezone = (yyvsp[(4) - (4)].Number);
01604            yyMeridian = MER24;
01605            yyDSTmode = DSToff;
01606        }
01607     break;
01608 
01609   case 11:
01610 
01611 /* Line 1806 of yacc.c  */
01612 #line 189 "parsedate.y"
01613     {
01614            yyHour = (yyvsp[(1) - (6)].Number);
01615            yyMinutes = (yyvsp[(3) - (6)].Number);
01616            yySeconds = (yyvsp[(5) - (6)].Number);
01617            yyMeridian = (yyvsp[(6) - (6)].Meridian);
01618        }
01619     break;
01620 
01621   case 12:
01622 
01623 /* Line 1806 of yacc.c  */
01624 #line 195 "parsedate.y"
01625     {
01626            yyHour = (yyvsp[(1) - (6)].Number);
01627            yyMinutes = (yyvsp[(3) - (6)].Number);
01628            yySeconds = (yyvsp[(5) - (6)].Number);
01629            yyTimezone = (yyvsp[(6) - (6)].Number);
01630            yyMeridian = MER24;
01631            yyDSTmode = DSToff;
01632        }
01633     break;
01634 
01635   case 13:
01636 
01637 /* Line 1806 of yacc.c  */
01638 #line 205 "parsedate.y"
01639     {
01640            (yyval.Number) = (yyvsp[(1) - (1)].Number);
01641            yyDSTmode = DSToff;
01642        }
01643     break;
01644 
01645   case 14:
01646 
01647 /* Line 1806 of yacc.c  */
01648 #line 209 "parsedate.y"
01649     {
01650            (yyval.Number) = (yyvsp[(1) - (1)].Number);
01651            yyDSTmode = DSTon;
01652        }
01653     break;
01654 
01655   case 15:
01656 
01657 /* Line 1806 of yacc.c  */
01658 #line 213 "parsedate.y"
01659     {
01660            /* Only allow "GMT+300" and "GMT-0800" */
01661            if ((yyvsp[(1) - (2)].Number) != 0) {
01662               YYABORT;
01663            }
01664            (yyval.Number) = (yyvsp[(2) - (2)].Number);
01665            yyDSTmode = DSToff;
01666        }
01667     break;
01668 
01669   case 16:
01670 
01671 /* Line 1806 of yacc.c  */
01672 #line 221 "parsedate.y"
01673     {
01674            (yyval.Number) = (yyvsp[(1) - (1)].Number);
01675            yyDSTmode = DSToff;
01676        }
01677     break;
01678 
01679   case 17:
01680 
01681 /* Line 1806 of yacc.c  */
01682 #line 227 "parsedate.y"
01683     {
01684            int              i;
01685 
01686            /* Unix and GMT and numeric timezones -- a little confusing. */
01687            if ((yyvsp[(1) - (1)].Number) < 0) {
01688               /* Don't work with negative modulus. */
01689               (yyvsp[(1) - (1)].Number) = -(yyvsp[(1) - (1)].Number);
01690               if ((yyvsp[(1) - (1)].Number) > 9999 || (i = (yyvsp[(1) - (1)].Number) % 100) >= 60) {
01691                   YYABORT;
01692               }
01693               (yyval.Number) = ((yyvsp[(1) - (1)].Number) / 100) * 60 + i;
01694            }
01695            else {
01696               if ((yyvsp[(1) - (1)].Number) > 9999 || (i = (yyvsp[(1) - (1)].Number) % 100) >= 60) {
01697                   YYABORT;
01698               }
01699               (yyval.Number) = -(((yyvsp[(1) - (1)].Number) / 100) * 60 + i);
01700            }
01701        }
01702     break;
01703 
01704   case 18:
01705 
01706 /* Line 1806 of yacc.c  */
01707 #line 248 "parsedate.y"
01708     {
01709            yyMonth = (yyvsp[(1) - (3)].Number);
01710            yyDay = (yyvsp[(3) - (3)].Number);
01711        }
01712     break;
01713 
01714   case 19:
01715 
01716 /* Line 1806 of yacc.c  */
01717 #line 252 "parsedate.y"
01718     {
01719            if ((yyvsp[(1) - (5)].Number) > 100) {
01720               yyYear = (yyvsp[(1) - (5)].Number);
01721               yyMonth = (yyvsp[(3) - (5)].Number);
01722               yyDay = (yyvsp[(5) - (5)].Number);
01723            }
01724            else {
01725               yyMonth = (yyvsp[(1) - (5)].Number);
01726               yyDay = (yyvsp[(3) - (5)].Number);
01727               yyYear = (yyvsp[(5) - (5)].Number);
01728            }
01729        }
01730     break;
01731 
01732   case 20:
01733 
01734 /* Line 1806 of yacc.c  */
01735 #line 264 "parsedate.y"
01736     {
01737            yyMonth = (yyvsp[(1) - (2)].Number);
01738            yyDay = (yyvsp[(2) - (2)].Number);
01739        }
01740     break;
01741 
01742   case 21:
01743 
01744 /* Line 1806 of yacc.c  */
01745 #line 268 "parsedate.y"
01746     {
01747            yyMonth = (yyvsp[(1) - (4)].Number);
01748            yyDay = (yyvsp[(2) - (4)].Number);
01749            yyYear = (yyvsp[(4) - (4)].Number);
01750        }
01751     break;
01752 
01753   case 22:
01754 
01755 /* Line 1806 of yacc.c  */
01756 #line 273 "parsedate.y"
01757     {
01758            yyDay = (yyvsp[(1) - (2)].Number);
01759            yyMonth = (yyvsp[(2) - (2)].Number);
01760        }
01761     break;
01762 
01763   case 23:
01764 
01765 /* Line 1806 of yacc.c  */
01766 #line 277 "parsedate.y"
01767     {
01768            yyDay = (yyvsp[(1) - (3)].Number);
01769            yyMonth = (yyvsp[(2) - (3)].Number);
01770            yyYear = (yyvsp[(3) - (3)].Number);
01771        }
01772     break;
01773 
01774   case 24:
01775 
01776 /* Line 1806 of yacc.c  */
01777 #line 282 "parsedate.y"
01778     {
01779            yyDay = (yyvsp[(3) - (5)].Number);
01780            yyMonth = (yyvsp[(4) - (5)].Number);
01781            yyYear = (yyvsp[(5) - (5)].Number);
01782        }
01783     break;
01784 
01785   case 25:
01786 
01787 /* Line 1806 of yacc.c  */
01788 #line 289 "parsedate.y"
01789     {
01790            yyRelSeconds += (yyvsp[(1) - (2)].Number) * (yyvsp[(2) - (2)].Number);
01791        }
01792     break;
01793 
01794   case 26:
01795 
01796 /* Line 1806 of yacc.c  */
01797 #line 292 "parsedate.y"
01798     {
01799            yyRelSeconds += (yyvsp[(1) - (2)].Number) * (yyvsp[(2) - (2)].Number);
01800        }
01801     break;
01802 
01803   case 27:
01804 
01805 /* Line 1806 of yacc.c  */
01806 #line 295 "parsedate.y"
01807     {
01808            yyRelMonth += (yyvsp[(1) - (2)].Number) * (yyvsp[(2) - (2)].Number);
01809        }
01810     break;
01811 
01812   case 28:
01813 
01814 /* Line 1806 of yacc.c  */
01815 #line 298 "parsedate.y"
01816     {
01817            yyRelMonth += (yyvsp[(1) - (2)].Number) * (yyvsp[(2) - (2)].Number);
01818        }
01819     break;
01820 
01821   case 29:
01822 
01823 /* Line 1806 of yacc.c  */
01824 #line 303 "parsedate.y"
01825     {
01826            (yyval.Meridian) = MER24;
01827        }
01828     break;
01829 
01830   case 30:
01831 
01832 /* Line 1806 of yacc.c  */
01833 #line 306 "parsedate.y"
01834     {
01835            (yyval.Meridian) = (yyvsp[(1) - (1)].Meridian);
01836        }
01837     break;
01838 
01839 
01840 
01841 /* Line 1806 of yacc.c  */
01842 #line 1843 "y.tab.c"
01843       default: break;
01844     }
01845   /* User semantic actions sometimes alter yychar, and that requires
01846      that yytoken be updated with the new translation.  We take the
01847      approach of translating immediately before every use of yytoken.
01848      One alternative is translating here after every semantic action,
01849      but that translation would be missed if the semantic action invokes
01850      YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
01851      if it invokes YYBACKUP.  In the case of YYABORT or YYACCEPT, an
01852      incorrect destructor might then be invoked immediately.  In the
01853      case of YYERROR or YYBACKUP, subsequent parser actions might lead
01854      to an incorrect destructor call or verbose syntax error message
01855      before the lookahead is translated.  */
01856   YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
01857 
01858   YYPOPSTACK (yylen);
01859   yylen = 0;
01860   YY_STACK_PRINT (yyss, yyssp);
01861 
01862   *++yyvsp = yyval;
01863 
01864   /* Now `shift' the result of the reduction.  Determine what state
01865      that goes to, based on the state we popped back to and the rule
01866      number reduced by.  */
01867 
01868   yyn = yyr1[yyn];
01869 
01870   yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
01871   if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
01872     yystate = yytable[yystate];
01873   else
01874     yystate = yydefgoto[yyn - YYNTOKENS];
01875 
01876   goto yynewstate;
01877 
01878 
01879 /*------------------------------------.
01880 | yyerrlab -- here on detecting error |
01881 `------------------------------------*/
01882 yyerrlab:
01883   /* Make sure we have latest lookahead translation.  See comments at
01884      user semantic actions for why this is necessary.  */
01885   yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
01886 
01887   /* If not already recovering from an error, report this error.  */
01888   if (!yyerrstatus)
01889     {
01890       ++yynerrs;
01891 #if ! YYERROR_VERBOSE
01892       yyerror (YY_("syntax error"));
01893 #else
01894 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
01895                                         yyssp, yytoken)
01896       {
01897         char const *yymsgp = YY_("syntax error");
01898         int yysyntax_error_status;
01899         yysyntax_error_status = YYSYNTAX_ERROR;
01900         if (yysyntax_error_status == 0)
01901           yymsgp = yymsg;
01902         else if (yysyntax_error_status == 1)
01903           {
01904             if (yymsg != yymsgbuf)
01905               YYSTACK_FREE (yymsg);
01906             yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
01907             if (!yymsg)
01908               {
01909                 yymsg = yymsgbuf;
01910                 yymsg_alloc = sizeof yymsgbuf;
01911                 yysyntax_error_status = 2;
01912               }
01913             else
01914               {
01915                 yysyntax_error_status = YYSYNTAX_ERROR;
01916                 yymsgp = yymsg;
01917               }
01918           }
01919         yyerror (yymsgp);
01920         if (yysyntax_error_status == 2)
01921           goto yyexhaustedlab;
01922       }
01923 # undef YYSYNTAX_ERROR
01924 #endif
01925     }
01926 
01927 
01928 
01929   if (yyerrstatus == 3)
01930     {
01931       /* If just tried and failed to reuse lookahead token after an
01932         error, discard it.  */
01933 
01934       if (yychar <= YYEOF)
01935        {
01936          /* Return failure if at end of input.  */
01937          if (yychar == YYEOF)
01938            YYABORT;
01939        }
01940       else
01941        {
01942          yydestruct ("Error: discarding",
01943                     yytoken, &yylval);
01944          yychar = YYEMPTY;
01945        }
01946     }
01947 
01948   /* Else will try to reuse lookahead token after shifting the error
01949      token.  */
01950   goto yyerrlab1;
01951 
01952 
01953 /*---------------------------------------------------.
01954 | yyerrorlab -- error raised explicitly by YYERROR.  |
01955 `---------------------------------------------------*/
01956 yyerrorlab:
01957 
01958   /* Pacify compilers like GCC when the user code never invokes
01959      YYERROR and the label yyerrorlab therefore never appears in user
01960      code.  */
01961   if (/*CONSTCOND*/ 0)
01962      goto yyerrorlab;
01963 
01964   /* Do not reclaim the symbols of the rule which action triggered
01965      this YYERROR.  */
01966   YYPOPSTACK (yylen);
01967   yylen = 0;
01968   YY_STACK_PRINT (yyss, yyssp);
01969   yystate = *yyssp;
01970   goto yyerrlab1;
01971 
01972 
01973 /*-------------------------------------------------------------.
01974 | yyerrlab1 -- common code for both syntax error and YYERROR.  |
01975 `-------------------------------------------------------------*/
01976 yyerrlab1:
01977   yyerrstatus = 3;   /* Each real token shifted decrements this.  */
01978 
01979   for (;;)
01980     {
01981       yyn = yypact[yystate];
01982       if (!yypact_value_is_default (yyn))
01983        {
01984          yyn += YYTERROR;
01985          if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
01986            {
01987              yyn = yytable[yyn];
01988              if (0 < yyn)
01989               break;
01990            }
01991        }
01992 
01993       /* Pop the current state because it cannot handle the error token.  */
01994       if (yyssp == yyss)
01995        YYABORT;
01996 
01997 
01998       yydestruct ("Error: popping",
01999                 yystos[yystate], yyvsp);
02000       YYPOPSTACK (1);
02001       yystate = *yyssp;
02002       YY_STACK_PRINT (yyss, yyssp);
02003     }
02004 
02005   *++yyvsp = yylval;
02006 
02007 
02008   /* Shift the error token.  */
02009   YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
02010 
02011   yystate = yyn;
02012   goto yynewstate;
02013 
02014 
02015 /*-------------------------------------.
02016 | yyacceptlab -- YYACCEPT comes here.  |
02017 `-------------------------------------*/
02018 yyacceptlab:
02019   yyresult = 0;
02020   goto yyreturn;
02021 
02022 /*-----------------------------------.
02023 | yyabortlab -- YYABORT comes here.  |
02024 `-----------------------------------*/
02025 yyabortlab:
02026   yyresult = 1;
02027   goto yyreturn;
02028 
02029 #if !defined(yyoverflow) || YYERROR_VERBOSE
02030 /*-------------------------------------------------.
02031 | yyexhaustedlab -- memory exhaustion comes here.  |
02032 `-------------------------------------------------*/
02033 yyexhaustedlab:
02034   yyerror (YY_("memory exhausted"));
02035   yyresult = 2;
02036   /* Fall through.  */
02037 #endif
02038 
02039 yyreturn:
02040   if (yychar != YYEMPTY)
02041     {
02042       /* Make sure we have latest lookahead translation.  See comments at
02043          user semantic actions for why this is necessary.  */
02044       yytoken = YYTRANSLATE (yychar);
02045       yydestruct ("Cleanup: discarding lookahead",
02046                   yytoken, &yylval);
02047     }
02048   /* Do not reclaim the symbols of the rule which action triggered
02049      this YYABORT or YYACCEPT.  */
02050   YYPOPSTACK (yylen);
02051   YY_STACK_PRINT (yyss, yyssp);
02052   while (yyssp != yyss)
02053     {
02054       yydestruct ("Cleanup: popping",
02055                 yystos[*yyssp], yyvsp);
02056       YYPOPSTACK (1);
02057     }
02058 #ifndef yyoverflow
02059   if (yyss != yyssa)
02060     YYSTACK_FREE (yyss);
02061 #endif
02062 #if YYERROR_VERBOSE
02063   if (yymsg != yymsgbuf)
02064     YYSTACK_FREE (yymsg);
02065 #endif
02066   /* Make sure YYID is used.  */
02067   return YYID (yyresult);
02068 }
02069 
02070 
02071 
02072 /* Line 2067 of yacc.c  */
02073 #line 311 "parsedate.y"
02074 
02075 
02076 /* Month and day table. */
02077 static TABLE  MonthDayTable[] = {
02078     { "january",     tMONTH,  1 },
02079     { "february",    tMONTH,  2 },
02080     { "march",              tMONTH,  3 },
02081     { "april",              tMONTH,  4 },
02082     { "may",         tMONTH,  5 },
02083     { "june",        tMONTH,  6 },
02084     { "july",        tMONTH,  7 },
02085     { "august",             tMONTH,  8 },
02086     { "september",   tMONTH,  9 },
02087     { "october",     tMONTH, 10 },
02088     { "november",    tMONTH, 11 },
02089     { "december",    tMONTH, 12 },
02090        /* The value of the day isn't used... */
02091     { "sunday",             tDAY, 0 },
02092     { "monday",             tDAY, 0 },
02093     { "tuesday",     tDAY, 0 },
02094     { "wednesday",   tDAY, 0 },
02095     { "thursday",    tDAY, 0 },
02096     { "friday",             tDAY, 0 },
02097     { "saturday",    tDAY, 0 },
02098 };
02099 
02100 /* Time units table. */
02101 static TABLE  UnitsTable[] = {
02102     { "year",        tMONTH_UNIT,  12 },
02103     { "month",              tMONTH_UNIT,  1 },
02104     { "week",        tSEC_UNIT,    7L * 24 * 60 * 60 },
02105     { "day",         tSEC_UNIT,    1L * 24 * 60 * 60 },
02106     { "hour",        tSEC_UNIT,    60 * 60 },
02107     { "minute",             tSEC_UNIT,    60 },
02108     { "min",         tSEC_UNIT,    60 },
02109     { "second",             tSEC_UNIT,    1 },
02110     { "sec",         tSEC_UNIT,    1 },
02111 };
02112 
02113 /* Timezone table. */
02114 static TABLE  TimezoneTable[] = {
02115     { "gmt",  tZONE,     HOUR( 0) },      /* Greenwich Mean */
02116     { "ut",   tZONE,     HOUR( 0) },      /* Universal */
02117     { "utc",  tZONE,     HOUR( 0) },      /* Universal Coordinated */
02118     { "cut",  tZONE,     HOUR( 0) },      /* Coordinated Universal */
02119     { "z",    tZONE,     HOUR( 0) },      /* Greenwich Mean */
02120     { "wet",  tZONE,     HOUR( 0) },      /* Western European */
02121     { "bst",  tDAYZONE,  HOUR( 0) },      /* British Summer */
02122     { "nst",  tZONE,     HOUR(3)+30 }, /* Newfoundland Standard */
02123     { "ndt",  tDAYZONE,  HOUR(3)+30 }, /* Newfoundland Daylight */
02124     { "ast",  tZONE,     HOUR( 4) },      /* Atlantic Standard */
02125     { "adt",  tDAYZONE,  HOUR( 4) },      /* Atlantic Daylight */
02126     { "est",  tZONE,     HOUR( 5) },      /* Eastern Standard */
02127     { "edt",  tDAYZONE,  HOUR( 5) },      /* Eastern Daylight */
02128     { "cst",  tZONE,     HOUR( 6) },      /* Central Standard */
02129     { "cdt",  tDAYZONE,  HOUR( 6) },      /* Central Daylight */
02130     { "mst",  tZONE,     HOUR( 7) },      /* Mountain Standard */
02131     { "mdt",  tDAYZONE,  HOUR( 7) },      /* Mountain Daylight */
02132     { "pst",  tZONE,     HOUR( 8) },      /* Pacific Standard */
02133     { "pdt",  tDAYZONE,  HOUR( 8) },      /* Pacific Daylight */
02134     { "yst",  tZONE,     HOUR( 9) },      /* Yukon Standard */
02135     { "ydt",  tDAYZONE,  HOUR( 9) },      /* Yukon Daylight */
02136     { "akst", tZONE,     HOUR( 9) },      /* Alaska Standard */
02137     { "akdt", tDAYZONE,  HOUR( 9) },      /* Alaska Daylight */
02138     { "hst",  tZONE,     HOUR(10) },      /* Hawaii Standard */
02139     { "hast", tZONE,     HOUR(10) },      /* Hawaii-Aleutian Standard */
02140     { "hadt", tDAYZONE,  HOUR(10) },      /* Hawaii-Aleutian Daylight */
02141     { "ces",  tDAYZONE,  -HOUR(1) },      /* Central European Summer */
02142     { "cest", tDAYZONE,  -HOUR(1) },      /* Central European Summer */
02143     { "mez",  tZONE,     -HOUR(1) },      /* Middle European */
02144     { "mezt", tDAYZONE,  -HOUR(1) },      /* Middle European Summer */
02145     { "cet",  tZONE,     -HOUR(1) },      /* Central European */
02146     { "met",  tZONE,     -HOUR(1) },      /* Middle European */
02147     { "eet",  tZONE,     -HOUR(2) },      /* Eastern Europe */
02148     { "msk",  tZONE,     -HOUR(3) },      /* Moscow Winter */
02149     { "msd",  tDAYZONE,  -HOUR(3) },      /* Moscow Summer */
02150     { "wast", tZONE,     -HOUR(8) },      /* West Australian Standard */
02151     { "wadt", tDAYZONE,  -HOUR(8) },      /* West Australian Daylight */
02152     { "hkt",  tZONE,     -HOUR(8) },      /* Hong Kong */
02153     { "cct",  tZONE,     -HOUR(8) },      /* China Coast */
02154     { "jst",  tZONE,     -HOUR(9) },      /* Japan Standard */
02155     { "kst",  tZONE,     -HOUR(9) },      /* Korean Standard */
02156     { "kdt",  tZONE,     -HOUR(9) },      /* Korean Daylight */
02157     { "cast", tZONE,     -(HOUR(9)+30) }, /* Central Australian Standard */
02158     { "cadt", tDAYZONE,  -(HOUR(9)+30) }, /* Central Australian Daylight */
02159     { "east", tZONE,     -HOUR(10) },     /* Eastern Australian Standard */
02160     { "eadt", tDAYZONE,  -HOUR(10) },     /* Eastern Australian Daylight */
02161     { "nzst", tZONE,     -HOUR(12) },     /* New Zealand Standard */
02162     { "nzdt", tDAYZONE,  -HOUR(12) },     /* New Zealand Daylight */
02163 
02164     /* For completeness we include the following entries. */
02165 #if 0
02166 
02167     /* Duplicate names.  Either they conflict with a zone listed above
02168      * (which is either more likely to be seen or just been in circulation
02169      * longer), or they conflict with another zone in this section and
02170      * we could not reasonably choose one over the other. */
02171     { "fst",  tZONE,     HOUR( 2) },      /* Fernando De Noronha Standard */
02172     { "fdt",  tDAYZONE,  HOUR( 2) },      /* Fernando De Noronha Daylight */
02173     { "bst",  tZONE,     HOUR( 3) },      /* Brazil Standard */
02174     { "est",  tZONE,     HOUR( 3) },      /* Eastern Standard (Brazil) */
02175     { "edt",  tDAYZONE,  HOUR( 3) },      /* Eastern Daylight (Brazil) */
02176     { "wst",  tZONE,     HOUR( 4) },      /* Western Standard (Brazil) */
02177     { "wdt",  tDAYZONE,  HOUR( 4) },      /* Western Daylight (Brazil) */
02178     { "cst",  tZONE,     HOUR( 5) },      /* Chile Standard */
02179     { "cdt",  tDAYZONE,  HOUR( 5) },      /* Chile Daylight */
02180     { "ast",  tZONE,     HOUR( 5) },      /* Acre Standard */
02181     { "adt",  tDAYZONE,  HOUR( 5) },      /* Acre Daylight */
02182     { "cst",  tZONE,     HOUR( 5) },      /* Cuba Standard */
02183     { "cdt",  tDAYZONE,  HOUR( 5) },      /* Cuba Daylight */
02184     { "est",  tZONE,     HOUR( 6) },      /* Easter Island Standard */
02185     { "edt",  tDAYZONE,  HOUR( 6) },      /* Easter Island Daylight */
02186     { "sst",  tZONE,     HOUR(11) },      /* Samoa Standard */
02187     { "ist",  tZONE,     -HOUR(2) },      /* Israel Standard */
02188     { "idt",  tDAYZONE,  -HOUR(2) },      /* Israel Daylight */
02189     { "idt",  tDAYZONE,  -(HOUR(3)+30) }, /* Iran Daylight */
02190     { "ist",  tZONE,     -(HOUR(3)+30) }, /* Iran Standard */
02191     { "cst",   tZONE,     -HOUR(8) },     /* China Standard */
02192     { "cdt",   tDAYZONE,  -HOUR(8) },     /* China Daylight */
02193     { "sst",   tZONE,     -HOUR(8) },     /* Singapore Standard */
02194 
02195     /* Dubious (e.g., not in Olson's TIMEZONE package) or obsolete. */
02196     { "gst",  tZONE,     HOUR( 3) },      /* Greenland Standard */
02197     { "wat",  tZONE,     -HOUR(1) },      /* West Africa */
02198     { "at",   tZONE,     HOUR( 2) },      /* Azores */
02199     { "gst",  tZONE,     -HOUR(10) },     /* Guam Standard */
02200     { "nft",  tZONE,     HOUR(3)+30 }, /* Newfoundland */
02201     { "idlw", tZONE,     HOUR(12) },      /* International Date Line West */
02202     { "mewt", tZONE,     -HOUR(1) },      /* Middle European Winter */
02203     { "mest", tDAYZONE,  -HOUR(1) },      /* Middle European Summer */
02204     { "swt",  tZONE,     -HOUR(1) },      /* Swedish Winter */
02205     { "sst",  tDAYZONE,  -HOUR(1) },      /* Swedish Summer */
02206     { "fwt",  tZONE,     -HOUR(1) },      /* French Winter */
02207     { "fst",  tDAYZONE,  -HOUR(1) },      /* French Summer */
02208     { "bt",   tZONE,     -HOUR(3) },      /* Baghdad */
02209     { "it",   tZONE,     -(HOUR(3)+30) }, /* Iran */
02210     { "zp4",  tZONE,     -HOUR(4) },      /* USSR Zone 3 */
02211     { "zp5",  tZONE,     -HOUR(5) },      /* USSR Zone 4 */
02212     { "ist",  tZONE,     -(HOUR(5)+30) }, /* Indian Standard */
02213     { "zp6",  tZONE,     -HOUR(6) },      /* USSR Zone 5 */
02214     { "nst",  tZONE,     -HOUR(7) },      /* North Sumatra */
02215     { "sst",  tZONE,     -HOUR(7) },      /* South Sumatra */
02216     { "jt",   tZONE,     -(HOUR(7)+30) }, /* Java (3pm in Cronusland!) */
02217     { "nzt",  tZONE,     -HOUR(12) },     /* New Zealand */
02218     { "idle", tZONE,     -HOUR(12) },     /* International Date Line East */
02219     { "cat",  tZONE,     HOUR(10) },      /* -- expired 1967 */
02220     { "nt",   tZONE,     HOUR(11) },      /* -- expired 1967 */
02221     { "ahst", tZONE,     HOUR(10) },      /* -- expired 1983 */
02222     { "hdt",  tDAYZONE,  HOUR(10) },      /* -- expired 1986 */
02223 #endif /* 0 */
02224 };
02225 
02226 
02227 /* ARGSUSED */
02228 static void
02229 date_error(char *s)
02230 {
02231     /* NOTREACHED */
02232 }
02233 
02234 
02235 static time_t
02236 ToSeconds(time_t Hours, time_t Minutes, time_t Seconds, MERIDIAN Meridian)
02237 {
02238     if (Minutes < 0 || Minutes > 59 || Seconds < 0 || Seconds > 61)
02239        return -1;
02240     if (Meridian == MER24) {
02241        if (Hours < 0 || Hours > 23)
02242            return -1;
02243     }
02244     else {
02245        if (Hours < 1 || Hours > 12)
02246            return -1;
02247        if (Hours == 12)
02248            Hours = 0;
02249        if (Meridian == MERpm)
02250            Hours += 12;
02251     }
02252     return (Hours * 60L + Minutes) * 60L + Seconds;
02253 }
02254 
02255 
02256 static time_t
02257 Convert(time_t Month, time_t Day, time_t Year,
02258        time_t Hours, time_t Minutes, time_t Seconds,
02259        MERIDIAN Meridian, DSTMODE dst)
02260 {
02261     static int       DaysNormal[13] = {
02262        0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
02263     };
02264     static int       DaysLeap[13] = {
02265        0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
02266     };
02267     static int       LeapYears[] = {
02268        1972, 1976, 1980, 1984, 1988, 1992, 1996,
02269        2000, 2004, 2008, 2012, 2016, 2020, 2024, 2028, 2032, 2036
02270     };
02271     register int     *yp;
02272     register int     *mp;
02273     register time_t  Julian;
02274     register int     i;
02275     time_t           tod;
02276 
02277     if (Year < 0)
02278        Year = -Year;
02279     if (Year < 100)
02280        Year += 1900;
02281     if (Year < EPOCH)
02282        Year += 100;
02283     for (mp = DaysNormal, yp = LeapYears; yp < ENDOF(LeapYears); yp++)
02284        if (Year == *yp) {
02285            mp = DaysLeap;
02286            break;
02287        }
02288     if (Year < EPOCH || Year > END_OF_TIME
02289      || Month < 1 || Month > 12
02290      /* NOSTRICT *//* conversion from long may lose accuracy */
02291      || Day < 1 || Day > mp[(int)Month])
02292        return -1;
02293 
02294     Julian = Day - 1 + (Year - EPOCH) * 365;
02295     for (yp = LeapYears; yp < ENDOF(LeapYears); yp++, Julian++)
02296        if (Year <= *yp)
02297            break;
02298     for (i = 1; i < Month; i++)
02299        Julian += *++mp;
02300     Julian *= SECSPERDAY;
02301     Julian += yyTimezone * 60L;
02302     if ((tod = ToSeconds(Hours, Minutes, Seconds, Meridian)) < 0)
02303        return -1;
02304     Julian += tod;
02305     tod = Julian;
02306     if (dst == DSTon || (dst == DSTmaybe && localtime(&tod)->tm_isdst))
02307        Julian -= DST_OFFSET * 60L * 60L;
02308     return Julian;
02309 }
02310 
02311 
02312 static time_t
02313 DSTcorrect(time_t Start, time_t Future)
02314 {
02315     time_t    StartDay;
02316     time_t    FutureDay;
02317 
02318     StartDay = (localtime(&Start)->tm_hour + 1) % 24;
02319     FutureDay = (localtime(&Future)->tm_hour + 1) % 24;
02320     return (Future - Start) + (StartDay - FutureDay) * DST_OFFSET * 60L * 60L;
02321 }
02322 
02323 
02324 static time_t
02325 RelativeMonth(time_t Start, time_t RelMonth)
02326 {
02327     struct tm *tm;
02328     time_t    Month;
02329     time_t    Year;
02330 
02331     tm = localtime(&Start);
02332     Month = 12 * tm->tm_year + tm->tm_mon + RelMonth;
02333     Year = Month / 12;
02334     Month = Month % 12 + 1;
02335     return DSTcorrect(Start,
02336            Convert(Month, (time_t)tm->tm_mday, Year,
02337               (time_t)tm->tm_hour, (time_t)tm->tm_min, (time_t)tm->tm_sec,
02338               MER24, DSTmaybe));
02339 }
02340 
02341 
02342 static int
02343 LookupWord(char *buff, register int length)
02344 {
02345     register char    *p;
02346     register char    *q;
02347     register TABLE   *tp;
02348     register int     c;
02349 
02350     p = buff;
02351     c = p[0];
02352 
02353     /* See if we have an abbreviation for a month. */
02354     if (length == 3 || (length == 4 && p[3] == '.'))
02355        for (tp = MonthDayTable; tp < ENDOF(MonthDayTable); tp++) {
02356            q = tp->name;
02357            if (c == q[0] && p[1] == q[1] && p[2] == q[2]) {
02358               yylval.Number = tp->value;
02359               return tp->type;
02360            }
02361        }
02362     else
02363        for (tp = MonthDayTable; tp < ENDOF(MonthDayTable); tp++)
02364            if (c == tp->name[0] && strcmp(p, tp->name) == 0) {
02365               yylval.Number = tp->value;
02366               return tp->type;
02367            }
02368 
02369     /* Try for a timezone. */
02370     for (tp = TimezoneTable; tp < ENDOF(TimezoneTable); tp++)
02371        if (c == tp->name[0] && p[1] == tp->name[1]
02372         && strcmp(p, tp->name) == 0) {
02373            yylval.Number = tp->value;
02374            return tp->type;
02375        }
02376 
02377     /* Try the units table. */
02378     for (tp = UnitsTable; tp < ENDOF(UnitsTable); tp++)
02379        if (c == tp->name[0] && strcmp(p, tp->name) == 0) {
02380            yylval.Number = tp->value;
02381            return tp->type;
02382        }
02383 
02384     /* Strip off any plural and try the units table again. */
02385     if (--length > 0 && p[length] == 's') {
02386        p[length] = '\0';
02387        for (tp = UnitsTable; tp < ENDOF(UnitsTable); tp++)
02388            if (c == tp->name[0] && strcmp(p, tp->name) == 0) {
02389               p[length] = 's';
02390               yylval.Number = tp->value;
02391               return tp->type;
02392            }
02393        p[length] = 's';
02394     }
02395     length++;
02396 
02397     /* Drop out any periods. */
02398     for (p = buff, q = (char*)buff; *q; q++)
02399        if (*q != '.')
02400            *p++ = *q;
02401     *p = '\0';
02402 
02403     /* Try the meridians. */
02404     if (buff[1] == 'm' && buff[2] == '\0') {
02405        if (buff[0] == 'a') {
02406            yylval.Meridian = MERam;
02407            return tMERIDIAN;
02408        }
02409        if (buff[0] == 'p') {
02410            yylval.Meridian = MERpm;
02411            return tMERIDIAN;
02412        }
02413     }
02414 
02415     /* If we saw any periods, try the timezones again. */
02416     if (p - buff != length) {
02417        c = buff[0];
02418        for (p = buff, tp = TimezoneTable; tp < ENDOF(TimezoneTable); tp++)
02419            if (c == tp->name[0] && p[1] == tp->name[1]
02420            && strcmp(p, tp->name) == 0) {
02421               yylval.Number = tp->value;
02422               return tp->type;
02423            }
02424     }
02425 
02426     /* Unknown word -- assume GMT timezone. */
02427     yylval.Number = 0;
02428     return tZONE;
02429 }
02430 
02431 
02432 int
02433 date_lex(void)
02434 {
02435     register char    c;
02436     register char    *p;
02437     char             buff[20];
02438     register int     sign;
02439     register int     i;
02440     register int     nesting;
02441 
02442     for ( ; ; ) {
02443        /* Get first character after the whitespace. */
02444        for ( ; ; ) {
02445            while (isspace(*yyInput))
02446               yyInput++;
02447            c = *yyInput;
02448 
02449            /* Ignore RFC 822 comments, typically time zone names. */
02450            if (c != LPAREN)
02451               break;
02452            for (nesting = 1; (c = *++yyInput) != RPAREN || --nesting; )
02453               if (c == LPAREN)
02454                   nesting++;
02455               else if (!IS7BIT(c) || c == '\0' || c == '\r'
02456                    || (c == '\\' && ((c = *++yyInput) == '\0' || !IS7BIT(c))))
02457                   /* Lexical error: bad comment. */
02458                   return '?';
02459            yyInput++;
02460        }
02461 
02462        /* A number? */
02463        if (isdigit(c) || c == '-' || c == '+') {
02464            if (c == '-' || c == '+') {
02465               sign = c == '-' ? -1 : 1;
02466               yyInput++;
02467               if (!isdigit(*yyInput))
02468                   /* Skip the plus or minus sign. */
02469                   continue;
02470            }
02471            else
02472               sign = 0;
02473            for (i = 0; (c = *yyInput++) != '\0' && isdigit(c); )
02474               i = 10 * i + c - '0';
02475            yyInput--;
02476            yylval.Number = sign < 0 ? -i : i;
02477            return sign ? tSNUMBER : tUNUMBER;
02478        }
02479 
02480        /* A word? */
02481        if (isalpha(c)) {
02482            for (p = buff; (c = *yyInput++) == '.' || isalpha(c); )
02483               if (p < &buff[sizeof buff - 1])
02484                   *p++ = isupper(c) ? tolower(c) : c;
02485            *p = '\0';
02486            yyInput--;
02487            return LookupWord(buff, p - buff);
02488        }
02489 
02490        return *yyInput++;
02491     }
02492 }
02493 
02494 
02495 time_t
02496 parsedate(const char *p)
02497 {
02498     extern int              date_parse(void);
02499     time_t           Start;
02500 
02501     yyInput = p; /* well, its supposed to be const... */
02502 
02503     yyYear = 0;
02504     yyMonth = 0;
02505     yyDay = 0;
02506     yyTimezone = 0;
02507     yyDSTmode = DSTmaybe;
02508     yyHour = 0;
02509     yyMinutes = 0;
02510     yySeconds = 0;
02511     yyMeridian = MER24;
02512     yyRelSeconds = 0;
02513     yyRelMonth = 0;
02514     yyHaveDate = 0;
02515     yyHaveRel = 0;
02516     yyHaveTime = 0;
02517 
02518     if (date_parse() || yyHaveTime > 1 || yyHaveDate > 1)
02519        return -1;
02520 
02521     if (yyHaveDate || yyHaveTime) {
02522        Start = Convert(yyMonth, yyDay, yyYear, yyHour, yyMinutes, yySeconds,
02523                   yyMeridian, yyDSTmode);
02524        if (Start < 0)
02525            return -1;
02526     }
02527     else
02528        return -1;
02529 
02530     Start += yyRelSeconds;
02531     if (yyRelMonth)
02532        Start += RelativeMonth(Start, yyRelMonth);
02533 
02534     /* Have to do *something* with a legitimate -1 so it's distinguishable
02535      * from the error return value.  (Alternately could set errno on error.) */
02536     return Start == -1 ? 0 : Start;
02537 }
02538 
02539 
02540 #ifdef TEST
02541 
02542 #if YYDEBUG
02543 extern int    yydebug;
02544 #endif /* YYDEBUG */
02545 
02546 /* ARGSUSED */
02547 int
02548 main(int ac, char *av[])
02549 {
02550     char      buff[128];
02551     time_t    d;
02552 
02553 #if YYDEBUG
02554     yydebug = 1;
02555 #endif /* YYDEBUG */
02556 
02557     (void)printf("Enter date, or blank line to exit.\n\t> ");
02558     for ( ; ; ) {
02559        (void)printf("\t> ");
02560        (void)fflush(stdout);
02561        if (fgets(buff, sizeof buff, stdin) == NULL || buff[0] == '\n')
02562            break;
02563 #if YYDEBUG
02564        if (strcmp(buff, "yydebug") == 0) {
02565            yydebug = !yydebug;
02566            printf("yydebug = %s\n", yydebug ? "on" : "off");
02567            continue;
02568        }
02569 #endif /* YYDEBUG */
02570        d = parsedate(buff, (TIMEINFO *)NULL);
02571        if (d == -1)
02572            (void)printf("Bad format - couldn't convert.\n");
02573        else
02574            (void)printf("%s", ctime(&d));
02575     }
02576 
02577     exit(0);
02578     /* NOTREACHED */
02579 }
02580 #endif /* TEST */
02581