Began setting up a second server socket that will be used exclusively for admin utilities
[citadel.git] / citadel / parsedate.c
1 /* A Bison parser, made by GNU Bison 2.5.  */
2
3 /* Bison implementation for Yacc-like parsers in C
4    
5       Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc.
6    
7    This program is free software: you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation, either version 3 of the License, or
10    (at your option) any later version.
11    
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16    
17    You should have received a copy of the GNU General Public License
18    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
19
20 /* As a special exception, you may create a larger work that contains
21    part or all of the Bison parser skeleton and distribute that work
22    under terms of your choice, so long as that work isn't itself a
23    parser generator using the skeleton or a modified version thereof
24    as a parser skeleton.  Alternatively, if you modify or redistribute
25    the parser skeleton itself, you may (at your option) remove this
26    special exception, which will cause the skeleton and the resulting
27    Bison output files to be licensed under the GNU General Public
28    License without this special exception.
29    
30    This special exception was added by the Free Software Foundation in
31    version 2.2 of Bison.  */
32
33 /* C LALR(1) parser skeleton written by Richard Stallman, by
34    simplifying the original so-called "semantic" parser.  */
35
36 /* All symbols defined below should begin with yy or YY, to avoid
37    infringing on user name space.  This should be done even for local
38    variables, as they might otherwise be expanded by user macros.
39    There are some unavoidable exceptions within include files to
40    define necessary library symbols; they are noted "INFRINGES ON
41    USER NAME SPACE" below.  */
42
43 /* Identify Bison output.  */
44 #define YYBISON 1
45
46 /* Bison version.  */
47 #define YYBISON_VERSION "2.5"
48
49 /* Skeleton name.  */
50 #define YYSKELETON_NAME "yacc.c"
51
52 /* Pure parsers.  */
53 #define YYPURE 0
54
55 /* Push parsers.  */
56 #define YYPUSH 0
57
58 /* Pull parsers.  */
59 #define YYPULL 1
60
61 /* Using locations.  */
62 #define YYLSP_NEEDED 0
63
64
65
66 /* Copy the first part of user declarations.  */
67
68 /* Line 268 of yacc.c  */
69 #line 1 "parsedate.y"
70
71 /* $Revision$
72 **
73 **  Originally written by Steven M. Bellovin <smb@research.att.com> while
74 **  at the University of North Carolina at Chapel Hill.  Later tweaked by
75 **  a couple of people on Usenet.  Completely overhauled by Rich $alz
76 **  <rsalz@osf.org> and Jim Berets <jberets@bbn.com> in August, 1990.
77 **  Further revised (removed obsolete constructs and cleaned up timezone
78 **  names) in August, 1991, by Rich.  Paul Eggert <eggert@twinsun.com>
79 **  helped in September, 1992.  Art Cancro <ajc@uncensored.citadel.org> cleaned
80 **  it up for ANSI C in December, 1999.
81 **
82 **  This grammar has six shift/reduce conflicts.
83 **
84 **  This code is in the public domain and has no copyright.
85 */
86 /* SUPPRESS 530 *//* Empty body for statement */
87 /* SUPPRESS 593 on yyerrlab *//* Label was not used */
88 /* SUPPRESS 593 on yynewstate *//* Label was not used */
89 /* SUPPRESS 595 on yypvt *//* Automatic variable may be used before set */
90
91 #include "sysdep.h"
92
93 #include <stdio.h>
94 #include <stdlib.h>
95 #include <sys/types.h>
96 #include <ctype.h>
97
98 #if TIME_WITH_SYS_TIME
99 # include <sys/time.h>
100 # include <time.h>
101 #else
102 # if HAVE_SYS_TIME_H
103 #  include <sys/time.h>
104 # else
105 #  include <time.h>
106 # endif
107 #endif
108
109 #if HAVE_STRING_H
110 # if !STDC_HEADERS && HAVE_MEMORY_H
111 #  include <memory.h>
112 # endif
113 # include <string.h>
114 #endif
115 #if HAVE_STRINGS_H
116 # include <strings.h>
117 #endif
118
119 #include "parsedate.h"
120
121 int date_lex(void);
122
123 #define yyparse         date_parse
124 #define yylex           date_lex
125 #define yyerror         date_error
126
127
128     /* See the LeapYears table in Convert. */
129 #define EPOCH           1970
130 #define END_OF_TIME     2038
131     /* Constants for general time calculations. */
132 #define DST_OFFSET      1
133 #define SECSPERDAY      (24L * 60L * 60L)
134     /* Readability for TABLE stuff. */
135 #define HOUR(x)         (x * 60)
136
137 #define LPAREN          '('
138 #define RPAREN          ')'
139 #define IS7BIT(x)       ((unsigned int)(x) < 0200)
140
141 #define SIZEOF(array)   ((int)(sizeof array / sizeof array[0]))
142 #define ENDOF(array)    (&array[SIZEOF(array)])
143
144
145 /*
146 **  An entry in the lexical lookup table.
147 */
148 typedef struct _TABLE {
149     char        *name;
150     int         type;
151     time_t      value;
152 } TABLE;
153
154 /*
155 **  Daylight-savings mode:  on, off, or not yet known.
156 */
157 typedef enum _DSTMODE {
158     DSTon, DSToff, DSTmaybe
159 } DSTMODE;
160
161 /*
162 **  Meridian:  am, pm, or 24-hour style.
163 */
164 typedef enum _MERIDIAN {
165     MERam, MERpm, MER24
166 } MERIDIAN;
167
168
169 /*
170 **  Global variables.  We could get rid of most of them by using a yacc
171 **  union, but this is more efficient.  (This routine predates the
172 **  yacc %union construct.)
173 */
174 static const char       *yyInput;
175 static DSTMODE  yyDSTmode;
176 static int      yyHaveDate;
177 static int      yyHaveRel;
178 static int      yyHaveTime;
179 static time_t   yyTimezone;
180 static time_t   yyDay;
181 static time_t   yyHour;
182 static time_t   yyMinutes;
183 static time_t   yyMonth;
184 static time_t   yySeconds;
185 static time_t   yyYear;
186 static MERIDIAN yyMeridian;
187 static time_t   yyRelMonth;
188 static time_t   yyRelSeconds;
189
190
191 static void             date_error(char *);
192
193
194 /* Line 268 of yacc.c  */
195 #line 196 "y.tab.c"
196
197 /* Enabling traces.  */
198 #ifndef YYDEBUG
199 # define YYDEBUG 0
200 #endif
201
202 /* Enabling verbose error messages.  */
203 #ifdef YYERROR_VERBOSE
204 # undef YYERROR_VERBOSE
205 # define YYERROR_VERBOSE 1
206 #else
207 # define YYERROR_VERBOSE 0
208 #endif
209
210 /* Enabling the token table.  */
211 #ifndef YYTOKEN_TABLE
212 # define YYTOKEN_TABLE 0
213 #endif
214
215
216 /* Tokens.  */
217 #ifndef YYTOKENTYPE
218 # define YYTOKENTYPE
219    /* Put the tokens into the symbol table, so that GDB and other debuggers
220       know about them.  */
221    enum yytokentype {
222      tDAY = 258,
223      tDAYZONE = 259,
224      tMERIDIAN = 260,
225      tMONTH = 261,
226      tMONTH_UNIT = 262,
227      tSEC_UNIT = 263,
228      tSNUMBER = 264,
229      tUNUMBER = 265,
230      tZONE = 266
231    };
232 #endif
233 /* Tokens.  */
234 #define tDAY 258
235 #define tDAYZONE 259
236 #define tMERIDIAN 260
237 #define tMONTH 261
238 #define tMONTH_UNIT 262
239 #define tSEC_UNIT 263
240 #define tSNUMBER 264
241 #define tUNUMBER 265
242 #define tZONE 266
243
244
245
246
247 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
248 typedef union YYSTYPE
249 {
250
251 /* Line 293 of yacc.c  */
252 #line 125 "parsedate.y"
253
254     time_t              Number;
255     enum _MERIDIAN      Meridian;
256
257
258
259 /* Line 293 of yacc.c  */
260 #line 261 "y.tab.c"
261 } YYSTYPE;
262 # define YYSTYPE_IS_TRIVIAL 1
263 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
264 # define YYSTYPE_IS_DECLARED 1
265 #endif
266
267
268 /* Copy the second part of user declarations.  */
269
270
271 /* Line 343 of yacc.c  */
272 #line 273 "y.tab.c"
273
274 #ifdef short
275 # undef short
276 #endif
277
278 #ifdef YYTYPE_UINT8
279 typedef YYTYPE_UINT8 yytype_uint8;
280 #else
281 typedef unsigned char yytype_uint8;
282 #endif
283
284 #ifdef YYTYPE_INT8
285 typedef YYTYPE_INT8 yytype_int8;
286 #elif (defined __STDC__ || defined __C99__FUNC__ \
287      || defined __cplusplus || defined _MSC_VER)
288 typedef signed char yytype_int8;
289 #else
290 typedef short int yytype_int8;
291 #endif
292
293 #ifdef YYTYPE_UINT16
294 typedef YYTYPE_UINT16 yytype_uint16;
295 #else
296 typedef unsigned short int yytype_uint16;
297 #endif
298
299 #ifdef YYTYPE_INT16
300 typedef YYTYPE_INT16 yytype_int16;
301 #else
302 typedef short int yytype_int16;
303 #endif
304
305 #ifndef YYSIZE_T
306 # ifdef __SIZE_TYPE__
307 #  define YYSIZE_T __SIZE_TYPE__
308 # elif defined size_t
309 #  define YYSIZE_T size_t
310 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
311      || defined __cplusplus || defined _MSC_VER)
312 #  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
313 #  define YYSIZE_T size_t
314 # else
315 #  define YYSIZE_T unsigned int
316 # endif
317 #endif
318
319 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
320
321 #ifndef YY_
322 # if defined YYENABLE_NLS && YYENABLE_NLS
323 #  if ENABLE_NLS
324 #   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
325 #   define YY_(msgid) dgettext ("bison-runtime", msgid)
326 #  endif
327 # endif
328 # ifndef YY_
329 #  define YY_(msgid) msgid
330 # endif
331 #endif
332
333 /* Suppress unused-variable warnings by "using" E.  */
334 #if ! defined lint || defined __GNUC__
335 # define YYUSE(e) ((void) (e))
336 #else
337 # define YYUSE(e) /* empty */
338 #endif
339
340 /* Identity function, used to suppress warnings about constant conditions.  */
341 #ifndef lint
342 # define YYID(n) (n)
343 #else
344 #if (defined __STDC__ || defined __C99__FUNC__ \
345      || defined __cplusplus || defined _MSC_VER)
346 static int
347 YYID (int yyi)
348 #else
349 static int
350 YYID (yyi)
351     int yyi;
352 #endif
353 {
354   return yyi;
355 }
356 #endif
357
358 #if ! defined yyoverflow || YYERROR_VERBOSE
359
360 /* The parser invokes alloca or malloc; define the necessary symbols.  */
361
362 # ifdef YYSTACK_USE_ALLOCA
363 #  if YYSTACK_USE_ALLOCA
364 #   ifdef __GNUC__
365 #    define YYSTACK_ALLOC __builtin_alloca
366 #   elif defined __BUILTIN_VA_ARG_INCR
367 #    include <alloca.h> /* INFRINGES ON USER NAME SPACE */
368 #   elif defined _AIX
369 #    define YYSTACK_ALLOC __alloca
370 #   elif defined _MSC_VER
371 #    include <malloc.h> /* INFRINGES ON USER NAME SPACE */
372 #    define alloca _alloca
373 #   else
374 #    define YYSTACK_ALLOC alloca
375 #    if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
376      || defined __cplusplus || defined _MSC_VER)
377 #     include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
378 #     ifndef EXIT_SUCCESS
379 #      define EXIT_SUCCESS 0
380 #     endif
381 #    endif
382 #   endif
383 #  endif
384 # endif
385
386 # ifdef YYSTACK_ALLOC
387    /* Pacify GCC's `empty if-body' warning.  */
388 #  define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
389 #  ifndef YYSTACK_ALLOC_MAXIMUM
390     /* The OS might guarantee only one guard page at the bottom of the stack,
391        and a page size can be as small as 4096 bytes.  So we cannot safely
392        invoke alloca (N) if N exceeds 4096.  Use a slightly smaller number
393        to allow for a few compiler-allocated temporary stack slots.  */
394 #   define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
395 #  endif
396 # else
397 #  define YYSTACK_ALLOC YYMALLOC
398 #  define YYSTACK_FREE YYFREE
399 #  ifndef YYSTACK_ALLOC_MAXIMUM
400 #   define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
401 #  endif
402 #  if (defined __cplusplus && ! defined EXIT_SUCCESS \
403        && ! ((defined YYMALLOC || defined malloc) \
404              && (defined YYFREE || defined free)))
405 #   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
406 #   ifndef EXIT_SUCCESS
407 #    define EXIT_SUCCESS 0
408 #   endif
409 #  endif
410 #  ifndef YYMALLOC
411 #   define YYMALLOC malloc
412 #   if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
413      || defined __cplusplus || defined _MSC_VER)
414 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
415 #   endif
416 #  endif
417 #  ifndef YYFREE
418 #   define YYFREE free
419 #   if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
420      || defined __cplusplus || defined _MSC_VER)
421 void free (void *); /* INFRINGES ON USER NAME SPACE */
422 #   endif
423 #  endif
424 # endif
425 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
426
427
428 #if (! defined yyoverflow \
429      && (! defined __cplusplus \
430          || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
431
432 /* A type that is properly aligned for any stack member.  */
433 union yyalloc
434 {
435   yytype_int16 yyss_alloc;
436   YYSTYPE yyvs_alloc;
437 };
438
439 /* The size of the maximum gap between one aligned stack and the next.  */
440 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
441
442 /* The size of an array large to enough to hold all stacks, each with
443    N elements.  */
444 # define YYSTACK_BYTES(N) \
445      ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
446       + YYSTACK_GAP_MAXIMUM)
447
448 # define YYCOPY_NEEDED 1
449
450 /* Relocate STACK from its old location to the new one.  The
451    local variables YYSIZE and YYSTACKSIZE give the old and new number of
452    elements in the stack, and YYPTR gives the new location of the
453    stack.  Advance YYPTR to a properly aligned location for the next
454    stack.  */
455 # define YYSTACK_RELOCATE(Stack_alloc, Stack)                           \
456     do                                                                  \
457       {                                                                 \
458         YYSIZE_T yynewbytes;                                            \
459         YYCOPY (&yyptr->Stack_alloc, Stack, yysize);                    \
460         Stack = &yyptr->Stack_alloc;                                    \
461         yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
462         yyptr += yynewbytes / sizeof (*yyptr);                          \
463       }                                                                 \
464     while (YYID (0))
465
466 #endif
467
468 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
469 /* Copy COUNT objects from FROM to TO.  The source and destination do
470    not overlap.  */
471 # ifndef YYCOPY
472 #  if defined __GNUC__ && 1 < __GNUC__
473 #   define YYCOPY(To, From, Count) \
474       __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
475 #  else
476 #   define YYCOPY(To, From, Count)              \
477       do                                        \
478         {                                       \
479           YYSIZE_T yyi;                         \
480           for (yyi = 0; yyi < (Count); yyi++)   \
481             (To)[yyi] = (From)[yyi];            \
482         }                                       \
483       while (YYID (0))
484 #  endif
485 # endif
486 #endif /* !YYCOPY_NEEDED */
487
488 /* YYFINAL -- State number of the termination state.  */
489 #define YYFINAL  2
490 /* YYLAST -- Last index in YYTABLE.  */
491 #define YYLAST   40
492
493 /* YYNTOKENS -- Number of terminals.  */
494 #define YYNTOKENS  15
495 /* YYNNTS -- Number of nonterminals.  */
496 #define YYNNTS  9
497 /* YYNRULES -- Number of rules.  */
498 #define YYNRULES  30
499 /* YYNRULES -- Number of states.  */
500 #define YYNSTATES  44
501
502 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
503 #define YYUNDEFTOK  2
504 #define YYMAXUTOK   266
505
506 #define YYTRANSLATE(YYX)                                                \
507   ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
508
509 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX.  */
510 static const yytype_uint8 yytranslate[] =
511 {
512        0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
513        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
514        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
515        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
516        2,     2,     2,     2,    14,     2,     2,    13,     2,     2,
517        2,     2,     2,     2,     2,     2,     2,     2,    12,     2,
518        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
519        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
520        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
521        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
522        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
523        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
524        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
525        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
526        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
527        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
528        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
529        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
530        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
531        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
532        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
533        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
534        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
535        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
536        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
537        2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
538        5,     6,     7,     8,     9,    10,    11
539 };
540
541 #if YYDEBUG
542 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
543    YYRHS.  */
544 static const yytype_uint8 yyprhs[] =
545 {
546        0,     0,     3,     4,     7,     9,    12,    14,    16,    19,
547       24,    29,    36,    43,    45,    47,    50,    52,    54,    58,
548       64,    67,    72,    75,    79,    85,    88,    91,    94,    97,
549       98
550 };
551
552 /* YYRHS -- A `-1'-separated list of the rules' RHS.  */
553 static const yytype_int8 yyrhs[] =
554 {
555       16,     0,    -1,    -1,    16,    17,    -1,    18,    -1,    18,
556       19,    -1,    21,    -1,    22,    -1,    10,    23,    -1,    10,
557       12,    10,    23,    -1,    10,    12,    10,    20,    -1,    10,
558       12,    10,    12,    10,    23,    -1,    10,    12,    10,    12,
559       10,    20,    -1,    11,    -1,     4,    -1,    11,    20,    -1,
560       20,    -1,     9,    -1,    10,    13,    10,    -1,    10,    13,
561       10,    13,    10,    -1,     6,    10,    -1,     6,    10,    14,
562       10,    -1,    10,     6,    -1,    10,     6,    10,    -1,     3,
563       14,    10,     6,    10,    -1,     9,     8,    -1,    10,     8,
564       -1,     9,     7,    -1,    10,     7,    -1,    -1,     5,    -1
565 };
566
567 /* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
568 static const yytype_uint16 yyrline[] =
569 {
570        0,   139,   139,   140,   143,   152,   156,   159,   164,   176,
571      182,   189,   195,   205,   209,   213,   221,   227,   248,   252,
572      264,   268,   273,   277,   282,   289,   292,   295,   298,   303,
573      306
574 };
575 #endif
576
577 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
578 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
579    First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
580 static const char *const yytname[] =
581 {
582   "$end", "error", "$undefined", "tDAY", "tDAYZONE", "tMERIDIAN",
583   "tMONTH", "tMONTH_UNIT", "tSEC_UNIT", "tSNUMBER", "tUNUMBER", "tZONE",
584   "':'", "'/'", "','", "$accept", "spec", "item", "time", "zone",
585   "numzone", "date", "rel", "o_merid", 0
586 };
587 #endif
588
589 # ifdef YYPRINT
590 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
591    token YYLEX-NUM.  */
592 static const yytype_uint16 yytoknum[] =
593 {
594        0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
595      265,   266,    58,    47,    44
596 };
597 # endif
598
599 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
600 static const yytype_uint8 yyr1[] =
601 {
602        0,    15,    16,    16,    17,    17,    17,    17,    18,    18,
603       18,    18,    18,    19,    19,    19,    19,    20,    21,    21,
604       21,    21,    21,    21,    21,    22,    22,    22,    22,    23,
605       23
606 };
607
608 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
609 static const yytype_uint8 yyr2[] =
610 {
611        0,     2,     0,     2,     1,     2,     1,     1,     2,     4,
612        4,     6,     6,     1,     1,     2,     1,     1,     3,     5,
613        2,     4,     2,     3,     5,     2,     2,     2,     2,     0,
614        1
615 };
616
617 /* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
618    Performed when YYTABLE doesn't specify something else to do.  Zero
619    means the default is an error.  */
620 static const yytype_uint8 yydefact[] =
621 {
622        2,     0,     1,     0,     0,     0,    29,     3,     4,     6,
623        7,     0,    20,    27,    25,    30,    22,    28,    26,     0,
624        0,     8,    14,    17,    13,     5,    16,     0,     0,    23,
625       29,    18,    15,     0,    21,     0,    10,     9,     0,    24,
626       29,    19,    12,    11
627 };
628
629 /* YYDEFGOTO[NTERM-NUM].  */
630 static const yytype_int8 yydefgoto[] =
631 {
632       -1,     1,     7,     8,    25,    26,     9,    10,    21
633 };
634
635 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
636    STATE-NUM.  */
637 #define YYPACT_NINF -29
638 static const yytype_int8 yypact[] =
639 {
640      -29,     1,   -29,   -11,    11,    20,    12,   -29,     4,   -29,
641      -29,    13,    16,   -29,   -29,   -29,    21,   -29,   -29,    22,
642       23,   -29,   -29,   -29,     5,   -29,   -29,    28,    25,   -29,
643       17,    24,   -29,    26,   -29,    29,   -29,   -29,    30,   -29,
644        0,   -29,   -29,   -29
645 };
646
647 /* YYPGOTO[NTERM-NUM].  */
648 static const yytype_int8 yypgoto[] =
649 {
650      -29,   -29,   -29,   -29,   -29,   -24,   -29,   -29,   -28
651 };
652
653 /* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
654    positive, shift that token.  If negative, reduce the rule which
655    number is the opposite.  If YYTABLE_NINF, syntax error.  */
656 #define YYTABLE_NINF -1
657 static const yytype_uint8 yytable[] =
658 {
659       32,     2,    37,    11,     3,    15,    36,     4,    22,    23,
660        5,     6,    43,    23,    23,    24,    42,    15,    16,    17,
661       18,    12,    15,    27,    19,    20,    23,    13,    14,    35,
662       28,    29,    30,    31,    33,    34,    39,    38,     0,    40,
663       41
664 };
665
666 #define yypact_value_is_default(yystate) \
667   ((yystate) == (-29))
668
669 #define yytable_value_is_error(yytable_value) \
670   YYID (0)
671
672 static const yytype_int8 yycheck[] =
673 {
674       24,     0,    30,    14,     3,     5,    30,     6,     4,     9,
675        9,    10,    40,     9,     9,    11,    40,     5,     6,     7,
676        8,    10,     5,    10,    12,    13,     9,     7,     8,    12,
677       14,    10,    10,    10,     6,    10,    10,    13,    -1,    10,
678       10
679 };
680
681 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
682    symbol of state STATE-NUM.  */
683 static const yytype_uint8 yystos[] =
684 {
685        0,    16,     0,     3,     6,     9,    10,    17,    18,    21,
686       22,    14,    10,     7,     8,     5,     6,     7,     8,    12,
687       13,    23,     4,     9,    11,    19,    20,    10,    14,    10,
688       10,    10,    20,     6,    10,    12,    20,    23,    13,    10,
689       10,    10,    20,    23
690 };
691
692 #define yyerrok         (yyerrstatus = 0)
693 #define yyclearin       (yychar = YYEMPTY)
694 #define YYEMPTY         (-2)
695 #define YYEOF           0
696
697 #define YYACCEPT        goto yyacceptlab
698 #define YYABORT         goto yyabortlab
699 #define YYERROR         goto yyerrorlab
700
701
702 /* Like YYERROR except do call yyerror.  This remains here temporarily
703    to ease the transition to the new meaning of YYERROR, for GCC.
704    Once GCC version 2 has supplanted version 1, this can go.  However,
705    YYFAIL appears to be in use.  Nevertheless, it is formally deprecated
706    in Bison 2.4.2's NEWS entry, where a plan to phase it out is
707    discussed.  */
708
709 #define YYFAIL          goto yyerrlab
710 #if defined YYFAIL
711   /* This is here to suppress warnings from the GCC cpp's
712      -Wunused-macros.  Normally we don't worry about that warning, but
713      some users do, and we want to make it easy for users to remove
714      YYFAIL uses, which will produce warnings from Bison 2.5.  */
715 #endif
716
717 #define YYRECOVERING()  (!!yyerrstatus)
718
719 #define YYBACKUP(Token, Value)                                  \
720 do                                                              \
721   if (yychar == YYEMPTY && yylen == 1)                          \
722     {                                                           \
723       yychar = (Token);                                         \
724       yylval = (Value);                                         \
725       YYPOPSTACK (1);                                           \
726       goto yybackup;                                            \
727     }                                                           \
728   else                                                          \
729     {                                                           \
730       yyerror (YY_("syntax error: cannot back up")); \
731       YYERROR;                                                  \
732     }                                                           \
733 while (YYID (0))
734
735
736 #define YYTERROR        1
737 #define YYERRCODE       256
738
739
740 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
741    If N is 0, then set CURRENT to the empty location which ends
742    the previous symbol: RHS[0] (always defined).  */
743
744 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
745 #ifndef YYLLOC_DEFAULT
746 # define YYLLOC_DEFAULT(Current, Rhs, N)                                \
747     do                                                                  \
748       if (YYID (N))                                                    \
749         {                                                               \
750           (Current).first_line   = YYRHSLOC (Rhs, 1).first_line;        \
751           (Current).first_column = YYRHSLOC (Rhs, 1).first_column;      \
752           (Current).last_line    = YYRHSLOC (Rhs, N).last_line;         \
753           (Current).last_column  = YYRHSLOC (Rhs, N).last_column;       \
754         }                                                               \
755       else                                                              \
756         {                                                               \
757           (Current).first_line   = (Current).last_line   =              \
758             YYRHSLOC (Rhs, 0).last_line;                                \
759           (Current).first_column = (Current).last_column =              \
760             YYRHSLOC (Rhs, 0).last_column;                              \
761         }                                                               \
762     while (YYID (0))
763 #endif
764
765
766 /* This macro is provided for backward compatibility. */
767
768 #ifndef YY_LOCATION_PRINT
769 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
770 #endif
771
772
773 /* YYLEX -- calling `yylex' with the right arguments.  */
774
775 #ifdef YYLEX_PARAM
776 # define YYLEX yylex (YYLEX_PARAM)
777 #else
778 # define YYLEX yylex ()
779 #endif
780
781 /* Enable debugging if requested.  */
782 #if YYDEBUG
783
784 # ifndef YYFPRINTF
785 #  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
786 #  define YYFPRINTF fprintf
787 # endif
788
789 # define YYDPRINTF(Args)                        \
790 do {                                            \
791   if (yydebug)                                  \
792     YYFPRINTF Args;                             \
793 } while (YYID (0))
794
795 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)                    \
796 do {                                                                      \
797   if (yydebug)                                                            \
798     {                                                                     \
799       YYFPRINTF (stderr, "%s ", Title);                                   \
800       yy_symbol_print (stderr,                                            \
801                   Type, Value); \
802       YYFPRINTF (stderr, "\n");                                           \
803     }                                                                     \
804 } while (YYID (0))
805
806
807 /*--------------------------------.
808 | Print this symbol on YYOUTPUT.  |
809 `--------------------------------*/
810
811 /*ARGSUSED*/
812 #if (defined __STDC__ || defined __C99__FUNC__ \
813      || defined __cplusplus || defined _MSC_VER)
814 static void
815 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
816 #else
817 static void
818 yy_symbol_value_print (yyoutput, yytype, yyvaluep)
819     FILE *yyoutput;
820     int yytype;
821     YYSTYPE const * const yyvaluep;
822 #endif
823 {
824   if (!yyvaluep)
825     return;
826 # ifdef YYPRINT
827   if (yytype < YYNTOKENS)
828     YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
829 # else
830   YYUSE (yyoutput);
831 # endif
832   switch (yytype)
833     {
834       default:
835         break;
836     }
837 }
838
839
840 /*--------------------------------.
841 | Print this symbol on YYOUTPUT.  |
842 `--------------------------------*/
843
844 #if (defined __STDC__ || defined __C99__FUNC__ \
845      || defined __cplusplus || defined _MSC_VER)
846 static void
847 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
848 #else
849 static void
850 yy_symbol_print (yyoutput, yytype, yyvaluep)
851     FILE *yyoutput;
852     int yytype;
853     YYSTYPE const * const yyvaluep;
854 #endif
855 {
856   if (yytype < YYNTOKENS)
857     YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
858   else
859     YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
860
861   yy_symbol_value_print (yyoutput, yytype, yyvaluep);
862   YYFPRINTF (yyoutput, ")");
863 }
864
865 /*------------------------------------------------------------------.
866 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
867 | TOP (included).                                                   |
868 `------------------------------------------------------------------*/
869
870 #if (defined __STDC__ || defined __C99__FUNC__ \
871      || defined __cplusplus || defined _MSC_VER)
872 static void
873 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
874 #else
875 static void
876 yy_stack_print (yybottom, yytop)
877     yytype_int16 *yybottom;
878     yytype_int16 *yytop;
879 #endif
880 {
881   YYFPRINTF (stderr, "Stack now");
882   for (; yybottom <= yytop; yybottom++)
883     {
884       int yybot = *yybottom;
885       YYFPRINTF (stderr, " %d", yybot);
886     }
887   YYFPRINTF (stderr, "\n");
888 }
889
890 # define YY_STACK_PRINT(Bottom, Top)                            \
891 do {                                                            \
892   if (yydebug)                                                  \
893     yy_stack_print ((Bottom), (Top));                           \
894 } while (YYID (0))
895
896
897 /*------------------------------------------------.
898 | Report that the YYRULE is going to be reduced.  |
899 `------------------------------------------------*/
900
901 #if (defined __STDC__ || defined __C99__FUNC__ \
902      || defined __cplusplus || defined _MSC_VER)
903 static void
904 yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
905 #else
906 static void
907 yy_reduce_print (yyvsp, yyrule)
908     YYSTYPE *yyvsp;
909     int yyrule;
910 #endif
911 {
912   int yynrhs = yyr2[yyrule];
913   int yyi;
914   unsigned long int yylno = yyrline[yyrule];
915   YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
916              yyrule - 1, yylno);
917   /* The symbols being reduced.  */
918   for (yyi = 0; yyi < yynrhs; yyi++)
919     {
920       YYFPRINTF (stderr, "   $%d = ", yyi + 1);
921       yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
922                        &(yyvsp[(yyi + 1) - (yynrhs)])
923                                        );
924       YYFPRINTF (stderr, "\n");
925     }
926 }
927
928 # define YY_REDUCE_PRINT(Rule)          \
929 do {                                    \
930   if (yydebug)                          \
931     yy_reduce_print (yyvsp, Rule); \
932 } while (YYID (0))
933
934 /* Nonzero means print parse trace.  It is left uninitialized so that
935    multiple parsers can coexist.  */
936 int yydebug;
937 #else /* !YYDEBUG */
938 # define YYDPRINTF(Args)
939 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
940 # define YY_STACK_PRINT(Bottom, Top)
941 # define YY_REDUCE_PRINT(Rule)
942 #endif /* !YYDEBUG */
943
944
945 /* YYINITDEPTH -- initial size of the parser's stacks.  */
946 #ifndef YYINITDEPTH
947 # define YYINITDEPTH 200
948 #endif
949
950 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
951    if the built-in stack extension method is used).
952
953    Do not make this value too large; the results are undefined if
954    YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
955    evaluated with infinite-precision integer arithmetic.  */
956
957 #ifndef YYMAXDEPTH
958 # define YYMAXDEPTH 10000
959 #endif
960
961
962 #if YYERROR_VERBOSE
963
964 # ifndef yystrlen
965 #  if defined __GLIBC__ && defined _STRING_H
966 #   define yystrlen strlen
967 #  else
968 /* Return the length of YYSTR.  */
969 #if (defined __STDC__ || defined __C99__FUNC__ \
970      || defined __cplusplus || defined _MSC_VER)
971 static YYSIZE_T
972 yystrlen (const char *yystr)
973 #else
974 static YYSIZE_T
975 yystrlen (yystr)
976     const char *yystr;
977 #endif
978 {
979   YYSIZE_T yylen;
980   for (yylen = 0; yystr[yylen]; yylen++)
981     continue;
982   return yylen;
983 }
984 #  endif
985 # endif
986
987 # ifndef yystpcpy
988 #  if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
989 #   define yystpcpy stpcpy
990 #  else
991 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
992    YYDEST.  */
993 #if (defined __STDC__ || defined __C99__FUNC__ \
994      || defined __cplusplus || defined _MSC_VER)
995 static char *
996 yystpcpy (char *yydest, const char *yysrc)
997 #else
998 static char *
999 yystpcpy (yydest, yysrc)
1000     char *yydest;
1001     const char *yysrc;
1002 #endif
1003 {
1004   char *yyd = yydest;
1005   const char *yys = yysrc;
1006
1007   while ((*yyd++ = *yys++) != '\0')
1008     continue;
1009
1010   return yyd - 1;
1011 }
1012 #  endif
1013 # endif
1014
1015 # ifndef yytnamerr
1016 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1017    quotes and backslashes, so that it's suitable for yyerror.  The
1018    heuristic is that double-quoting is unnecessary unless the string
1019    contains an apostrophe, a comma, or backslash (other than
1020    backslash-backslash).  YYSTR is taken from yytname.  If YYRES is
1021    null, do not copy; instead, return the length of what the result
1022    would have been.  */
1023 static YYSIZE_T
1024 yytnamerr (char *yyres, const char *yystr)
1025 {
1026   if (*yystr == '"')
1027     {
1028       YYSIZE_T yyn = 0;
1029       char const *yyp = yystr;
1030
1031       for (;;)
1032         switch (*++yyp)
1033           {
1034           case '\'':
1035           case ',':
1036             goto do_not_strip_quotes;
1037
1038           case '\\':
1039             if (*++yyp != '\\')
1040               goto do_not_strip_quotes;
1041             /* Fall through.  */
1042           default:
1043             if (yyres)
1044               yyres[yyn] = *yyp;
1045             yyn++;
1046             break;
1047
1048           case '"':
1049             if (yyres)
1050               yyres[yyn] = '\0';
1051             return yyn;
1052           }
1053     do_not_strip_quotes: ;
1054     }
1055
1056   if (! yyres)
1057     return yystrlen (yystr);
1058
1059   return yystpcpy (yyres, yystr) - yyres;
1060 }
1061 # endif
1062
1063 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
1064    about the unexpected token YYTOKEN for the state stack whose top is
1065    YYSSP.
1066
1067    Return 0 if *YYMSG was successfully written.  Return 1 if *YYMSG is
1068    not large enough to hold the message.  In that case, also set
1069    *YYMSG_ALLOC to the required number of bytes.  Return 2 if the
1070    required number of bytes is too large to store.  */
1071 static int
1072 yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
1073                 yytype_int16 *yyssp, int yytoken)
1074 {
1075   YYSIZE_T yysize0 = yytnamerr (0, yytname[yytoken]);
1076   YYSIZE_T yysize = yysize0;
1077   YYSIZE_T yysize1;
1078   enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1079   /* Internationalized format string. */
1080   const char *yyformat = 0;
1081   /* Arguments of yyformat. */
1082   char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1083   /* Number of reported tokens (one for the "unexpected", one per
1084      "expected"). */
1085   int yycount = 0;
1086
1087   /* There are many possibilities here to consider:
1088      - Assume YYFAIL is not used.  It's too flawed to consider.  See
1089        <http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html>
1090        for details.  YYERROR is fine as it does not invoke this
1091        function.
1092      - If this state is a consistent state with a default action, then
1093        the only way this function was invoked is if the default action
1094        is an error action.  In that case, don't check for expected
1095        tokens because there are none.
1096      - The only way there can be no lookahead present (in yychar) is if
1097        this state is a consistent state with a default action.  Thus,
1098        detecting the absence of a lookahead is sufficient to determine
1099        that there is no unexpected or expected token to report.  In that
1100        case, just report a simple "syntax error".
1101      - Don't assume there isn't a lookahead just because this state is a
1102        consistent state with a default action.  There might have been a
1103        previous inconsistent state, consistent state with a non-default
1104        action, or user semantic action that manipulated yychar.
1105      - Of course, the expected token list depends on states to have
1106        correct lookahead information, and it depends on the parser not
1107        to perform extra reductions after fetching a lookahead from the
1108        scanner and before detecting a syntax error.  Thus, state merging
1109        (from LALR or IELR) and default reductions corrupt the expected
1110        token list.  However, the list is correct for canonical LR with
1111        one exception: it will still contain any token that will not be
1112        accepted due to an error action in a later state.
1113   */
1114   if (yytoken != YYEMPTY)
1115     {
1116       int yyn = yypact[*yyssp];
1117       yyarg[yycount++] = yytname[yytoken];
1118       if (!yypact_value_is_default (yyn))
1119         {
1120           /* Start YYX at -YYN if negative to avoid negative indexes in
1121              YYCHECK.  In other words, skip the first -YYN actions for
1122              this state because they are default actions.  */
1123           int yyxbegin = yyn < 0 ? -yyn : 0;
1124           /* Stay within bounds of both yycheck and yytname.  */
1125           int yychecklim = YYLAST - yyn + 1;
1126           int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1127           int yyx;
1128
1129           for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1130             if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
1131                 && !yytable_value_is_error (yytable[yyx + yyn]))
1132               {
1133                 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1134                   {
1135                     yycount = 1;
1136                     yysize = yysize0;
1137                     break;
1138                   }
1139                 yyarg[yycount++] = yytname[yyx];
1140                 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1141                 if (! (yysize <= yysize1
1142                        && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1143                   return 2;
1144                 yysize = yysize1;
1145               }
1146         }
1147     }
1148
1149   switch (yycount)
1150     {
1151 # define YYCASE_(N, S)                      \
1152       case N:                               \
1153         yyformat = S;                       \
1154       break
1155       YYCASE_(0, YY_("syntax error"));
1156       YYCASE_(1, YY_("syntax error, unexpected %s"));
1157       YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1158       YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1159       YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1160       YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1161 # undef YYCASE_
1162     }
1163
1164   yysize1 = yysize + yystrlen (yyformat);
1165   if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1166     return 2;
1167   yysize = yysize1;
1168
1169   if (*yymsg_alloc < yysize)
1170     {
1171       *yymsg_alloc = 2 * yysize;
1172       if (! (yysize <= *yymsg_alloc
1173              && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1174         *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1175       return 1;
1176     }
1177
1178   /* Avoid sprintf, as that infringes on the user's name space.
1179      Don't have undefined behavior even if the translation
1180      produced a string with the wrong number of "%s"s.  */
1181   {
1182     char *yyp = *yymsg;
1183     int yyi = 0;
1184     while ((*yyp = *yyformat) != '\0')
1185       if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1186         {
1187           yyp += yytnamerr (yyp, yyarg[yyi++]);
1188           yyformat += 2;
1189         }
1190       else
1191         {
1192           yyp++;
1193           yyformat++;
1194         }
1195   }
1196   return 0;
1197 }
1198 #endif /* YYERROR_VERBOSE */
1199
1200 /*-----------------------------------------------.
1201 | Release the memory associated to this symbol.  |
1202 `-----------------------------------------------*/
1203
1204 /*ARGSUSED*/
1205 #if (defined __STDC__ || defined __C99__FUNC__ \
1206      || defined __cplusplus || defined _MSC_VER)
1207 static void
1208 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1209 #else
1210 static void
1211 yydestruct (yymsg, yytype, yyvaluep)
1212     const char *yymsg;
1213     int yytype;
1214     YYSTYPE *yyvaluep;
1215 #endif
1216 {
1217   YYUSE (yyvaluep);
1218
1219   if (!yymsg)
1220     yymsg = "Deleting";
1221   YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1222
1223   switch (yytype)
1224     {
1225
1226       default:
1227         break;
1228     }
1229 }
1230
1231
1232 /* Prevent warnings from -Wmissing-prototypes.  */
1233 #ifdef YYPARSE_PARAM
1234 #if defined __STDC__ || defined __cplusplus
1235 int yyparse (void *YYPARSE_PARAM);
1236 #else
1237 int yyparse ();
1238 #endif
1239 #else /* ! YYPARSE_PARAM */
1240 #if defined __STDC__ || defined __cplusplus
1241 int yyparse (void);
1242 #else
1243 int yyparse ();
1244 #endif
1245 #endif /* ! YYPARSE_PARAM */
1246
1247
1248 /* The lookahead symbol.  */
1249 int yychar;
1250
1251 /* The semantic value of the lookahead symbol.  */
1252 YYSTYPE yylval;
1253
1254 /* Number of syntax errors so far.  */
1255 int yynerrs;
1256
1257
1258 /*----------.
1259 | yyparse.  |
1260 `----------*/
1261
1262 #ifdef YYPARSE_PARAM
1263 #if (defined __STDC__ || defined __C99__FUNC__ \
1264      || defined __cplusplus || defined _MSC_VER)
1265 int
1266 yyparse (void *YYPARSE_PARAM)
1267 #else
1268 int
1269 yyparse (YYPARSE_PARAM)
1270     void *YYPARSE_PARAM;
1271 #endif
1272 #else /* ! YYPARSE_PARAM */
1273 #if (defined __STDC__ || defined __C99__FUNC__ \
1274      || defined __cplusplus || defined _MSC_VER)
1275 int
1276 yyparse (void)
1277 #else
1278 int
1279 yyparse ()
1280
1281 #endif
1282 #endif
1283 {
1284     int yystate;
1285     /* Number of tokens to shift before error messages enabled.  */
1286     int yyerrstatus;
1287
1288     /* The stacks and their tools:
1289        `yyss': related to states.
1290        `yyvs': related to semantic values.
1291
1292        Refer to the stacks thru separate pointers, to allow yyoverflow
1293        to reallocate them elsewhere.  */
1294
1295     /* The state stack.  */
1296     yytype_int16 yyssa[YYINITDEPTH];
1297     yytype_int16 *yyss;
1298     yytype_int16 *yyssp;
1299
1300     /* The semantic value stack.  */
1301     YYSTYPE yyvsa[YYINITDEPTH];
1302     YYSTYPE *yyvs;
1303     YYSTYPE *yyvsp;
1304
1305     YYSIZE_T yystacksize;
1306
1307   int yyn;
1308   int yyresult;
1309   /* Lookahead token as an internal (translated) token number.  */
1310   int yytoken;
1311   /* The variables used to return semantic value and location from the
1312      action routines.  */
1313   YYSTYPE yyval;
1314
1315 #if YYERROR_VERBOSE
1316   /* Buffer for error messages, and its allocated size.  */
1317   char yymsgbuf[128];
1318   char *yymsg = yymsgbuf;
1319   YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1320 #endif
1321
1322 #define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N))
1323
1324   /* The number of symbols on the RHS of the reduced rule.
1325      Keep to zero when no symbol should be popped.  */
1326   int yylen = 0;
1327
1328   yytoken = 0;
1329   yyss = yyssa;
1330   yyvs = yyvsa;
1331   yystacksize = YYINITDEPTH;
1332
1333   YYDPRINTF ((stderr, "Starting parse\n"));
1334
1335   yystate = 0;
1336   yyerrstatus = 0;
1337   yynerrs = 0;
1338   yychar = YYEMPTY; /* Cause a token to be read.  */
1339
1340   /* Initialize stack pointers.
1341      Waste one element of value and location stack
1342      so that they stay on the same level as the state stack.
1343      The wasted elements are never initialized.  */
1344   yyssp = yyss;
1345   yyvsp = yyvs;
1346
1347   goto yysetstate;
1348
1349 /*------------------------------------------------------------.
1350 | yynewstate -- Push a new state, which is found in yystate.  |
1351 `------------------------------------------------------------*/
1352  yynewstate:
1353   /* In all cases, when you get here, the value and location stacks
1354      have just been pushed.  So pushing a state here evens the stacks.  */
1355   yyssp++;
1356
1357  yysetstate:
1358   *yyssp = yystate;
1359
1360   if (yyss + yystacksize - 1 <= yyssp)
1361     {
1362       /* Get the current used size of the three stacks, in elements.  */
1363       YYSIZE_T yysize = yyssp - yyss + 1;
1364
1365 #ifdef yyoverflow
1366       {
1367         /* Give user a chance to reallocate the stack.  Use copies of
1368            these so that the &'s don't force the real ones into
1369            memory.  */
1370         YYSTYPE *yyvs1 = yyvs;
1371         yytype_int16 *yyss1 = yyss;
1372
1373         /* Each stack pointer address is followed by the size of the
1374            data in use in that stack, in bytes.  This used to be a
1375            conditional around just the two extra args, but that might
1376            be undefined if yyoverflow is a macro.  */
1377         yyoverflow (YY_("memory exhausted"),
1378                     &yyss1, yysize * sizeof (*yyssp),
1379                     &yyvs1, yysize * sizeof (*yyvsp),
1380                     &yystacksize);
1381
1382         yyss = yyss1;
1383         yyvs = yyvs1;
1384       }
1385 #else /* no yyoverflow */
1386 # ifndef YYSTACK_RELOCATE
1387       goto yyexhaustedlab;
1388 # else
1389       /* Extend the stack our own way.  */
1390       if (YYMAXDEPTH <= yystacksize)
1391         goto yyexhaustedlab;
1392       yystacksize *= 2;
1393       if (YYMAXDEPTH < yystacksize)
1394         yystacksize = YYMAXDEPTH;
1395
1396       {
1397         yytype_int16 *yyss1 = yyss;
1398         union yyalloc *yyptr =
1399           (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1400         if (! yyptr)
1401           goto yyexhaustedlab;
1402         YYSTACK_RELOCATE (yyss_alloc, yyss);
1403         YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1404 #  undef YYSTACK_RELOCATE
1405         if (yyss1 != yyssa)
1406           YYSTACK_FREE (yyss1);
1407       }
1408 # endif
1409 #endif /* no yyoverflow */
1410
1411       yyssp = yyss + yysize - 1;
1412       yyvsp = yyvs + yysize - 1;
1413
1414       YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1415                   (unsigned long int) yystacksize));
1416
1417       if (yyss + yystacksize - 1 <= yyssp)
1418         YYABORT;
1419     }
1420
1421   YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1422
1423   if (yystate == YYFINAL)
1424     YYACCEPT;
1425
1426   goto yybackup;
1427
1428 /*-----------.
1429 | yybackup.  |
1430 `-----------*/
1431 yybackup:
1432
1433   /* Do appropriate processing given the current state.  Read a
1434      lookahead token if we need one and don't already have one.  */
1435
1436   /* First try to decide what to do without reference to lookahead token.  */
1437   yyn = yypact[yystate];
1438   if (yypact_value_is_default (yyn))
1439     goto yydefault;
1440
1441   /* Not known => get a lookahead token if don't already have one.  */
1442
1443   /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol.  */
1444   if (yychar == YYEMPTY)
1445     {
1446       YYDPRINTF ((stderr, "Reading a token: "));
1447       yychar = YYLEX;
1448     }
1449
1450   if (yychar <= YYEOF)
1451     {
1452       yychar = yytoken = YYEOF;
1453       YYDPRINTF ((stderr, "Now at end of input.\n"));
1454     }
1455   else
1456     {
1457       yytoken = YYTRANSLATE (yychar);
1458       YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1459     }
1460
1461   /* If the proper action on seeing token YYTOKEN is to reduce or to
1462      detect an error, take that action.  */
1463   yyn += yytoken;
1464   if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1465     goto yydefault;
1466   yyn = yytable[yyn];
1467   if (yyn <= 0)
1468     {
1469       if (yytable_value_is_error (yyn))
1470         goto yyerrlab;
1471       yyn = -yyn;
1472       goto yyreduce;
1473     }
1474
1475   /* Count tokens shifted since error; after three, turn off error
1476      status.  */
1477   if (yyerrstatus)
1478     yyerrstatus--;
1479
1480   /* Shift the lookahead token.  */
1481   YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1482
1483   /* Discard the shifted token.  */
1484   yychar = YYEMPTY;
1485
1486   yystate = yyn;
1487   *++yyvsp = yylval;
1488
1489   goto yynewstate;
1490
1491
1492 /*-----------------------------------------------------------.
1493 | yydefault -- do the default action for the current state.  |
1494 `-----------------------------------------------------------*/
1495 yydefault:
1496   yyn = yydefact[yystate];
1497   if (yyn == 0)
1498     goto yyerrlab;
1499   goto yyreduce;
1500
1501
1502 /*-----------------------------.
1503 | yyreduce -- Do a reduction.  |
1504 `-----------------------------*/
1505 yyreduce:
1506   /* yyn is the number of a rule to reduce with.  */
1507   yylen = yyr2[yyn];
1508
1509   /* If YYLEN is nonzero, implement the default value of the action:
1510      `$$ = $1'.
1511
1512      Otherwise, the following line sets YYVAL to garbage.
1513      This behavior is undocumented and Bison
1514      users should not rely upon it.  Assigning to YYVAL
1515      unconditionally makes the parser a bit smaller, and it avoids a
1516      GCC warning that YYVAL may be used uninitialized.  */
1517   yyval = yyvsp[1-yylen];
1518
1519
1520   YY_REDUCE_PRINT (yyn);
1521   switch (yyn)
1522     {
1523         case 4:
1524
1525 /* Line 1806 of yacc.c  */
1526 #line 143 "parsedate.y"
1527     {
1528             yyHaveTime++;
1529 #ifdef lint
1530             /* I am compulsive about lint natterings... */
1531             if (yyHaveTime == -1) {
1532                 YYERROR;
1533             }
1534 #endif /* lint */
1535         }
1536     break;
1537
1538   case 5:
1539
1540 /* Line 1806 of yacc.c  */
1541 #line 152 "parsedate.y"
1542     {
1543             yyHaveTime++;
1544             yyTimezone = (yyvsp[(2) - (2)].Number);
1545         }
1546     break;
1547
1548   case 6:
1549
1550 /* Line 1806 of yacc.c  */
1551 #line 156 "parsedate.y"
1552     {
1553             yyHaveDate++;
1554         }
1555     break;
1556
1557   case 7:
1558
1559 /* Line 1806 of yacc.c  */
1560 #line 159 "parsedate.y"
1561     {
1562             yyHaveRel = 1;
1563         }
1564     break;
1565
1566   case 8:
1567
1568 /* Line 1806 of yacc.c  */
1569 #line 164 "parsedate.y"
1570     {
1571             if ((yyvsp[(1) - (2)].Number) < 100) {
1572                 yyHour = (yyvsp[(1) - (2)].Number);
1573                 yyMinutes = 0;
1574             }
1575             else {
1576                 yyHour = (yyvsp[(1) - (2)].Number) / 100;
1577                 yyMinutes = (yyvsp[(1) - (2)].Number) % 100;
1578             }
1579             yySeconds = 0;
1580             yyMeridian = (yyvsp[(2) - (2)].Meridian);
1581         }
1582     break;
1583
1584   case 9:
1585
1586 /* Line 1806 of yacc.c  */
1587 #line 176 "parsedate.y"
1588     {
1589             yyHour = (yyvsp[(1) - (4)].Number);
1590             yyMinutes = (yyvsp[(3) - (4)].Number);
1591             yySeconds = 0;
1592             yyMeridian = (yyvsp[(4) - (4)].Meridian);
1593         }
1594     break;
1595
1596   case 10:
1597
1598 /* Line 1806 of yacc.c  */
1599 #line 182 "parsedate.y"
1600     {
1601             yyHour = (yyvsp[(1) - (4)].Number);
1602             yyMinutes = (yyvsp[(3) - (4)].Number);
1603             yyTimezone = (yyvsp[(4) - (4)].Number);
1604             yyMeridian = MER24;
1605             yyDSTmode = DSToff;
1606         }
1607     break;
1608
1609   case 11:
1610
1611 /* Line 1806 of yacc.c  */
1612 #line 189 "parsedate.y"
1613     {
1614             yyHour = (yyvsp[(1) - (6)].Number);
1615             yyMinutes = (yyvsp[(3) - (6)].Number);
1616             yySeconds = (yyvsp[(5) - (6)].Number);
1617             yyMeridian = (yyvsp[(6) - (6)].Meridian);
1618         }
1619     break;
1620
1621   case 12:
1622
1623 /* Line 1806 of yacc.c  */
1624 #line 195 "parsedate.y"
1625     {
1626             yyHour = (yyvsp[(1) - (6)].Number);
1627             yyMinutes = (yyvsp[(3) - (6)].Number);
1628             yySeconds = (yyvsp[(5) - (6)].Number);
1629             yyTimezone = (yyvsp[(6) - (6)].Number);
1630             yyMeridian = MER24;
1631             yyDSTmode = DSToff;
1632         }
1633     break;
1634
1635   case 13:
1636
1637 /* Line 1806 of yacc.c  */
1638 #line 205 "parsedate.y"
1639     {
1640             (yyval.Number) = (yyvsp[(1) - (1)].Number);
1641             yyDSTmode = DSToff;
1642         }
1643     break;
1644
1645   case 14:
1646
1647 /* Line 1806 of yacc.c  */
1648 #line 209 "parsedate.y"
1649     {
1650             (yyval.Number) = (yyvsp[(1) - (1)].Number);
1651             yyDSTmode = DSTon;
1652         }
1653     break;
1654
1655   case 15:
1656
1657 /* Line 1806 of yacc.c  */
1658 #line 213 "parsedate.y"
1659     {
1660             /* Only allow "GMT+300" and "GMT-0800" */
1661             if ((yyvsp[(1) - (2)].Number) != 0) {
1662                 YYABORT;
1663             }
1664             (yyval.Number) = (yyvsp[(2) - (2)].Number);
1665             yyDSTmode = DSToff;
1666         }
1667     break;
1668
1669   case 16:
1670
1671 /* Line 1806 of yacc.c  */
1672 #line 221 "parsedate.y"
1673     {
1674             (yyval.Number) = (yyvsp[(1) - (1)].Number);
1675             yyDSTmode = DSToff;
1676         }
1677     break;
1678
1679   case 17:
1680
1681 /* Line 1806 of yacc.c  */
1682 #line 227 "parsedate.y"
1683     {
1684             int         i;
1685
1686             /* Unix and GMT and numeric timezones -- a little confusing. */
1687             if ((yyvsp[(1) - (1)].Number) < 0) {
1688                 /* Don't work with negative modulus. */
1689                 (yyvsp[(1) - (1)].Number) = -(yyvsp[(1) - (1)].Number);
1690                 if ((yyvsp[(1) - (1)].Number) > 9999 || (i = (yyvsp[(1) - (1)].Number) % 100) >= 60) {
1691                     YYABORT;
1692                 }
1693                 (yyval.Number) = ((yyvsp[(1) - (1)].Number) / 100) * 60 + i;
1694             }
1695             else {
1696                 if ((yyvsp[(1) - (1)].Number) > 9999 || (i = (yyvsp[(1) - (1)].Number) % 100) >= 60) {
1697                     YYABORT;
1698                 }
1699                 (yyval.Number) = -(((yyvsp[(1) - (1)].Number) / 100) * 60 + i);
1700             }
1701         }
1702     break;
1703
1704   case 18:
1705
1706 /* Line 1806 of yacc.c  */
1707 #line 248 "parsedate.y"
1708     {
1709             yyMonth = (yyvsp[(1) - (3)].Number);
1710             yyDay = (yyvsp[(3) - (3)].Number);
1711         }
1712     break;
1713
1714   case 19:
1715
1716 /* Line 1806 of yacc.c  */
1717 #line 252 "parsedate.y"
1718     {
1719             if ((yyvsp[(1) - (5)].Number) > 100) {
1720                 yyYear = (yyvsp[(1) - (5)].Number);
1721                 yyMonth = (yyvsp[(3) - (5)].Number);
1722                 yyDay = (yyvsp[(5) - (5)].Number);
1723             }
1724             else {
1725                 yyMonth = (yyvsp[(1) - (5)].Number);
1726                 yyDay = (yyvsp[(3) - (5)].Number);
1727                 yyYear = (yyvsp[(5) - (5)].Number);
1728             }
1729         }
1730     break;
1731
1732   case 20:
1733
1734 /* Line 1806 of yacc.c  */
1735 #line 264 "parsedate.y"
1736     {
1737             yyMonth = (yyvsp[(1) - (2)].Number);
1738             yyDay = (yyvsp[(2) - (2)].Number);
1739         }
1740     break;
1741
1742   case 21:
1743
1744 /* Line 1806 of yacc.c  */
1745 #line 268 "parsedate.y"
1746     {
1747             yyMonth = (yyvsp[(1) - (4)].Number);
1748             yyDay = (yyvsp[(2) - (4)].Number);
1749             yyYear = (yyvsp[(4) - (4)].Number);
1750         }
1751     break;
1752
1753   case 22:
1754
1755 /* Line 1806 of yacc.c  */
1756 #line 273 "parsedate.y"
1757     {
1758             yyDay = (yyvsp[(1) - (2)].Number);
1759             yyMonth = (yyvsp[(2) - (2)].Number);
1760         }
1761     break;
1762
1763   case 23:
1764
1765 /* Line 1806 of yacc.c  */
1766 #line 277 "parsedate.y"
1767     {
1768             yyDay = (yyvsp[(1) - (3)].Number);
1769             yyMonth = (yyvsp[(2) - (3)].Number);
1770             yyYear = (yyvsp[(3) - (3)].Number);
1771         }
1772     break;
1773
1774   case 24:
1775
1776 /* Line 1806 of yacc.c  */
1777 #line 282 "parsedate.y"
1778     {
1779             yyDay = (yyvsp[(3) - (5)].Number);
1780             yyMonth = (yyvsp[(4) - (5)].Number);
1781             yyYear = (yyvsp[(5) - (5)].Number);
1782         }
1783     break;
1784
1785   case 25:
1786
1787 /* Line 1806 of yacc.c  */
1788 #line 289 "parsedate.y"
1789     {
1790             yyRelSeconds += (yyvsp[(1) - (2)].Number) * (yyvsp[(2) - (2)].Number);
1791         }
1792     break;
1793
1794   case 26:
1795
1796 /* Line 1806 of yacc.c  */
1797 #line 292 "parsedate.y"
1798     {
1799             yyRelSeconds += (yyvsp[(1) - (2)].Number) * (yyvsp[(2) - (2)].Number);
1800         }
1801     break;
1802
1803   case 27:
1804
1805 /* Line 1806 of yacc.c  */
1806 #line 295 "parsedate.y"
1807     {
1808             yyRelMonth += (yyvsp[(1) - (2)].Number) * (yyvsp[(2) - (2)].Number);
1809         }
1810     break;
1811
1812   case 28:
1813
1814 /* Line 1806 of yacc.c  */
1815 #line 298 "parsedate.y"
1816     {
1817             yyRelMonth += (yyvsp[(1) - (2)].Number) * (yyvsp[(2) - (2)].Number);
1818         }
1819     break;
1820
1821   case 29:
1822
1823 /* Line 1806 of yacc.c  */
1824 #line 303 "parsedate.y"
1825     {
1826             (yyval.Meridian) = MER24;
1827         }
1828     break;
1829
1830   case 30:
1831
1832 /* Line 1806 of yacc.c  */
1833 #line 306 "parsedate.y"
1834     {
1835             (yyval.Meridian) = (yyvsp[(1) - (1)].Meridian);
1836         }
1837     break;
1838
1839
1840
1841 /* Line 1806 of yacc.c  */
1842 #line 1843 "y.tab.c"
1843       default: break;
1844     }
1845   /* User semantic actions sometimes alter yychar, and that requires
1846      that yytoken be updated with the new translation.  We take the
1847      approach of translating immediately before every use of yytoken.
1848      One alternative is translating here after every semantic action,
1849      but that translation would be missed if the semantic action invokes
1850      YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1851      if it invokes YYBACKUP.  In the case of YYABORT or YYACCEPT, an
1852      incorrect destructor might then be invoked immediately.  In the
1853      case of YYERROR or YYBACKUP, subsequent parser actions might lead
1854      to an incorrect destructor call or verbose syntax error message
1855      before the lookahead is translated.  */
1856   YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1857
1858   YYPOPSTACK (yylen);
1859   yylen = 0;
1860   YY_STACK_PRINT (yyss, yyssp);
1861
1862   *++yyvsp = yyval;
1863
1864   /* Now `shift' the result of the reduction.  Determine what state
1865      that goes to, based on the state we popped back to and the rule
1866      number reduced by.  */
1867
1868   yyn = yyr1[yyn];
1869
1870   yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1871   if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1872     yystate = yytable[yystate];
1873   else
1874     yystate = yydefgoto[yyn - YYNTOKENS];
1875
1876   goto yynewstate;
1877
1878
1879 /*------------------------------------.
1880 | yyerrlab -- here on detecting error |
1881 `------------------------------------*/
1882 yyerrlab:
1883   /* Make sure we have latest lookahead translation.  See comments at
1884      user semantic actions for why this is necessary.  */
1885   yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
1886
1887   /* If not already recovering from an error, report this error.  */
1888   if (!yyerrstatus)
1889     {
1890       ++yynerrs;
1891 #if ! YYERROR_VERBOSE
1892       yyerror (YY_("syntax error"));
1893 #else
1894 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
1895                                         yyssp, yytoken)
1896       {
1897         char const *yymsgp = YY_("syntax error");
1898         int yysyntax_error_status;
1899         yysyntax_error_status = YYSYNTAX_ERROR;
1900         if (yysyntax_error_status == 0)
1901           yymsgp = yymsg;
1902         else if (yysyntax_error_status == 1)
1903           {
1904             if (yymsg != yymsgbuf)
1905               YYSTACK_FREE (yymsg);
1906             yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
1907             if (!yymsg)
1908               {
1909                 yymsg = yymsgbuf;
1910                 yymsg_alloc = sizeof yymsgbuf;
1911                 yysyntax_error_status = 2;
1912               }
1913             else
1914               {
1915                 yysyntax_error_status = YYSYNTAX_ERROR;
1916                 yymsgp = yymsg;
1917               }
1918           }
1919         yyerror (yymsgp);
1920         if (yysyntax_error_status == 2)
1921           goto yyexhaustedlab;
1922       }
1923 # undef YYSYNTAX_ERROR
1924 #endif
1925     }
1926
1927
1928
1929   if (yyerrstatus == 3)
1930     {
1931       /* If just tried and failed to reuse lookahead token after an
1932          error, discard it.  */
1933
1934       if (yychar <= YYEOF)
1935         {
1936           /* Return failure if at end of input.  */
1937           if (yychar == YYEOF)
1938             YYABORT;
1939         }
1940       else
1941         {
1942           yydestruct ("Error: discarding",
1943                       yytoken, &yylval);
1944           yychar = YYEMPTY;
1945         }
1946     }
1947
1948   /* Else will try to reuse lookahead token after shifting the error
1949      token.  */
1950   goto yyerrlab1;
1951
1952
1953 /*---------------------------------------------------.
1954 | yyerrorlab -- error raised explicitly by YYERROR.  |
1955 `---------------------------------------------------*/
1956 yyerrorlab:
1957
1958   /* Pacify compilers like GCC when the user code never invokes
1959      YYERROR and the label yyerrorlab therefore never appears in user
1960      code.  */
1961   if (/*CONSTCOND*/ 0)
1962      goto yyerrorlab;
1963
1964   /* Do not reclaim the symbols of the rule which action triggered
1965      this YYERROR.  */
1966   YYPOPSTACK (yylen);
1967   yylen = 0;
1968   YY_STACK_PRINT (yyss, yyssp);
1969   yystate = *yyssp;
1970   goto yyerrlab1;
1971
1972
1973 /*-------------------------------------------------------------.
1974 | yyerrlab1 -- common code for both syntax error and YYERROR.  |
1975 `-------------------------------------------------------------*/
1976 yyerrlab1:
1977   yyerrstatus = 3;      /* Each real token shifted decrements this.  */
1978
1979   for (;;)
1980     {
1981       yyn = yypact[yystate];
1982       if (!yypact_value_is_default (yyn))
1983         {
1984           yyn += YYTERROR;
1985           if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1986             {
1987               yyn = yytable[yyn];
1988               if (0 < yyn)
1989                 break;
1990             }
1991         }
1992
1993       /* Pop the current state because it cannot handle the error token.  */
1994       if (yyssp == yyss)
1995         YYABORT;
1996
1997
1998       yydestruct ("Error: popping",
1999                   yystos[yystate], yyvsp);
2000       YYPOPSTACK (1);
2001       yystate = *yyssp;
2002       YY_STACK_PRINT (yyss, yyssp);
2003     }
2004
2005   *++yyvsp = yylval;
2006
2007
2008   /* Shift the error token.  */
2009   YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
2010
2011   yystate = yyn;
2012   goto yynewstate;
2013
2014
2015 /*-------------------------------------.
2016 | yyacceptlab -- YYACCEPT comes here.  |
2017 `-------------------------------------*/
2018 yyacceptlab:
2019   yyresult = 0;
2020   goto yyreturn;
2021
2022 /*-----------------------------------.
2023 | yyabortlab -- YYABORT comes here.  |
2024 `-----------------------------------*/
2025 yyabortlab:
2026   yyresult = 1;
2027   goto yyreturn;
2028
2029 #if !defined(yyoverflow) || YYERROR_VERBOSE
2030 /*-------------------------------------------------.
2031 | yyexhaustedlab -- memory exhaustion comes here.  |
2032 `-------------------------------------------------*/
2033 yyexhaustedlab:
2034   yyerror (YY_("memory exhausted"));
2035   yyresult = 2;
2036   /* Fall through.  */
2037 #endif
2038
2039 yyreturn:
2040   if (yychar != YYEMPTY)
2041     {
2042       /* Make sure we have latest lookahead translation.  See comments at
2043          user semantic actions for why this is necessary.  */
2044       yytoken = YYTRANSLATE (yychar);
2045       yydestruct ("Cleanup: discarding lookahead",
2046                   yytoken, &yylval);
2047     }
2048   /* Do not reclaim the symbols of the rule which action triggered
2049      this YYABORT or YYACCEPT.  */
2050   YYPOPSTACK (yylen);
2051   YY_STACK_PRINT (yyss, yyssp);
2052   while (yyssp != yyss)
2053     {
2054       yydestruct ("Cleanup: popping",
2055                   yystos[*yyssp], yyvsp);
2056       YYPOPSTACK (1);
2057     }
2058 #ifndef yyoverflow
2059   if (yyss != yyssa)
2060     YYSTACK_FREE (yyss);
2061 #endif
2062 #if YYERROR_VERBOSE
2063   if (yymsg != yymsgbuf)
2064     YYSTACK_FREE (yymsg);
2065 #endif
2066   /* Make sure YYID is used.  */
2067   return YYID (yyresult);
2068 }
2069
2070
2071
2072 /* Line 2067 of yacc.c  */
2073 #line 311 "parsedate.y"
2074
2075
2076 /* Month and day table. */
2077 static TABLE    MonthDayTable[] = {
2078     { "january",        tMONTH,  1 },
2079     { "february",       tMONTH,  2 },
2080     { "march",          tMONTH,  3 },
2081     { "april",          tMONTH,  4 },
2082     { "may",            tMONTH,  5 },
2083     { "june",           tMONTH,  6 },
2084     { "july",           tMONTH,  7 },
2085     { "august",         tMONTH,  8 },
2086     { "september",      tMONTH,  9 },
2087     { "october",        tMONTH, 10 },
2088     { "november",       tMONTH, 11 },
2089     { "december",       tMONTH, 12 },
2090         /* The value of the day isn't used... */
2091     { "sunday",         tDAY, 0 },
2092     { "monday",         tDAY, 0 },
2093     { "tuesday",        tDAY, 0 },
2094     { "wednesday",      tDAY, 0 },
2095     { "thursday",       tDAY, 0 },
2096     { "friday",         tDAY, 0 },
2097     { "saturday",       tDAY, 0 },
2098 };
2099
2100 /* Time units table. */
2101 static TABLE    UnitsTable[] = {
2102     { "year",           tMONTH_UNIT,    12 },
2103     { "month",          tMONTH_UNIT,    1 },
2104     { "week",           tSEC_UNIT,      7L * 24 * 60 * 60 },
2105     { "day",            tSEC_UNIT,      1L * 24 * 60 * 60 },
2106     { "hour",           tSEC_UNIT,      60 * 60 },
2107     { "minute",         tSEC_UNIT,      60 },
2108     { "min",            tSEC_UNIT,      60 },
2109     { "second",         tSEC_UNIT,      1 },
2110     { "sec",            tSEC_UNIT,      1 },
2111 };
2112
2113 /* Timezone table. */
2114 static TABLE    TimezoneTable[] = {
2115     { "gmt",    tZONE,     HOUR( 0) },  /* Greenwich Mean */
2116     { "ut",     tZONE,     HOUR( 0) },  /* Universal */
2117     { "utc",    tZONE,     HOUR( 0) },  /* Universal Coordinated */
2118     { "cut",    tZONE,     HOUR( 0) },  /* Coordinated Universal */
2119     { "z",      tZONE,     HOUR( 0) },  /* Greenwich Mean */
2120     { "wet",    tZONE,     HOUR( 0) },  /* Western European */
2121     { "bst",    tDAYZONE,  HOUR( 0) },  /* British Summer */
2122     { "nst",    tZONE,     HOUR(3)+30 }, /* Newfoundland Standard */
2123     { "ndt",    tDAYZONE,  HOUR(3)+30 }, /* Newfoundland Daylight */
2124     { "ast",    tZONE,     HOUR( 4) },  /* Atlantic Standard */
2125     { "adt",    tDAYZONE,  HOUR( 4) },  /* Atlantic Daylight */
2126     { "est",    tZONE,     HOUR( 5) },  /* Eastern Standard */
2127     { "edt",    tDAYZONE,  HOUR( 5) },  /* Eastern Daylight */
2128     { "cst",    tZONE,     HOUR( 6) },  /* Central Standard */
2129     { "cdt",    tDAYZONE,  HOUR( 6) },  /* Central Daylight */
2130     { "mst",    tZONE,     HOUR( 7) },  /* Mountain Standard */
2131     { "mdt",    tDAYZONE,  HOUR( 7) },  /* Mountain Daylight */
2132     { "pst",    tZONE,     HOUR( 8) },  /* Pacific Standard */
2133     { "pdt",    tDAYZONE,  HOUR( 8) },  /* Pacific Daylight */
2134     { "yst",    tZONE,     HOUR( 9) },  /* Yukon Standard */
2135     { "ydt",    tDAYZONE,  HOUR( 9) },  /* Yukon Daylight */
2136     { "akst",   tZONE,     HOUR( 9) },  /* Alaska Standard */
2137     { "akdt",   tDAYZONE,  HOUR( 9) },  /* Alaska Daylight */
2138     { "hst",    tZONE,     HOUR(10) },  /* Hawaii Standard */
2139     { "hast",   tZONE,     HOUR(10) },  /* Hawaii-Aleutian Standard */
2140     { "hadt",   tDAYZONE,  HOUR(10) },  /* Hawaii-Aleutian Daylight */
2141     { "ces",    tDAYZONE,  -HOUR(1) },  /* Central European Summer */
2142     { "cest",   tDAYZONE,  -HOUR(1) },  /* Central European Summer */
2143     { "mez",    tZONE,     -HOUR(1) },  /* Middle European */
2144     { "mezt",   tDAYZONE,  -HOUR(1) },  /* Middle European Summer */
2145     { "cet",    tZONE,     -HOUR(1) },  /* Central European */
2146     { "met",    tZONE,     -HOUR(1) },  /* Middle European */
2147     { "eet",    tZONE,     -HOUR(2) },  /* Eastern Europe */
2148     { "msk",    tZONE,     -HOUR(3) },  /* Moscow Winter */
2149     { "msd",    tDAYZONE,  -HOUR(3) },  /* Moscow Summer */
2150     { "wast",   tZONE,     -HOUR(8) },  /* West Australian Standard */
2151     { "wadt",   tDAYZONE,  -HOUR(8) },  /* West Australian Daylight */
2152     { "hkt",    tZONE,     -HOUR(8) },  /* Hong Kong */
2153     { "cct",    tZONE,     -HOUR(8) },  /* China Coast */
2154     { "jst",    tZONE,     -HOUR(9) },  /* Japan Standard */
2155     { "kst",    tZONE,     -HOUR(9) },  /* Korean Standard */
2156     { "kdt",    tZONE,     -HOUR(9) },  /* Korean Daylight */
2157     { "cast",   tZONE,     -(HOUR(9)+30) }, /* Central Australian Standard */
2158     { "cadt",   tDAYZONE,  -(HOUR(9)+30) }, /* Central Australian Daylight */
2159     { "east",   tZONE,     -HOUR(10) }, /* Eastern Australian Standard */
2160     { "eadt",   tDAYZONE,  -HOUR(10) }, /* Eastern Australian Daylight */
2161     { "nzst",   tZONE,     -HOUR(12) }, /* New Zealand Standard */
2162     { "nzdt",   tDAYZONE,  -HOUR(12) }, /* New Zealand Daylight */
2163
2164     /* For completeness we include the following entries. */
2165 #if 0
2166
2167     /* Duplicate names.  Either they conflict with a zone listed above
2168      * (which is either more likely to be seen or just been in circulation
2169      * longer), or they conflict with another zone in this section and
2170      * we could not reasonably choose one over the other. */
2171     { "fst",    tZONE,     HOUR( 2) },  /* Fernando De Noronha Standard */
2172     { "fdt",    tDAYZONE,  HOUR( 2) },  /* Fernando De Noronha Daylight */
2173     { "bst",    tZONE,     HOUR( 3) },  /* Brazil Standard */
2174     { "est",    tZONE,     HOUR( 3) },  /* Eastern Standard (Brazil) */
2175     { "edt",    tDAYZONE,  HOUR( 3) },  /* Eastern Daylight (Brazil) */
2176     { "wst",    tZONE,     HOUR( 4) },  /* Western Standard (Brazil) */
2177     { "wdt",    tDAYZONE,  HOUR( 4) },  /* Western Daylight (Brazil) */
2178     { "cst",    tZONE,     HOUR( 5) },  /* Chile Standard */
2179     { "cdt",    tDAYZONE,  HOUR( 5) },  /* Chile Daylight */
2180     { "ast",    tZONE,     HOUR( 5) },  /* Acre Standard */
2181     { "adt",    tDAYZONE,  HOUR( 5) },  /* Acre Daylight */
2182     { "cst",    tZONE,     HOUR( 5) },  /* Cuba Standard */
2183     { "cdt",    tDAYZONE,  HOUR( 5) },  /* Cuba Daylight */
2184     { "est",    tZONE,     HOUR( 6) },  /* Easter Island Standard */
2185     { "edt",    tDAYZONE,  HOUR( 6) },  /* Easter Island Daylight */
2186     { "sst",    tZONE,     HOUR(11) },  /* Samoa Standard */
2187     { "ist",    tZONE,     -HOUR(2) },  /* Israel Standard */
2188     { "idt",    tDAYZONE,  -HOUR(2) },  /* Israel Daylight */
2189     { "idt",    tDAYZONE,  -(HOUR(3)+30) }, /* Iran Daylight */
2190     { "ist",    tZONE,     -(HOUR(3)+30) }, /* Iran Standard */
2191     { "cst",     tZONE,     -HOUR(8) }, /* China Standard */
2192     { "cdt",     tDAYZONE,  -HOUR(8) }, /* China Daylight */
2193     { "sst",     tZONE,     -HOUR(8) }, /* Singapore Standard */
2194
2195     /* Dubious (e.g., not in Olson's TIMEZONE package) or obsolete. */
2196     { "gst",    tZONE,     HOUR( 3) },  /* Greenland Standard */
2197     { "wat",    tZONE,     -HOUR(1) },  /* West Africa */
2198     { "at",     tZONE,     HOUR( 2) },  /* Azores */
2199     { "gst",    tZONE,     -HOUR(10) }, /* Guam Standard */
2200     { "nft",    tZONE,     HOUR(3)+30 }, /* Newfoundland */
2201     { "idlw",   tZONE,     HOUR(12) },  /* International Date Line West */
2202     { "mewt",   tZONE,     -HOUR(1) },  /* Middle European Winter */
2203     { "mest",   tDAYZONE,  -HOUR(1) },  /* Middle European Summer */
2204     { "swt",    tZONE,     -HOUR(1) },  /* Swedish Winter */
2205     { "sst",    tDAYZONE,  -HOUR(1) },  /* Swedish Summer */
2206     { "fwt",    tZONE,     -HOUR(1) },  /* French Winter */
2207     { "fst",    tDAYZONE,  -HOUR(1) },  /* French Summer */
2208     { "bt",     tZONE,     -HOUR(3) },  /* Baghdad */
2209     { "it",     tZONE,     -(HOUR(3)+30) }, /* Iran */
2210     { "zp4",    tZONE,     -HOUR(4) },  /* USSR Zone 3 */
2211     { "zp5",    tZONE,     -HOUR(5) },  /* USSR Zone 4 */
2212     { "ist",    tZONE,     -(HOUR(5)+30) }, /* Indian Standard */
2213     { "zp6",    tZONE,     -HOUR(6) },  /* USSR Zone 5 */
2214     { "nst",    tZONE,     -HOUR(7) },  /* North Sumatra */
2215     { "sst",    tZONE,     -HOUR(7) },  /* South Sumatra */
2216     { "jt",     tZONE,     -(HOUR(7)+30) }, /* Java (3pm in Cronusland!) */
2217     { "nzt",    tZONE,     -HOUR(12) }, /* New Zealand */
2218     { "idle",   tZONE,     -HOUR(12) }, /* International Date Line East */
2219     { "cat",    tZONE,     HOUR(10) },  /* -- expired 1967 */
2220     { "nt",     tZONE,     HOUR(11) },  /* -- expired 1967 */
2221     { "ahst",   tZONE,     HOUR(10) },  /* -- expired 1983 */
2222     { "hdt",    tDAYZONE,  HOUR(10) },  /* -- expired 1986 */
2223 #endif /* 0 */
2224 };
2225
2226
2227 /* ARGSUSED */
2228 static void
2229 date_error(char *s)
2230 {
2231     /* NOTREACHED */
2232 }
2233
2234
2235 static time_t
2236 ToSeconds(time_t Hours, time_t Minutes, time_t Seconds, MERIDIAN Meridian)
2237 {
2238     if (Minutes < 0 || Minutes > 59 || Seconds < 0 || Seconds > 61)
2239         return -1;
2240     if (Meridian == MER24) {
2241         if (Hours < 0 || Hours > 23)
2242             return -1;
2243     }
2244     else {
2245         if (Hours < 1 || Hours > 12)
2246             return -1;
2247         if (Hours == 12)
2248             Hours = 0;
2249         if (Meridian == MERpm)
2250             Hours += 12;
2251     }
2252     return (Hours * 60L + Minutes) * 60L + Seconds;
2253 }
2254
2255
2256 static time_t
2257 Convert(time_t Month, time_t Day, time_t Year,
2258         time_t Hours, time_t Minutes, time_t Seconds,
2259         MERIDIAN Meridian, DSTMODE dst)
2260 {
2261     static int  DaysNormal[13] = {
2262         0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
2263     };
2264     static int  DaysLeap[13] = {
2265         0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
2266     };
2267     static int  LeapYears[] = {
2268         1972, 1976, 1980, 1984, 1988, 1992, 1996,
2269         2000, 2004, 2008, 2012, 2016, 2020, 2024, 2028, 2032, 2036
2270     };
2271     register int        *yp;
2272     register int        *mp;
2273     register time_t     Julian;
2274     register int        i;
2275     time_t              tod;
2276
2277     if (Year < 0)
2278         Year = -Year;
2279     if (Year < 100)
2280         Year += 1900;
2281     if (Year < EPOCH)
2282         Year += 100;
2283     for (mp = DaysNormal, yp = LeapYears; yp < ENDOF(LeapYears); yp++)
2284         if (Year == *yp) {
2285             mp = DaysLeap;
2286             break;
2287         }
2288     if (Year < EPOCH || Year > END_OF_TIME
2289      || Month < 1 || Month > 12
2290      /* NOSTRICT *//* conversion from long may lose accuracy */
2291      || Day < 1 || Day > mp[(int)Month])
2292         return -1;
2293
2294     Julian = Day - 1 + (Year - EPOCH) * 365;
2295     for (yp = LeapYears; yp < ENDOF(LeapYears); yp++, Julian++)
2296         if (Year <= *yp)
2297             break;
2298     for (i = 1; i < Month; i++)
2299         Julian += *++mp;
2300     Julian *= SECSPERDAY;
2301     Julian += yyTimezone * 60L;
2302     if ((tod = ToSeconds(Hours, Minutes, Seconds, Meridian)) < 0)
2303         return -1;
2304     Julian += tod;
2305     tod = Julian;
2306     if (dst == DSTon || (dst == DSTmaybe && localtime(&tod)->tm_isdst))
2307         Julian -= DST_OFFSET * 60L * 60L;
2308     return Julian;
2309 }
2310
2311
2312 static time_t
2313 DSTcorrect(time_t Start, time_t Future)
2314 {
2315     time_t      StartDay;
2316     time_t      FutureDay;
2317
2318     StartDay = (localtime(&Start)->tm_hour + 1) % 24;
2319     FutureDay = (localtime(&Future)->tm_hour + 1) % 24;
2320     return (Future - Start) + (StartDay - FutureDay) * DST_OFFSET * 60L * 60L;
2321 }
2322
2323
2324 static time_t
2325 RelativeMonth(time_t Start, time_t RelMonth)
2326 {
2327     struct tm   *tm;
2328     time_t      Month;
2329     time_t      Year;
2330
2331     tm = localtime(&Start);
2332     Month = 12 * tm->tm_year + tm->tm_mon + RelMonth;
2333     Year = Month / 12;
2334     Month = Month % 12 + 1;
2335     return DSTcorrect(Start,
2336             Convert(Month, (time_t)tm->tm_mday, Year,
2337                 (time_t)tm->tm_hour, (time_t)tm->tm_min, (time_t)tm->tm_sec,
2338                 MER24, DSTmaybe));
2339 }
2340
2341
2342 static int
2343 LookupWord(char *buff, register int length)
2344 {
2345     register char       *p;
2346     register char       *q;
2347     register TABLE      *tp;
2348     register int        c;
2349
2350     p = buff;
2351     c = p[0];
2352
2353     /* See if we have an abbreviation for a month. */
2354     if (length == 3 || (length == 4 && p[3] == '.'))
2355         for (tp = MonthDayTable; tp < ENDOF(MonthDayTable); tp++) {
2356             q = tp->name;
2357             if (c == q[0] && p[1] == q[1] && p[2] == q[2]) {
2358                 yylval.Number = tp->value;
2359                 return tp->type;
2360             }
2361         }
2362     else
2363         for (tp = MonthDayTable; tp < ENDOF(MonthDayTable); tp++)
2364             if (c == tp->name[0] && strcmp(p, tp->name) == 0) {
2365                 yylval.Number = tp->value;
2366                 return tp->type;
2367             }
2368
2369     /* Try for a timezone. */
2370     for (tp = TimezoneTable; tp < ENDOF(TimezoneTable); tp++)
2371         if (c == tp->name[0] && p[1] == tp->name[1]
2372          && strcmp(p, tp->name) == 0) {
2373             yylval.Number = tp->value;
2374             return tp->type;
2375         }
2376
2377     /* Try the units table. */
2378     for (tp = UnitsTable; tp < ENDOF(UnitsTable); tp++)
2379         if (c == tp->name[0] && strcmp(p, tp->name) == 0) {
2380             yylval.Number = tp->value;
2381             return tp->type;
2382         }
2383
2384     /* Strip off any plural and try the units table again. */
2385     if (--length > 0 && p[length] == 's') {
2386         p[length] = '\0';
2387         for (tp = UnitsTable; tp < ENDOF(UnitsTable); tp++)
2388             if (c == tp->name[0] && strcmp(p, tp->name) == 0) {
2389                 p[length] = 's';
2390                 yylval.Number = tp->value;
2391                 return tp->type;
2392             }
2393         p[length] = 's';
2394     }
2395     length++;
2396
2397     /* Drop out any periods. */
2398     for (p = buff, q = (char*)buff; *q; q++)
2399         if (*q != '.')
2400             *p++ = *q;
2401     *p = '\0';
2402
2403     /* Try the meridians. */
2404     if (buff[1] == 'm' && buff[2] == '\0') {
2405         if (buff[0] == 'a') {
2406             yylval.Meridian = MERam;
2407             return tMERIDIAN;
2408         }
2409         if (buff[0] == 'p') {
2410             yylval.Meridian = MERpm;
2411             return tMERIDIAN;
2412         }
2413     }
2414
2415     /* If we saw any periods, try the timezones again. */
2416     if (p - buff != length) {
2417         c = buff[0];
2418         for (p = buff, tp = TimezoneTable; tp < ENDOF(TimezoneTable); tp++)
2419             if (c == tp->name[0] && p[1] == tp->name[1]
2420             && strcmp(p, tp->name) == 0) {
2421                 yylval.Number = tp->value;
2422                 return tp->type;
2423             }
2424     }
2425
2426     /* Unknown word -- assume GMT timezone. */
2427     yylval.Number = 0;
2428     return tZONE;
2429 }
2430
2431
2432 int
2433 date_lex(void)
2434 {
2435     register char       c;
2436     register char       *p;
2437     char                buff[20];
2438     register int        sign;
2439     register int        i;
2440     register int        nesting;
2441
2442     for ( ; ; ) {
2443         /* Get first character after the whitespace. */
2444         for ( ; ; ) {
2445             while (isspace(*yyInput))
2446                 yyInput++;
2447             c = *yyInput;
2448
2449             /* Ignore RFC 822 comments, typically time zone names. */
2450             if (c != LPAREN)
2451                 break;
2452             for (nesting = 1; (c = *++yyInput) != RPAREN || --nesting; )
2453                 if (c == LPAREN)
2454                     nesting++;
2455                 else if (!IS7BIT(c) || c == '\0' || c == '\r'
2456                      || (c == '\\' && ((c = *++yyInput) == '\0' || !IS7BIT(c))))
2457                     /* Lexical error: bad comment. */
2458                     return '?';
2459             yyInput++;
2460         }
2461
2462         /* A number? */
2463         if (isdigit(c) || c == '-' || c == '+') {
2464             if (c == '-' || c == '+') {
2465                 sign = c == '-' ? -1 : 1;
2466                 yyInput++;
2467                 if (!isdigit(*yyInput))
2468                     /* Skip the plus or minus sign. */
2469                     continue;
2470             }
2471             else
2472                 sign = 0;
2473             for (i = 0; (c = *yyInput++) != '\0' && isdigit(c); )
2474                 i = 10 * i + c - '0';
2475             yyInput--;
2476             yylval.Number = sign < 0 ? -i : i;
2477             return sign ? tSNUMBER : tUNUMBER;
2478         }
2479
2480         /* A word? */
2481         if (isalpha(c)) {
2482             for (p = buff; (c = *yyInput++) == '.' || isalpha(c); )
2483                 if (p < &buff[sizeof buff - 1])
2484                     *p++ = isupper(c) ? tolower(c) : c;
2485             *p = '\0';
2486             yyInput--;
2487             return LookupWord(buff, p - buff);
2488         }
2489
2490         return *yyInput++;
2491     }
2492 }
2493
2494
2495 time_t
2496 parsedate(const char *p)
2497 {
2498     extern int          date_parse(void);
2499     time_t              Start;
2500
2501     yyInput = p; /* well, its supposed to be const... */
2502
2503     yyYear = 0;
2504     yyMonth = 0;
2505     yyDay = 0;
2506     yyTimezone = 0;
2507     yyDSTmode = DSTmaybe;
2508     yyHour = 0;
2509     yyMinutes = 0;
2510     yySeconds = 0;
2511     yyMeridian = MER24;
2512     yyRelSeconds = 0;
2513     yyRelMonth = 0;
2514     yyHaveDate = 0;
2515     yyHaveRel = 0;
2516     yyHaveTime = 0;
2517
2518     if (date_parse() || yyHaveTime > 1 || yyHaveDate > 1)
2519         return -1;
2520
2521     if (yyHaveDate || yyHaveTime) {
2522         Start = Convert(yyMonth, yyDay, yyYear, yyHour, yyMinutes, yySeconds,
2523                     yyMeridian, yyDSTmode);
2524         if (Start < 0)
2525             return -1;
2526     }
2527     else
2528         return -1;
2529
2530     Start += yyRelSeconds;
2531     if (yyRelMonth)
2532         Start += RelativeMonth(Start, yyRelMonth);
2533
2534     /* Have to do *something* with a legitimate -1 so it's distinguishable
2535      * from the error return value.  (Alternately could set errno on error.) */
2536     return Start == -1 ? 0 : Start;
2537 }
2538
2539
2540 #ifdef TEST
2541
2542 #if YYDEBUG
2543 extern int      yydebug;
2544 #endif /* YYDEBUG */
2545
2546 /* ARGSUSED */
2547 int
2548 main(int ac, char *av[])
2549 {
2550     char        buff[128];
2551     time_t      d;
2552
2553 #if YYDEBUG
2554     yydebug = 1;
2555 #endif /* YYDEBUG */
2556
2557     (void)printf("Enter date, or blank line to exit.\n\t> ");
2558     for ( ; ; ) {
2559         (void)printf("\t> ");
2560         (void)fflush(stdout);
2561         if (fgets(buff, sizeof buff, stdin) == NULL || buff[0] == '\n')
2562             break;
2563 #if YYDEBUG
2564         if (strcmp(buff, "yydebug") == 0) {
2565             yydebug = !yydebug;
2566             printf("yydebug = %s\n", yydebug ? "on" : "off");
2567             continue;
2568         }
2569 #endif /* YYDEBUG */
2570         d = parsedate(buff, (TIMEINFO *)NULL);
2571         if (d == -1)
2572             (void)printf("Bad format - couldn't convert.\n");
2573         else
2574             (void)printf("%s", ctime(&d));
2575     }
2576
2577     exit(0);
2578     /* NOTREACHED */
2579 }
2580 #endif /* TEST */
2581