Debian Codegraph @

generic/tclDate.c

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