1
/* A Bison parser, made by GNU Bison 2.1. */
3
/* Skeleton parser for Yacc-like parsing with Bison,
4
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
6
This program is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2, or (at your option)
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU General Public License for more details.
16
You should have received a copy of the GNU General Public License
17
along with this program; if not, write to the Free Software
18
Foundation, Inc., 51 Franklin Street, Fifth Floor,
19
Boston, MA 02110-1301, USA. */
21
/* As a special exception, when this file is copied by Bison into a
22
Bison output file, you may use that output file without restriction.
23
This special exception was added by the Free Software Foundation
24
in version 1.24 of Bison. */
26
/* Written by Richard Stallman by simplifying the original so called
27
``semantic'' parser. */
29
/* All symbols defined below should begin with yy or YY, to avoid
30
infringing on user name space. This should be done even for local
31
variables, as they might otherwise be expanded by user macros.
32
There are some unavoidable exceptions within include files to
33
define necessary library symbols; they are noted "INFRINGES ON
34
USER NAME SPACE" below. */
36
/* Identify Bison output. */
40
#define YYBISON_VERSION "2.1"
43
#define YYSKELETON_NAME "yacc.c"
48
/* Using locations. */
49
#define YYLSP_NEEDED 0
51
/* Substitute the variable and function names. */
52
#define yyparse lu_gdparse
53
#define yylex lu_gdlex
54
#define yyerror lu_gderror
55
#define yylval lu_gdlval
56
#define yychar lu_gdchar
57
#define yydebug lu_gddebug
58
#define yynerrs lu_gdnerrs
64
/* Put the tokens into the symbol table, so that GDB and other debuggers
91
#define tHOUR_UNIT 263
94
#define tMINUTE_UNIT 266
96
#define tMONTH_UNIT 268
100
#define tYEAR_UNIT 272
106
/* Copy the first part of user declarations. */
107
#line 1 "lib/getdate.y"
110
** Originally written by Steven M. Bellovin <smb@research.att.com> while
111
** at the University of North Carolina at Chapel Hill. Later tweaked by
112
** a couple of people on Usenet. Completely overhauled by Rich $alz
113
** <rsalz@bbn.com> and Jim Berets <jberets@bbn.com> in August, 1990;
115
** This grammar has 13 shift/reduce conflicts.
117
** This code is in the public domain and has no copyright.
124
/* Since the code of getdate.y is not included in the Emacs executable
125
itself, there is no need to #define static in this file. Even if
126
the code were included in the Emacs executable, it probably
127
wouldn't do any harm to #undef it here; this will only cause
128
problems if we try to write to a static variable, which I don't
129
think this code needs to do. */
140
#define ISDIGIT(c) ((unsigned) (c) - '0' <= 9)
142
#include "lib/internal.h"
145
#define HOUR(x) ((x) * 60)
147
#define MAX_BUFF_LEN 128 /* size of buffer to read the date into */
150
** An entry in the lexical lookup table.
152
typedef struct _TABLE {
160
** Meridian: am, pm, or 24-hour style.
162
typedef enum _MERIDIAN {
191
static int yylex (union YYSTYPE *lvalp, const char **yyInput);
192
static int yyerror (const char **yyInput, struct global *yy, char *s);
193
static int yyparse (const char **yyInput, struct global *yy);
195
#define YYENABLE_NLS 0
196
#define YYLTYPE_IS_TRIVIAL 0
200
/* Enabling traces. */
205
/* Enabling verbose error messages. */
206
#ifdef YYERROR_VERBOSE
207
# undef YYERROR_VERBOSE
208
# define YYERROR_VERBOSE 1
210
# define YYERROR_VERBOSE 0
213
/* Enabling the token table. */
214
#ifndef YYTOKEN_TABLE
215
# define YYTOKEN_TABLE 0
218
#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
219
#line 100 "lib/getdate.y"
220
typedef union YYSTYPE {
222
enum _MERIDIAN Meridian;
224
/* Line 196 of yacc.c. */
225
#line 226 "lib/getdate.c"
226
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
227
# define YYSTYPE_IS_DECLARED 1
228
# define YYSTYPE_IS_TRIVIAL 1
233
/* Copy the second part of user declarations. */
236
/* Line 219 of yacc.c. */
237
#line 238 "lib/getdate.c"
239
#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
240
# define YYSIZE_T __SIZE_TYPE__
242
#if ! defined (YYSIZE_T) && defined (size_t)
243
# define YYSIZE_T size_t
245
#if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus))
246
# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
247
# define YYSIZE_T size_t
249
#if ! defined (YYSIZE_T)
250
# define YYSIZE_T unsigned int
256
# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
257
# define YY_(msgid) dgettext ("bison-runtime", msgid)
261
# define YY_(msgid) msgid
265
#if ! defined (yyoverflow) || YYERROR_VERBOSE
267
/* The parser invokes alloca or malloc; define the necessary symbols. */
269
# ifdef YYSTACK_USE_ALLOCA
270
# if YYSTACK_USE_ALLOCA
272
# define YYSTACK_ALLOC __builtin_alloca
274
# define YYSTACK_ALLOC alloca
275
# if defined (__STDC__) || defined (__cplusplus)
276
# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
277
# define YYINCLUDED_STDLIB_H
283
# ifdef YYSTACK_ALLOC
284
/* Pacify GCC's `empty if-body' warning. */
285
# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
286
# ifndef YYSTACK_ALLOC_MAXIMUM
287
/* The OS might guarantee only one guard page at the bottom of the stack,
288
and a page size can be as small as 4096 bytes. So we cannot safely
289
invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
290
to allow for a few compiler-allocated temporary stack slots. */
291
# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */
294
# define YYSTACK_ALLOC YYMALLOC
295
# define YYSTACK_FREE YYFREE
296
# ifndef YYSTACK_ALLOC_MAXIMUM
297
# define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1)
303
# define YYMALLOC malloc
304
# if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \
305
&& (defined (__STDC__) || defined (__cplusplus)))
306
void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
311
# if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \
312
&& (defined (__STDC__) || defined (__cplusplus)))
313
void free (void *); /* INFRINGES ON USER NAME SPACE */
320
#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
323
#if (! defined (yyoverflow) \
324
&& (! defined (__cplusplus) \
325
|| (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
327
/* A type that is properly aligned for any stack member. */
334
/* The size of the maximum gap between one aligned stack and the next. */
335
# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
337
/* The size of an array large to enough to hold all stacks, each with
339
# define YYSTACK_BYTES(N) \
340
((N) * (sizeof (short int) + sizeof (YYSTYPE)) \
341
+ YYSTACK_GAP_MAXIMUM)
343
/* Copy COUNT objects from FROM to TO. The source and destination do
346
# if defined (__GNUC__) && 1 < __GNUC__
347
# define YYCOPY(To, From, Count) \
348
__builtin_memcpy (To, From, (Count) * sizeof (*(From)))
350
# define YYCOPY(To, From, Count) \
354
for (yyi = 0; yyi < (Count); yyi++) \
355
(To)[yyi] = (From)[yyi]; \
361
/* Relocate STACK from its old location to the new one. The
362
local variables YYSIZE and YYSTACKSIZE give the old and new number of
363
elements in the stack, and YYPTR gives the new location of the
364
stack. Advance YYPTR to a properly aligned location for the next
366
# define YYSTACK_RELOCATE(Stack) \
369
YYSIZE_T yynewbytes; \
370
YYCOPY (&yyptr->Stack, Stack, yysize); \
371
Stack = &yyptr->Stack; \
372
yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
373
yyptr += yynewbytes / sizeof (*yyptr); \
379
#if defined (__STDC__) || defined (__cplusplus)
380
typedef signed char yysigned_char;
382
typedef short int yysigned_char;
385
/* YYFINAL -- State number of the termination state. */
387
/* YYLAST -- Last index in YYTABLE. */
390
/* YYNTOKENS -- Number of terminals. */
392
/* YYNNTS -- Number of nonterminals. */
394
/* YYNRULES -- Number of rules. */
396
/* YYNRULES -- Number of states. */
399
/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
401
#define YYMAXUTOK 273
403
#define YYTRANSLATE(YYX) \
404
((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
406
/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
407
static const unsigned char yytranslate[] =
409
0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
410
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
411
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
412
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
413
2, 2, 2, 2, 20, 2, 2, 21, 2, 2,
414
2, 2, 2, 2, 2, 2, 2, 2, 19, 2,
415
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
416
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
417
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
418
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
419
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
420
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
421
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
422
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
423
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
424
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
425
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
426
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
427
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
428
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
429
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
430
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
431
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
432
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
433
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
434
2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
435
5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
440
/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
442
static const unsigned char yyprhs[] =
444
0, 0, 3, 4, 7, 9, 11, 13, 15, 17,
445
19, 22, 27, 32, 39, 46, 48, 50, 53, 55,
446
58, 61, 65, 71, 75, 79, 82, 87, 90, 94,
447
97, 99, 102, 105, 107, 110, 113, 115, 118, 121,
448
123, 126, 129, 131, 134, 137, 139, 142, 145, 147,
452
/* YYRHS -- A `-1'-separated list of the rules' RHS. */
453
static const yysigned_char yyrhs[] =
455
23, 0, -1, -1, 23, 24, -1, 25, -1, 26,
456
-1, 28, -1, 27, -1, 29, -1, 31, -1, 16,
457
10, -1, 16, 19, 16, 32, -1, 16, 19, 16,
458
15, -1, 16, 19, 16, 19, 16, 32, -1, 16,
459
19, 16, 19, 16, 15, -1, 18, -1, 6, -1,
460
18, 7, -1, 4, -1, 4, 20, -1, 16, 4,
461
-1, 16, 21, 16, -1, 16, 21, 16, 21, 16,
462
-1, 16, 15, 15, -1, 16, 12, 15, -1, 12,
463
16, -1, 12, 16, 20, 16, -1, 16, 12, -1,
464
16, 12, 16, -1, 30, 3, -1, 30, -1, 16,
465
17, -1, 15, 17, -1, 17, -1, 16, 13, -1,
466
15, 13, -1, 13, -1, 16, 5, -1, 15, 5,
467
-1, 5, -1, 16, 8, -1, 15, 8, -1, 8,
468
-1, 16, 11, -1, 15, 11, -1, 11, -1, 16,
469
14, -1, 15, 14, -1, 14, -1, 16, -1, -1,
473
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
474
static const unsigned short int yyrline[] =
476
0, 118, 118, 119, 122, 125, 128, 131, 134, 137,
477
140, 146, 152, 161, 167, 179, 182, 186, 191, 195,
478
199, 205, 209, 227, 233, 239, 243, 248, 252, 259,
479
267, 270, 273, 276, 279, 282, 285, 288, 291, 294,
480
297, 300, 303, 306, 309, 312, 315, 318, 321, 326,
485
#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
486
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
487
First, the terminals, then, starting at YYNTOKENS, nonterminals. */
488
static const char *const yytname[] =
490
"$end", "error", "$undefined", "tAGO", "tDAY", "tDAY_UNIT", "tDAYZONE",
491
"tDST", "tHOUR_UNIT", "tID", "tMERIDIAN", "tMINUTE_UNIT", "tMONTH",
492
"tMONTH_UNIT", "tSEC_UNIT", "tSNUMBER", "tUNUMBER", "tYEAR_UNIT",
493
"tZONE", "':'", "','", "'/'", "$accept", "spec", "item", "time", "zone",
494
"day", "date", "rel", "relunit", "number", "o_merid", 0
499
/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
501
static const unsigned short int yytoknum[] =
503
0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
504
265, 266, 267, 268, 269, 270, 271, 272, 273, 58,
509
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
510
static const unsigned char yyr1[] =
512
0, 22, 23, 23, 24, 24, 24, 24, 24, 24,
513
25, 25, 25, 25, 25, 26, 26, 26, 27, 27,
514
27, 28, 28, 28, 28, 28, 28, 28, 28, 29,
515
29, 30, 30, 30, 30, 30, 30, 30, 30, 30,
516
30, 30, 30, 30, 30, 30, 30, 30, 30, 31,
520
/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
521
static const unsigned char yyr2[] =
523
0, 2, 0, 2, 1, 1, 1, 1, 1, 1,
524
2, 4, 4, 6, 6, 1, 1, 2, 1, 2,
525
2, 3, 5, 3, 3, 2, 4, 2, 3, 2,
526
1, 2, 2, 1, 2, 2, 1, 2, 2, 1,
527
2, 2, 1, 2, 2, 1, 2, 2, 1, 1,
531
/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
532
STATE-NUM when YYTABLE doesn't specify something else to do. Zero
533
means the default is an error. */
534
static const unsigned char yydefact[] =
536
2, 0, 1, 18, 39, 16, 42, 45, 0, 36,
537
48, 0, 49, 33, 15, 3, 4, 5, 7, 6,
538
8, 30, 9, 19, 25, 38, 41, 44, 35, 47,
539
32, 20, 37, 40, 10, 43, 27, 34, 46, 0,
540
31, 0, 0, 17, 29, 0, 24, 28, 23, 50,
541
21, 26, 51, 12, 0, 11, 0, 50, 22, 14,
545
/* YYDEFGOTO[NTERM-NUM]. */
546
static const yysigned_char yydefgoto[] =
548
-1, 1, 15, 16, 17, 18, 19, 20, 21, 22,
552
/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
554
#define YYPACT_NINF -20
555
static const yysigned_char yypact[] =
557
-20, 0, -20, -19, -20, -20, -20, -20, -13, -20,
558
-20, 30, 15, -20, 14, -20, -20, -20, -20, -20,
559
-20, 19, -20, -20, 4, -20, -20, -20, -20, -20,
560
-20, -20, -20, -20, -20, -20, -6, -20, -20, 16,
561
-20, 17, 23, -20, -20, 24, -20, -20, -20, 27,
562
28, -20, -20, -20, 29, -20, 32, -8, -20, -20,
566
/* YYPGOTO[NTERM-NUM]. */
567
static const yysigned_char yypgoto[] =
569
-20, -20, -20, -20, -20, -20, -20, -20, -20, -20,
573
/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
574
positive, shift that token. If negative, reduce the rule which
575
number is the opposite. If zero, do what YYDEFACT says.
576
If YYTABLE_NINF, syntax error. */
577
#define YYTABLE_NINF -1
578
static const unsigned char yytable[] =
580
2, 23, 52, 24, 3, 4, 5, 59, 6, 46,
581
47, 7, 8, 9, 10, 11, 12, 13, 14, 31,
582
32, 43, 44, 33, 45, 34, 35, 36, 37, 38,
583
39, 48, 40, 49, 41, 25, 42, 52, 26, 50,
584
51, 27, 53, 28, 29, 57, 54, 30, 58, 56,
588
static const unsigned char yycheck[] =
590
0, 20, 10, 16, 4, 5, 6, 15, 8, 15,
591
16, 11, 12, 13, 14, 15, 16, 17, 18, 4,
592
5, 7, 3, 8, 20, 10, 11, 12, 13, 14,
593
15, 15, 17, 16, 19, 5, 21, 10, 8, 16,
594
16, 11, 15, 13, 14, 16, 19, 17, 16, 21,
598
/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
599
symbol of state STATE-NUM. */
600
static const unsigned char yystos[] =
602
0, 23, 0, 4, 5, 6, 8, 11, 12, 13,
603
14, 15, 16, 17, 18, 24, 25, 26, 27, 28,
604
29, 30, 31, 20, 16, 5, 8, 11, 13, 14,
605
17, 4, 5, 8, 10, 11, 12, 13, 14, 15,
606
17, 19, 21, 7, 3, 20, 15, 16, 15, 16,
607
16, 16, 10, 15, 19, 32, 21, 16, 16, 15,
611
#define yyerrok (yyerrstatus = 0)
612
#define yyclearin (yychar = YYEMPTY)
616
#define YYACCEPT goto yyacceptlab
617
#define YYABORT goto yyabortlab
618
#define YYERROR goto yyerrorlab
621
/* Like YYERROR except do call yyerror. This remains here temporarily
622
to ease the transition to the new meaning of YYERROR, for GCC.
623
Once GCC version 2 has supplanted version 1, this can go. */
625
#define YYFAIL goto yyerrlab
627
#define YYRECOVERING() (!!yyerrstatus)
629
#define YYBACKUP(Token, Value) \
631
if (yychar == YYEMPTY && yylen == 1) \
635
yytoken = YYTRANSLATE (yychar); \
641
yyerror (yyInput, yy, YY_("syntax error: cannot back up")); \
648
#define YYERRCODE 256
651
/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
652
If N is 0, then set CURRENT to the empty location which ends
653
the previous symbol: RHS[0] (always defined). */
655
#define YYRHSLOC(Rhs, K) ((Rhs)[K])
656
#ifndef YYLLOC_DEFAULT
657
# define YYLLOC_DEFAULT(Current, Rhs, N) \
661
(Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
662
(Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
663
(Current).last_line = YYRHSLOC (Rhs, N).last_line; \
664
(Current).last_column = YYRHSLOC (Rhs, N).last_column; \
668
(Current).first_line = (Current).last_line = \
669
YYRHSLOC (Rhs, 0).last_line; \
670
(Current).first_column = (Current).last_column = \
671
YYRHSLOC (Rhs, 0).last_column; \
677
/* YY_LOCATION_PRINT -- Print the location on the stream.
678
This macro was not mandated originally: define only if we know
679
we won't break user code: when these are the locations we know. */
681
#ifndef YY_LOCATION_PRINT
682
# if YYLTYPE_IS_TRIVIAL
683
# define YY_LOCATION_PRINT(File, Loc) \
684
fprintf (File, "%d.%d-%d.%d", \
685
(Loc).first_line, (Loc).first_column, \
686
(Loc).last_line, (Loc).last_column)
688
# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
693
/* YYLEX -- calling `yylex' with the right arguments. */
696
# define YYLEX yylex (&yylval, YYLEX_PARAM)
698
# define YYLEX yylex (&yylval, yyInput)
701
/* Enable debugging if requested. */
705
# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
706
# define YYFPRINTF fprintf
709
# define YYDPRINTF(Args) \
715
# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
719
YYFPRINTF (stderr, "%s ", Title); \
720
yysymprint (stderr, \
722
YYFPRINTF (stderr, "\n"); \
726
/*------------------------------------------------------------------.
727
| yy_stack_print -- Print the state stack from its BOTTOM up to its |
729
`------------------------------------------------------------------*/
731
#if defined (__STDC__) || defined (__cplusplus)
733
yy_stack_print (short int *bottom, short int *top)
736
yy_stack_print (bottom, top)
741
YYFPRINTF (stderr, "Stack now");
742
for (/* Nothing. */; bottom <= top; ++bottom)
743
YYFPRINTF (stderr, " %d", *bottom);
744
YYFPRINTF (stderr, "\n");
747
# define YY_STACK_PRINT(Bottom, Top) \
750
yy_stack_print ((Bottom), (Top)); \
754
/*------------------------------------------------.
755
| Report that the YYRULE is going to be reduced. |
756
`------------------------------------------------*/
758
#if defined (__STDC__) || defined (__cplusplus)
760
yy_reduce_print (int yyrule)
763
yy_reduce_print (yyrule)
768
unsigned long int yylno = yyrline[yyrule];
769
YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ",
771
/* Print the symbols being reduced, and their result. */
772
for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
773
YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
774
YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]);
777
# define YY_REDUCE_PRINT(Rule) \
780
yy_reduce_print (Rule); \
783
/* Nonzero means print parse trace. It is left uninitialized so that
784
multiple parsers can coexist. */
787
# define YYDPRINTF(Args)
788
# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
789
# define YY_STACK_PRINT(Bottom, Top)
790
# define YY_REDUCE_PRINT(Rule)
791
#endif /* !YYDEBUG */
794
/* YYINITDEPTH -- initial size of the parser's stacks. */
796
# define YYINITDEPTH 200
799
/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
800
if the built-in stack extension method is used).
802
Do not make this value too large; the results are undefined if
803
YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
804
evaluated with infinite-precision integer arithmetic. */
807
# define YYMAXDEPTH 10000
815
# if defined (__GLIBC__) && defined (_STRING_H)
816
# define yystrlen strlen
818
/* Return the length of YYSTR. */
820
# if defined (__STDC__) || defined (__cplusplus)
821
yystrlen (const char *yystr)
827
const char *yys = yystr;
829
while (*yys++ != '\0')
832
return yys - yystr - 1;
838
# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
839
# define yystpcpy stpcpy
841
/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
844
# if defined (__STDC__) || defined (__cplusplus)
845
yystpcpy (char *yydest, const char *yysrc)
847
yystpcpy (yydest, yysrc)
853
const char *yys = yysrc;
855
while ((*yyd++ = *yys++) != '\0')
864
/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
865
quotes and backslashes, so that it's suitable for yyerror. The
866
heuristic is that double-quoting is unnecessary unless the string
867
contains an apostrophe, a comma, or backslash (other than
868
backslash-backslash). YYSTR is taken from yytname. If YYRES is
869
null, do not copy; instead, return the length of what the result
872
yytnamerr (char *yyres, const char *yystr)
877
char const *yyp = yystr;
884
goto do_not_strip_quotes;
888
goto do_not_strip_quotes;
901
do_not_strip_quotes: ;
905
return yystrlen (yystr);
907
return yystpcpy (yyres, yystr) - yyres;
911
#endif /* YYERROR_VERBOSE */
916
/*--------------------------------.
917
| Print this symbol on YYOUTPUT. |
918
`--------------------------------*/
920
#if defined (__STDC__) || defined (__cplusplus)
922
yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
925
yysymprint (yyoutput, yytype, yyvaluep)
931
/* Pacify ``unused variable'' warnings. */
934
if (yytype < YYNTOKENS)
935
YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
937
YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
941
if (yytype < YYNTOKENS)
942
YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
949
YYFPRINTF (yyoutput, ")");
952
#endif /* ! YYDEBUG */
953
/*-----------------------------------------------.
954
| Release the memory associated to this symbol. |
955
`-----------------------------------------------*/
957
#if defined (__STDC__) || defined (__cplusplus)
959
yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
962
yydestruct (yymsg, yytype, yyvaluep)
968
/* Pacify ``unused variable'' warnings. */
973
YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
984
/* Prevent warnings from -Wmissing-prototypes. */
987
# if defined (__STDC__) || defined (__cplusplus)
988
int yyparse (void *YYPARSE_PARAM);
992
#else /* ! YYPARSE_PARAM */
993
#if defined (__STDC__) || defined (__cplusplus)
994
int yyparse (const char **yyInput, struct global *yy);
998
#endif /* ! YYPARSE_PARAM */
1009
#ifdef YYPARSE_PARAM
1010
# if defined (__STDC__) || defined (__cplusplus)
1011
int yyparse (void *YYPARSE_PARAM)
1013
int yyparse (YYPARSE_PARAM)
1014
void *YYPARSE_PARAM;
1016
#else /* ! YYPARSE_PARAM */
1017
#if defined (__STDC__) || defined (__cplusplus)
1019
yyparse (const char **yyInput, struct global *yy)
1022
yyparse (yyInput, yy)
1023
const char **yyInput;
1028
/* The look-ahead symbol. */
1031
/* The semantic value of the look-ahead symbol. */
1034
/* Number of syntax errors so far. */
1040
/* Number of tokens to shift before error messages enabled. */
1042
/* Look-ahead token as an internal (translated) token number. */
1045
/* Three stacks and their tools:
1046
`yyss': related to states,
1047
`yyvs': related to semantic values,
1048
`yyls': related to locations.
1050
Refer to the stacks thru separate pointers, to allow yyoverflow
1051
to reallocate them elsewhere. */
1053
/* The state stack. */
1054
short int yyssa[YYINITDEPTH];
1055
short int *yyss = yyssa;
1058
/* The semantic value stack. */
1059
YYSTYPE yyvsa[YYINITDEPTH];
1060
YYSTYPE *yyvs = yyvsa;
1065
#define YYPOPSTACK (yyvsp--, yyssp--)
1067
YYSIZE_T yystacksize = YYINITDEPTH;
1069
/* The variables used to return semantic value and location from the
1074
/* When reducing, the number of symbols on the RHS of the reduced
1078
YYDPRINTF ((stderr, "Starting parse\n"));
1083
yychar = YYEMPTY; /* Cause a token to be read. */
1085
/* Initialize stack pointers.
1086
Waste one element of value and location stack
1087
so that they stay on the same level as the state stack.
1088
The wasted elements are never initialized. */
1095
/*------------------------------------------------------------.
1096
| yynewstate -- Push a new state, which is found in yystate. |
1097
`------------------------------------------------------------*/
1099
/* In all cases, when you get here, the value and location stacks
1100
have just been pushed. so pushing a state here evens the stacks.
1107
if (yyss + yystacksize - 1 <= yyssp)
1109
/* Get the current used size of the three stacks, in elements. */
1110
YYSIZE_T yysize = yyssp - yyss + 1;
1114
/* Give user a chance to reallocate the stack. Use copies of
1115
these so that the &'s don't force the real ones into
1117
YYSTYPE *yyvs1 = yyvs;
1118
short int *yyss1 = yyss;
1121
/* Each stack pointer address is followed by the size of the
1122
data in use in that stack, in bytes. This used to be a
1123
conditional around just the two extra args, but that might
1124
be undefined if yyoverflow is a macro. */
1125
yyoverflow (YY_("memory exhausted"),
1126
&yyss1, yysize * sizeof (*yyssp),
1127
&yyvs1, yysize * sizeof (*yyvsp),
1134
#else /* no yyoverflow */
1135
# ifndef YYSTACK_RELOCATE
1136
goto yyexhaustedlab;
1138
/* Extend the stack our own way. */
1139
if (YYMAXDEPTH <= yystacksize)
1140
goto yyexhaustedlab;
1142
if (YYMAXDEPTH < yystacksize)
1143
yystacksize = YYMAXDEPTH;
1146
short int *yyss1 = yyss;
1147
union yyalloc *yyptr =
1148
(union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1150
goto yyexhaustedlab;
1151
YYSTACK_RELOCATE (yyss);
1152
YYSTACK_RELOCATE (yyvs);
1154
# undef YYSTACK_RELOCATE
1156
YYSTACK_FREE (yyss1);
1159
#endif /* no yyoverflow */
1161
yyssp = yyss + yysize - 1;
1162
yyvsp = yyvs + yysize - 1;
1165
YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1166
(unsigned long int) yystacksize));
1168
if (yyss + yystacksize - 1 <= yyssp)
1172
YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1181
/* Do appropriate processing given the current state. */
1182
/* Read a look-ahead token if we need one and don't already have one. */
1185
/* First try to decide what to do without reference to look-ahead token. */
1187
yyn = yypact[yystate];
1188
if (yyn == YYPACT_NINF)
1191
/* Not known => get a look-ahead token if don't already have one. */
1193
/* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
1194
if (yychar == YYEMPTY)
1196
YYDPRINTF ((stderr, "Reading a token: "));
1200
if (yychar <= YYEOF)
1202
yychar = yytoken = YYEOF;
1203
YYDPRINTF ((stderr, "Now at end of input.\n"));
1207
yytoken = YYTRANSLATE (yychar);
1208
YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1211
/* If the proper action on seeing token YYTOKEN is to reduce or to
1212
detect an error, take that action. */
1214
if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1219
if (yyn == 0 || yyn == YYTABLE_NINF)
1228
/* Shift the look-ahead token. */
1229
YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1231
/* Discard the token being shifted unless it is eof. */
1232
if (yychar != YYEOF)
1238
/* Count tokens shifted since error; after three, turn off error
1247
/*-----------------------------------------------------------.
1248
| yydefault -- do the default action for the current state. |
1249
`-----------------------------------------------------------*/
1251
yyn = yydefact[yystate];
1257
/*-----------------------------.
1258
| yyreduce -- Do a reduction. |
1259
`-----------------------------*/
1261
/* yyn is the number of a rule to reduce with. */
1264
/* If YYLEN is nonzero, implement the default value of the action:
1267
Otherwise, the following line sets YYVAL to garbage.
1268
This behavior is undocumented and Bison
1269
users should not rely upon it. Assigning to YYVAL
1270
unconditionally makes the parser a bit smaller, and it avoids a
1271
GCC warning that YYVAL may be used uninitialized. */
1272
yyval = yyvsp[1-yylen];
1275
YY_REDUCE_PRINT (yyn);
1279
#line 122 "lib/getdate.y"
1286
#line 125 "lib/getdate.y"
1293
#line 128 "lib/getdate.y"
1300
#line 131 "lib/getdate.y"
1307
#line 134 "lib/getdate.y"
1314
#line 140 "lib/getdate.y"
1316
yy->Hour = (yyvsp[-1].Number);
1319
yy->Meridian = (yyvsp[0].Meridian);
1324
#line 146 "lib/getdate.y"
1326
yy->Hour = (yyvsp[-3].Number);
1327
yy->Minutes = (yyvsp[-1].Number);
1329
yy->Meridian = (yyvsp[0].Meridian);
1334
#line 152 "lib/getdate.y"
1336
yy->Hour = (yyvsp[-3].Number);
1337
yy->Minutes = (yyvsp[-1].Number);
1338
yy->Meridian = MER24;
1340
yy->Timezone = ((yyvsp[0].Number) < 0
1341
? -(yyvsp[0].Number) % 100 + (-(yyvsp[0].Number) / 100) * 60
1342
: - ((yyvsp[0].Number) % 100 + ((yyvsp[0].Number) / 100) * 60));
1347
#line 161 "lib/getdate.y"
1349
yy->Hour = (yyvsp[-5].Number);
1350
yy->Minutes = (yyvsp[-3].Number);
1351
yy->Seconds = (yyvsp[-1].Number);
1352
yy->Meridian = (yyvsp[0].Meridian);
1357
#line 167 "lib/getdate.y"
1359
yy->Hour = (yyvsp[-5].Number);
1360
yy->Minutes = (yyvsp[-3].Number);
1361
yy->Seconds = (yyvsp[-1].Number);
1362
yy->Meridian = MER24;
1364
yy->Timezone = ((yyvsp[0].Number) < 0
1365
? -(yyvsp[0].Number) % 100 + (-(yyvsp[0].Number) / 100) * 60
1366
: - ((yyvsp[0].Number) % 100 + ((yyvsp[0].Number) / 100) * 60));
1371
#line 179 "lib/getdate.y"
1373
yy->Timezone = (yyvsp[0].Number);
1378
#line 182 "lib/getdate.y"
1380
yy->Timezone = (yyvsp[0].Number) - 60;
1385
#line 186 "lib/getdate.y"
1387
yy->Timezone = (yyvsp[-1].Number) - 60;
1392
#line 191 "lib/getdate.y"
1395
yy->DayNumber = (yyvsp[0].Number);
1400
#line 195 "lib/getdate.y"
1403
yy->DayNumber = (yyvsp[-1].Number);
1408
#line 199 "lib/getdate.y"
1410
yy->DayOrdinal = (yyvsp[-1].Number);
1411
yy->DayNumber = (yyvsp[0].Number);
1416
#line 205 "lib/getdate.y"
1418
yy->Month = (yyvsp[-2].Number);
1419
yy->Day = (yyvsp[0].Number);
1424
#line 209 "lib/getdate.y"
1426
/* Interpret as YY->YY/MM/DD if $1 >= 1000, otherwise as MM/DD/YY.
1427
The goal in recognizing YY->YY/MM/DD is solely to support legacy
1428
machine-generated dates like those in an RCS log listing. If
1429
you want portability, use the ISO 8601 format. */
1430
if ((yyvsp[-4].Number) >= 1000)
1432
yy->Year = (yyvsp[-4].Number);
1433
yy->Month = (yyvsp[-2].Number);
1434
yy->Day = (yyvsp[0].Number);
1438
yy->Month = (yyvsp[-4].Number);
1439
yy->Day = (yyvsp[-2].Number);
1440
yy->Year = (yyvsp[0].Number);
1446
#line 227 "lib/getdate.y"
1448
/* ISO 8601 format. yy->yy-mm-dd. */
1449
yy->Year = (yyvsp[-2].Number);
1450
yy->Month = -(yyvsp[-1].Number);
1451
yy->Day = -(yyvsp[0].Number);
1456
#line 233 "lib/getdate.y"
1458
/* e.g. 17-JUN-1992. */
1459
yy->Day = (yyvsp[-2].Number);
1460
yy->Month = (yyvsp[-1].Number);
1461
yy->Year = -(yyvsp[0].Number);
1466
#line 239 "lib/getdate.y"
1468
yy->Month = (yyvsp[-1].Number);
1469
yy->Day = (yyvsp[0].Number);
1474
#line 243 "lib/getdate.y"
1476
yy->Month = (yyvsp[-3].Number);
1477
yy->Day = (yyvsp[-2].Number);
1478
yy->Year = (yyvsp[0].Number);
1483
#line 248 "lib/getdate.y"
1485
yy->Month = (yyvsp[0].Number);
1486
yy->Day = (yyvsp[-1].Number);
1491
#line 252 "lib/getdate.y"
1493
yy->Month = (yyvsp[-1].Number);
1494
yy->Day = (yyvsp[-2].Number);
1495
yy->Year = (yyvsp[0].Number);
1500
#line 259 "lib/getdate.y"
1502
yy->RelSeconds = -yy->RelSeconds;
1503
yy->RelMinutes = -yy->RelMinutes;
1504
yy->RelHour = -yy->RelHour;
1505
yy->RelDay = -yy->RelDay;
1506
yy->RelMonth = -yy->RelMonth;
1507
yy->RelYear = -yy->RelYear;
1512
#line 270 "lib/getdate.y"
1514
yy->RelYear += (yyvsp[-1].Number) * (yyvsp[0].Number);
1519
#line 273 "lib/getdate.y"
1521
yy->RelYear += (yyvsp[-1].Number) * (yyvsp[0].Number);
1526
#line 276 "lib/getdate.y"
1533
#line 279 "lib/getdate.y"
1535
yy->RelMonth += (yyvsp[-1].Number) * (yyvsp[0].Number);
1540
#line 282 "lib/getdate.y"
1542
yy->RelMonth += (yyvsp[-1].Number) * (yyvsp[0].Number);
1547
#line 285 "lib/getdate.y"
1554
#line 288 "lib/getdate.y"
1556
yy->RelDay += (yyvsp[-1].Number) * (yyvsp[0].Number);
1561
#line 291 "lib/getdate.y"
1563
yy->RelDay += (yyvsp[-1].Number) * (yyvsp[0].Number);
1568
#line 294 "lib/getdate.y"
1575
#line 297 "lib/getdate.y"
1577
yy->RelHour += (yyvsp[-1].Number) * (yyvsp[0].Number);
1582
#line 300 "lib/getdate.y"
1584
yy->RelHour += (yyvsp[-1].Number) * (yyvsp[0].Number);
1589
#line 303 "lib/getdate.y"
1596
#line 306 "lib/getdate.y"
1598
yy->RelMinutes += (yyvsp[-1].Number) * (yyvsp[0].Number);
1603
#line 309 "lib/getdate.y"
1605
yy->RelMinutes += (yyvsp[-1].Number) * (yyvsp[0].Number);
1610
#line 312 "lib/getdate.y"
1617
#line 315 "lib/getdate.y"
1619
yy->RelSeconds += (yyvsp[-1].Number) * (yyvsp[0].Number);
1624
#line 318 "lib/getdate.y"
1626
yy->RelSeconds += (yyvsp[-1].Number) * (yyvsp[0].Number);
1631
#line 321 "lib/getdate.y"
1638
#line 327 "lib/getdate.y"
1640
if (yy->HaveTime && yy->HaveDate && !yy->HaveRel)
1641
yy->Year = (yyvsp[0].Number);
1644
if ((yyvsp[0].Number)>10000)
1647
yy->Day= ((yyvsp[0].Number))%100;
1648
yy->Month= ((yyvsp[0].Number)/100)%100;
1649
yy->Year = (yyvsp[0].Number)/10000;
1654
if ((yyvsp[0].Number) < 100)
1656
yy->Hour = (yyvsp[0].Number);
1661
yy->Hour = (yyvsp[0].Number) / 100;
1662
yy->Minutes = (yyvsp[0].Number) % 100;
1665
yy->Meridian = MER24;
1672
#line 360 "lib/getdate.y"
1674
(yyval.Meridian) = MER24;
1679
#line 364 "lib/getdate.y"
1681
(yyval.Meridian) = (yyvsp[0].Meridian);
1689
/* Line 1126 of yacc.c. */
1690
#line 1691 "lib/getdate.c"
1696
YY_STACK_PRINT (yyss, yyssp);
1701
/* Now `shift' the result of the reduction. Determine what state
1702
that goes to, based on the state we popped back to and the rule
1703
number reduced by. */
1707
yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1708
if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1709
yystate = yytable[yystate];
1711
yystate = yydefgoto[yyn - YYNTOKENS];
1716
/*------------------------------------.
1717
| yyerrlab -- here on detecting error |
1718
`------------------------------------*/
1720
/* If not already recovering from an error, report this error. */
1725
yyn = yypact[yystate];
1727
if (YYPACT_NINF < yyn && yyn < YYLAST)
1729
int yytype = YYTRANSLATE (yychar);
1730
YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
1731
YYSIZE_T yysize = yysize0;
1733
int yysize_overflow = 0;
1735
# define YYERROR_VERBOSE_ARGS_MAXIMUM 5
1736
char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1740
/* This is so xgettext sees the translatable formats that are
1741
constructed on the fly. */
1742
YY_("syntax error, unexpected %s");
1743
YY_("syntax error, unexpected %s, expecting %s");
1744
YY_("syntax error, unexpected %s, expecting %s or %s");
1745
YY_("syntax error, unexpected %s, expecting %s or %s or %s");
1746
YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
1750
static char const yyunexpected[] = "syntax error, unexpected %s";
1751
static char const yyexpecting[] = ", expecting %s";
1752
static char const yyor[] = " or %s";
1753
char yyformat[sizeof yyunexpected
1754
+ sizeof yyexpecting - 1
1755
+ ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
1756
* (sizeof yyor - 1))];
1757
char const *yyprefix = yyexpecting;
1759
/* Start YYX at -YYN if negative to avoid negative indexes in
1761
int yyxbegin = yyn < 0 ? -yyn : 0;
1763
/* Stay within bounds of both yycheck and yytname. */
1764
int yychecklim = YYLAST - yyn;
1765
int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1768
yyarg[0] = yytname[yytype];
1769
yyfmt = yystpcpy (yyformat, yyunexpected);
1771
for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1772
if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1774
if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1778
yyformat[sizeof yyunexpected - 1] = '\0';
1781
yyarg[yycount++] = yytname[yyx];
1782
yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1783
yysize_overflow |= yysize1 < yysize;
1785
yyfmt = yystpcpy (yyfmt, yyprefix);
1789
yyf = YY_(yyformat);
1790
yysize1 = yysize + yystrlen (yyf);
1791
yysize_overflow |= yysize1 < yysize;
1794
if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM)
1795
yymsg = (char *) YYSTACK_ALLOC (yysize);
1798
/* Avoid sprintf, as that infringes on the user's name space.
1799
Don't have undefined behavior even if the translation
1800
produced a string with the wrong number of "%s"s. */
1803
while ((*yyp = *yyf))
1805
if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
1807
yyp += yytnamerr (yyp, yyarg[yyi++]);
1816
yyerror (yyInput, yy, yymsg);
1817
YYSTACK_FREE (yymsg);
1821
yyerror (yyInput, yy, YY_("syntax error"));
1822
goto yyexhaustedlab;
1826
#endif /* YYERROR_VERBOSE */
1827
yyerror (yyInput, yy, YY_("syntax error"));
1832
if (yyerrstatus == 3)
1834
/* If just tried and failed to reuse look-ahead token after an
1835
error, discard it. */
1837
if (yychar <= YYEOF)
1839
/* Return failure if at end of input. */
1840
if (yychar == YYEOF)
1845
yydestruct ("Error: discarding", yytoken, &yylval);
1850
/* Else will try to reuse look-ahead token after shifting the error
1855
/*---------------------------------------------------.
1856
| yyerrorlab -- error raised explicitly by YYERROR. |
1857
`---------------------------------------------------*/
1860
/* Pacify compilers like GCC when the user code never invokes
1861
YYERROR and the label yyerrorlab therefore never appears in user
1872
/*-------------------------------------------------------------.
1873
| yyerrlab1 -- common code for both syntax error and YYERROR. |
1874
`-------------------------------------------------------------*/
1876
yyerrstatus = 3; /* Each real token shifted decrements this. */
1880
yyn = yypact[yystate];
1881
if (yyn != YYPACT_NINF)
1884
if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1892
/* Pop the current state because it cannot handle the error token. */
1897
yydestruct ("Error: popping", yystos[yystate], yyvsp);
1900
YY_STACK_PRINT (yyss, yyssp);
1909
/* Shift the error token. */
1910
YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1916
/*-------------------------------------.
1917
| yyacceptlab -- YYACCEPT comes here. |
1918
`-------------------------------------*/
1923
/*-----------------------------------.
1924
| yyabortlab -- YYABORT comes here. |
1925
`-----------------------------------*/
1931
/*-------------------------------------------------.
1932
| yyexhaustedlab -- memory exhaustion comes here. |
1933
`-------------------------------------------------*/
1935
yyerror (yyInput, yy, YY_("memory exhausted"));
1941
if (yychar != YYEOF && yychar != YYEMPTY)
1942
yydestruct ("Cleanup: discarding lookahead",
1944
while (yyssp != yyss)
1946
yydestruct ("Cleanup: popping",
1947
yystos[*yyssp], yyvsp);
1952
YYSTACK_FREE (yyss);
1958
#line 369 "lib/getdate.y"
1961
/* Month and day table. */
1962
static TABLE const MonthDayTable[] = {
1963
{ "january", tMONTH, 1 },
1964
{ "february", tMONTH, 2 },
1965
{ "march", tMONTH, 3 },
1966
{ "april", tMONTH, 4 },
1967
{ "may", tMONTH, 5 },
1968
{ "june", tMONTH, 6 },
1969
{ "july", tMONTH, 7 },
1970
{ "august", tMONTH, 8 },
1971
{ "september", tMONTH, 9 },
1972
{ "sept", tMONTH, 9 },
1973
{ "october", tMONTH, 10 },
1974
{ "november", tMONTH, 11 },
1975
{ "december", tMONTH, 12 },
1976
{ "sunday", tDAY, 0 },
1977
{ "monday", tDAY, 1 },
1978
{ "tuesday", tDAY, 2 },
1979
{ "tues", tDAY, 2 },
1980
{ "wednesday", tDAY, 3 },
1981
{ "wednes", tDAY, 3 },
1982
{ "thursday", tDAY, 4 },
1983
{ "thur", tDAY, 4 },
1984
{ "thurs", tDAY, 4 },
1985
{ "friday", tDAY, 5 },
1986
{ "saturday", tDAY, 6 },
1990
/* Time units table. */
1991
static TABLE const UnitsTable[] = {
1992
{ "year", tYEAR_UNIT, 1 },
1993
{ "month", tMONTH_UNIT, 1 },
1994
{ "fortnight", tDAY_UNIT, 14 },
1995
{ "week", tDAY_UNIT, 7 },
1996
{ "day", tDAY_UNIT, 1 },
1997
{ "hour", tHOUR_UNIT, 1 },
1998
{ "minute", tMINUTE_UNIT, 1 },
1999
{ "min", tMINUTE_UNIT, 1 },
2000
{ "second", tSEC_UNIT, 1 },
2001
{ "sec", tSEC_UNIT, 1 },
2005
/* Assorted relative-time words. */
2006
static TABLE const OtherTable[] = {
2007
{ "tomorrow", tMINUTE_UNIT, 1 * 24 * 60 },
2008
{ "yesterday", tMINUTE_UNIT, -1 * 24 * 60 },
2009
{ "today", tMINUTE_UNIT, 0 },
2010
{ "now", tMINUTE_UNIT, 0 },
2011
{ "last", tUNUMBER, -1 },
2012
{ "this", tMINUTE_UNIT, 0 },
2013
{ "next", tUNUMBER, 2 },
2014
{ "first", tUNUMBER, 1 },
2015
/* { "second", tUNUMBER, 2 }, */
2016
{ "third", tUNUMBER, 3 },
2017
{ "fourth", tUNUMBER, 4 },
2018
{ "fifth", tUNUMBER, 5 },
2019
{ "sixth", tUNUMBER, 6 },
2020
{ "seventh", tUNUMBER, 7 },
2021
{ "eighth", tUNUMBER, 8 },
2022
{ "ninth", tUNUMBER, 9 },
2023
{ "tenth", tUNUMBER, 10 },
2024
{ "eleventh", tUNUMBER, 11 },
2025
{ "twelfth", tUNUMBER, 12 },
2030
/* The timezone table. */
2031
static TABLE const TimezoneTable[] = {
2032
{ "gmt", tZONE, HOUR ( 0) }, /* Greenwich Mean */
2033
{ "ut", tZONE, HOUR ( 0) }, /* Universal (Coordinated) */
2034
{ "utc", tZONE, HOUR ( 0) },
2035
{ "wet", tZONE, HOUR ( 0) }, /* Western European */
2036
{ "bst", tDAYZONE, HOUR ( 0) }, /* British Summer */
2037
{ "wat", tZONE, HOUR ( 1) }, /* West Africa */
2038
{ "at", tZONE, HOUR ( 2) }, /* Azores */
2039
{ "ast", tZONE, HOUR ( 4) }, /* Atlantic Standard */
2040
{ "adt", tDAYZONE, HOUR ( 4) }, /* Atlantic Daylight */
2041
{ "est", tZONE, HOUR ( 5) }, /* Eastern Standard */
2042
{ "edt", tDAYZONE, HOUR ( 5) }, /* Eastern Daylight */
2043
{ "cst", tZONE, HOUR ( 6) }, /* Central Standard */
2044
{ "cdt", tDAYZONE, HOUR ( 6) }, /* Central Daylight */
2045
{ "mst", tZONE, HOUR ( 7) }, /* Mountain Standard */
2046
{ "mdt", tDAYZONE, HOUR ( 7) }, /* Mountain Daylight */
2047
{ "pst", tZONE, HOUR ( 8) }, /* Pacific Standard */
2048
{ "pdt", tDAYZONE, HOUR ( 8) }, /* Pacific Daylight */
2049
{ "yst", tZONE, HOUR ( 9) }, /* Yukon Standard */
2050
{ "ydt", tDAYZONE, HOUR ( 9) }, /* Yukon Daylight */
2051
{ "hst", tZONE, HOUR (10) }, /* Hawaii Standard */
2052
{ "hdt", tDAYZONE, HOUR (10) }, /* Hawaii Daylight */
2053
{ "cat", tZONE, HOUR (10) }, /* Central Alaska */
2054
{ "ahst", tZONE, HOUR (10) }, /* Alaska-Hawaii Standard */
2055
{ "nt", tZONE, HOUR (11) }, /* Nome */
2056
{ "idlw", tZONE, HOUR (12) }, /* International Date Line West */
2057
{ "cet", tZONE, -HOUR (1) }, /* Central European */
2058
{ "met", tZONE, -HOUR (1) }, /* Middle European */
2059
{ "mewt", tZONE, -HOUR (1) }, /* Middle European Winter */
2060
{ "mest", tDAYZONE, -HOUR (1) }, /* Middle European Summer */
2061
{ "mesz", tDAYZONE, -HOUR (1) }, /* Middle European Summer */
2062
{ "swt", tZONE, -HOUR (1) }, /* Swedish Winter */
2063
{ "sst", tDAYZONE, -HOUR (1) }, /* Swedish Summer */
2064
{ "fwt", tZONE, -HOUR (1) }, /* French Winter */
2065
{ "fst", tDAYZONE, -HOUR (1) }, /* French Summer */
2066
{ "eet", tZONE, -HOUR (2) }, /* Eastern Europe, USSR Zone 1 */
2067
{ "bt", tZONE, -HOUR (3) }, /* Baghdad, USSR Zone 2 */
2068
{ "zp4", tZONE, -HOUR (4) }, /* USSR Zone 3 */
2069
{ "zp5", tZONE, -HOUR (5) }, /* USSR Zone 4 */
2070
{ "zp6", tZONE, -HOUR (6) }, /* USSR Zone 5 */
2071
{ "wast", tZONE, -HOUR (7) }, /* West Australian Standard */
2072
{ "wadt", tDAYZONE, -HOUR (7) }, /* West Australian Daylight */
2073
{ "cct", tZONE, -HOUR (8) }, /* China Coast, USSR Zone 7 */
2074
{ "jst", tZONE, -HOUR (9) }, /* Japan Standard, USSR Zone 8 */
2075
{ "east", tZONE, -HOUR (10) }, /* Eastern Australian Standard */
2076
{ "eadt", tDAYZONE, -HOUR (10) }, /* Eastern Australian Daylight */
2077
{ "gst", tZONE, -HOUR (10) }, /* Guam Standard, USSR Zone 9 */
2078
{ "nzt", tZONE, -HOUR (12) }, /* New Zealand */
2079
{ "nzst", tZONE, -HOUR (12) }, /* New Zealand Standard */
2080
{ "nzdt", tDAYZONE, -HOUR (12) }, /* New Zealand Daylight */
2081
{ "idle", tZONE, -HOUR (12) }, /* International Date Line East */
2085
/* Military timezone table. */
2086
static TABLE const MilitaryTable[] = {
2087
{ "a", tZONE, HOUR ( 1) },
2088
{ "b", tZONE, HOUR ( 2) },
2089
{ "c", tZONE, HOUR ( 3) },
2090
{ "d", tZONE, HOUR ( 4) },
2091
{ "e", tZONE, HOUR ( 5) },
2092
{ "f", tZONE, HOUR ( 6) },
2093
{ "g", tZONE, HOUR ( 7) },
2094
{ "h", tZONE, HOUR ( 8) },
2095
{ "i", tZONE, HOUR ( 9) },
2096
{ "k", tZONE, HOUR ( 10) },
2097
{ "l", tZONE, HOUR ( 11) },
2098
{ "m", tZONE, HOUR ( 12) },
2099
{ "n", tZONE, HOUR (- 1) },
2100
{ "o", tZONE, HOUR (- 2) },
2101
{ "p", tZONE, HOUR (- 3) },
2102
{ "q", tZONE, HOUR (- 4) },
2103
{ "r", tZONE, HOUR (- 5) },
2104
{ "s", tZONE, HOUR (- 6) },
2105
{ "t", tZONE, HOUR (- 7) },
2106
{ "u", tZONE, HOUR (- 8) },
2107
{ "v", tZONE, HOUR (- 9) },
2108
{ "w", tZONE, HOUR (-10) },
2109
{ "x", tZONE, HOUR (-11) },
2110
{ "y", tZONE, HOUR (-12) },
2111
{ "z", tZONE, HOUR ( 0) },
2120
yyerror (const char **yyInput, struct global *yy, char *s)
2129
ToHour (int Hours, MERIDIAN Meridian)
2134
if (Hours < 0 || Hours > 23)
2138
if (Hours < 1 || Hours > 12)
2144
if (Hours < 1 || Hours > 12)
2161
/* XPG4 suggests that years 00-68 map to 2000-2068, and
2162
years 69-99 map to 1969-1999. */
2165
else if (Year < 100)
2172
LookupWord (YYSTYPE *lvalp, char *buff)
2176
register const TABLE *tp;
2180
/* Make it lowercase. */
2181
for (p = buff; *p; p++)
2182
if (isupper ((unsigned char)*p))
2185
if (strcmp (buff, "am") == 0 || strcmp (buff, "a.m.") == 0)
2187
lvalp->Meridian = MERam;
2190
if (strcmp (buff, "pm") == 0 || strcmp (buff, "p.m.") == 0)
2192
lvalp->Meridian = MERpm;
2196
/* See if we have an abbreviation for a month. */
2197
if (strlen (buff) == 3)
2199
else if (strlen (buff) == 4 && buff[3] == '.')
2207
for (tp = MonthDayTable; tp->name; tp++)
2211
if (strncmp (buff, tp->name, 3) == 0)
2213
lvalp->Number = tp->value;
2217
else if (strcmp (buff, tp->name) == 0)
2219
lvalp->Number = tp->value;
2224
for (tp = TimezoneTable; tp->name; tp++)
2225
if (strcmp (buff, tp->name) == 0)
2227
lvalp->Number = tp->value;
2231
if (strcmp (buff, "dst") == 0)
2234
for (tp = UnitsTable; tp->name; tp++)
2235
if (strcmp (buff, tp->name) == 0)
2237
lvalp->Number = tp->value;
2241
/* Strip off any plural and try the units table again. */
2242
i = strlen (buff) - 1;
2246
for (tp = UnitsTable; tp->name; tp++)
2247
if (strcmp (buff, tp->name) == 0)
2249
lvalp->Number = tp->value;
2252
buff[i] = 's'; /* Put back for "this" in OtherTable. */
2255
for (tp = OtherTable; tp->name; tp++)
2256
if (strcmp (buff, tp->name) == 0)
2258
lvalp->Number = tp->value;
2262
/* Military timezones. */
2263
if (buff[1] == '\0' && isalpha ((unsigned char)*buff))
2265
for (tp = MilitaryTable; tp->name; tp++)
2266
if (strcmp (buff, tp->name) == 0)
2268
lvalp->Number = tp->value;
2273
/* Drop out any periods and try the timezone table again. */
2274
for (i = 0, p = q = buff; *q; q++)
2281
for (tp = TimezoneTable; tp->name; tp++)
2282
if (strcmp (buff, tp->name) == 0)
2284
lvalp->Number = tp->value;
2292
yylex (YYSTYPE *lvalp, const char **yyInput)
2302
while (isspace ((unsigned char)**yyInput))
2305
if (ISDIGIT (c = **yyInput) || c == '-' || c == '+')
2307
if (c == '-' || c == '+')
2309
sign = c == '-' ? -1 : 1;
2310
if (!ISDIGIT (*++*yyInput))
2311
/* skip the '-' sign */
2316
for (lvalp->Number = 0; ISDIGIT (c = *(*yyInput)++);)
2317
lvalp->Number = 10 * lvalp->Number + c - '0';
2320
lvalp->Number = -lvalp->Number;
2321
return sign ? tSNUMBER : tUNUMBER;
2323
if (isalpha ((unsigned char)c))
2325
for (p = buff; (c = *(*yyInput)++, isalpha ((unsigned char)c))
2327
if (p < &buff[sizeof buff - 1])
2331
return LookupWord (lvalp, buff);
2334
return *(*yyInput)++;
2350
#define TM_YEAR_ORIGIN 1900
2352
/* Yield A - B, measured in seconds. */
2354
difftm (struct tm *a, struct tm *b)
2356
int ay = a->tm_year + (TM_YEAR_ORIGIN - 1);
2357
int by = b->tm_year + (TM_YEAR_ORIGIN - 1);
2359
/* difference in day of year */
2360
a->tm_yday - b->tm_yday
2361
/* + intervening leap days */
2362
+ ((ay >> 2) - (by >> 2))
2363
- (ay / 100 - by / 100)
2364
+ ((ay / 100 >> 2) - (by / 100 >> 2))
2365
/* + difference in years * 365 */
2366
+ (long) (ay - by) * 365
2368
return (60 * (60 * (24 * days + (a->tm_hour - b->tm_hour))
2369
+ (a->tm_min - b->tm_min))
2370
+ (a->tm_sec - b->tm_sec));
2374
lu_get_date (const char *p, const time_t *now)
2376
struct tm tm, tm0, *tmp;
2380
Start = now ? *now : time ((time_t *) NULL);
2381
tmp = localtime (&Start);
2382
memset (&yy, 0, sizeof(yy));
2383
yy.Year = tmp->tm_year + TM_YEAR_ORIGIN;
2384
yy.Month = tmp->tm_mon + 1;
2385
yy.Day = tmp->tm_mday;
2386
yy.Hour = tmp->tm_hour;
2387
yy.Minutes = tmp->tm_min;
2388
yy.Seconds = tmp->tm_sec;
2389
yy.Meridian = MER24;
2402
if (yyparse (&p, &yy)
2403
|| yy.HaveTime > 1 || yy.HaveZone > 1 || yy.HaveDate > 1 || yy.HaveDay > 1)
2406
tm.tm_year = ToYear (yy.Year) - TM_YEAR_ORIGIN + yy.RelYear;
2407
tm.tm_mon = yy.Month - 1 + yy.RelMonth;
2408
tm.tm_mday = yy.Day + yy.RelDay;
2409
if (yy.HaveTime || (yy.HaveRel && !yy.HaveDate && !yy.HaveDay))
2411
tm.tm_hour = ToHour (yy.Hour, yy.Meridian);
2414
tm.tm_min = yy.Minutes;
2415
tm.tm_sec = yy.Seconds;
2419
tm.tm_hour = tm.tm_min = tm.tm_sec = 0;
2421
tm.tm_hour += yy.RelHour;
2422
tm.tm_min += yy.RelMinutes;
2423
tm.tm_sec += yy.RelSeconds;
2427
Start = mktime (&tm);
2429
if (Start == (time_t) -1)
2432
/* Guard against falsely reporting errors near the time_t boundaries
2433
when parsing times in other time zones. For example, if the min
2434
time_t value is 1970-01-01 00:00:00 UTC and we are 8 hours ahead
2435
of UTC, then the min localtime value is 1970-01-01 08:00:00; if
2436
we apply mktime to 1970-01-01 00:00:00 we will get an error, so
2437
we apply mktime to 1970-01-02 08:00:00 instead and adjust the time
2438
zone by 24 hours to compensate. This algorithm assumes that
2439
there is no DST transition within a day of the time_t boundaries. */
2443
if (tm.tm_year <= EPOCH - TM_YEAR_ORIGIN)
2446
yy.Timezone -= 24 * 60;
2451
yy.Timezone += 24 * 60;
2453
Start = mktime (&tm);
2456
if (Start == (time_t) -1)
2460
if (yy.HaveDay && !yy.HaveDate)
2462
tm.tm_mday += ((yy.DayNumber - tm.tm_wday + 7) % 7
2463
+ 7 * (yy.DayOrdinal - (0 < yy.DayOrdinal)));
2464
Start = mktime (&tm);
2465
if (Start == (time_t) -1)
2471
long delta = yy.Timezone * 60L + difftm (&tm, gmtime (&Start));
2472
if ((Start + delta < Start) != (delta < 0))
2473
return -1; /* time_t overflow */
2488
char buff[MAX_BUFF_LEN + 1];
2491
(void) printf ("Enter date, or blank line to exit.\n\t> ");
2492
(void) fflush (stdout);
2494
buff[MAX_BUFF_LEN] = 0;
2495
while (fgets (buff, MAX_BUFF_LEN, stdin) && buff[0])
2497
d = lu_get_date (buff, (time_t *) NULL);
2499
(void) printf ("Bad format - couldn't convert.\n");
2501
(void) printf ("%s", ctime (&d));
2502
(void) printf ("\t> ");
2503
(void) fflush (stdout);
2508
#endif /* defined (TEST) */