1/* A Bison parser, made by GNU Bison 2.3.  */
2
3/* Skeleton implementation for Bison's Yacc-like parsers in C
4
5   Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
6   Free Software Foundation, Inc.
7
8   This program is free software; you can redistribute it and/or modify
9   it under the terms of the GNU General Public License as published by
10   the Free Software Foundation; either version 2, or (at your option)
11   any later version.
12
13   This program is distributed in the hope that it will be useful,
14   but WITHOUT ANY WARRANTY; without even the implied warranty of
15   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16   GNU General Public License for more details.
17
18   You should have received a copy of the GNU General Public License
19   along with this program; if not, write to the Free Software
20   Foundation, Inc., 51 Franklin Street, Fifth Floor,
21   Boston, MA 02110-1301, USA.  */
22
23/* As a special exception, you may create a larger work that contains
24   part or all of the Bison parser skeleton and distribute that work
25   under terms of your choice, so long as that work isn't itself a
26   parser generator using the skeleton or a modified version thereof
27   as a parser skeleton.  Alternatively, if you modify or redistribute
28   the parser skeleton itself, you may (at your option) remove this
29   special exception, which will cause the skeleton and the resulting
30   Bison output files to be licensed under the GNU General Public
31   License without this special exception.
32
33   This special exception was added by the Free Software Foundation in
34   version 2.2 of Bison.  */
35
36/* C LALR(1) parser skeleton written by Richard Stallman, by
37   simplifying the original so-called "semantic" parser.  */
38
39/* All symbols defined below should begin with yy or YY, to avoid
40   infringing on user name space.  This should be done even for local
41   variables, as they might otherwise be expanded by user macros.
42   There are some unavoidable exceptions within include files to
43   define necessary library symbols; they are noted "INFRINGES ON
44   USER NAME SPACE" below.  */
45
46/* Identify Bison output.  */
47#define YYBISON 1
48
49/* Bison version.  */
50#define YYBISON_VERSION "2.3"
51
52/* Skeleton name.  */
53#define YYSKELETON_NAME "yacc.c"
54
55/* Pure parsers.  */
56#define YYPURE 1
57
58/* Using locations.  */
59#define YYLSP_NEEDED 1
60
61/* Substitute the variable and function names.  */
62#define yyparse TclDateparse
63#define yylex   TclDatelex
64#define yyerror TclDateerror
65#define yylval  TclDatelval
66#define yychar  TclDatechar
67#define yydebug TclDatedebug
68#define yynerrs TclDatenerrs
69#define yylloc TclDatelloc
70
71/* Tokens.  */
72#ifndef YYTOKENTYPE
73# define YYTOKENTYPE
74   /* Put the tokens into the symbol table, so that GDB and other debuggers
75      know about them.  */
76   enum yytokentype {
77     tAGO = 258,
78     tDAY = 259,
79     tDAYZONE = 260,
80     tID = 261,
81     tMERIDIAN = 262,
82     tMONTH = 263,
83     tMONTH_UNIT = 264,
84     tSTARDATE = 265,
85     tSEC_UNIT = 266,
86     tSNUMBER = 267,
87     tUNUMBER = 268,
88     tZONE = 269,
89     tEPOCH = 270,
90     tDST = 271,
91     tISOBASE = 272,
92     tDAY_UNIT = 273,
93     tNEXT = 274
94   };
95#endif
96/* Tokens.  */
97#define tAGO 258
98#define tDAY 259
99#define tDAYZONE 260
100#define tID 261
101#define tMERIDIAN 262
102#define tMONTH 263
103#define tMONTH_UNIT 264
104#define tSTARDATE 265
105#define tSEC_UNIT 266
106#define tSNUMBER 267
107#define tUNUMBER 268
108#define tZONE 269
109#define tEPOCH 270
110#define tDST 271
111#define tISOBASE 272
112#define tDAY_UNIT 273
113#define tNEXT 274
114
115
116
117
118/* Copy the first part of user declarations.  */
119
120
121/*
122 * tclDate.c --
123 *
124 *	This file is generated from a yacc grammar defined in the file
125 *	tclGetDate.y. It should not be edited directly.
126 *
127 * Copyright (c) 1992-1995 Karl Lehenbauer and Mark Diekhans.
128 * Copyright (c) 1995-1997 Sun Microsystems, Inc.
129 *
130 * See the file "license.terms" for information on usage and redistribution of
131 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
132 *
133 */
134#include "tclInt.h"
135
136/*
137 * Bison generates several labels that happen to be unused. MS Visual C++
138 * doesn't like that, and complains. Tell it to shut up.
139 */
140
141#ifdef _MSC_VER
142#pragma warning( disable : 4102 )
143#endif /* _MSC_VER */
144
145/*
146 * yyparse will accept a 'struct DateInfo' as its parameter; that's where the
147 * parsed fields will be returned.
148 */
149
150typedef struct DateInfo {
151
152    Tcl_Obj* messages;		/* Error messages */
153    const char* separatrix;	/* String separating messages */
154
155    time_t dateYear;
156    time_t dateMonth;
157    time_t dateDay;
158    int dateHaveDate;
159
160    time_t dateHour;
161    time_t dateMinutes;
162    time_t dateSeconds;
163    int dateMeridian;
164    int dateHaveTime;
165
166    time_t dateTimezone;
167    int dateDSTmode;
168    int dateHaveZone;
169
170    time_t dateRelMonth;
171    time_t dateRelDay;
172    time_t dateRelSeconds;
173    int dateHaveRel;
174
175    time_t dateMonthOrdinal;
176    int dateHaveOrdinalMonth;
177
178    time_t dateDayOrdinal;
179    time_t dateDayNumber;
180    int dateHaveDay;
181
182    const char *dateStart;
183    const char *dateInput;
184    time_t *dateRelPointer;
185
186    int dateDigitCount;
187} DateInfo;
188
189#define YYMALLOC	ckalloc
190#define YYFREE(x)	(ckfree((void*) (x)))
191
192#define yyDSTmode	(info->dateDSTmode)
193#define yyDayOrdinal	(info->dateDayOrdinal)
194#define yyDayNumber	(info->dateDayNumber)
195#define yyMonthOrdinal	(info->dateMonthOrdinal)
196#define yyHaveDate	(info->dateHaveDate)
197#define yyHaveDay	(info->dateHaveDay)
198#define yyHaveOrdinalMonth (info->dateHaveOrdinalMonth)
199#define yyHaveRel	(info->dateHaveRel)
200#define yyHaveTime	(info->dateHaveTime)
201#define yyHaveZone	(info->dateHaveZone)
202#define yyTimezone	(info->dateTimezone)
203#define yyDay		(info->dateDay)
204#define yyMonth		(info->dateMonth)
205#define yyYear		(info->dateYear)
206#define yyHour		(info->dateHour)
207#define yyMinutes	(info->dateMinutes)
208#define yySeconds	(info->dateSeconds)
209#define yyMeridian	(info->dateMeridian)
210#define yyRelMonth	(info->dateRelMonth)
211#define yyRelDay	(info->dateRelDay)
212#define yyRelSeconds	(info->dateRelSeconds)
213#define yyRelPointer	(info->dateRelPointer)
214#define yyInput		(info->dateInput)
215#define yyDigitCount	(info->dateDigitCount)
216
217#define EPOCH		1970
218#define START_OF_TIME	1902
219#define END_OF_TIME	2037
220
221/*
222 * The offset of tm_year of struct tm returned by localtime, gmtime, etc.
223 * Posix requires 1900.
224 */
225
226#define TM_YEAR_BASE	1900
227
228#define HOUR(x)		((int) (60 * x))
229#define SECSPERDAY	(24L * 60L * 60L)
230#define IsLeapYear(x)	((x % 4 == 0) && (x % 100 != 0 || x % 400 == 0))
231
232/*
233 * An entry in the lexical lookup table.
234 */
235
236typedef struct _TABLE {
237    const char *name;
238    int type;
239    time_t value;
240} TABLE;
241
242/*
243 * Daylight-savings mode: on, off, or not yet known.
244 */
245
246typedef enum _DSTMODE {
247    DSTon, DSToff, DSTmaybe
248} DSTMODE;
249
250/*
251 * Meridian: am, pm, or 24-hour style.
252 */
253
254typedef enum _MERIDIAN {
255    MERam, MERpm, MER24
256} MERIDIAN;
257
258
259
260/* Enabling traces.  */
261#ifndef YYDEBUG
262# define YYDEBUG 0
263#endif
264
265/* Enabling verbose error messages.  */
266#ifdef YYERROR_VERBOSE
267# undef YYERROR_VERBOSE
268# define YYERROR_VERBOSE 1
269#else
270# define YYERROR_VERBOSE 0
271#endif
272
273/* Enabling the token table.  */
274#ifndef YYTOKEN_TABLE
275# define YYTOKEN_TABLE 0
276#endif
277
278#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
279typedef union YYSTYPE
280
281{
282    time_t Number;
283    enum _MERIDIAN Meridian;
284}
285/* Line 187 of yacc.c.  */
286
287	YYSTYPE;
288# define yystype YYSTYPE /* obsolescent; will be withdrawn */
289# define YYSTYPE_IS_DECLARED 1
290# define YYSTYPE_IS_TRIVIAL 1
291#endif
292
293#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
294typedef struct YYLTYPE
295{
296  int first_line;
297  int first_column;
298  int last_line;
299  int last_column;
300} YYLTYPE;
301# define yyltype YYLTYPE /* obsolescent; will be withdrawn */
302# define YYLTYPE_IS_DECLARED 1
303# define YYLTYPE_IS_TRIVIAL 1
304#endif
305
306
307/* Copy the second part of user declarations.  */
308
309
310
311/*
312 * Prototypes of internal functions.
313 */
314
315static int		LookupWord(YYSTYPE* yylvalPtr, char *buff);
316 static void		TclDateerror(YYLTYPE* location,
317				     DateInfo* info, const char *s);
318 static int		TclDatelex(YYSTYPE* yylvalPtr, YYLTYPE* location,
319				   DateInfo* info);
320static time_t		ToSeconds(time_t Hours, time_t Minutes,
321			    time_t Seconds, MERIDIAN Meridian);
322MODULE_SCOPE int	yyparse(DateInfo*);
323
324
325
326/* Line 216 of yacc.c.  */
327
328
329#ifdef short
330# undef short
331#endif
332
333#ifdef YYTYPE_UINT8
334typedef YYTYPE_UINT8 yytype_uint8;
335#else
336typedef unsigned char yytype_uint8;
337#endif
338
339#ifdef YYTYPE_INT8
340typedef YYTYPE_INT8 yytype_int8;
341#elif (defined __STDC__ || defined __C99__FUNC__ \
342     || defined __cplusplus || defined _MSC_VER)
343typedef signed char yytype_int8;
344#else
345typedef short int yytype_int8;
346#endif
347
348#ifdef YYTYPE_UINT16
349typedef YYTYPE_UINT16 yytype_uint16;
350#else
351typedef unsigned short int yytype_uint16;
352#endif
353
354#ifdef YYTYPE_INT16
355typedef YYTYPE_INT16 yytype_int16;
356#else
357typedef short int yytype_int16;
358#endif
359
360#ifndef YYSIZE_T
361# ifdef __SIZE_TYPE__
362#  define YYSIZE_T __SIZE_TYPE__
363# elif defined size_t
364#  define YYSIZE_T size_t
365# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
366     || defined __cplusplus || defined _MSC_VER)
367#  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
368#  define YYSIZE_T size_t
369# else
370#  define YYSIZE_T unsigned int
371# endif
372#endif
373
374#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
375
376#ifndef YY_
377# if YYENABLE_NLS
378#  if ENABLE_NLS
379#   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
380#   define YY_(msgid) dgettext ("bison-runtime", msgid)
381#  endif
382# endif
383# ifndef YY_
384#  define YY_(msgid) msgid
385# endif
386#endif
387
388/* Suppress unused-variable warnings by "using" E.  */
389#if ! defined lint || defined __GNUC__
390# define YYUSE(e) ((void) (e))
391#else
392# define YYUSE(e) /* empty */
393#endif
394
395/* Identity function, used to suppress warnings about constant conditions.  */
396#ifndef lint
397# define YYID(n) (n)
398#else
399#if (defined __STDC__ || defined __C99__FUNC__ \
400     || defined __cplusplus || defined _MSC_VER)
401static int
402YYID (int i)
403#else
404static int
405YYID (i)
406    int i;
407#endif
408{
409  return i;
410}
411#endif
412
413#if ! defined yyoverflow || YYERROR_VERBOSE
414
415/* The parser invokes alloca or malloc; define the necessary symbols.  */
416
417# ifdef YYSTACK_USE_ALLOCA
418#  if YYSTACK_USE_ALLOCA
419#   ifdef __GNUC__
420#    define YYSTACK_ALLOC __builtin_alloca
421#   elif defined __BUILTIN_VA_ARG_INCR
422#    include <alloca.h> /* INFRINGES ON USER NAME SPACE */
423#   elif defined _AIX
424#    define YYSTACK_ALLOC __alloca
425#   elif defined _MSC_VER
426#    include <malloc.h> /* INFRINGES ON USER NAME SPACE */
427#    define alloca _alloca
428#   else
429#    define YYSTACK_ALLOC alloca
430#    if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
431     || defined __cplusplus || defined _MSC_VER)
432#     include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
433#     ifndef _STDLIB_H
434#      define _STDLIB_H 1
435#     endif
436#    endif
437#   endif
438#  endif
439# endif
440
441# ifdef YYSTACK_ALLOC
442   /* Pacify GCC's `empty if-body' warning.  */
443#  define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
444#  ifndef YYSTACK_ALLOC_MAXIMUM
445    /* The OS might guarantee only one guard page at the bottom of the stack,
446       and a page size can be as small as 4096 bytes.  So we cannot safely
447       invoke alloca (N) if N exceeds 4096.  Use a slightly smaller number
448       to allow for a few compiler-allocated temporary stack slots.  */
449#   define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
450#  endif
451# else
452#  define YYSTACK_ALLOC YYMALLOC
453#  define YYSTACK_FREE YYFREE
454#  ifndef YYSTACK_ALLOC_MAXIMUM
455#   define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
456#  endif
457#  if (defined __cplusplus && ! defined _STDLIB_H \
458       && ! ((defined YYMALLOC || defined malloc) \
459	     && (defined YYFREE || defined free)))
460#   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
461#   ifndef _STDLIB_H
462#    define _STDLIB_H 1
463#   endif
464#  endif
465#  ifndef YYMALLOC
466#   define YYMALLOC malloc
467#   if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
468     || defined __cplusplus || defined _MSC_VER)
469void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
470#   endif
471#  endif
472#  ifndef YYFREE
473#   define YYFREE free
474#   if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
475     || defined __cplusplus || defined _MSC_VER)
476void free (void *); /* INFRINGES ON USER NAME SPACE */
477#   endif
478#  endif
479# endif
480#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
481
482
483#if (! defined yyoverflow \
484     && (! defined __cplusplus \
485	 || (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \
486	     && defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
487
488/* A type that is properly aligned for any stack member.  */
489union yyalloc
490{
491  yytype_int16 yyss;
492  YYSTYPE yyvs;
493    YYLTYPE yyls;
494};
495
496/* The size of the maximum gap between one aligned stack and the next.  */
497# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
498
499/* The size of an array large to enough to hold all stacks, each with
500   N elements.  */
501# define YYSTACK_BYTES(N) \
502     ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
503      + 2 * YYSTACK_GAP_MAXIMUM)
504
505/* Copy COUNT objects from FROM to TO.  The source and destination do
506   not overlap.  */
507# ifndef YYCOPY
508#  if defined __GNUC__ && 1 < __GNUC__
509#   define YYCOPY(To, From, Count) \
510      __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
511#  else
512#   define YYCOPY(To, From, Count)		\
513      do					\
514	{					\
515	  YYSIZE_T yyi;				\
516	  for (yyi = 0; yyi < (Count); yyi++)	\
517	    (To)[yyi] = (From)[yyi];		\
518	}					\
519      while (YYID (0))
520#  endif
521# endif
522
523/* Relocate STACK from its old location to the new one.  The
524   local variables YYSIZE and YYSTACKSIZE give the old and new number of
525   elements in the stack, and YYPTR gives the new location of the
526   stack.  Advance YYPTR to a properly aligned location for the next
527   stack.  */
528# define YYSTACK_RELOCATE(Stack)					\
529    do									\
530      {									\
531	YYSIZE_T yynewbytes;						\
532	YYCOPY (&yyptr->Stack, Stack, yysize);				\
533	Stack = &yyptr->Stack;						\
534	yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
535	yyptr += yynewbytes / sizeof (*yyptr);				\
536      }									\
537    while (YYID (0))
538
539#endif
540
541/* YYFINAL -- State number of the termination state.  */
542#define YYFINAL  2
543/* YYLAST -- Last index in YYTABLE.  */
544#define YYLAST   79
545
546/* YYNTOKENS -- Number of terminals.  */
547#define YYNTOKENS  26
548/* YYNNTS -- Number of nonterminals.  */
549#define YYNNTS  16
550/* YYNRULES -- Number of rules.  */
551#define YYNRULES  56
552/* YYNRULES -- Number of states.  */
553#define YYNSTATES  83
554
555/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
556#define YYUNDEFTOK  2
557#define YYMAXUTOK   274
558
559#define YYTRANSLATE(YYX)						\
560  ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
561
562/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX.  */
563static const yytype_uint8 yytranslate[] =
564{
565       0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
566       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
567       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
568       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
569       2,     2,     2,    25,    22,    21,    24,    23,     2,     2,
570       2,     2,     2,     2,     2,     2,     2,     2,    20,     2,
571       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
572       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
573       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
574       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
575       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
576       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
577       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
578       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
579       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
580       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
581       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
582       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
583       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
584       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
585       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
586       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
587       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
588       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
589       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
590       2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
591       5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
592      15,    16,    17,    18,    19
593};
594
595#if YYDEBUG
596/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
597   YYRHS.  */
598static const yytype_uint8 yyprhs[] =
599{
600       0,     0,     3,     4,     7,     9,    11,    13,    15,    17,
601      19,    21,    23,    25,    28,    33,    39,    46,    54,    57,
602      59,    61,    63,    66,    69,    73,    76,    80,    86,    88,
603      94,   100,   103,   108,   111,   113,   117,   120,   124,   128,
604     136,   139,   144,   147,   149,   153,   156,   159,   163,   165,
605     167,   169,   171,   173,   175,   177,   178
606};
607
608/* YYRHS -- A `-1'-separated list of the rules' RHS.  */
609static const yytype_int8 yyrhs[] =
610{
611      27,     0,    -1,    -1,    27,    28,    -1,    29,    -1,    30,
612      -1,    32,    -1,    33,    -1,    31,    -1,    36,    -1,    34,
613      -1,    35,    -1,    40,    -1,    13,     7,    -1,    13,    20,
614      13,    41,    -1,    13,    20,    13,    21,    13,    -1,    13,
615      20,    13,    20,    13,    41,    -1,    13,    20,    13,    20,
616      13,    21,    13,    -1,    14,    16,    -1,    14,    -1,     5,
617      -1,     4,    -1,     4,    22,    -1,    13,     4,    -1,    38,
618      13,     4,    -1,    19,     4,    -1,    13,    23,    13,    -1,
619      13,    23,    13,    23,    13,    -1,    17,    -1,    13,    21,
620       8,    21,    13,    -1,    13,    21,    13,    21,    13,    -1,
621       8,    13,    -1,     8,    13,    22,    13,    -1,    13,     8,
622      -1,    15,    -1,    13,     8,    13,    -1,    19,     8,    -1,
623      19,    13,     8,    -1,    17,    14,    17,    -1,    17,    14,
624      13,    20,    13,    20,    13,    -1,    17,    17,    -1,    10,
625      13,    24,    13,    -1,    37,     3,    -1,    37,    -1,    38,
626      13,    39,    -1,    13,    39,    -1,    19,    39,    -1,    19,
627      13,    39,    -1,    39,    -1,    21,    -1,    25,    -1,    11,
628      -1,    18,    -1,     9,    -1,    13,    -1,    -1,     7,    -1
629};
630
631/* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
632static const yytype_uint16 yyrline[] =
633{
634       0,   225,   225,   226,   229,   232,   235,   238,   241,   244,
635     247,   251,   256,   259,   265,   271,   279,   285,   296,   300,
636     304,   310,   314,   318,   322,   326,   332,   336,   341,   346,
637     351,   356,   360,   365,   369,   374,   381,   385,   391,   400,
638     409,   419,   433,   438,   441,   444,   447,   450,   453,   458,
639     461,   466,   470,   474,   480,   498,   501
640};
641#endif
642
643#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
644/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
645   First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
646static const char *const yytname[] =
647{
648  "$end", "error", "$undefined", "tAGO", "tDAY", "tDAYZONE", "tID",
649  "tMERIDIAN", "tMONTH", "tMONTH_UNIT", "tSTARDATE", "tSEC_UNIT",
650  "tSNUMBER", "tUNUMBER", "tZONE", "tEPOCH", "tDST", "tISOBASE",
651  "tDAY_UNIT", "tNEXT", "':'", "'-'", "','", "'/'", "'.'", "'+'",
652  "$accept", "spec", "item", "time", "zone", "day", "date", "ordMonth",
653  "iso", "trek", "relspec", "relunits", "sign", "unit", "number",
654  "o_merid", 0
655};
656#endif
657
658# ifdef YYPRINT
659/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
660   token YYLEX-NUM.  */
661static const yytype_uint16 yytoknum[] =
662{
663       0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
664     265,   266,   267,   268,   269,   270,   271,   272,   273,   274,
665      58,    45,    44,    47,    46,    43
666};
667# endif
668
669/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
670static const yytype_uint8 yyr1[] =
671{
672       0,    26,    27,    27,    28,    28,    28,    28,    28,    28,
673      28,    28,    28,    29,    29,    29,    29,    29,    30,    30,
674      30,    31,    31,    31,    31,    31,    32,    32,    32,    32,
675      32,    32,    32,    32,    32,    32,    33,    33,    34,    34,
676      34,    35,    36,    36,    37,    37,    37,    37,    37,    38,
677      38,    39,    39,    39,    40,    41,    41
678};
679
680/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
681static const yytype_uint8 yyr2[] =
682{
683       0,     2,     0,     2,     1,     1,     1,     1,     1,     1,
684       1,     1,     1,     2,     4,     5,     6,     7,     2,     1,
685       1,     1,     2,     2,     3,     2,     3,     5,     1,     5,
686       5,     2,     4,     2,     1,     3,     2,     3,     3,     7,
687       2,     4,     2,     1,     3,     2,     2,     3,     1,     1,
688       1,     1,     1,     1,     1,     0,     1
689};
690
691/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
692   STATE-NUM when YYTABLE doesn't specify something else to do.  Zero
693   means the default is an error.  */
694static const yytype_uint8 yydefact[] =
695{
696       2,     0,     1,    21,    20,     0,    53,     0,    51,    54,
697      19,    34,    28,    52,     0,    49,    50,     3,     4,     5,
698       8,     6,     7,    10,    11,     9,    43,     0,    48,    12,
699      22,    31,     0,    23,    13,    33,     0,     0,     0,    45,
700      18,     0,    40,    25,    36,     0,    46,    42,     0,     0,
701       0,    35,    55,     0,     0,    26,     0,    38,    37,    47,
702      24,    44,    32,    41,    56,     0,     0,    14,     0,     0,
703       0,     0,    55,    15,    29,    30,    27,     0,     0,    16,
704       0,    17,    39
705};
706
707/* YYDEFGOTO[NTERM-NUM].  */
708static const yytype_int8 yydefgoto[] =
709{
710      -1,     1,    17,    18,    19,    20,    21,    22,    23,    24,
711      25,    26,    27,    28,    29,    67
712};
713
714/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
715   STATE-NUM.  */
716#define YYPACT_NINF -22
717static const yytype_int8 yypact[] =
718{
719     -22,     2,   -22,   -21,   -22,    -4,   -22,     1,   -22,    22,
720      18,   -22,     8,   -22,    40,   -22,   -22,   -22,   -22,   -22,
721     -22,   -22,   -22,   -22,   -22,   -22,    32,    28,   -22,   -22,
722     -22,    24,    26,   -22,   -22,    42,    47,    -5,    49,   -22,
723     -22,    15,   -22,   -22,   -22,    48,   -22,   -22,    43,    50,
724      51,   -22,    17,    44,    46,    45,    52,   -22,   -22,   -22,
725     -22,   -22,   -22,   -22,   -22,    56,    57,   -22,    58,    60,
726      61,    62,    -3,   -22,   -22,   -22,   -22,    59,    63,   -22,
727      64,   -22,   -22
728};
729
730/* YYPGOTO[NTERM-NUM].  */
731static const yytype_int8 yypgoto[] =
732{
733     -22,   -22,   -22,   -22,   -22,   -22,   -22,   -22,   -22,   -22,
734     -22,   -22,   -22,    -9,   -22,     6
735};
736
737/* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
738   positive, shift that token.  If negative, reduce the rule which
739   number is the opposite.  If zero, do what YYDEFACT says.
740   If YYTABLE_NINF, syntax error.  */
741#define YYTABLE_NINF -1
742static const yytype_uint8 yytable[] =
743{
744      39,    30,     2,    53,    64,    46,     3,     4,    54,    31,
745       5,     6,     7,     8,    32,     9,    10,    11,    78,    12,
746      13,    14,    41,    15,    64,    42,    33,    16,    56,    34,
747      35,     6,    57,     8,    40,    47,    59,    65,    66,    61,
748      13,    48,    36,    37,    43,    38,    49,    60,    44,     6,
749      50,     8,     6,    45,     8,    51,    58,     6,    13,     8,
750      52,    13,    55,    62,    63,    68,    13,    69,    70,    72,
751      73,    74,    71,    75,    76,    77,    81,    82,    79,    80
752};
753
754static const yytype_uint8 yycheck[] =
755{
756       9,    22,     0,     8,     7,    14,     4,     5,    13,    13,
757       8,     9,    10,    11,    13,    13,    14,    15,    21,    17,
758      18,    19,    14,    21,     7,    17,     4,    25,    13,     7,
759       8,     9,    17,    11,    16,     3,    45,    20,    21,    48,
760      18,    13,    20,    21,     4,    23,    22,     4,     8,     9,
761      24,    11,     9,    13,    11,    13,     8,     9,    18,    11,
762      13,    18,    13,    13,    13,    21,    18,    21,    23,    13,
763      13,    13,    20,    13,    13,    13,    13,    13,    72,    20
764};
765
766/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
767   symbol of state STATE-NUM.  */
768static const yytype_uint8 yystos[] =
769{
770       0,    27,     0,     4,     5,     8,     9,    10,    11,    13,
771      14,    15,    17,    18,    19,    21,    25,    28,    29,    30,
772      31,    32,    33,    34,    35,    36,    37,    38,    39,    40,
773      22,    13,    13,     4,     7,     8,    20,    21,    23,    39,
774      16,    14,    17,     4,     8,    13,    39,     3,    13,    22,
775      24,    13,    13,     8,    13,    13,    13,    17,     8,    39,
776       4,    39,    13,    13,     7,    20,    21,    41,    21,    21,
777      23,    20,    13,    13,    13,    13,    13,    13,    21,    41,
778      20,    13,    13
779};
780
781#define yyerrok		(yyerrstatus = 0)
782#define yyclearin	(yychar = YYEMPTY)
783#define YYEMPTY		(-2)
784#define YYEOF		0
785
786#define YYACCEPT	goto yyacceptlab
787#define YYABORT		goto yyabortlab
788#define YYERROR		goto yyerrorlab
789
790
791/* Like YYERROR except do call yyerror.  This remains here temporarily
792   to ease the transition to the new meaning of YYERROR, for GCC.
793   Once GCC version 2 has supplanted version 1, this can go.  */
794
795#define YYFAIL		goto yyerrlab
796
797#define YYRECOVERING()  (!!yyerrstatus)
798
799#define YYBACKUP(Token, Value)					\
800do								\
801  if (yychar == YYEMPTY && yylen == 1)				\
802    {								\
803      yychar = (Token);						\
804      yylval = (Value);						\
805      yytoken = YYTRANSLATE (yychar);				\
806      YYPOPSTACK (1);						\
807      goto yybackup;						\
808    }								\
809  else								\
810    {								\
811      yyerror (&yylloc, info, YY_("syntax error: cannot back up")); \
812      YYERROR;							\
813    }								\
814while (YYID (0))
815
816
817#define YYTERROR	1
818#define YYERRCODE	256
819
820
821/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
822   If N is 0, then set CURRENT to the empty location which ends
823   the previous symbol: RHS[0] (always defined).  */
824
825#define YYRHSLOC(Rhs, K) ((Rhs)[K])
826#ifndef YYLLOC_DEFAULT
827# define YYLLOC_DEFAULT(Current, Rhs, N)				\
828    do									\
829      if (YYID (N))                                                    \
830	{								\
831	  (Current).first_line   = YYRHSLOC (Rhs, 1).first_line;	\
832	  (Current).first_column = YYRHSLOC (Rhs, 1).first_column;	\
833	  (Current).last_line    = YYRHSLOC (Rhs, N).last_line;		\
834	  (Current).last_column  = YYRHSLOC (Rhs, N).last_column;	\
835	}								\
836      else								\
837	{								\
838	  (Current).first_line   = (Current).last_line   =		\
839	    YYRHSLOC (Rhs, 0).last_line;				\
840	  (Current).first_column = (Current).last_column =		\
841	    YYRHSLOC (Rhs, 0).last_column;				\
842	}								\
843    while (YYID (0))
844#endif
845
846
847/* YY_LOCATION_PRINT -- Print the location on the stream.
848   This macro was not mandated originally: define only if we know
849   we won't break user code: when these are the locations we know.  */
850
851#ifndef YY_LOCATION_PRINT
852# if YYLTYPE_IS_TRIVIAL
853#  define YY_LOCATION_PRINT(File, Loc)			\
854     fprintf (File, "%d.%d-%d.%d",			\
855	      (Loc).first_line, (Loc).first_column,	\
856	      (Loc).last_line,  (Loc).last_column)
857# else
858#  define YY_LOCATION_PRINT(File, Loc) ((void) 0)
859# endif
860#endif
861
862
863/* YYLEX -- calling `yylex' with the right arguments.  */
864
865#ifdef YYLEX_PARAM
866# define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
867#else
868# define YYLEX yylex (&yylval, &yylloc, info)
869#endif
870
871/* Enable debugging if requested.  */
872#if YYDEBUG
873
874# ifndef YYFPRINTF
875#  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
876#  define YYFPRINTF fprintf
877# endif
878
879# define YYDPRINTF(Args)			\
880do {						\
881  if (yydebug)					\
882    YYFPRINTF Args;				\
883} while (YYID (0))
884
885# define YY_SYMBOL_PRINT(Title, Type, Value, Location)			  \
886do {									  \
887  if (yydebug)								  \
888    {									  \
889      YYFPRINTF (stderr, "%s ", Title);					  \
890      yy_symbol_print (stderr,						  \
891		  Type, Value, Location, info); \
892      YYFPRINTF (stderr, "\n");						  \
893    }									  \
894} while (YYID (0))
895
896
897/*--------------------------------.
898| Print this symbol on YYOUTPUT.  |
899`--------------------------------*/
900
901/*ARGSUSED*/
902#if (defined __STDC__ || defined __C99__FUNC__ \
903     || defined __cplusplus || defined _MSC_VER)
904static void
905yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, DateInfo* info)
906#else
907static void
908yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, info)
909    FILE *yyoutput;
910    int yytype;
911    YYSTYPE const * const yyvaluep;
912    YYLTYPE const * const yylocationp;
913    DateInfo* info;
914#endif
915{
916  if (!yyvaluep)
917    return;
918  YYUSE (yylocationp);
919  YYUSE (info);
920# ifdef YYPRINT
921  if (yytype < YYNTOKENS)
922    YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
923# else
924  YYUSE (yyoutput);
925# endif
926  switch (yytype)
927    {
928      default:
929	break;
930    }
931}
932
933
934/*--------------------------------.
935| Print this symbol on YYOUTPUT.  |
936`--------------------------------*/
937
938#if (defined __STDC__ || defined __C99__FUNC__ \
939     || defined __cplusplus || defined _MSC_VER)
940static void
941yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, DateInfo* info)
942#else
943static void
944yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp, info)
945    FILE *yyoutput;
946    int yytype;
947    YYSTYPE const * const yyvaluep;
948    YYLTYPE const * const yylocationp;
949    DateInfo* info;
950#endif
951{
952  if (yytype < YYNTOKENS)
953    YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
954  else
955    YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
956
957  YY_LOCATION_PRINT (yyoutput, *yylocationp);
958  YYFPRINTF (yyoutput, ": ");
959  yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, info);
960  YYFPRINTF (yyoutput, ")");
961}
962
963/*------------------------------------------------------------------.
964| yy_stack_print -- Print the state stack from its BOTTOM up to its |
965| TOP (included).                                                   |
966`------------------------------------------------------------------*/
967
968#if (defined __STDC__ || defined __C99__FUNC__ \
969     || defined __cplusplus || defined _MSC_VER)
970static void
971yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
972#else
973static void
974yy_stack_print (bottom, top)
975    yytype_int16 *bottom;
976    yytype_int16 *top;
977#endif
978{
979  YYFPRINTF (stderr, "Stack now");
980  for (; bottom <= top; ++bottom)
981    YYFPRINTF (stderr, " %d", *bottom);
982  YYFPRINTF (stderr, "\n");
983}
984
985# define YY_STACK_PRINT(Bottom, Top)				\
986do {								\
987  if (yydebug)							\
988    yy_stack_print ((Bottom), (Top));				\
989} while (YYID (0))
990
991
992/*------------------------------------------------.
993| Report that the YYRULE is going to be reduced.  |
994`------------------------------------------------*/
995
996#if (defined __STDC__ || defined __C99__FUNC__ \
997     || defined __cplusplus || defined _MSC_VER)
998static void
999yy_reduce_print (YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule, DateInfo* info)
1000#else
1001static void
1002yy_reduce_print (yyvsp, yylsp, yyrule, info)
1003    YYSTYPE *yyvsp;
1004    YYLTYPE *yylsp;
1005    int yyrule;
1006    DateInfo* info;
1007#endif
1008{
1009  int yynrhs = yyr2[yyrule];
1010  int yyi;
1011  unsigned long int yylno = yyrline[yyrule];
1012  YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
1013	     yyrule - 1, yylno);
1014  /* The symbols being reduced.  */
1015  for (yyi = 0; yyi < yynrhs; yyi++)
1016    {
1017      fprintf (stderr, "   $%d = ", yyi + 1);
1018      yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
1019		       &(yyvsp[(yyi + 1) - (yynrhs)])
1020		       , &(yylsp[(yyi + 1) - (yynrhs)])		       , info);
1021      fprintf (stderr, "\n");
1022    }
1023}
1024
1025# define YY_REDUCE_PRINT(Rule)		\
1026do {					\
1027  if (yydebug)				\
1028    yy_reduce_print (yyvsp, yylsp, Rule, info); \
1029} while (YYID (0))
1030
1031/* Nonzero means print parse trace.  It is left uninitialized so that
1032   multiple parsers can coexist.  */
1033int yydebug;
1034#else /* !YYDEBUG */
1035# define YYDPRINTF(Args)
1036# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
1037# define YY_STACK_PRINT(Bottom, Top)
1038# define YY_REDUCE_PRINT(Rule)
1039#endif /* !YYDEBUG */
1040
1041
1042/* YYINITDEPTH -- initial size of the parser's stacks.  */
1043#ifndef	YYINITDEPTH
1044# define YYINITDEPTH 200
1045#endif
1046
1047/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1048   if the built-in stack extension method is used).
1049
1050   Do not make this value too large; the results are undefined if
1051   YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
1052   evaluated with infinite-precision integer arithmetic.  */
1053
1054#ifndef YYMAXDEPTH
1055# define YYMAXDEPTH 10000
1056#endif
1057
1058
1059
1060#if YYERROR_VERBOSE
1061
1062# ifndef yystrlen
1063#  if defined __GLIBC__ && defined _STRING_H
1064#   define yystrlen strlen
1065#  else
1066/* Return the length of YYSTR.  */
1067#if (defined __STDC__ || defined __C99__FUNC__ \
1068     || defined __cplusplus || defined _MSC_VER)
1069static YYSIZE_T
1070yystrlen (const char *yystr)
1071#else
1072static YYSIZE_T
1073yystrlen (yystr)
1074    const char *yystr;
1075#endif
1076{
1077  YYSIZE_T yylen;
1078  for (yylen = 0; yystr[yylen]; yylen++)
1079    continue;
1080  return yylen;
1081}
1082#  endif
1083# endif
1084
1085# ifndef yystpcpy
1086#  if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1087#   define yystpcpy stpcpy
1088#  else
1089/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1090   YYDEST.  */
1091#if (defined __STDC__ || defined __C99__FUNC__ \
1092     || defined __cplusplus || defined _MSC_VER)
1093static char *
1094yystpcpy (char *yydest, const char *yysrc)
1095#else
1096static char *
1097yystpcpy (yydest, yysrc)
1098    char *yydest;
1099    const char *yysrc;
1100#endif
1101{
1102  char *yyd = yydest;
1103  const char *yys = yysrc;
1104
1105  while ((*yyd++ = *yys++) != '\0')
1106    continue;
1107
1108  return yyd - 1;
1109}
1110#  endif
1111# endif
1112
1113# ifndef yytnamerr
1114/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1115   quotes and backslashes, so that it's suitable for yyerror.  The
1116   heuristic is that double-quoting is unnecessary unless the string
1117   contains an apostrophe, a comma, or backslash (other than
1118   backslash-backslash).  YYSTR is taken from yytname.  If YYRES is
1119   null, do not copy; instead, return the length of what the result
1120   would have been.  */
1121static YYSIZE_T
1122yytnamerr (char *yyres, const char *yystr)
1123{
1124  if (*yystr == '"')
1125    {
1126      YYSIZE_T yyn = 0;
1127      char const *yyp = yystr;
1128
1129      for (;;)
1130	switch (*++yyp)
1131	  {
1132	  case '\'':
1133	  case ',':
1134	    goto do_not_strip_quotes;
1135
1136	  case '\\':
1137	    if (*++yyp != '\\')
1138	      goto do_not_strip_quotes;
1139	    /* Fall through.  */
1140	  default:
1141	    if (yyres)
1142	      yyres[yyn] = *yyp;
1143	    yyn++;
1144	    break;
1145
1146	  case '"':
1147	    if (yyres)
1148	      yyres[yyn] = '\0';
1149	    return yyn;
1150	  }
1151    do_not_strip_quotes: ;
1152    }
1153
1154  if (! yyres)
1155    return yystrlen (yystr);
1156
1157  return yystpcpy (yyres, yystr) - yyres;
1158}
1159# endif
1160
1161/* Copy into YYRESULT an error message about the unexpected token
1162   YYCHAR while in state YYSTATE.  Return the number of bytes copied,
1163   including the terminating null byte.  If YYRESULT is null, do not
1164   copy anything; just return the number of bytes that would be
1165   copied.  As a special case, return 0 if an ordinary "syntax error"
1166   message will do.  Return YYSIZE_MAXIMUM if overflow occurs during
1167   size calculation.  */
1168static YYSIZE_T
1169yysyntax_error (char *yyresult, int yystate, int yychar)
1170{
1171  int yyn = yypact[yystate];
1172
1173  if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
1174    return 0;
1175  else
1176    {
1177      int yytype = YYTRANSLATE (yychar);
1178      YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
1179      YYSIZE_T yysize = yysize0;
1180      YYSIZE_T yysize1;
1181      int yysize_overflow = 0;
1182      enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1183      char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1184      int yyx;
1185
1186# if 0
1187      /* This is so xgettext sees the translatable formats that are
1188	 constructed on the fly.  */
1189      YY_("syntax error, unexpected %s");
1190      YY_("syntax error, unexpected %s, expecting %s");
1191      YY_("syntax error, unexpected %s, expecting %s or %s");
1192      YY_("syntax error, unexpected %s, expecting %s or %s or %s");
1193      YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
1194# endif
1195      char *yyfmt;
1196      char const *yyf;
1197      static char const yyunexpected[] = "syntax error, unexpected %s";
1198      static char const yyexpecting[] = ", expecting %s";
1199      static char const yyor[] = " or %s";
1200      char yyformat[sizeof yyunexpected
1201		    + sizeof yyexpecting - 1
1202		    + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
1203		       * (sizeof yyor - 1))];
1204      char const *yyprefix = yyexpecting;
1205
1206      /* Start YYX at -YYN if negative to avoid negative indexes in
1207	 YYCHECK.  */
1208      int yyxbegin = yyn < 0 ? -yyn : 0;
1209
1210      /* Stay within bounds of both yycheck and yytname.  */
1211      int yychecklim = YYLAST - yyn + 1;
1212      int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1213      int yycount = 1;
1214
1215      yyarg[0] = yytname[yytype];
1216      yyfmt = yystpcpy (yyformat, yyunexpected);
1217
1218      for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1219	if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1220	  {
1221	    if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1222	      {
1223		yycount = 1;
1224		yysize = yysize0;
1225		yyformat[sizeof yyunexpected - 1] = '\0';
1226		break;
1227	      }
1228	    yyarg[yycount++] = yytname[yyx];
1229	    yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1230	    yysize_overflow |= (yysize1 < yysize);
1231	    yysize = yysize1;
1232	    yyfmt = yystpcpy (yyfmt, yyprefix);
1233	    yyprefix = yyor;
1234	  }
1235
1236      yyf = YY_(yyformat);
1237      yysize1 = yysize + yystrlen (yyf);
1238      yysize_overflow |= (yysize1 < yysize);
1239      yysize = yysize1;
1240
1241      if (yysize_overflow)
1242	return YYSIZE_MAXIMUM;
1243
1244      if (yyresult)
1245	{
1246	  /* Avoid sprintf, as that infringes on the user's name space.
1247	     Don't have undefined behavior even if the translation
1248	     produced a string with the wrong number of "%s"s.  */
1249	  char *yyp = yyresult;
1250	  int yyi = 0;
1251	  while ((*yyp = *yyf) != '\0')
1252	    {
1253	      if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
1254		{
1255		  yyp += yytnamerr (yyp, yyarg[yyi++]);
1256		  yyf += 2;
1257		}
1258	      else
1259		{
1260		  yyp++;
1261		  yyf++;
1262		}
1263	    }
1264	}
1265      return yysize;
1266    }
1267}
1268#endif /* YYERROR_VERBOSE */
1269
1270
1271/*-----------------------------------------------.
1272| Release the memory associated to this symbol.  |
1273`-----------------------------------------------*/
1274
1275/*ARGSUSED*/
1276#if (defined __STDC__ || defined __C99__FUNC__ \
1277     || defined __cplusplus || defined _MSC_VER)
1278static void
1279yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp, DateInfo* info)
1280#else
1281static void
1282yydestruct (yymsg, yytype, yyvaluep, yylocationp, info)
1283    const char *yymsg;
1284    int yytype;
1285    YYSTYPE *yyvaluep;
1286    YYLTYPE *yylocationp;
1287    DateInfo* info;
1288#endif
1289{
1290  YYUSE (yyvaluep);
1291  YYUSE (yylocationp);
1292  YYUSE (info);
1293
1294  if (!yymsg)
1295    yymsg = "Deleting";
1296  YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1297
1298  switch (yytype)
1299    {
1300
1301      default:
1302	break;
1303    }
1304}
1305
1306
1307/* Prevent warnings from -Wmissing-prototypes.  */
1308
1309#ifdef YYPARSE_PARAM
1310#if defined __STDC__ || defined __cplusplus
1311int yyparse (void *YYPARSE_PARAM);
1312#else
1313int yyparse ();
1314#endif
1315#else /* ! YYPARSE_PARAM */
1316#if defined __STDC__ || defined __cplusplus
1317int yyparse (DateInfo* info);
1318#else
1319int yyparse ();
1320#endif
1321#endif /* ! YYPARSE_PARAM */
1322
1323
1324
1325
1326
1327
1328/*----------.
1329| yyparse.  |
1330`----------*/
1331
1332#ifdef YYPARSE_PARAM
1333#if (defined __STDC__ || defined __C99__FUNC__ \
1334     || defined __cplusplus || defined _MSC_VER)
1335int
1336yyparse (void *YYPARSE_PARAM)
1337#else
1338int
1339yyparse (YYPARSE_PARAM)
1340    void *YYPARSE_PARAM;
1341#endif
1342#else /* ! YYPARSE_PARAM */
1343#if (defined __STDC__ || defined __C99__FUNC__ \
1344     || defined __cplusplus || defined _MSC_VER)
1345int
1346yyparse (DateInfo* info)
1347#else
1348int
1349yyparse (info)
1350    DateInfo* info;
1351#endif
1352#endif
1353{
1354  /* The look-ahead symbol.  */
1355int yychar;
1356
1357/* The semantic value of the look-ahead symbol.  */
1358YYSTYPE yylval;
1359
1360/* Number of syntax errors so far.  */
1361int yynerrs;
1362/* Location data for the look-ahead symbol.  */
1363YYLTYPE yylloc;
1364
1365  int yystate;
1366  int yyn;
1367  int yyresult;
1368  /* Number of tokens to shift before error messages enabled.  */
1369  int yyerrstatus;
1370  /* Look-ahead token as an internal (translated) token number.  */
1371  int yytoken = 0;
1372#if YYERROR_VERBOSE
1373  /* Buffer for error messages, and its allocated size.  */
1374  char yymsgbuf[128];
1375  char *yymsg = yymsgbuf;
1376  YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1377#endif
1378
1379  /* Three stacks and their tools:
1380     `yyss': related to states,
1381     `yyvs': related to semantic values,
1382     `yyls': related to locations.
1383
1384     Refer to the stacks thru separate pointers, to allow yyoverflow
1385     to reallocate them elsewhere.  */
1386
1387  /* The state stack.  */
1388  yytype_int16 yyssa[YYINITDEPTH];
1389  yytype_int16 *yyss = yyssa;
1390  yytype_int16 *yyssp;
1391
1392  /* The semantic value stack.  */
1393  YYSTYPE yyvsa[YYINITDEPTH];
1394  YYSTYPE *yyvs = yyvsa;
1395  YYSTYPE *yyvsp;
1396
1397  /* The location stack.  */
1398  YYLTYPE yylsa[YYINITDEPTH];
1399  YYLTYPE *yyls = yylsa;
1400  YYLTYPE *yylsp;
1401  /* The locations where the error started and ended.  */
1402  YYLTYPE yyerror_range[2];
1403
1404#define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N), yylsp -= (N))
1405
1406  YYSIZE_T yystacksize = YYINITDEPTH;
1407
1408  /* The variables used to return semantic value and location from the
1409     action routines.  */
1410  YYSTYPE yyval;
1411  YYLTYPE yyloc;
1412
1413  /* The number of symbols on the RHS of the reduced rule.
1414     Keep to zero when no symbol should be popped.  */
1415  int yylen = 0;
1416
1417  YYDPRINTF ((stderr, "Starting parse\n"));
1418
1419  yystate = 0;
1420  yyerrstatus = 0;
1421  yynerrs = 0;
1422  yychar = YYEMPTY;		/* Cause a token to be read.  */
1423
1424  /* Initialize stack pointers.
1425     Waste one element of value and location stack
1426     so that they stay on the same level as the state stack.
1427     The wasted elements are never initialized.  */
1428
1429  yyssp = yyss;
1430  yyvsp = yyvs;
1431  yylsp = yyls;
1432#if YYLTYPE_IS_TRIVIAL
1433  /* Initialize the default location before parsing starts.  */
1434  yylloc.first_line   = yylloc.last_line   = 1;
1435  yylloc.first_column = yylloc.last_column = 0;
1436#endif
1437
1438  goto yysetstate;
1439
1440/*------------------------------------------------------------.
1441| yynewstate -- Push a new state, which is found in yystate.  |
1442`------------------------------------------------------------*/
1443 yynewstate:
1444  /* In all cases, when you get here, the value and location stacks
1445     have just been pushed.  So pushing a state here evens the stacks.  */
1446  yyssp++;
1447
1448 yysetstate:
1449  *yyssp = yystate;
1450
1451  if (yyss + yystacksize - 1 <= yyssp)
1452    {
1453      /* Get the current used size of the three stacks, in elements.  */
1454      YYSIZE_T yysize = yyssp - yyss + 1;
1455
1456#ifdef yyoverflow
1457      {
1458	/* Give user a chance to reallocate the stack.  Use copies of
1459	   these so that the &'s don't force the real ones into
1460	   memory.  */
1461	YYSTYPE *yyvs1 = yyvs;
1462	yytype_int16 *yyss1 = yyss;
1463	YYLTYPE *yyls1 = yyls;
1464
1465	/* Each stack pointer address is followed by the size of the
1466	   data in use in that stack, in bytes.  This used to be a
1467	   conditional around just the two extra args, but that might
1468	   be undefined if yyoverflow is a macro.  */
1469	yyoverflow (YY_("memory exhausted"),
1470		    &yyss1, yysize * sizeof (*yyssp),
1471		    &yyvs1, yysize * sizeof (*yyvsp),
1472		    &yyls1, yysize * sizeof (*yylsp),
1473		    &yystacksize);
1474	yyls = yyls1;
1475	yyss = yyss1;
1476	yyvs = yyvs1;
1477      }
1478#else /* no yyoverflow */
1479# ifndef YYSTACK_RELOCATE
1480      goto yyexhaustedlab;
1481# else
1482      /* Extend the stack our own way.  */
1483      if (YYMAXDEPTH <= yystacksize)
1484	goto yyexhaustedlab;
1485      yystacksize *= 2;
1486      if (YYMAXDEPTH < yystacksize)
1487	yystacksize = YYMAXDEPTH;
1488
1489      {
1490	yytype_int16 *yyss1 = yyss;
1491	union yyalloc *yyptr =
1492	  (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1493	if (! yyptr)
1494	  goto yyexhaustedlab;
1495	YYSTACK_RELOCATE (yyss);
1496	YYSTACK_RELOCATE (yyvs);
1497	YYSTACK_RELOCATE (yyls);
1498#  undef YYSTACK_RELOCATE
1499	if (yyss1 != yyssa)
1500	  YYSTACK_FREE (yyss1);
1501      }
1502# endif
1503#endif /* no yyoverflow */
1504
1505      yyssp = yyss + yysize - 1;
1506      yyvsp = yyvs + yysize - 1;
1507      yylsp = yyls + yysize - 1;
1508
1509      YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1510		  (unsigned long int) yystacksize));
1511
1512      if (yyss + yystacksize - 1 <= yyssp)
1513	YYABORT;
1514    }
1515
1516  YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1517
1518  goto yybackup;
1519
1520/*-----------.
1521| yybackup.  |
1522`-----------*/
1523yybackup:
1524
1525  /* Do appropriate processing given the current state.  Read a
1526     look-ahead token if we need one and don't already have one.  */
1527
1528  /* First try to decide what to do without reference to look-ahead token.  */
1529  yyn = yypact[yystate];
1530  if (yyn == YYPACT_NINF)
1531    goto yydefault;
1532
1533  /* Not known => get a look-ahead token if don't already have one.  */
1534
1535  /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol.  */
1536  if (yychar == YYEMPTY)
1537    {
1538      YYDPRINTF ((stderr, "Reading a token: "));
1539      yychar = YYLEX;
1540    }
1541
1542  if (yychar <= YYEOF)
1543    {
1544      yychar = yytoken = YYEOF;
1545      YYDPRINTF ((stderr, "Now at end of input.\n"));
1546    }
1547  else
1548    {
1549      yytoken = YYTRANSLATE (yychar);
1550      YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1551    }
1552
1553  /* If the proper action on seeing token YYTOKEN is to reduce or to
1554     detect an error, take that action.  */
1555  yyn += yytoken;
1556  if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1557    goto yydefault;
1558  yyn = yytable[yyn];
1559  if (yyn <= 0)
1560    {
1561      if (yyn == 0 || yyn == YYTABLE_NINF)
1562	goto yyerrlab;
1563      yyn = -yyn;
1564      goto yyreduce;
1565    }
1566
1567  if (yyn == YYFINAL)
1568    YYACCEPT;
1569
1570  /* Count tokens shifted since error; after three, turn off error
1571     status.  */
1572  if (yyerrstatus)
1573    yyerrstatus--;
1574
1575  /* Shift the look-ahead token.  */
1576  YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1577
1578  /* Discard the shifted token unless it is eof.  */
1579  if (yychar != YYEOF)
1580    yychar = YYEMPTY;
1581
1582  yystate = yyn;
1583  *++yyvsp = yylval;
1584  *++yylsp = yylloc;
1585  goto yynewstate;
1586
1587
1588/*-----------------------------------------------------------.
1589| yydefault -- do the default action for the current state.  |
1590`-----------------------------------------------------------*/
1591yydefault:
1592  yyn = yydefact[yystate];
1593  if (yyn == 0)
1594    goto yyerrlab;
1595  goto yyreduce;
1596
1597
1598/*-----------------------------.
1599| yyreduce -- Do a reduction.  |
1600`-----------------------------*/
1601yyreduce:
1602  /* yyn is the number of a rule to reduce with.  */
1603  yylen = yyr2[yyn];
1604
1605  /* If YYLEN is nonzero, implement the default value of the action:
1606     `$$ = $1'.
1607
1608     Otherwise, the following line sets YYVAL to garbage.
1609     This behavior is undocumented and Bison
1610     users should not rely upon it.  Assigning to YYVAL
1611     unconditionally makes the parser a bit smaller, and it avoids a
1612     GCC warning that YYVAL may be used uninitialized.  */
1613  yyval = yyvsp[1-yylen];
1614
1615  /* Default location.  */
1616  YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
1617  YY_REDUCE_PRINT (yyn);
1618  switch (yyn)
1619    {
1620        case 4:
1621
1622    {
1623	    yyHaveTime++;
1624	;}
1625    break;
1626
1627  case 5:
1628
1629    {
1630	    yyHaveZone++;
1631	;}
1632    break;
1633
1634  case 6:
1635
1636    {
1637	    yyHaveDate++;
1638	;}
1639    break;
1640
1641  case 7:
1642
1643    {
1644	    yyHaveOrdinalMonth++;
1645	;}
1646    break;
1647
1648  case 8:
1649
1650    {
1651	    yyHaveDay++;
1652	;}
1653    break;
1654
1655  case 9:
1656
1657    {
1658	    yyHaveRel++;
1659	;}
1660    break;
1661
1662  case 10:
1663
1664    {
1665	    yyHaveTime++;
1666	    yyHaveDate++;
1667	;}
1668    break;
1669
1670  case 11:
1671
1672    {
1673	    yyHaveTime++;
1674	    yyHaveDate++;
1675	    yyHaveRel++;
1676	;}
1677    break;
1678
1679  case 13:
1680
1681    {
1682	    yyHour = (yyvsp[(1) - (2)].Number);
1683	    yyMinutes = 0;
1684	    yySeconds = 0;
1685	    yyMeridian = (yyvsp[(2) - (2)].Meridian);
1686	;}
1687    break;
1688
1689  case 14:
1690
1691    {
1692	    yyHour = (yyvsp[(1) - (4)].Number);
1693	    yyMinutes = (yyvsp[(3) - (4)].Number);
1694	    yySeconds = 0;
1695	    yyMeridian = (yyvsp[(4) - (4)].Meridian);
1696	;}
1697    break;
1698
1699  case 15:
1700
1701    {
1702	    yyHour = (yyvsp[(1) - (5)].Number);
1703	    yyMinutes = (yyvsp[(3) - (5)].Number);
1704	    yyMeridian = MER24;
1705	    yyDSTmode = DSToff;
1706	    yyTimezone = ((yyvsp[(5) - (5)].Number) % 100 + ((yyvsp[(5) - (5)].Number) / 100) * 60);
1707	    ++yyHaveZone;
1708	;}
1709    break;
1710
1711  case 16:
1712
1713    {
1714	    yyHour = (yyvsp[(1) - (6)].Number);
1715	    yyMinutes = (yyvsp[(3) - (6)].Number);
1716	    yySeconds = (yyvsp[(5) - (6)].Number);
1717	    yyMeridian = (yyvsp[(6) - (6)].Meridian);
1718	;}
1719    break;
1720
1721  case 17:
1722
1723    {
1724	    yyHour = (yyvsp[(1) - (7)].Number);
1725	    yyMinutes = (yyvsp[(3) - (7)].Number);
1726	    yySeconds = (yyvsp[(5) - (7)].Number);
1727	    yyMeridian = MER24;
1728	    yyDSTmode = DSToff;
1729	    yyTimezone = ((yyvsp[(7) - (7)].Number) % 100 + ((yyvsp[(7) - (7)].Number) / 100) * 60);
1730	    ++yyHaveZone;
1731	;}
1732    break;
1733
1734  case 18:
1735
1736    {
1737	    yyTimezone = (yyvsp[(1) - (2)].Number);
1738	    yyDSTmode = DSTon;
1739	;}
1740    break;
1741
1742  case 19:
1743
1744    {
1745	    yyTimezone = (yyvsp[(1) - (1)].Number);
1746	    yyDSTmode = DSToff;
1747	;}
1748    break;
1749
1750  case 20:
1751
1752    {
1753	    yyTimezone = (yyvsp[(1) - (1)].Number);
1754	    yyDSTmode = DSTon;
1755	;}
1756    break;
1757
1758  case 21:
1759
1760    {
1761	    yyDayOrdinal = 1;
1762	    yyDayNumber = (yyvsp[(1) - (1)].Number);
1763	;}
1764    break;
1765
1766  case 22:
1767
1768    {
1769	    yyDayOrdinal = 1;
1770	    yyDayNumber = (yyvsp[(1) - (2)].Number);
1771	;}
1772    break;
1773
1774  case 23:
1775
1776    {
1777	    yyDayOrdinal = (yyvsp[(1) - (2)].Number);
1778	    yyDayNumber = (yyvsp[(2) - (2)].Number);
1779	;}
1780    break;
1781
1782  case 24:
1783
1784    {
1785	    yyDayOrdinal = (yyvsp[(1) - (3)].Number) * (yyvsp[(2) - (3)].Number);
1786	    yyDayNumber = (yyvsp[(3) - (3)].Number);
1787	;}
1788    break;
1789
1790  case 25:
1791
1792    {
1793	    yyDayOrdinal = 2;
1794	    yyDayNumber = (yyvsp[(2) - (2)].Number);
1795	;}
1796    break;
1797
1798  case 26:
1799
1800    {
1801	    yyMonth = (yyvsp[(1) - (3)].Number);
1802	    yyDay = (yyvsp[(3) - (3)].Number);
1803	;}
1804    break;
1805
1806  case 27:
1807
1808    {
1809	    yyMonth = (yyvsp[(1) - (5)].Number);
1810	    yyDay = (yyvsp[(3) - (5)].Number);
1811	    yyYear = (yyvsp[(5) - (5)].Number);
1812	;}
1813    break;
1814
1815  case 28:
1816
1817    {
1818	    yyYear = (yyvsp[(1) - (1)].Number) / 10000;
1819	    yyMonth = ((yyvsp[(1) - (1)].Number) % 10000)/100;
1820	    yyDay = (yyvsp[(1) - (1)].Number) % 100;
1821	;}
1822    break;
1823
1824  case 29:
1825
1826    {
1827	    yyDay = (yyvsp[(1) - (5)].Number);
1828	    yyMonth = (yyvsp[(3) - (5)].Number);
1829	    yyYear = (yyvsp[(5) - (5)].Number);
1830	;}
1831    break;
1832
1833  case 30:
1834
1835    {
1836	    yyMonth = (yyvsp[(3) - (5)].Number);
1837	    yyDay = (yyvsp[(5) - (5)].Number);
1838	    yyYear = (yyvsp[(1) - (5)].Number);
1839	;}
1840    break;
1841
1842  case 31:
1843
1844    {
1845	    yyMonth = (yyvsp[(1) - (2)].Number);
1846	    yyDay = (yyvsp[(2) - (2)].Number);
1847	;}
1848    break;
1849
1850  case 32:
1851
1852    {
1853	    yyMonth = (yyvsp[(1) - (4)].Number);
1854	    yyDay = (yyvsp[(2) - (4)].Number);
1855	    yyYear = (yyvsp[(4) - (4)].Number);
1856	;}
1857    break;
1858
1859  case 33:
1860
1861    {
1862	    yyMonth = (yyvsp[(2) - (2)].Number);
1863	    yyDay = (yyvsp[(1) - (2)].Number);
1864	;}
1865    break;
1866
1867  case 34:
1868
1869    {
1870	    yyMonth = 1;
1871	    yyDay = 1;
1872	    yyYear = EPOCH;
1873	;}
1874    break;
1875
1876  case 35:
1877
1878    {
1879	    yyMonth = (yyvsp[(2) - (3)].Number);
1880	    yyDay = (yyvsp[(1) - (3)].Number);
1881	    yyYear = (yyvsp[(3) - (3)].Number);
1882	;}
1883    break;
1884
1885  case 36:
1886
1887    {
1888	    yyMonthOrdinal = 1;
1889	    yyMonth = (yyvsp[(2) - (2)].Number);
1890	;}
1891    break;
1892
1893  case 37:
1894
1895    {
1896	    yyMonthOrdinal = (yyvsp[(2) - (3)].Number);
1897	    yyMonth = (yyvsp[(3) - (3)].Number);
1898	;}
1899    break;
1900
1901  case 38:
1902
1903    {
1904	    if ((yyvsp[(2) - (3)].Number) != HOUR( 7)) YYABORT;
1905	    yyYear = (yyvsp[(1) - (3)].Number) / 10000;
1906	    yyMonth = ((yyvsp[(1) - (3)].Number) % 10000)/100;
1907	    yyDay = (yyvsp[(1) - (3)].Number) % 100;
1908	    yyHour = (yyvsp[(3) - (3)].Number) / 10000;
1909	    yyMinutes = ((yyvsp[(3) - (3)].Number) % 10000)/100;
1910	    yySeconds = (yyvsp[(3) - (3)].Number) % 100;
1911	;}
1912    break;
1913
1914  case 39:
1915
1916    {
1917	    if ((yyvsp[(2) - (7)].Number) != HOUR( 7)) YYABORT;
1918	    yyYear = (yyvsp[(1) - (7)].Number) / 10000;
1919	    yyMonth = ((yyvsp[(1) - (7)].Number) % 10000)/100;
1920	    yyDay = (yyvsp[(1) - (7)].Number) % 100;
1921	    yyHour = (yyvsp[(3) - (7)].Number);
1922	    yyMinutes = (yyvsp[(5) - (7)].Number);
1923	    yySeconds = (yyvsp[(7) - (7)].Number);
1924	;}
1925    break;
1926
1927  case 40:
1928
1929    {
1930	    yyYear = (yyvsp[(1) - (2)].Number) / 10000;
1931	    yyMonth = ((yyvsp[(1) - (2)].Number) % 10000)/100;
1932	    yyDay = (yyvsp[(1) - (2)].Number) % 100;
1933	    yyHour = (yyvsp[(2) - (2)].Number) / 10000;
1934	    yyMinutes = ((yyvsp[(2) - (2)].Number) % 10000)/100;
1935	    yySeconds = (yyvsp[(2) - (2)].Number) % 100;
1936	;}
1937    break;
1938
1939  case 41:
1940
1941    {
1942	    /*
1943	     * Offset computed year by -377 so that the returned years will be
1944	     * in a range accessible with a 32 bit clock seconds value.
1945	     */
1946
1947	    yyYear = (yyvsp[(2) - (4)].Number)/1000 + 2323 - 377;
1948	    yyDay  = 1;
1949	    yyMonth = 1;
1950	    yyRelDay += (((yyvsp[(2) - (4)].Number)%1000)*(365 + IsLeapYear(yyYear)))/1000;
1951	    yyRelSeconds += (yyvsp[(4) - (4)].Number) * 144 * 60;
1952	;}
1953    break;
1954
1955  case 42:
1956
1957    {
1958	    yyRelSeconds *= -1;
1959	    yyRelMonth *= -1;
1960	    yyRelDay *= -1;
1961	;}
1962    break;
1963
1964  case 44:
1965
1966    {
1967	    *yyRelPointer += (yyvsp[(1) - (3)].Number) * (yyvsp[(2) - (3)].Number) * (yyvsp[(3) - (3)].Number);
1968	;}
1969    break;
1970
1971  case 45:
1972
1973    {
1974	    *yyRelPointer += (yyvsp[(1) - (2)].Number) * (yyvsp[(2) - (2)].Number);
1975	;}
1976    break;
1977
1978  case 46:
1979
1980    {
1981	    *yyRelPointer += (yyvsp[(2) - (2)].Number);
1982	;}
1983    break;
1984
1985  case 47:
1986
1987    {
1988	    *yyRelPointer += (yyvsp[(2) - (3)].Number) * (yyvsp[(3) - (3)].Number);
1989	;}
1990    break;
1991
1992  case 48:
1993
1994    {
1995	    *yyRelPointer += (yyvsp[(1) - (1)].Number);
1996	;}
1997    break;
1998
1999  case 49:
2000
2001    {
2002	    (yyval.Number) = -1;
2003	;}
2004    break;
2005
2006  case 50:
2007
2008    {
2009	    (yyval.Number) =  1;
2010	;}
2011    break;
2012
2013  case 51:
2014
2015    {
2016	    (yyval.Number) = (yyvsp[(1) - (1)].Number);
2017	    yyRelPointer = &yyRelSeconds;
2018	;}
2019    break;
2020
2021  case 52:
2022
2023    {
2024	    (yyval.Number) = (yyvsp[(1) - (1)].Number);
2025	    yyRelPointer = &yyRelDay;
2026	;}
2027    break;
2028
2029  case 53:
2030
2031    {
2032	    (yyval.Number) = (yyvsp[(1) - (1)].Number);
2033	    yyRelPointer = &yyRelMonth;
2034	;}
2035    break;
2036
2037  case 54:
2038
2039    {
2040	    if (yyHaveTime && yyHaveDate && !yyHaveRel) {
2041		yyYear = (yyvsp[(1) - (1)].Number);
2042	    } else {
2043		yyHaveTime++;
2044		if (yyDigitCount <= 2) {
2045		    yyHour = (yyvsp[(1) - (1)].Number);
2046		    yyMinutes = 0;
2047		} else {
2048		    yyHour = (yyvsp[(1) - (1)].Number) / 100;
2049		    yyMinutes = (yyvsp[(1) - (1)].Number) % 100;
2050		}
2051		yySeconds = 0;
2052		yyMeridian = MER24;
2053	    }
2054	;}
2055    break;
2056
2057  case 55:
2058
2059    {
2060	    (yyval.Meridian) = MER24;
2061	;}
2062    break;
2063
2064  case 56:
2065
2066    {
2067	    (yyval.Meridian) = (yyvsp[(1) - (1)].Meridian);
2068	;}
2069    break;
2070
2071
2072/* Line 1267 of yacc.c.  */
2073
2074      default: break;
2075    }
2076  YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
2077
2078  YYPOPSTACK (yylen);
2079  yylen = 0;
2080  YY_STACK_PRINT (yyss, yyssp);
2081
2082  *++yyvsp = yyval;
2083  *++yylsp = yyloc;
2084
2085  /* Now `shift' the result of the reduction.  Determine what state
2086     that goes to, based on the state we popped back to and the rule
2087     number reduced by.  */
2088
2089  yyn = yyr1[yyn];
2090
2091  yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
2092  if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
2093    yystate = yytable[yystate];
2094  else
2095    yystate = yydefgoto[yyn - YYNTOKENS];
2096
2097  goto yynewstate;
2098
2099
2100/*------------------------------------.
2101| yyerrlab -- here on detecting error |
2102`------------------------------------*/
2103yyerrlab:
2104  /* If not already recovering from an error, report this error.  */
2105  if (!yyerrstatus)
2106    {
2107      ++yynerrs;
2108#if ! YYERROR_VERBOSE
2109      yyerror (&yylloc, info, YY_("syntax error"));
2110#else
2111      {
2112	YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
2113	if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
2114	  {
2115	    YYSIZE_T yyalloc = 2 * yysize;
2116	    if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
2117	      yyalloc = YYSTACK_ALLOC_MAXIMUM;
2118	    if (yymsg != yymsgbuf)
2119	      YYSTACK_FREE (yymsg);
2120	    yymsg = (char *) YYSTACK_ALLOC (yyalloc);
2121	    if (yymsg)
2122	      yymsg_alloc = yyalloc;
2123	    else
2124	      {
2125		yymsg = yymsgbuf;
2126		yymsg_alloc = sizeof yymsgbuf;
2127	      }
2128	  }
2129
2130	if (0 < yysize && yysize <= yymsg_alloc)
2131	  {
2132	    (void) yysyntax_error (yymsg, yystate, yychar);
2133	    yyerror (&yylloc, info, yymsg);
2134	  }
2135	else
2136	  {
2137	    yyerror (&yylloc, info, YY_("syntax error"));
2138	    if (yysize != 0)
2139	      goto yyexhaustedlab;
2140	  }
2141      }
2142#endif
2143    }
2144
2145  yyerror_range[0] = yylloc;
2146
2147  if (yyerrstatus == 3)
2148    {
2149      /* If just tried and failed to reuse look-ahead token after an
2150	 error, discard it.  */
2151
2152      if (yychar <= YYEOF)
2153	{
2154	  /* Return failure if at end of input.  */
2155	  if (yychar == YYEOF)
2156	    YYABORT;
2157	}
2158      else
2159	{
2160	  yydestruct ("Error: discarding",
2161		      yytoken, &yylval, &yylloc, info);
2162	  yychar = YYEMPTY;
2163	}
2164    }
2165
2166  /* Else will try to reuse look-ahead token after shifting the error
2167     token.  */
2168  goto yyerrlab1;
2169
2170
2171/*---------------------------------------------------.
2172| yyerrorlab -- error raised explicitly by YYERROR.  |
2173`---------------------------------------------------*/
2174yyerrorlab:
2175
2176  /* Pacify compilers like GCC when the user code never invokes
2177     YYERROR and the label yyerrorlab therefore never appears in user
2178     code.  */
2179  if (/*CONSTCOND*/ 0)
2180     goto yyerrorlab;
2181
2182  yyerror_range[0] = yylsp[1-yylen];
2183  /* Do not reclaim the symbols of the rule which action triggered
2184     this YYERROR.  */
2185  YYPOPSTACK (yylen);
2186  yylen = 0;
2187  YY_STACK_PRINT (yyss, yyssp);
2188  yystate = *yyssp;
2189  goto yyerrlab1;
2190
2191
2192/*-------------------------------------------------------------.
2193| yyerrlab1 -- common code for both syntax error and YYERROR.  |
2194`-------------------------------------------------------------*/
2195yyerrlab1:
2196  yyerrstatus = 3;	/* Each real token shifted decrements this.  */
2197
2198  for (;;)
2199    {
2200      yyn = yypact[yystate];
2201      if (yyn != YYPACT_NINF)
2202	{
2203	  yyn += YYTERROR;
2204	  if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
2205	    {
2206	      yyn = yytable[yyn];
2207	      if (0 < yyn)
2208		break;
2209	    }
2210	}
2211
2212      /* Pop the current state because it cannot handle the error token.  */
2213      if (yyssp == yyss)
2214	YYABORT;
2215
2216      yyerror_range[0] = *yylsp;
2217      yydestruct ("Error: popping",
2218		  yystos[yystate], yyvsp, yylsp, info);
2219      YYPOPSTACK (1);
2220      yystate = *yyssp;
2221      YY_STACK_PRINT (yyss, yyssp);
2222    }
2223
2224  if (yyn == YYFINAL)
2225    YYACCEPT;
2226
2227  *++yyvsp = yylval;
2228
2229  yyerror_range[1] = yylloc;
2230  /* Using YYLLOC is tempting, but would change the location of
2231     the look-ahead.  YYLOC is available though.  */
2232  YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2);
2233  *++yylsp = yyloc;
2234
2235  /* Shift the error token.  */
2236  YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
2237
2238  yystate = yyn;
2239  goto yynewstate;
2240
2241
2242/*-------------------------------------.
2243| yyacceptlab -- YYACCEPT comes here.  |
2244`-------------------------------------*/
2245yyacceptlab:
2246  yyresult = 0;
2247  goto yyreturn;
2248
2249/*-----------------------------------.
2250| yyabortlab -- YYABORT comes here.  |
2251`-----------------------------------*/
2252yyabortlab:
2253  yyresult = 1;
2254  goto yyreturn;
2255
2256#ifndef yyoverflow
2257/*-------------------------------------------------.
2258| yyexhaustedlab -- memory exhaustion comes here.  |
2259`-------------------------------------------------*/
2260yyexhaustedlab:
2261  yyerror (&yylloc, info, YY_("memory exhausted"));
2262  yyresult = 2;
2263  /* Fall through.  */
2264#endif
2265
2266yyreturn:
2267  if (yychar != YYEOF && yychar != YYEMPTY)
2268     yydestruct ("Cleanup: discarding lookahead",
2269		 yytoken, &yylval, &yylloc, info);
2270  /* Do not reclaim the symbols of the rule which action triggered
2271     this YYABORT or YYACCEPT.  */
2272  YYPOPSTACK (yylen);
2273  YY_STACK_PRINT (yyss, yyssp);
2274  while (yyssp != yyss)
2275    {
2276      yydestruct ("Cleanup: popping",
2277		  yystos[*yyssp], yyvsp, yylsp, info);
2278      YYPOPSTACK (1);
2279    }
2280#ifndef yyoverflow
2281  if (yyss != yyssa)
2282    YYSTACK_FREE (yyss);
2283#endif
2284#if YYERROR_VERBOSE
2285  if (yymsg != yymsgbuf)
2286    YYSTACK_FREE (yymsg);
2287#endif
2288  /* Make sure YYID is used.  */
2289  return YYID (yyresult);
2290}
2291
2292
2293
2294
2295MODULE_SCOPE int yychar;
2296MODULE_SCOPE YYSTYPE yylval;
2297MODULE_SCOPE int yynerrs;
2298
2299/*
2300 * Month and day table.
2301 */
2302
2303static TABLE MonthDayTable[] = {
2304    { "january",	tMONTH,	 1 },
2305    { "february",	tMONTH,	 2 },
2306    { "march",		tMONTH,	 3 },
2307    { "april",		tMONTH,	 4 },
2308    { "may",		tMONTH,	 5 },
2309    { "june",		tMONTH,	 6 },
2310    { "july",		tMONTH,	 7 },
2311    { "august",		tMONTH,	 8 },
2312    { "september",	tMONTH,	 9 },
2313    { "sept",		tMONTH,	 9 },
2314    { "october",	tMONTH, 10 },
2315    { "november",	tMONTH, 11 },
2316    { "december",	tMONTH, 12 },
2317    { "sunday",		tDAY, 0 },
2318    { "monday",		tDAY, 1 },
2319    { "tuesday",	tDAY, 2 },
2320    { "tues",		tDAY, 2 },
2321    { "wednesday",	tDAY, 3 },
2322    { "wednes",		tDAY, 3 },
2323    { "thursday",	tDAY, 4 },
2324    { "thur",		tDAY, 4 },
2325    { "thurs",		tDAY, 4 },
2326    { "friday",		tDAY, 5 },
2327    { "saturday",	tDAY, 6 },
2328    { NULL }
2329};
2330
2331/*
2332 * Time units table.
2333 */
2334
2335static TABLE UnitsTable[] = {
2336    { "year",		tMONTH_UNIT,	12 },
2337    { "month",		tMONTH_UNIT,	 1 },
2338    { "fortnight",	tDAY_UNIT,	14 },
2339    { "week",		tDAY_UNIT,	 7 },
2340    { "day",		tDAY_UNIT,	 1 },
2341    { "hour",		tSEC_UNIT, 60 * 60 },
2342    { "minute",		tSEC_UNIT,	60 },
2343    { "min",		tSEC_UNIT,	60 },
2344    { "second",		tSEC_UNIT,	 1 },
2345    { "sec",		tSEC_UNIT,	 1 },
2346    { NULL }
2347};
2348
2349/*
2350 * Assorted relative-time words.
2351 */
2352
2353static TABLE OtherTable[] = {
2354    { "tomorrow",	tDAY_UNIT,	1 },
2355    { "yesterday",	tDAY_UNIT,	-1 },
2356    { "today",		tDAY_UNIT,	0 },
2357    { "now",		tSEC_UNIT,	0 },
2358    { "last",		tUNUMBER,	-1 },
2359    { "this",		tSEC_UNIT,	0 },
2360    { "next",		tNEXT,		1 },
2361#if 0
2362    { "first",		tUNUMBER,	1 },
2363    { "second",		tUNUMBER,	2 },
2364    { "third",		tUNUMBER,	3 },
2365    { "fourth",		tUNUMBER,	4 },
2366    { "fifth",		tUNUMBER,	5 },
2367    { "sixth",		tUNUMBER,	6 },
2368    { "seventh",	tUNUMBER,	7 },
2369    { "eighth",		tUNUMBER,	8 },
2370    { "ninth",		tUNUMBER,	9 },
2371    { "tenth",		tUNUMBER,	10 },
2372    { "eleventh",	tUNUMBER,	11 },
2373    { "twelfth",	tUNUMBER,	12 },
2374#endif
2375    { "ago",		tAGO,		1 },
2376    { "epoch",		tEPOCH,		0 },
2377    { "stardate",	tSTARDATE,	0 },
2378    { NULL }
2379};
2380
2381/*
2382 * The timezone table. (Note: This table was modified to not use any floating
2383 * point constants to work around an SGI compiler bug).
2384 */
2385
2386static TABLE TimezoneTable[] = {
2387    { "gmt",	tZONE,	   HOUR( 0) },	    /* Greenwich Mean */
2388    { "ut",	tZONE,	   HOUR( 0) },	    /* Universal (Coordinated) */
2389    { "utc",	tZONE,	   HOUR( 0) },
2390    { "uct",	tZONE,	   HOUR( 0) },	    /* Universal Coordinated Time */
2391    { "wet",	tZONE,	   HOUR( 0) },	    /* Western European */
2392    { "bst",	tDAYZONE,  HOUR( 0) },	    /* British Summer */
2393    { "wat",	tZONE,	   HOUR( 1) },	    /* West Africa */
2394    { "at",	tZONE,	   HOUR( 2) },	    /* Azores */
2395#if	0
2396    /* For completeness.  BST is also British Summer, and GST is
2397     * also Guam Standard. */
2398    { "bst",	tZONE,	   HOUR( 3) },	    /* Brazil Standard */
2399    { "gst",	tZONE,	   HOUR( 3) },	    /* Greenland Standard */
2400#endif
2401    { "nft",	tZONE,	   HOUR( 7/2) },    /* Newfoundland */
2402    { "nst",	tZONE,	   HOUR( 7/2) },    /* Newfoundland Standard */
2403    { "ndt",	tDAYZONE,  HOUR( 7/2) },    /* Newfoundland Daylight */
2404    { "ast",	tZONE,	   HOUR( 4) },	    /* Atlantic Standard */
2405    { "adt",	tDAYZONE,  HOUR( 4) },	    /* Atlantic Daylight */
2406    { "est",	tZONE,	   HOUR( 5) },	    /* Eastern Standard */
2407    { "edt",	tDAYZONE,  HOUR( 5) },	    /* Eastern Daylight */
2408    { "cst",	tZONE,	   HOUR( 6) },	    /* Central Standard */
2409    { "cdt",	tDAYZONE,  HOUR( 6) },	    /* Central Daylight */
2410    { "mst",	tZONE,	   HOUR( 7) },	    /* Mountain Standard */
2411    { "mdt",	tDAYZONE,  HOUR( 7) },	    /* Mountain Daylight */
2412    { "pst",	tZONE,	   HOUR( 8) },	    /* Pacific Standard */
2413    { "pdt",	tDAYZONE,  HOUR( 8) },	    /* Pacific Daylight */
2414    { "yst",	tZONE,	   HOUR( 9) },	    /* Yukon Standard */
2415    { "ydt",	tDAYZONE,  HOUR( 9) },	    /* Yukon Daylight */
2416    { "hst",	tZONE,	   HOUR(10) },	    /* Hawaii Standard */
2417    { "hdt",	tDAYZONE,  HOUR(10) },	    /* Hawaii Daylight */
2418    { "cat",	tZONE,	   HOUR(10) },	    /* Central Alaska */
2419    { "ahst",	tZONE,	   HOUR(10) },	    /* Alaska-Hawaii Standard */
2420    { "nt",	tZONE,	   HOUR(11) },	    /* Nome */
2421    { "idlw",	tZONE,	   HOUR(12) },	    /* International Date Line West */
2422    { "cet",	tZONE,	  -HOUR( 1) },	    /* Central European */
2423    { "cest",	tDAYZONE, -HOUR( 1) },	    /* Central European Summer */
2424    { "met",	tZONE,	  -HOUR( 1) },	    /* Middle European */
2425    { "mewt",	tZONE,	  -HOUR( 1) },	    /* Middle European Winter */
2426    { "mest",	tDAYZONE, -HOUR( 1) },	    /* Middle European Summer */
2427    { "swt",	tZONE,	  -HOUR( 1) },	    /* Swedish Winter */
2428    { "sst",	tDAYZONE, -HOUR( 1) },	    /* Swedish Summer */
2429    { "fwt",	tZONE,	  -HOUR( 1) },	    /* French Winter */
2430    { "fst",	tDAYZONE, -HOUR( 1) },	    /* French Summer */
2431    { "eet",	tZONE,	  -HOUR( 2) },	    /* Eastern Europe, USSR Zone 1 */
2432    { "bt",	tZONE,	  -HOUR( 3) },	    /* Baghdad, USSR Zone 2 */
2433    { "it",	tZONE,	  -HOUR( 7/2) },    /* Iran */
2434    { "zp4",	tZONE,	  -HOUR( 4) },	    /* USSR Zone 3 */
2435    { "zp5",	tZONE,	  -HOUR( 5) },	    /* USSR Zone 4 */
2436    { "ist",	tZONE,	  -HOUR(11/2) },    /* Indian Standard */
2437    { "zp6",	tZONE,	  -HOUR( 6) },	    /* USSR Zone 5 */
2438#if	0
2439    /* For completeness.  NST is also Newfoundland Stanard, nad SST is
2440     * also Swedish Summer. */
2441    { "nst",	tZONE,	  -HOUR(13/2) },    /* North Sumatra */
2442    { "sst",	tZONE,	  -HOUR( 7) },	    /* South Sumatra, USSR Zone 6 */
2443#endif	/* 0 */
2444    { "wast",	tZONE,	  -HOUR( 7) },	    /* West Australian Standard */
2445    { "wadt",	tDAYZONE, -HOUR( 7) },	    /* West Australian Daylight */
2446    { "jt",	tZONE,	  -HOUR(15/2) },    /* Java (3pm in Cronusland!) */
2447    { "cct",	tZONE,	  -HOUR( 8) },	    /* China Coast, USSR Zone 7 */
2448    { "jst",	tZONE,	  -HOUR( 9) },	    /* Japan Standard, USSR Zone 8 */
2449    { "jdt",	tDAYZONE, -HOUR( 9) },	    /* Japan Daylight */
2450    { "kst",	tZONE,	  -HOUR( 9) },	    /* Korea Standard */
2451    { "kdt",	tDAYZONE, -HOUR( 9) },	    /* Korea Daylight */
2452    { "cast",	tZONE,	  -HOUR(19/2) },    /* Central Australian Standard */
2453    { "cadt",	tDAYZONE, -HOUR(19/2) },    /* Central Australian Daylight */
2454    { "east",	tZONE,	  -HOUR(10) },	    /* Eastern Australian Standard */
2455    { "eadt",	tDAYZONE, -HOUR(10) },	    /* Eastern Australian Daylight */
2456    { "gst",	tZONE,	  -HOUR(10) },	    /* Guam Standard, USSR Zone 9 */
2457    { "nzt",	tZONE,	  -HOUR(12) },	    /* New Zealand */
2458    { "nzst",	tZONE,	  -HOUR(12) },	    /* New Zealand Standard */
2459    { "nzdt",	tDAYZONE, -HOUR(12) },	    /* New Zealand Daylight */
2460    { "idle",	tZONE,	  -HOUR(12) },	    /* International Date Line East */
2461    /* ADDED BY Marco Nijdam */
2462    { "dst",	tDST,	  HOUR( 0) },	    /* DST on (hour is ignored) */
2463    /* End ADDED */
2464    {  NULL  }
2465};
2466
2467/*
2468 * Military timezone table.
2469 */
2470
2471static TABLE	MilitaryTable[] = {
2472    { "a",	tZONE,	-HOUR( 1) },
2473    { "b",	tZONE,	-HOUR( 2) },
2474    { "c",	tZONE,	-HOUR( 3) },
2475    { "d",	tZONE,	-HOUR( 4) },
2476    { "e",	tZONE,	-HOUR( 5) },
2477    { "f",	tZONE,	-HOUR( 6) },
2478    { "g",	tZONE,	-HOUR( 7) },
2479    { "h",	tZONE,	-HOUR( 8) },
2480    { "i",	tZONE,	-HOUR( 9) },
2481    { "k",	tZONE,	-HOUR(10) },
2482    { "l",	tZONE,	-HOUR(11) },
2483    { "m",	tZONE,	-HOUR(12) },
2484    { "n",	tZONE,	HOUR(  1) },
2485    { "o",	tZONE,	HOUR(  2) },
2486    { "p",	tZONE,	HOUR(  3) },
2487    { "q",	tZONE,	HOUR(  4) },
2488    { "r",	tZONE,	HOUR(  5) },
2489    { "s",	tZONE,	HOUR(  6) },
2490    { "t",	tZONE,	HOUR(  7) },
2491    { "u",	tZONE,	HOUR(  8) },
2492    { "v",	tZONE,	HOUR(  9) },
2493    { "w",	tZONE,	HOUR( 10) },
2494    { "x",	tZONE,	HOUR( 11) },
2495    { "y",	tZONE,	HOUR( 12) },
2496    { "z",	tZONE,	HOUR( 0) },
2497    { NULL }
2498};
2499
2500/*
2501 * Dump error messages in the bit bucket.
2502 */
2503
2504static void
2505TclDateerror(
2506    YYLTYPE* location,
2507    DateInfo* infoPtr,
2508    const char *s)
2509{
2510    Tcl_Obj* t;
2511    Tcl_AppendToObj(infoPtr->messages, infoPtr->separatrix, -1);
2512    Tcl_AppendToObj(infoPtr->messages, s, -1);
2513    Tcl_AppendToObj(infoPtr->messages, " (characters ", -1);
2514    t = Tcl_NewIntObj(location->first_column);
2515    Tcl_IncrRefCount(t);
2516    Tcl_AppendObjToObj(infoPtr->messages, t);
2517    Tcl_DecrRefCount(t);
2518    Tcl_AppendToObj(infoPtr->messages, "-", -1);
2519    t = Tcl_NewIntObj(location->last_column);
2520    Tcl_IncrRefCount(t);
2521    Tcl_AppendObjToObj(infoPtr->messages, t);
2522    Tcl_DecrRefCount(t);
2523    Tcl_AppendToObj(infoPtr->messages, ")", -1);
2524    infoPtr->separatrix = "\n";
2525}
2526
2527static time_t
2528ToSeconds(
2529    time_t Hours,
2530    time_t Minutes,
2531    time_t Seconds,
2532    MERIDIAN Meridian)
2533{
2534    if (Minutes < 0 || Minutes > 59 || Seconds < 0 || Seconds > 59) {
2535	return -1;
2536    }
2537    switch (Meridian) {
2538    case MER24:
2539	if (Hours < 0 || Hours > 23) {
2540	    return -1;
2541	}
2542	return (Hours * 60L + Minutes) * 60L + Seconds;
2543    case MERam:
2544	if (Hours < 1 || Hours > 12) {
2545	    return -1;
2546	}
2547	return ((Hours % 12) * 60L + Minutes) * 60L + Seconds;
2548    case MERpm:
2549	if (Hours < 1 || Hours > 12) {
2550	    return -1;
2551	}
2552	return (((Hours % 12) + 12) * 60L + Minutes) * 60L + Seconds;
2553    }
2554    return -1;			/* Should never be reached */
2555}
2556
2557static int
2558LookupWord(
2559    YYSTYPE* yylvalPtr,
2560    char *buff)
2561{
2562    register char *p;
2563    register char *q;
2564    register TABLE *tp;
2565    int i, abbrev;
2566
2567    /*
2568     * Make it lowercase.
2569     */
2570
2571    Tcl_UtfToLower(buff);
2572
2573    if (strcmp(buff, "am") == 0 || strcmp(buff, "a.m.") == 0) {
2574	yylvalPtr->Meridian = MERam;
2575	return tMERIDIAN;
2576    }
2577    if (strcmp(buff, "pm") == 0 || strcmp(buff, "p.m.") == 0) {
2578	yylvalPtr->Meridian = MERpm;
2579	return tMERIDIAN;
2580    }
2581
2582    /*
2583     * See if we have an abbreviation for a month.
2584     */
2585
2586    if (strlen(buff) == 3) {
2587	abbrev = 1;
2588    } else if (strlen(buff) == 4 && buff[3] == '.') {
2589	abbrev = 1;
2590	buff[3] = '\0';
2591    } else {
2592	abbrev = 0;
2593    }
2594
2595    for (tp = MonthDayTable; tp->name; tp++) {
2596	if (abbrev) {
2597	    if (strncmp(buff, tp->name, 3) == 0) {
2598		yylvalPtr->Number = tp->value;
2599		return tp->type;
2600	    }
2601	} else if (strcmp(buff, tp->name) == 0) {
2602	    yylvalPtr->Number = tp->value;
2603	    return tp->type;
2604	}
2605    }
2606
2607    for (tp = TimezoneTable; tp->name; tp++) {
2608	if (strcmp(buff, tp->name) == 0) {
2609	    yylvalPtr->Number = tp->value;
2610	    return tp->type;
2611	}
2612    }
2613
2614    for (tp = UnitsTable; tp->name; tp++) {
2615	if (strcmp(buff, tp->name) == 0) {
2616	    yylvalPtr->Number = tp->value;
2617	    return tp->type;
2618	}
2619    }
2620
2621    /*
2622     * Strip off any plural and try the units table again.
2623     */
2624
2625    i = strlen(buff) - 1;
2626    if (i > 0 && buff[i] == 's') {
2627	buff[i] = '\0';
2628	for (tp = UnitsTable; tp->name; tp++) {
2629	    if (strcmp(buff, tp->name) == 0) {
2630		yylvalPtr->Number = tp->value;
2631		return tp->type;
2632	    }
2633	}
2634    }
2635
2636    for (tp = OtherTable; tp->name; tp++) {
2637	if (strcmp(buff, tp->name) == 0) {
2638	    yylvalPtr->Number = tp->value;
2639	    return tp->type;
2640	}
2641    }
2642
2643    /*
2644     * Military timezones.
2645     */
2646
2647    if (buff[1] == '\0' && !(*buff & 0x80)
2648	    && isalpha(UCHAR(*buff))) {			/* INTL: ISO only */
2649	for (tp = MilitaryTable; tp->name; tp++) {
2650	    if (strcmp(buff, tp->name) == 0) {
2651		yylvalPtr->Number = tp->value;
2652		return tp->type;
2653	    }
2654	}
2655    }
2656
2657    /*
2658     * Drop out any periods and try the timezone table again.
2659     */
2660
2661    for (i = 0, p = q = buff; *q; q++) {
2662	if (*q != '.') {
2663	    *p++ = *q;
2664	} else {
2665	    i++;
2666	}
2667    }
2668    *p = '\0';
2669    if (i) {
2670	for (tp = TimezoneTable; tp->name; tp++) {
2671	    if (strcmp(buff, tp->name) == 0) {
2672		yylvalPtr->Number = tp->value;
2673		return tp->type;
2674	    }
2675	}
2676    }
2677
2678    return tID;
2679}
2680
2681static int
2682TclDatelex(
2683    YYSTYPE* yylvalPtr,
2684    YYLTYPE* location,
2685    DateInfo *info)
2686{
2687    register char c;
2688    register char *p;
2689    char buff[20];
2690    int Count;
2691
2692    location->first_column = yyInput - info->dateStart;
2693    for ( ; ; ) {
2694	while (isspace(UCHAR(*yyInput))) {
2695	    yyInput++;
2696	}
2697
2698	if (isdigit(UCHAR(c = *yyInput))) { /* INTL: digit */
2699	    /*
2700	     * Convert the string into a number; count the number of digits.
2701	     */
2702
2703	    Count = 0;
2704	    for (yylvalPtr->Number = 0;
2705		    isdigit(UCHAR(c = *yyInput++)); ) {	  /* INTL: digit */
2706		yylvalPtr->Number = 10 * yylvalPtr->Number + c - '0';
2707		Count++;
2708	    }
2709	    yyInput--;
2710	    yyDigitCount = Count;
2711
2712	    /*
2713	     * A number with 6 or more digits is considered an ISO 8601 base.
2714	     */
2715
2716	    if (Count >= 6) {
2717		location->last_column = yyInput - info->dateStart - 1;
2718		return tISOBASE;
2719	    } else {
2720		location->last_column = yyInput - info->dateStart - 1;
2721		return tUNUMBER;
2722	    }
2723	}
2724	if (!(c & 0x80) && isalpha(UCHAR(c))) {		  /* INTL: ISO only. */
2725	    for (p = buff; isalpha(UCHAR(c = *yyInput++)) /* INTL: ISO only. */
2726		     || c == '.'; ) {
2727		if (p < &buff[sizeof buff - 1]) {
2728		    *p++ = c;
2729		}
2730	    }
2731	    *p = '\0';
2732	    yyInput--;
2733	    location->last_column = yyInput - info->dateStart - 1;
2734	    return LookupWord(yylvalPtr, buff);
2735	}
2736	if (c != '(') {
2737	    location->last_column = yyInput - info->dateStart;
2738	    return *yyInput++;
2739	}
2740	Count = 0;
2741	do {
2742	    c = *yyInput++;
2743	    if (c == '\0') {
2744		location->last_column = yyInput - info->dateStart - 1;
2745		return c;
2746	    } else if (c == '(') {
2747		Count++;
2748	    } else if (c == ')') {
2749		Count--;
2750	    }
2751	} while (Count > 0);
2752    }
2753}
2754
2755int
2756TclClockOldscanObjCmd(
2757    ClientData clientData,	/* Unused */
2758    Tcl_Interp *interp,		/* Tcl interpreter */
2759    int objc,			/* Count of paraneters */
2760    Tcl_Obj *CONST *objv)	/* Parameters */
2761{
2762    Tcl_Obj *result, *resultElement;
2763    int yr, mo, da;
2764    DateInfo dateInfo;
2765    DateInfo* info = &dateInfo;
2766    int status;
2767
2768    if (objc != 5) {
2769	Tcl_WrongNumArgs(interp, 1, objv,
2770		"stringToParse baseYear baseMonth baseDay" );
2771	return TCL_ERROR;
2772    }
2773
2774    yyInput = Tcl_GetString( objv[1] );
2775    dateInfo.dateStart = yyInput;
2776
2777    yyHaveDate = 0;
2778    if (Tcl_GetIntFromObj(interp, objv[2], &yr) != TCL_OK
2779	    || Tcl_GetIntFromObj(interp, objv[3], &mo) != TCL_OK
2780	    || Tcl_GetIntFromObj(interp, objv[4], &da) != TCL_OK) {
2781	return TCL_ERROR;
2782    }
2783    yyYear = yr; yyMonth = mo; yyDay = da;
2784
2785    yyHaveTime = 0;
2786    yyHour = 0; yyMinutes = 0; yySeconds = 0; yyMeridian = MER24;
2787
2788    yyHaveZone = 0;
2789    yyTimezone = 0; yyDSTmode = DSTmaybe;
2790
2791    yyHaveOrdinalMonth = 0;
2792    yyMonthOrdinal = 0;
2793
2794    yyHaveDay = 0;
2795    yyDayOrdinal = 0; yyDayNumber = 0;
2796
2797    yyHaveRel = 0;
2798    yyRelMonth = 0; yyRelDay = 0; yyRelSeconds = 0; yyRelPointer = NULL;
2799
2800    dateInfo.messages = Tcl_NewObj();
2801    dateInfo.separatrix = "";
2802    Tcl_IncrRefCount(dateInfo.messages);
2803
2804    status = yyparse(&dateInfo);
2805    if (status == 1) {
2806	Tcl_SetObjResult(interp, dateInfo.messages);
2807	Tcl_DecrRefCount(dateInfo.messages);
2808	return TCL_ERROR;
2809    } else if (status == 2) {
2810	Tcl_SetObjResult(interp, Tcl_NewStringObj("memory exhausted", -1));
2811	Tcl_DecrRefCount(dateInfo.messages);
2812	return TCL_ERROR;
2813    } else if (status != 0) {
2814	Tcl_SetObjResult(interp, Tcl_NewStringObj("Unknown status returned "
2815						  "from date parser. Please "
2816						  "report this error as a "
2817						  "bug in Tcl.", -1));
2818	Tcl_DecrRefCount(dateInfo.messages);
2819	return TCL_ERROR;
2820    }
2821    Tcl_DecrRefCount(dateInfo.messages);
2822
2823    if (yyHaveDate > 1) {
2824	Tcl_SetObjResult(interp,
2825		Tcl_NewStringObj("more than one date in string", -1));
2826	return TCL_ERROR;
2827    }
2828    if (yyHaveTime > 1) {
2829	Tcl_SetObjResult(interp,
2830		Tcl_NewStringObj("more than one time of day in string", -1));
2831	return TCL_ERROR;
2832    }
2833    if (yyHaveZone > 1) {
2834	Tcl_SetObjResult(interp,
2835		Tcl_NewStringObj("more than one time zone in string", -1));
2836	return TCL_ERROR;
2837    }
2838    if (yyHaveDay > 1) {
2839	Tcl_SetObjResult(interp,
2840		Tcl_NewStringObj("more than one weekday in string", -1));
2841	return TCL_ERROR;
2842    }
2843    if (yyHaveOrdinalMonth > 1) {
2844	Tcl_SetObjResult(interp,
2845		Tcl_NewStringObj("more than one ordinal month in string", -1));
2846	return TCL_ERROR;
2847    }
2848
2849    result = Tcl_NewObj();
2850    resultElement = Tcl_NewObj();
2851    if (yyHaveDate) {
2852	Tcl_ListObjAppendElement(interp, resultElement,
2853		Tcl_NewIntObj((int) yyYear));
2854	Tcl_ListObjAppendElement(interp, resultElement,
2855		Tcl_NewIntObj((int) yyMonth));
2856	Tcl_ListObjAppendElement(interp, resultElement,
2857		Tcl_NewIntObj((int) yyDay));
2858    }
2859    Tcl_ListObjAppendElement(interp, result, resultElement);
2860
2861    if (yyHaveTime) {
2862	Tcl_ListObjAppendElement(interp, result, Tcl_NewIntObj((int)
2863		ToSeconds(yyHour, yyMinutes, yySeconds, yyMeridian)));
2864    } else {
2865	Tcl_ListObjAppendElement(interp, result, Tcl_NewObj());
2866    }
2867
2868    resultElement = Tcl_NewObj();
2869    if (yyHaveZone) {
2870	Tcl_ListObjAppendElement(interp, resultElement,
2871		Tcl_NewIntObj((int) -yyTimezone));
2872	Tcl_ListObjAppendElement(interp, resultElement,
2873		Tcl_NewIntObj(1 - yyDSTmode));
2874    }
2875    Tcl_ListObjAppendElement(interp, result, resultElement);
2876
2877    resultElement = Tcl_NewObj();
2878    if (yyHaveRel) {
2879	Tcl_ListObjAppendElement(interp, resultElement,
2880		Tcl_NewIntObj((int) yyRelMonth));
2881	Tcl_ListObjAppendElement(interp, resultElement,
2882		Tcl_NewIntObj((int) yyRelDay));
2883	Tcl_ListObjAppendElement(interp, resultElement,
2884		Tcl_NewIntObj((int) yyRelSeconds));
2885    }
2886    Tcl_ListObjAppendElement(interp, result, resultElement);
2887
2888    resultElement = Tcl_NewObj();
2889    if (yyHaveDay && !yyHaveDate) {
2890	Tcl_ListObjAppendElement(interp, resultElement,
2891		Tcl_NewIntObj((int) yyDayOrdinal));
2892	Tcl_ListObjAppendElement(interp, resultElement,
2893		Tcl_NewIntObj((int) yyDayNumber));
2894    }
2895    Tcl_ListObjAppendElement(interp, result, resultElement);
2896
2897    resultElement = Tcl_NewObj();
2898    if (yyHaveOrdinalMonth) {
2899	Tcl_ListObjAppendElement(interp, resultElement,
2900		Tcl_NewIntObj((int) yyMonthOrdinal));
2901	Tcl_ListObjAppendElement(interp, resultElement,
2902		Tcl_NewIntObj((int) yyMonth));
2903    }
2904    Tcl_ListObjAppendElement(interp, result, resultElement);
2905
2906    Tcl_SetObjResult(interp, result);
2907    return TCL_OK;
2908}
2909
2910/*
2911 * Local Variables:
2912 * mode: c
2913 * c-basic-offset: 4
2914 * fill-column: 78
2915 * End:
2916 */
2917
2918