/* A Bison parser, made from ../common/getdate.y
by GNU bison 1.35. */
#define YYBISON 1 /* Identify Bison output. */
# define tAGO 257
# define tDAY 258
# define tDAYZONE 259
# define tID 260
# define tMERIDIAN 261
# define tMINUTE_UNIT 262
# define tMONTH 263
# define tMONTH_UNIT 264
# define tSNUMBER 265
# define tUNUMBER 266
# define t4DIGITNUMBER 267
# define t6DIGITNUMBER 268
# define tSEC_UNIT 269
# define tZONE 270
# define tMILZONE 271
# define tDST 272
#line 1 "../common/getdate.y"
/*
** Originally written by Steven M. Bellovin <smb@research.att.com> while
** at the University of North Carolina at Chapel Hill. Later tweaked by
** a couple of people on Usenet. Completely overhauled by Rich $alz
** <rsalz@bbn.com> and Jim Berets <jberets@bbn.com> in August, 1990;
**
** Major hack to coerce it into use with the Equivalence Portable
** Windows Library.
**
** This grammar has 10 shift/reduce conflicts.
**
** This code is in the public domain and has no copyright.
*/
/* SUPPRESS 287 on yaccpar_sccsid *//* Unused static variable */
/* SUPPRESS 288 on yyerrlab *//* Label unused */
#include <time.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#ifndef EOF
#include <stdio.h>
#endif
#ifdef _WIN32
#ifdef _MSC_VER
#pragma warning(disable:4131 4701)
#endif
#define STDAPICALLTYPE __stdcall
#define MSDOS
#else
#define STDAPICALLTYPE
#endif
extern int STDAPICALLTYPE PTimeGetChar(void * stream);
extern void STDAPICALLTYPE PTimeUngetChar(void * stream, int c);
int STDAPICALLTYPE PTimeGetDateOrder();
int STDAPICALLTYPE PTimeIsMonthName(const char *, int, int);
int STDAPICALLTYPE PTimeIsDayName(const char *, int, int);
#define EPOCH 1970
#define HOUR(x) ((time_t)(x) * 60)
#define SECSPERDAY (24L * 60L * 60L)
/*
** An entry in the lexical lookup table.
*/
typedef struct _TABLE {
char *name;
int type;
time_t value;
} TABLE;
/*
** Daylight-savings mode: on, off, or not yet known.
*/
typedef enum _DSTMODE {
DSTon, DSToff, DSTmaybe
} DSTMODE;
/*
** Meridian: am, pm, or 24-hour style.
*/
typedef enum _MERIDIAN {
MERam, MERpm, MER24
} MERIDIAN;
/*
** Global variables. We could get rid of most of these by using a good
** union as the yacc stack. (This routine was originally written before
** yacc had the %union construct.) Maybe someday; right now we only use
** the %union very rarely.
*/
struct Variables {
void *yyInput;
DSTMODE yyDSTmode;
time_t yyDayOrdinal;
time_t yyDayNumber;
int yyHaveDate;
int yyHaveDay;
int yyHaveRel;
int yyHaveTime;
int yyHaveZone;
time_t yyTimezone;
time_t yyDay;
time_t yyHour;
time_t yyMinutes;
time_t yyMonth;
time_t yySeconds;
time_t yyYear;
MERIDIAN yyMeridian;
time_t yyRelMonth;
time_t yyRelSeconds;
};
#define VARIABLE ((struct Variables*)parseParam)
#define YYPURE 1
#define YYLEX_PARAM VARIABLE->yyInput
#define YYPARSE_PARAM parseParam
#define yyparse PTime_yyparse
#define yylex PTime_yylex
#define yyerror PTime_yyerror
static int yyparse(void *);
static int yylex();
#ifdef __GNUC__
static int yyerror();
#else
static void yyerror();
#endif
static void SetPossibleDate(struct Variables*, time_t, time_t, time_t);
#line 133 "../common/getdate.y"
#ifndef YYSTYPE
typedef union {
time_t Number;
enum _MERIDIAN Meridian;
} yystype;
# define YYSTYPE yystype
# define YYSTYPE_IS_TRIVIAL 1
#endif
#ifndef YYDEBUG
# define YYDEBUG 0
#endif
#define YYFINAL 61
#define YYFLAG -32768
#define YYNTBASE 22
/* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */
#define YYTRANSLATE(x) ((unsigned)(x) <= 272 ? yytranslate[x] : 33)
/* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */
static const char yytranslate[] =
{
0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 20, 2, 2, 21, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 19, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 1, 3, 4, 5,
6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18
};
#if YYDEBUG
static const short yyprhs[] =
{
0, 0, 1, 4, 6, 8, 10, 12, 14, 16,
19, 22, 25, 30, 35, 42, 49, 51, 53, 56,
58, 60, 63, 66, 70, 76, 80, 84, 87, 92,
95, 99, 102, 104, 107, 110, 112, 115, 118, 120,
123, 126, 128, 130, 132, 134, 136, 138, 140, 141
};
static const short yyrhs[] =
{
-1, 22, 23, 0, 24, 0, 25, 0, 27, 0,
26, 0, 28, 0, 31, 0, 12, 7, 0, 13,
11, 0, 14, 11, 0, 30, 19, 30, 32, 0,
30, 19, 30, 11, 0, 30, 19, 30, 19, 30,
32, 0, 30, 19, 30, 19, 30, 11, 0, 16,
0, 5, 0, 16, 18, 0, 17, 0, 4, 0,
4, 20, 0, 30, 4, 0, 30, 21, 30, 0,
30, 21, 30, 21, 30, 0, 30, 11, 11, 0,
30, 9, 11, 0, 9, 30, 0, 9, 30, 20,
30, 0, 30, 9, 0, 30, 9, 30, 0, 29,
3, 0, 29, 0, 30, 8, 0, 11, 8, 0,
8, 0, 11, 15, 0, 30, 15, 0, 15, 0,
11, 10, 0, 30, 10, 0, 10, 0, 12, 0,
13, 0, 14, 0, 12, 0, 13, 0, 14, 0,
0, 7, 0
};
#endif
#if YYDEBUG
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
static const short yyrline[] =
{
0, 149, 150, 153, 156, 159, 162, 165, 168, 171,
177, 185, 193, 199, 206, 212, 222, 226, 230, 235,
245, 249, 253, 259, 262, 265, 275, 281, 285, 290,
294, 301, 305, 308, 311, 314, 317, 320, 323, 326,
329, 332, 337, 340, 343, 348, 374, 385, 402, 405
};
#endif
#if (YYDEBUG) || defined YYERROR_VERBOSE
/* YYTNAME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */
static const char *const yytname[] =
{
"$", "error", "$undefined.", "tAGO", "tDAY", "tDAYZONE", "tID",
"tMERIDIAN", "tMINUTE_UNIT", "tMONTH", "tMONTH_UNIT", "tSNUMBER",
"tUNUMBER", "t4DIGITNUMBER", "t6DIGITNUMBER", "tSEC_UNIT", "tZONE",
"tMILZONE", "tDST", "':'", "','", "'/'", "spec", "item", "time", "zone",
"day", "date", "rel", "relunit", "unumber", "number", "o_merid", 0
};
#endif
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
static const short yyr1[] =
{
0, 22, 22, 23, 23, 23, 23, 23, 23, 24,
24, 24, 24, 24, 24, 24, 25, 25, 25, 25,
26, 26, 26, 27, 27, 27, 27, 27, 27, 27,
27, 28, 28, 29, 29, 29, 29, 29, 29, 29,
29, 29, 30, 30, 30, 31, 31, 31, 32, 32
};
/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
static const short yyr2[] =
{
0, 0, 2, 1, 1, 1, 1, 1, 1, 2,
2, 2, 4, 4, 6, 6, 1, 1, 2, 1,
1, 2, 2, 3, 5, 3, 3, 2, 4, 2,
3, 2, 1, 2, 2, 1, 2, 2, 1, 2,
2, 1, 1, 1, 1, 1, 1, 1, 0, 1
};
/* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
doesn't specify something else to do. Zero means the default is an
error. */
static const short yydefact[] =
{
1, 0, 20, 17, 35, 0, 41, 0, 42, 43,
44, 38, 16, 19, 2, 3, 4, 6, 5, 7,
32, 0, 8, 21, 42, 43, 44, 27, 34, 39,
36, 9, 10, 11, 18, 31, 22, 33, 29, 40,
0, 37, 0, 0, 0, 26, 30, 25, 48, 23,
28, 49, 13, 0, 12, 0, 48, 24, 15, 14,
0, 0
};
static const short yydefgoto[] =
{
1, 14, 15, 16, 17, 18, 19, 20, 21, 22,
54
};
static const short yypact[] =
{
-32768, 1, -18,-32768,-32768, 8,-32768, 17, 29, 44,
54,-32768, -14,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
5, 65,-32768,-32768,-32768,-32768,-32768, 4,-32768,-32768,
-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 76,-32768,
15,-32768, 8, 8, 8,-32768,-32768,-32768, 12, 7,
-32768,-32768,-32768, 8,-32768, 8, -4,-32768,-32768,-32768,
30,-32768
};
static const short yypgoto[] =
{
-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, -5,-32768,
-21
};
#define YYLAST 90
static const short yytable[] =
{
27, 60, 23, 51, 34, 2, 3, 58, 35, 4,
5, 6, 7, 8, 9, 10, 11, 12, 13, 51,
24, 25, 26, 52, 44, 28, 47, 29, 55, -45,
61, 53, 30, 46, -45, 59, 31, 48, 49, 50,
0, -45, -45, -45, -46, -45, -45, 0, 56, -46,
57, 0, 0, 0, -47, 32, -46, -46, -46, -47,
-46, -46, 0, 0, 0, 33, -47, -47, -47, 36,
-47, -47, 0, 37, 38, 39, 40, 0, 0, 0,
41, 0, 0, 0, 42, 0, 43, 45, 24, 25,
26
};
static const short yycheck[] =
{
5, 0, 20, 7, 18, 4, 5, 11, 3, 8,
9, 10, 11, 12, 13, 14, 15, 16, 17, 7,
12, 13, 14, 11, 20, 8, 11, 10, 21, 0,
0, 19, 15, 38, 5, 56, 7, 42, 43, 44,
-1, 12, 13, 14, 0, 16, 17, -1, 53, 5,
55, -1, -1, -1, 0, 11, 12, 13, 14, 5,
16, 17, -1, -1, -1, 11, 12, 13, 14, 4,
16, 17, -1, 8, 9, 10, 11, -1, -1, -1,
15, -1, -1, -1, 19, -1, 21, 11, 12, 13,
14
};
#define YYPURE 1
/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
#line 3 "/usr/local/share/bison/bison.simple"
/* Skeleton output parser for bison,
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software
Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
/* As a special exception, when this file is copied by Bison into a
Bison output file, you may use that output file without restriction.
This special exception was added by the Free Software Foundation
in version 1.24 of Bison. */
/* This is the parser code that is written into each bison parser when
the %semantic_parser declaration is not specified in the grammar.
It was written by Richard Stallman by simplifying the hairy parser
used when %semantic_parser is specified. */
/* All symbols defined below should begin with yy or YY, to avoid
infringing on user name space. This should be done even for local
variables, as they might otherwise be expanded by user macros.
There are some unavoidable exceptions within include files to
define necessary library symbols; they are noted "INFRINGES ON
USER NAME SPACE" below. */
#if ! defined (yyoverflow) || defined (YYERROR_VERBOSE)
/* The parser invokes alloca or malloc; define the necessary symbols. */
# if YYSTACK_USE_ALLOCA
# define YYSTACK_ALLOC alloca
# else
# ifndef YYSTACK_USE_ALLOCA
# if defined (alloca) || defined (_ALLOCA_H)
# define YYSTACK_ALLOC alloca
# else
# ifdef __GNUC__
# define YYSTACK_ALLOC __builtin_alloca
# endif
# endif
# endif
# endif
# ifdef YYSTACK_ALLOC
/* Pacify GCC's `empty if-body' warning. */
# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
# else
# if defined (__STDC__) || defined (__cplusplus)
# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
# define YYSIZE_T size_t
# endif
# define YYSTACK_ALLOC malloc
# define YYSTACK_FREE free
# endif
#endif /* ! defined (yyoverflow) || defined (YYERROR_VERBOSE) */
#if (! defined (yyoverflow) \
&& (! defined (__cplusplus) \
|| (YYLTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
/* A type that is properly aligned for any stack member. */
union yyalloc
{
short yyss;
YYSTYPE yyvs;
# if YYLSP_NEEDED
YYLTYPE yyls;
# endif
};
/* The size of the maximum gap between one aligned stack and the next. */
# define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1)
/* The size of an array large to enough to hold all stacks, each with
N elements. */
# if YYLSP_NEEDED
# define YYSTACK_BYTES(N) \
((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
+ 2 * YYSTACK_GAP_MAX)
# else
# define YYSTACK_BYTES(N) \
((N) * (sizeof (short) + sizeof (YYSTYPE)) \
+ YYSTACK_GAP_MAX)
# endif
/* Copy COUNT objects from FROM to TO. The source and destination do
not overlap. */
# ifndef YYCOPY
# if 1 < __GNUC__
# define YYCOPY(To, From, Count) \
__builtin_memcpy (To, From, (Count) * sizeof (*(From)))
# else
# define YYCOPY(To, From, Count) \
do \
{ \
register YYSIZE_T yyi; \
for (yyi = 0; yyi < (Count); yyi++) \
(To)[yyi] = (From)[yyi]; \
} \
while (0)
# endif
# endif
/* Relocate STACK from its old location to the new one. The
local variables YYSIZE and YYSTACKSIZE give the old and new number of
elements in the stack, and YYPTR gives the new location of the
stack. Advance YYPTR to a properly aligned location for the next
stack. */
# define YYSTACK_RELOCATE(Stack) \
do \
{ \
YYSIZE_T yynewbytes; \
YYCOPY (&yyptr->Stack, Stack, yysize); \
Stack = &yyptr->Stack; \
yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAX; \
yyptr += yynewbytes / sizeof (*yyptr); \
} \
while (0)
#endif
#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
# define YYSIZE_T __SIZE_TYPE__
#endif
#if ! defined (YYSIZE_T) && defined (size_t)
# define YYSIZE_T size_t
#endif
#if ! defined (YYSIZE_T)
# if defined (__STDC__) || defined (__cplusplus)
# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
# define YYSIZE_T size_t
# endif
#endif
#if ! defined (YYSIZE_T)
# define YYSIZE_T unsigned int
#endif
#define yyerrok (yyerrstatus = 0)
#define yyclearin (yychar = YYEMPTY)
#define YYEMPTY -2
#define YYEOF 0
#define YYACCEPT goto yyacceptlab
#define YYABORT goto yyabortlab
#define YYERROR goto yyerrlab1
/* Like YYERROR except do call yyerror. This remains here temporarily
to ease the transition to the new meaning of YYERROR, for GCC.
Once GCC version 2 has supplanted version 1, this can go. */
#define YYFAIL goto yyerrlab
#define YYRECOVERING() (!!yyerrstatus)
#define YYBACKUP(Token, Value) \
do \
if (yychar == YYEMPTY && yylen == 1) \
{ \
yychar = (Token); \
yylval = (Value); \
yychar1 = YYTRANSLATE (yychar); \
YYPOPSTACK; \
goto yybackup; \
} \
else \
{ \
yyerror ("syntax error: cannot back up"); \
YYERROR; \
} \
while (0)
#define YYTERROR 1
#define YYERRCODE 256
/* YYLLOC_DEFAULT -- Compute the default location (before the actions
are run).
When YYLLOC_DEFAULT is run, CURRENT is set the location of the
first token. By default, to implement support for ranges, extend
its range to the last symbol. */
#ifndef YYLLOC_DEFAULT
# define YYLLOC_DEFAULT(Current, Rhs, N) \
Current.last_line = Rhs[N].last_line; \
Current.last_column = Rhs[N].last_column;
#endif
/* YYLEX -- calling `yylex' with the right arguments. */
#if YYPURE
# if YYLSP_NEEDED
# ifdef YYLEX_PARAM
# define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
# else
# define YYLEX yylex (&yylval, &yylloc)
# endif
# else /* !YYLSP_NEEDED */
# ifdef YYLEX_PARAM
# define YYLEX yylex (&yylval, YYLEX_PARAM)
# else
# define YYLEX yylex (&yylval)
# endif
# endif /* !YYLSP_NEEDED */
#else /* !YYPURE */
# define YYLEX yylex ()
#endif /* !YYPURE */
/* Enable debugging if requested. */
#if YYDEBUG
# ifndef YYFPRINTF
# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
# define YYFPRINTF fprintf
# endif
# define YYDPRINTF(Args) \
do { \
if (yydebug) \
YYFPRINTF Args; \
} while (0)
/* Nonzero means print parse trace. It is left uninitialized so that
multiple parsers can coexist. */
int yydebug;
#else /* !YYDEBUG */
# define YYDPRINTF(Args)
#endif /* !YYDEBUG */
/* YYINITDEPTH -- initial size of the parser's stacks. */
#ifndef YYINITDEPTH
# define YYINITDEPTH 200
#endif
/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
if the built-in stack extension method is used).
Do not make this value too large; the results are undefined if
SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
evaluated with infinite-precision integer arithmetic. */
#if YYMAXDEPTH == 0
# undef YYMAXDEPTH
#endif
#ifndef YYMAXDEPTH
# define YYMAXDEPTH 10000
#endif
#ifdef YYERROR_VERBOSE
# ifndef yystrlen
# if defined (__GLIBC__) && defined (_STRING_H)
# define yystrlen strlen
# else
/* Return the length of YYSTR. */
static YYSIZE_T
# if defined (__STDC__) || defined (__cplusplus)
yystrlen (const char *yystr)
# else
yystrlen (yystr)
const char *yystr;
# endif
{
register const char *yys = yystr;
while (*yys++ != '\0')
continue;
return yys - yystr - 1;
}
# endif
# endif
# ifndef yystpcpy
# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
# define yystpcpy stpcpy
# else
/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
YYDEST. */
static char *
# if defined (__STDC__) || defined (__cplusplus)
yystpcpy (char *yydest, const char *yysrc)
# else
yystpcpy (yydest, yysrc)
char *yydest;
const char *yysrc;
# endif
{
register char *yyd = yydest;
register const char *yys = yysrc;
while ((*yyd++ = *yys++) != '\0')
continue;
return yyd - 1;
}
# endif
# endif
#endif
#line 315 "/usr/local/share/bison/bison.simple"
/* The user can define YYPARSE_PARAM as the name of an argument to be passed
into yyparse. The argument should have type void *.
It should actually point to an object.
Grammar actions can access the variable by casting it
to the proper pointer type. */
#ifdef YYPARSE_PARAM
# if defined (__STDC__) || defined (__cplusplus)
# define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
# define YYPARSE_PARAM_DECL
# else
# define YYPARSE_PARAM_ARG YYPARSE_PARAM
# define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
# endif
#else /* !YYPARSE_PARAM */
# define YYPARSE_PARAM_ARG
# define YYPARSE_PARAM_DECL
#endif /* !YYPARSE_PARAM */
/* Prevent warning if -Wstrict-prototypes. */
#ifdef __GNUC__
# ifdef YYPARSE_PARAM
int yyparse (void *);
# else
int yyparse (void);
# endif
#endif
/* YY_DECL_VARIABLES -- depending whether we use a pure parser,
variables are global, or local to YYPARSE. */
#define YY_DECL_NON_LSP_VARIABLES \
/* The lookahead symbol. */ \
int yychar; \
\
/* The semantic value of the lookahead symbol. */ \
YYSTYPE yylval; \
\
/* Number of parse errors so far. */ \
int yynerrs;
#if YYLSP_NEEDED
# define YY_DECL_VARIABLES \
YY_DECL_NON_LSP_VARIABLES \
\
/* Location data for the lookahead symbol. */ \
YYLTYPE yylloc;
#else
# define YY_DECL_VARIABLES \
YY_DECL_NON_LSP_VARIABLES
#endif
/* If nonreentrant, generate the variables here. */
#if !YYPURE
YY_DECL_VARIABLES
#endif /* !YYPURE */
int
yyparse (YYPARSE_PARAM_ARG)
YYPARSE_PARAM_DECL
{
/* If reentrant, generate the variables here. */
#if YYPURE
YY_DECL_VARIABLES
#endif /* !YYPURE */
register int yystate;
register int yyn;
int yyresult;
/* Number of tokens to shift before error messages enabled. */
int yyerrstatus;
/* Lookahead token as an internal (translated) token number. */
int yychar1 = 0;
/* Three stacks and their tools:
`yyss': related to states,
`yyvs': related to semantic values,
`yyls': related to locations.
Refer to the stacks thru separate pointers, to allow yyoverflow
to reallocate them elsewhere. */
/* The state stack. */
short yyssa[YYINITDEPTH];
short *yyss = yyssa;
register short *yyssp;
/* The semantic value stack. */
YYSTYPE yyvsa[YYINITDEPTH];
YYSTYPE *yyvs = yyvsa;
register YYSTYPE *yyvsp;
#if YYLSP_NEEDED
/* The location stack. */
YYLTYPE yylsa[YYINITDEPTH];
YYLTYPE *yyls = yylsa;
YYLTYPE *yylsp;
#endif
#if YYLSP_NEEDED
# define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
#else
# define YYPOPSTACK (yyvsp--, yyssp--)
#endif
YYSIZE_T yystacksize = YYINITDEPTH;
/* The variables used to return semantic value and location from the
action routines. */
YYSTYPE yyval;
#if YYLSP_NEEDED
YYLTYPE yyloc;
#endif
/* When reducing, the number of symbols on the RHS of the reduced
rule. */
int yylen;
YYDPRINTF ((stderr, "Starting parse\n"));
yystate = 0;
yyerrstatus = 0;
yynerrs = 0;
yychar = YYEMPTY; /* Cause a token to be read. */
/* Initialize stack pointers.
Waste one element of value and location stack
so that they stay on the same level as the state stack.
The wasted elements are never initialized. */
yyssp = yyss;
yyvsp = yyvs;
#if YYLSP_NEEDED
yylsp = yyls;
#endif
goto yysetstate;
/*------------------------------------------------------------.
| yynewstate -- Push a new state, which is found in yystate. |
`------------------------------------------------------------*/
yynewstate:
/* In all cases, when you get here, the value and location stacks
have just been pushed. so pushing a state here evens the stacks.
*/
yyssp++;
yysetstate:
*yyssp = yystate;
if (yyssp >= yyss + yystacksize - 1)
{
/* Get the current used size of the three stacks, in elements. */
YYSIZE_T yysize = yyssp - yyss + 1;
#ifdef yyoverflow
{
/* Give user a chance to reallocate the stack. Use copies of
these so that the &'s don't force the real ones into
memory. */
YYSTYPE *yyvs1 = yyvs;
short *yyss1 = yyss;
/* Each stack pointer address is followed by the size of the
data in use in that stack, in bytes. */
# if YYLSP_NEEDED
YYLTYPE *yyls1 = yyls;
/* This used to be a conditional around just the two extra args,
but that might be undefined if yyoverflow is a macro. */
yyoverflow ("parser stack overflow",
&yyss1, yysize * sizeof (*yyssp),
&yyvs1, yysize * sizeof (*yyvsp),
&yyls1, yysize * sizeof (*yylsp),
&yystacksize);
yyls = yyls1;
# else
yyoverflow ("parser stack overflow",
&yyss1, yysize * sizeof (*yyssp),
&yyvs1, yysize * sizeof (*yyvsp),
&yystacksize);
# endif
yyss = yyss1;
yyvs = yyvs1;
}
#else /* no yyoverflow */
# ifndef YYSTACK_RELOCATE
goto yyoverflowlab;
# else
/* Extend the stack our own way. */
if (yystacksize >= YYMAXDEPTH)
goto yyoverflowlab;
yystacksize *= 2;
if (yystacksize > YYMAXDEPTH)
yystacksize = YYMAXDEPTH;
{
short *yyss1 = yyss;
union yyalloc *yyptr =
(union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
if (! yyptr)
goto yyoverflowlab;
YYSTACK_RELOCATE (yyss);
YYSTACK_RELOCATE (yyvs);
# if YYLSP_NEEDED
YYSTACK_RELOCATE (yyls);
# endif
# undef YYSTACK_RELOCATE
if (yyss1 != yyssa)
YYSTACK_FREE (yyss1);
}
# endif
#endif /* no yyoverflow */
yyssp = yyss + yysize - 1;
yyvsp = yyvs + yysize - 1;
#if YYLSP_NEEDED
yylsp = yyls + yysize - 1;
#endif
YYDPRINTF ((stderr, "Stack size increased to %lu\n",
(unsigned long int) yystacksize));
if (yyssp >= yyss + yystacksize - 1)
YYABORT;
}
YYDPRINTF ((stderr, "Entering state %d\n", yystate));
goto yybackup;
/*-----------.
| yybackup. |
`-----------*/
yybackup:
/* Do appropriate processing given the current state. */
/* Read a lookahead token if we need one and don't already have one. */
/* yyresume: */
/* First try to decide what to do without reference to lookahead token. */
yyn = yypact[yystate];
if (yyn == YYFLAG)
goto yydefault;
/* Not known => get a lookahead token if don't already have one. */
/* yychar is either YYEMPTY or YYEOF
or a valid token in external form. */
if (yychar == YYEMPTY)
{
YYDPRINTF ((stderr, "Reading a token: "));
yychar = YYLEX;
}
/* Convert token to internal form (in yychar1) for indexing tables with */
if (yychar <= 0) /* This means end of input. */
{
yychar1 = 0;
yychar = YYEOF; /* Don't call YYLEX any more */
YYDPRINTF ((stderr, "Now at end of input.\n"));
}
else
{
yychar1 = YYTRANSLATE (yychar);
#if YYDEBUG
/* We have to keep this `#if YYDEBUG', since we use variables
which are defined only if `YYDEBUG' is set. */
if (yydebug)
{
YYFPRINTF (stderr, "Next token is %d (%s",
yychar, yytname[yychar1]);
/* Give the individual parser a way to print the precise
meaning of a token, for further debugging info. */
# ifdef YYPRINT
YYPRINT (stderr, yychar, yylval);
# endif
YYFPRINTF (stderr, ")\n");
}
#endif
}
yyn += yychar1;
if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
goto yydefault;
yyn = yytable[yyn];
/* yyn is what to do for this token type in this state.
Negative => reduce, -yyn is rule number.
Positive => shift, yyn is new state.
New state is final state => don't bother to shift,
just return success.
0, or most negative number => error. */
if (yyn < 0)
{
if (yyn == YYFLAG)
goto yyerrlab;
yyn = -yyn;
goto yyreduce;
}
else if (yyn == 0)
goto yyerrlab;
if (yyn == YYFINAL)
YYACCEPT;
/* Shift the lookahead token. */
YYDPRINTF ((stderr, "Shifting token %d (%s), ",
yychar, yytname[yychar1]));
/* Discard the token being shifted unless it is eof. */
if (yychar != YYEOF)
yychar = YYEMPTY;
*++yyvsp = yylval;
#if YYLSP_NEEDED
*++yylsp = yylloc;
#endif
/* Count tokens shifted since error; after three, turn off error
status. */
if (yyerrstatus)
yyerrstatus--;
yystate = yyn;
goto yynewstate;
/*-----------------------------------------------------------.
| yydefault -- do the default action for the current state. |
`-----------------------------------------------------------*/
yydefault:
yyn = yydefact[yystate];
if (yyn == 0)
goto yyerrlab;
goto yyreduce;
/*-----------------------------.
| yyreduce -- Do a reduction. |
`-----------------------------*/
yyreduce:
/* yyn is the number of a rule to reduce with. */
yylen = yyr2[yyn];
/* If YYLEN is nonzero, implement the default value of the action:
`$$ = $1'.
Otherwise, the following line sets YYVAL to the semantic value of
the lookahead token. This behavior is undocumented and Bison
users should not rely upon it. Assigning to YYVAL
unconditionally makes the parser a bit smaller, and it avoids a
GCC warning that YYVAL may be used uninitialized. */
yyval = yyvsp[1-yylen];
#if YYLSP_NEEDED
/* Similarly for the default location. Let the user run additional
commands if for instance locations are ranges. */
yyloc = yylsp[1-yylen];
YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
#endif
#if YYDEBUG
/* We have to keep this `#if YYDEBUG', since we use variables which
are defined only if `YYDEBUG' is set. */
if (yydebug)
{
int yyi;
YYFPRINTF (stderr, "Reducing via rule %d (line %d), ",
yyn, yyrline[yyn]);
/* Print the symbols being reduced, and their result. */
for (yyi = yyprhs[yyn]; yyrhs[yyi] > 0; yyi++)
YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
YYFPRINTF (stderr, " -> %s\n", yytname[yyr1[yyn]]);
}
#endif
switch (yyn) {
case 3:
#line 153 "../common/getdate.y"
{
VARIABLE->yyHaveTime++;
;
break;}
case 4:
#line 156 "../common/getdate.y"
{
VARIABLE->yyHaveZone++;
;
break;}
case 5:
#line 159 "../common/getdate.y"
{
VARIABLE->yyHaveDate++;
;
break;}
case 6:
#line 162 "../common/getdate.y"
{
VARIABLE->yyHaveDay++;
;
break;}
case 7:
#line 165 "../common/getdate.y"
{
VARIABLE->yyHaveRel++;
;
break;}
case 9:
#line 171 "../common/getdate.y"
{
VARIABLE->yyHour = yyvsp[-1].Number;
VARIABLE->yyMinutes = 0;
VARIABLE->yySeconds = 0;
VARIABLE->yyMeridian = yyvsp[0].Meridian;
;
break;}
case 10:
#line 177 "../common/getdate.y"
{
VARIABLE->yyHour = yyvsp[-1].Number/100;
VARIABLE->yyMinutes = yyvsp[-1].Number%100;
VARIABLE->yySeconds = 0;
VARIABLE->yyMeridian = MER24;
VARIABLE->yyDSTmode = DSToff;
VARIABLE->yyTimezone = - (yyvsp[0].Number % 100 + (yyvsp[0].Number / 100) * 60);
;
break;}
case 11:
#line 185 "../common/getdate.y"
{
VARIABLE->yyHour = yyvsp[-1].Number/10000;
VARIABLE->yyMinutes = (yyvsp[-1].Number/100)%100;
VARIABLE->yySeconds = yyvsp[-1].Number % 100;
VARIABLE->yyMeridian = MER24;
VARIABLE->yyDSTmode = DSToff;
VARIABLE->yyTimezone = - (yyvsp[0].Number % 100 + (yyvsp[0].Number / 100) * 60);
;
break;}
case 12:
#line 193 "../common/getdate.y"
{
VARIABLE->yyHour = yyvsp[-3].Number;
VARIABLE->yyMinutes = yyvsp[-1].Number;
VARIABLE->yySeconds = 0;
VARIABLE->yyMeridian = yyvsp[0].Meridian;
;
break;}
case 13:
#line 199 "../common/getdate.y"
{
VARIABLE->yyHour = yyvsp[-3].Number;
VARIABLE->yyMinutes = yyvsp[-1].Number;
VARIABLE->yyMeridian = MER24;
VARIABLE->yyDSTmode = DSToff;
VARIABLE->yyTimezone = - (yyvsp[0].Number % 100 + (yyvsp[0].Number / 100) * 60);
;
break;}
case 14:
#line 206 "../common/getdate.y"
{
VARIABLE->yyHour = yyvsp[-5].Number;
VARIABLE->yyMinutes = yyvsp[-3].Number;
VARIABLE->yySeconds = yyvsp[-1].Number;
VARIABLE->yyMeridian = yyvsp[0].Meridian;
;
break;}
case 15:
#line 212 "../common/getdate.y"
{
VARIABLE->yyHour = yyvsp[-5].Number;
VARIABLE->yyMinutes = yyvsp[-3].Number;
VARIABLE->yySeconds = yyvsp[-1].Number;
VARIABLE->yyMeridian = MER24;
VARIABLE->yyDSTmode = DSToff;
VARIABLE->yyTimezone = - (yyvsp[0].Number % 100 + (yyvsp[0].Number / 100) * 60);
;
break;}
case 16:
#line 222 "../common/getdate.y"
{
VARIABLE->yyTimezone = yyvsp[0].Number;
VARIABLE->yyDSTmode = DSToff;
;
break;}
case 17:
#line 226 "../common/getdate.y"
{
VARIABLE->yyTimezone = yyvsp[0].Number;
VARIABLE->yyDSTmode = DSTon;
;
break;}
case 18:
#line 231 "../common/getdate.y"
{
VARIABLE->yyTimezone = yyvsp[-1].Number;
VARIABLE->yyDSTmode = DSTon;
;
break;}
case 19:
#line 235 "../common/getdate.y"
{
if (VARIABLE->yyHaveTime > 0) {
VARIABLE->yyTimezone = yyvsp[0].Number;
VARIABLE->yyDSTmode = DSToff;
}
else
VARIABLE->yyHaveZone--;
;
break;}
case 20:
#line 245 "../common/getdate.y"
{
VARIABLE->yyDayOrdinal = 1;
VARIABLE->yyDayNumber = yyvsp[0].Number;
;
break;}
case 21:
#line 249 "../common/getdate.y"
{
VARIABLE->yyDayOrdinal = 1;
VARIABLE->yyDayNumber = yyvsp[-1].Number;
;
break;}
case 22:
#line 253 "../common/getdate.y"
{
VARIABLE->yyDayOrdinal = yyvsp[-1].Number;
VARIABLE->yyDayNumber = yyvsp[0].Number;
;
break;}
case 23:
#line 259 "../common/getdate.y"
{
SetPossibleDate(VARIABLE, yyvsp[-2].Number, yyvsp[0].Number, VARIABLE->yyYear);
;
break;}
case 24:
#line 262 "../common/getdate.y"
{
SetPossibleDate(VARIABLE, yyvsp[-4].Number, yyvsp[-2].Number, yyvsp[0].Number);
;
break;}
case 25:
#line 265 "../common/getdate.y"
{
/* ISO 8601 format. yyyy-mm-dd. */
if (yyvsp[-2].Number > 31) {
VARIABLE->yyYear = yyvsp[-2].Number;
VARIABLE->yyMonth = -yyvsp[-1].Number;
VARIABLE->yyDay = -yyvsp[0].Number;
}
else
SetPossibleDate(VARIABLE, yyvsp[-2].Number, -yyvsp[-1].Number, -yyvsp[0].Number);
;
break;}
case 26:
#line 275 "../common/getdate.y"
{
/* e.g. 17-JUN-1992. */
VARIABLE->yyDay = yyvsp[-2].Number;
VARIABLE->yyMonth = yyvsp[-1].Number;
VARIABLE->yyYear = -yyvsp[0].Number;
;
break;}
case 27:
#line 281 "../common/getdate.y"
{
VARIABLE->yyMonth = yyvsp[-1].Number;
VARIABLE->yyDay = yyvsp[0].Number;
;
break;}
case 28:
#line 285 "../common/getdate.y"
{
VARIABLE->yyMonth = yyvsp[-3].Number;
VARIABLE->yyDay = yyvsp[-2].Number;
VARIABLE->yyYear = yyvsp[0].Number;
;
break;}
case 29:
#line 290 "../common/getdate.y"
{
VARIABLE->yyMonth = yyvsp[0].Number;
VARIABLE->yyDay = yyvsp[-1].Number;
;
break;}
case 30:
#line 294 "../common/getdate.y"
{
VARIABLE->yyMonth = yyvsp[-1].Number;
VARIABLE->yyDay = yyvsp[-2].Number;
VARIABLE->yyYear = yyvsp[0].Number;
;
break;}
case 31:
#line 301 "../common/getdate.y"
{
VARIABLE->yyRelSeconds = -VARIABLE->yyRelSeconds;
VARIABLE->yyRelMonth = -VARIABLE->yyRelMonth;
;
break;}
case 33:
#line 308 "../common/getdate.y"
{
VARIABLE->yyRelSeconds += yyvsp[-1].Number * yyvsp[0].Number * 60L;
;
break;}
case 34:
#line 311 "../common/getdate.y"
{
VARIABLE->yyRelSeconds += yyvsp[-1].Number * yyvsp[0].Number * 60L;
;
break;}
case 35:
#line 314 "../common/getdate.y"
{
VARIABLE->yyRelSeconds += yyvsp[0].Number * 60L;
;
break;}
case 36:
#line 317 "../common/getdate.y"
{
VARIABLE->yyRelSeconds += yyvsp[-1].Number;
;
break;}
case 37:
#line 320 "../common/getdate.y"
{
VARIABLE->yyRelSeconds += yyvsp[-1].Number;
;
break;}
case 38:
#line 323 "../common/getdate.y"
{
VARIABLE->yyRelSeconds++;
;
break;}
case 39:
#line 326 "../common/getdate.y"
{
VARIABLE->yyRelMonth += yyvsp[-1].Number * yyvsp[0].Number;
;
break;}
case 40:
#line 329 "../common/getdate.y"
{
VARIABLE->yyRelMonth += yyvsp[-1].Number * yyvsp[0].Number;
;
break;}
case 41:
#line 332 "../common/getdate.y"
{
VARIABLE->yyRelMonth += yyvsp[0].Number;
;
break;}
case 42:
#line 337 "../common/getdate.y"
{
yyval.Number = yyvsp[0].Number;
;
break;}
case 43:
#line 340 "../common/getdate.y"
{
yyval.Number = yyvsp[0].Number;
;
break;}
case 44:
#line 343 "../common/getdate.y"
{
yyval.Number = yyvsp[0].Number;
;
break;}
case 45:
#line 348 "../common/getdate.y"
{
if (VARIABLE->yyHaveTime && VARIABLE->yyHaveDate && !VARIABLE->yyHaveRel)
VARIABLE->yyYear = yyvsp[0].Number;
else {
if(yyvsp[0].Number>240000) {
VARIABLE->yyHaveDate++;
VARIABLE->yyDay= (yyvsp[0].Number)%100;
VARIABLE->yyMonth= (yyvsp[0].Number/100)%100;
VARIABLE->yyYear = yyvsp[0].Number/10000;
}
else {
VARIABLE->yyHaveTime++;
if (yyvsp[0].Number < 10000) {
VARIABLE->yyHour = yyvsp[0].Number / 100;
VARIABLE->yyMinutes = yyvsp[0].Number % 100;
VARIABLE->yySeconds = 0;
}
else {
VARIABLE->yyHour = yyvsp[0].Number/10000;
VARIABLE->yyMinutes = (yyvsp[0].Number/100)%100;
VARIABLE->yySeconds = yyvsp[0].Number % 100;
}
VARIABLE->yyMeridian = MER24;
}
}
;
break;}
case 46:
#line 374 "../common/getdate.y"
{
if (VARIABLE->yyHaveTime && VARIABLE->yyHaveDate && !VARIABLE->yyHaveRel)
VARIABLE->yyYear = yyvsp[0].Number;
else {
VARIABLE->yyHaveTime++;
VARIABLE->yyHour = yyvsp[0].Number/100;
VARIABLE->yyMinutes = yyvsp[0].Number%100;
VARIABLE->yySeconds = 0;
VARIABLE->yyMeridian = MER24;
}
;
break;}
case 47:
#line 385 "../common/getdate.y"
{
if (!VARIABLE->yyHaveDate && yyvsp[0].Number>240000) {
VARIABLE->yyHaveDate++;
VARIABLE->yyDay= (yyvsp[0].Number)%100;
VARIABLE->yyMonth= (yyvsp[0].Number/100)%100;
VARIABLE->yyYear = yyvsp[0].Number/10000;
}
else if (!VARIABLE->yyHaveTime) {
VARIABLE->yyHaveTime++;
VARIABLE->yyHour = yyvsp[0].Number/10000;
VARIABLE->yyMinutes = (yyvsp[0].Number/100)%100;
VARIABLE->yySeconds = yyvsp[0].Number % 100;
VARIABLE->yyMeridian = MER24;
}
;
break;}
case 48:
#line 402 "../common/getdate.y"
{
yyval.Meridian = MER24;
;
break;}
case 49:
#line 405 "../common/getdate.y"
{
yyval.Meridian = yyvsp[0].Meridian;
;
break;}
}
#line 705 "/usr/local/share/bison/bison.simple"
yyvsp -= yylen;
yyssp -= yylen;
#if YYLSP_NEEDED
yylsp -= yylen;
#endif
#if YYDEBUG
if (yydebug)
{
short *yyssp1 = yyss - 1;
YYFPRINTF (stderr, "state stack now");
while (yyssp1 != yyssp)
YYFPRINTF (stderr, " %d", *++yyssp1);
YYFPRINTF (stderr, "\n");
}
#endif
*++yyvsp = yyval;
#if YYLSP_NEEDED
*++yylsp = yyloc;
#endif
/* Now `shift' the result of the reduction. Determine what state
that goes to, based on the state we popped back to and the rule
number reduced by. */
yyn = yyr1[yyn];
yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
yystate = yytable[yystate];
else
yystate = yydefgoto[yyn - YYNTBASE];
goto yynewstate;
/*------------------------------------.
| yyerrlab -- here on detecting error |
`------------------------------------*/
yyerrlab:
/* If not already recovering from an error, report this error. */
if (!yyerrstatus)
{
++yynerrs;
#ifdef YYERROR_VERBOSE
yyn = yypact[yystate];
if (yyn > YYFLAG && yyn < YYLAST)
{
YYSIZE_T yysize = 0;
char *yymsg;
int yyx, yycount;
yycount = 0;
/* Start YYX at -YYN if negative to avoid negative indexes in
YYCHECK. */
for (yyx = yyn < 0 ? -yyn : 0;
yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
if (yycheck[yyx + yyn] == yyx)
yysize += yystrlen (yytname[yyx]) + 15, yycount++;
yysize += yystrlen ("parse error, unexpected ") + 1;
yysize += yystrlen (yytname[YYTRANSLATE (yychar)]);
yymsg = (char *) YYSTACK_ALLOC (yysize);
if (yymsg != 0)
{
char *yyp = yystpcpy (yymsg, "parse error, unexpected ");
yyp = yystpcpy (yyp, yytname[YYTRANSLATE (yychar)]);
if (yycount < 5)
{
yycount = 0;
for (yyx = yyn < 0 ? -yyn : 0;
yyx < (int) (sizeof (yytname) / sizeof (char *));
yyx++)
if (yycheck[yyx + yyn] == yyx)
{
const char *yyq = ! yycount ? ", expecting " : " or ";
yyp = yystpcpy (yyp, yyq);
yyp = yystpcpy (yyp, yytname[yyx]);
yycount++;
}
}
yyerror (yymsg);
YYSTACK_FREE (yymsg);
}
else
yyerror ("parse error; also virtual memory exhausted");
}
else
#endif /* defined (YYERROR_VERBOSE) */
yyerror ("parse error");
}
goto yyerrlab1;
/*--------------------------------------------------.
| yyerrlab1 -- error raised explicitly by an action |
`--------------------------------------------------*/
yyerrlab1:
if (yyerrstatus == 3)
{
/* If just tried and failed to reuse lookahead token after an
error, discard it. */
/* return failure if at end of input */
if (yychar == YYEOF)
YYABORT;
YYDPRINTF ((stderr, "Discarding token %d (%s).\n",
yychar, yytname[yychar1]));
yychar = YYEMPTY;
}
/* Else will try to reuse lookahead token after shifting the error
token. */
yyerrstatus = 3; /* Each real token shifted decrements this */
goto yyerrhandle;
/*-------------------------------------------------------------------.
| yyerrdefault -- current state does not do anything special for the |
| error token. |
`-------------------------------------------------------------------*/
yyerrdefault:
#if 0
/* This is wrong; only states that explicitly want error tokens
should shift them. */
/* If its default is to accept any token, ok. Otherwise pop it. */
yyn = yydefact[yystate];
if (yyn)
goto yydefault;
#endif
/*---------------------------------------------------------------.
| yyerrpop -- pop the current state because it cannot handle the |
| error token |
`---------------------------------------------------------------*/
yyerrpop:
if (yyssp == yyss)
YYABORT;
yyvsp--;
yystate = *--yyssp;
#if YYLSP_NEEDED
yylsp--;
#endif
#if YYDEBUG
if (yydebug)
{
short *yyssp1 = yyss - 1;
YYFPRINTF (stderr, "Error: state stack now");
while (yyssp1 != yyssp)
YYFPRINTF (stderr, " %d", *++yyssp1);
YYFPRINTF (stderr, "\n");
}
#endif
/*--------------.
| yyerrhandle. |
`--------------*/
yyerrhandle:
yyn = yypact[yystate];
if (yyn == YYFLAG)
goto yyerrdefault;
yyn += YYTERROR;
if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
goto yyerrdefault;
yyn = yytable[yyn];
if (yyn < 0)
{
if (yyn == YYFLAG)
goto yyerrpop;
yyn = -yyn;
goto yyreduce;
}
else if (yyn == 0)
goto yyerrpop;
if (yyn == YYFINAL)
YYACCEPT;
YYDPRINTF ((stderr, "Shifting error token, "));
*++yyvsp = yylval;
#if YYLSP_NEEDED
*++yylsp = yylloc;
#endif
yystate = yyn;
goto yynewstate;
/*-------------------------------------.
| yyacceptlab -- YYACCEPT comes here. |
`-------------------------------------*/
yyacceptlab:
yyresult = 0;
goto yyreturn;
/*-----------------------------------.
| yyabortlab -- YYABORT comes here. |
`-----------------------------------*/
yyabortlab:
yyresult = 1;
goto yyreturn;
/*---------------------------------------------.
| yyoverflowab -- parser overflow comes here. |
`---------------------------------------------*/
yyoverflowlab:
yyerror ("parser stack overflow");
yyresult = 2;
/* Fall through. */
yyreturn:
#ifndef yyoverflow
if (yyss != yyssa)
YYSTACK_FREE (yyss);
#endif
return yyresult;
}
#line 410 "../common/getdate.y"
/* Month and day table. */
static TABLE const MonthDayTable[] = {
{ "january", tMONTH, 1 },
{ "february", tMONTH, 2 },
{ "march", tMONTH, 3 },
{ "april", tMONTH, 4 },
{ "may", tMONTH, 5 },
{ "june", tMONTH, 6 },
{ "july", tMONTH, 7 },
{ "august", tMONTH, 8 },
{ "september", tMONTH, 9 },
{ "sept", tMONTH, 9 },
{ "october", tMONTH, 10 },
{ "november", tMONTH, 11 },
{ "december", tMONTH, 12 },
{ "sunday", tDAY, 0 },
{ "monday", tDAY, 1 },
{ "tuesday", tDAY, 2 },
{ "tues", tDAY, 2 },
{ "wednesday", tDAY, 3 },
{ "wednes", tDAY, 3 },
{ "thursday", tDAY, 4 },
{ "thur", tDAY, 4 },
{ "thurs", tDAY, 4 },
{ "friday", tDAY, 5 },
{ "saturday", tDAY, 6 },
{ NULL }
};
/* Time units table. */
static TABLE const UnitsTable[] = {
{ "year", tMONTH_UNIT, 12 },
{ "month", tMONTH_UNIT, 1 },
{ "fortnight", tMINUTE_UNIT, 14 * 24 * 60 },
{ "week", tMINUTE_UNIT, 7 * 24 * 60 },
{ "day", tMINUTE_UNIT, 1 * 24 * 60 },
{ "hour", tMINUTE_UNIT, 60 },
{ "minute", tMINUTE_UNIT, 1 },
{ "min", tMINUTE_UNIT, 1 },
{ "second", tSEC_UNIT, 1 },
{ "sec", tSEC_UNIT, 1 },
{ NULL }
};
/* Assorted relative-time words. */
static TABLE const OtherTable[] = {
{ "tomorrow", tMINUTE_UNIT, 1 * 24 * 60 },
{ "yesterday", tMINUTE_UNIT, -1 * 24 * 60 },
{ "today", tMINUTE_UNIT, 0 },
{ "now", tMINUTE_UNIT, 0 },
{ "last", tUNUMBER, -1 },
{ "this", tMINUTE_UNIT, 0 },
{ "next", tUNUMBER, 2 },
{ "first", tUNUMBER, 1 },
/* { "second", tUNUMBER, 2 }, */
{ "third", tUNUMBER, 3 },
{ "fourth", tUNUMBER, 4 },
{ "fifth", tUNUMBER, 5 },
{ "sixth", tUNUMBER, 6 },
{ "seventh", tUNUMBER, 7 },
{ "eighth", tUNUMBER, 8 },
{ "ninth", tUNUMBER, 9 },
{ "tenth", tUNUMBER, 10 },
{ "eleventh", tUNUMBER, 11 },
{ "twelfth", tUNUMBER, 12 },
{ "ago", tAGO, 1 },
{ NULL }
};
/* The timezone table. */
/* Some of these are commented out because a time_t can't store a float. */
static TABLE const TimezoneTable[] = {
{ "gmt", tZONE, HOUR( 0) }, /* Greenwich Mean */
{ "ut", tZONE, HOUR( 0) }, /* Universal (Coordinated) */
{ "utc", tZONE, HOUR( 0) },
{ "wet", tZONE, HOUR( 0) }, /* Western European */
{ "bst", tDAYZONE, HOUR( 0) }, /* British Summer */
{ "wat", tZONE, HOUR( 1) }, /* West Africa */
{ "at", tZONE, HOUR( 2) }, /* Azores */
#if 0
/* For completeness. BST is also British Summer, and GST is
* also Guam Standard. */
{ "bst", tZONE, HOUR( 3) }, /* Brazil Standard */
{ "gst", tZONE, HOUR( 3) }, /* Greenland Standard */
#endif
#if 0
{ "nft", tZONE, HOUR(3.5) }, /* Newfoundland */
{ "nst", tZONE, HOUR(3.5) }, /* Newfoundland Standard */
{ "ndt", tDAYZONE, HOUR(3.5) }, /* Newfoundland Daylight */
#endif
{ "ast", tZONE, HOUR( 4) }, /* Atlantic Standard */
{ "adt", tDAYZONE, HOUR( 4) }, /* Atlantic Daylight */
{ "est", tZONE, HOUR( 5) }, /* Eastern Standard */
{ "edt", tDAYZONE, HOUR( 5) }, /* Eastern Daylight */
{ "cst", tZONE, HOUR( 6) }, /* Central Standard */
{ "cdt", tDAYZONE, HOUR( 6) }, /* Central Daylight */
{ "mst", tZONE, HOUR( 7) }, /* Mountain Standard */
{ "mdt", tDAYZONE, HOUR( 7) }, /* Mountain Daylight */
{ "pst", tZONE, HOUR( 8) }, /* Pacific Standard */
{ "pdt", tDAYZONE, HOUR( 8) }, /* Pacific Daylight */
{ "yst", tZONE, HOUR( 9) }, /* Yukon Standard */
{ "ydt", tDAYZONE, HOUR( 9) }, /* Yukon Daylight */
{ "hst", tZONE, HOUR(10) }, /* Hawaii Standard */
{ "hdt", tDAYZONE, HOUR(10) }, /* Hawaii Daylight */
{ "cat", tZONE, HOUR(10) }, /* Central Alaska */
{ "ahst", tZONE, HOUR(10) }, /* Alaska-Hawaii Standard */
{ "nt", tZONE, HOUR(11) }, /* Nome */
{ "idlw", tZONE, HOUR(12) }, /* International Date Line West */
{ "cet", tZONE, -HOUR(1) }, /* Central European */
{ "met", tZONE, -HOUR(1) }, /* Middle European */
{ "mewt", tZONE, -HOUR(1) }, /* Middle European Winter */
{ "mest", tDAYZONE, -HOUR(1) }, /* Middle European Summer */
{ "swt", tZONE, -HOUR(1) }, /* Swedish Winter */
{ "sst", tDAYZONE, -HOUR(1) }, /* Swedish Summer */
{ "fwt", tZONE, -HOUR(1) }, /* French Winter */
{ "fst", tDAYZONE, -HOUR(1) }, /* French Summer */
{ "eet", tZONE, -HOUR(2) }, /* Eastern Europe, USSR Zone 1 */
{ "bt", tZONE, -HOUR(3) }, /* Baghdad, USSR Zone 2 */
#if 0
{ "it", tZONE, -HOUR(3.5) },/* Iran */
#endif
{ "zp4", tZONE, -HOUR(4) }, /* USSR Zone 3 */
{ "zp5", tZONE, -HOUR(5) }, /* USSR Zone 4 */
#if 0
{ "ist", tZONE, -HOUR(5.5) },/* Indian Standard */
#endif
{ "zp6", tZONE, -HOUR(6) }, /* USSR Zone 5 */
#if 0
/* For completeness. NST is also Newfoundland Stanard, and SST is
* also Swedish Summer. */
{ "nst", tZONE, -HOUR(6.5) },/* North Sumatra */
{ "sst", tZONE, -HOUR(7) }, /* South Sumatra, USSR Zone 6 */
#endif /* 0 */
{ "wast", tZONE, -HOUR(7) }, /* West Australian Standard */
{ "wadt", tDAYZONE, -HOUR(7) }, /* West Australian Daylight */
#if 0
{ "jt", tZONE, -HOUR(7.5) },/* Java (3pm in Cronusland!) */
#endif
{ "cct", tZONE, -HOUR(8) }, /* China Coast, USSR Zone 7 */
{ "jst", tZONE, -HOUR(9) }, /* Japan Standard, USSR Zone 8 */
#if 0
{ "cast", tZONE, -HOUR(9.5) },/* Central Australian Standard */
{ "cadt", tDAYZONE, -HOUR(9.5) },/* Central Australian Daylight */
#endif
{ "east", tZONE, -HOUR(10) }, /* Eastern Australian Standard */
{ "eadt", tDAYZONE, -HOUR(10) }, /* Eastern Australian Daylight */
{ "gst", tZONE, -HOUR(10) }, /* Guam Standard, USSR Zone 9 */
{ "nzt", tZONE, -HOUR(12) }, /* New Zealand */
{ "nzst", tZONE, -HOUR(12) }, /* New Zealand Standard */
{ "nzdt", tDAYZONE, -HOUR(12) }, /* New Zealand Daylight */
{ "idle", tZONE, -HOUR(12) }, /* International Date Line East */
{ NULL }
};
/* Military timezone table. */
static TABLE const MilitaryTable[] = {
{ "a", tMILZONE, HOUR( 1) },
{ "b", tMILZONE, HOUR( 2) },
{ "c", tMILZONE, HOUR( 3) },
{ "d", tMILZONE, HOUR( 4) },
{ "e", tMILZONE, HOUR( 5) },
{ "f", tMILZONE, HOUR( 6) },
{ "g", tMILZONE, HOUR( 7) },
{ "h", tMILZONE, HOUR( 8) },
{ "i", tMILZONE, HOUR( 9) },
{ "k", tMILZONE, HOUR( 10) },
{ "l", tMILZONE, HOUR( 11) },
{ "m", tMILZONE, HOUR( 12) },
{ "n", tMILZONE, HOUR(- 1) },
{ "o", tMILZONE, HOUR(- 2) },
{ "p", tMILZONE, HOUR(- 3) },
{ "q", tMILZONE, HOUR(- 4) },
{ "r", tMILZONE, HOUR(- 5) },
{ "s", tMILZONE, HOUR(- 6) },
{ "t", tMILZONE, HOUR(- 7) },
{ "u", tMILZONE, HOUR(- 8) },
{ "v", tMILZONE, HOUR(- 9) },
{ "w", tMILZONE, HOUR(-10) },
{ "x", tMILZONE, HOUR(-11) },
{ "y", tMILZONE, HOUR(-12) },
{ "z", tZONE, HOUR( 0) }, /* Deliberately tZONE */
{ NULL }
};
static int LookupWord(char * buff, YYSTYPE * yylval)
{
register char *p;
register char *q;
register const TABLE *tp;
int i;
int abbrev;
/* Make it lowercase. */
for (p = buff; *p != '\0'; p++)
*p = (char)tolower(*p);
if (strcmp(buff, "am") == 0 || strcmp(buff, "a.m.") == 0) {
yylval->Meridian = MERam;
return tMERIDIAN;
}
if (strcmp(buff, "pm") == 0 || strcmp(buff, "p.m.") == 0) {
yylval->Meridian = MERpm;
return tMERIDIAN;
}
/* See if we have an abbreviation for a month. */
if (strlen(buff) == 3)
abbrev = 1;
else if (strlen(buff) == 4 && buff[3] == '.') {
abbrev = 1;
buff[3] = '\0';
}
else
abbrev = 0;
for (tp = MonthDayTable; tp->name; tp++) {
if (abbrev) {
if (strncmp(buff, tp->name, 3) == 0) {
yylval->Number = tp->value;
return tp->type;
}
}
else if (strcmp(buff, tp->name) == 0) {
yylval->Number = tp->value;
return tp->type;
}
}
for (tp = TimezoneTable; tp->name; tp++)
if (strcmp(buff, tp->name) == 0) {
yylval->Number = tp->value;
return tp->type;
}
if (strcmp(buff, "dst") == 0)
return tDST;
for (tp = UnitsTable; tp->name; tp++)
if (strcmp(buff, tp->name) == 0) {
yylval->Number = tp->value;
return tp->type;
}
/* Strip off any plural and try the units table again. */
i = strlen(buff) - 1;
if (buff[i] == 's') {
buff[i] = '\0';
for (tp = UnitsTable; tp->name; tp++)
if (strcmp(buff, tp->name) == 0) {
yylval->Number = tp->value;
return tp->type;
}
buff[i] = 's'; /* Put back for "this" in OtherTable. */
}
for (tp = OtherTable; tp->name; tp++)
if (strcmp(buff, tp->name) == 0) {
yylval->Number = tp->value;
return tp->type;
}
/* Military timezones. */
if (buff[1] == '\0' && isalpha(*buff)) {
for (tp = MilitaryTable; tp->name; tp++)
if (strcmp(buff, tp->name) == 0) {
yylval->Number = tp->value;
return tp->type;
}
}
/* Drop out any periods and try the timezone table again. */
for (i = 0, p = q = buff; *q; q++)
if (*q != '.')
*p++ = *q;
else
i++;
*p = '\0';
if (i)
for (tp = TimezoneTable; tp->name; tp++)
if (strcmp(buff, tp->name) == 0) {
yylval->Number = tp->value;
return tp->type;
}
for (i = 1; i <= 12; i++)
for (abbrev = 0; abbrev < 2; abbrev++)
if (PTimeIsMonthName(buff, i, abbrev)) {
yylval->Number = i;
return tMONTH;
}
for (i = 1; i <= 7; i++)
for (abbrev = 0; abbrev < 2; abbrev++)
if (PTimeIsDayName(buff, i, abbrev)) {
yylval->Number = i;
return tDAY;
}
return tID;
}
#ifdef _MSC_VER
#pragma warning(disable:4211)
#endif
#ifndef __GNUC__
static
#endif
int yylex(YYSTYPE * yylval, void * yyInput)
{
register char *p;
char buff[20];
int Count;
int sign;
register int c = PTimeGetChar(yyInput);
while (c != EOF && c != '\0' && c != '\n') {
while (isspace(c))
c = PTimeGetChar(yyInput);
if (isdigit(c) || c == '-' || c == '+') {
if (c == '-' || c == '+') {
sign = c == '-' ? -1 : 1;
if (!isdigit(c = PTimeGetChar(yyInput)))
/* skip the '-' sign */
continue;
}
else
sign = 0;
yylval->Number = 0;
Count = 0; /* Count number of digits */
while (isdigit(c)) {
yylval->Number = 10 * yylval->Number + c - '0';
c = PTimeGetChar(yyInput);
Count++;
}
PTimeUngetChar(yyInput, c);
if (sign < 0)
yylval->Number = -yylval->Number;
if (sign)
return tSNUMBER;
if (Count == 4)
return t4DIGITNUMBER;
if (Count == 6)
return t6DIGITNUMBER;
return tUNUMBER;
}
if (isalpha(c)) {
for (p = buff; isalpha(c) || c == '.'; c = PTimeGetChar(yyInput)) {
if (p < &buff[sizeof(buff)-1])
*p++ = (char)c;
}
*p = '\0';
PTimeUngetChar(yyInput, c);
return LookupWord(buff, yylval);
}
if (c != '(')
return c;
Count = 0;
do {
c = PTimeGetChar(yyInput);
if (c == '\0' || c == EOF)
return c;
if (c == '(')
Count++;
else if (c == ')')
Count--;
} while (Count > 0);
}
return EOF;
}
#ifdef _MSC_VER
#pragma warning(default:4211)
#endif
static time_t ToSeconds(time_t Hours, time_t Minutes, time_t Seconds,
MERIDIAN Meridian)
{
if (Minutes < 0 || Minutes > 59 || Seconds < 0 || Seconds > 59)
return -1;
switch (Meridian) {
case MER24:
if (Hours < 0 || Hours > 23)
return -1;
return (Hours * 60L + Minutes) * 60L + Seconds;
case MERam:
if (Hours < 1 || Hours > 12)
return -1;
if (Hours == 12)
Hours = 0;
return (Hours * 60L + Minutes) * 60L + Seconds;
case MERpm:
if (Hours < 1 || Hours > 12)
return -1;
if (Hours == 12)
Hours = 0;
return ((Hours + 12) * 60L + Minutes) * 60L + Seconds;
}
return -1;
}
static time_t Convert(time_t Month, time_t Day, time_t Year,
time_t Hours, time_t Minutes, time_t Seconds,
MERIDIAN Meridian, DSTMODE DSTmode, time_t yyTimezone)
{
static int DaysInMonth[12] = {
31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
};
time_t tod;
time_t Julian;
int i;
if (Year < 0)
Year = -Year;
if (Year < 70)
Year += 2000;
else if (Year < 100)
Year += 1900;
DaysInMonth[1] = Year % 4 == 0 && (Year % 100 != 0 || Year % 400 == 0)
? 29 : 28;
/* Checking for 2038 bogusly assumes that time_t is 32 bits. But
I'm too lazy to try to check for time_t overflow in another way. */
if (Year < EPOCH || Year > 2038
|| Month < 1 || Month > 12
/* Lint fluff: "conversion from long may lose accuracy" */
|| Day < 1 || Day > DaysInMonth[(int)--Month])
return -1;
for (Julian = Day - 1, i = 0; i < Month; i++)
Julian += DaysInMonth[i];
for (i = EPOCH; i < Year; i++)
Julian += 365 + (i % 4 == 0);
Julian *= SECSPERDAY;
Julian += yyTimezone * 60L;
if ((tod = ToSeconds(Hours, Minutes, Seconds, Meridian)) < 0)
return -1;
Julian += tod;
if (DSTmode == DSTon
|| (DSTmode == DSTmaybe && localtime(&Julian)->tm_isdst))
Julian -= 60 * 60;
return Julian;
}
static time_t DSTcorrect(time_t Start, time_t Future)
{
time_t StartDay;
time_t FutureDay;
StartDay = (localtime(&Start)->tm_hour + 1) % 24;
FutureDay = (localtime(&Future)->tm_hour + 1) % 24;
return (Future - Start) + (StartDay - FutureDay) * 60L * 60L;
}
static time_t RelativeDate(time_t Start, time_t DayOrdinal, time_t DayNumber)
{
struct tm *tm;
time_t now;
now = Start;
tm = localtime(&now);
now += SECSPERDAY * ((DayNumber - tm->tm_wday + 7) % 7);
now += 7 * SECSPERDAY * (DayOrdinal <= 0 ? DayOrdinal : DayOrdinal - 1);
return DSTcorrect(Start, now);
}
static time_t RelativeMonth(time_t Start, time_t RelMonth, time_t yyTimezone)
{
struct tm *tm;
time_t Month;
time_t Year;
if (RelMonth == 0)
return 0;
tm = localtime(&Start);
Month = 12 * tm->tm_year + tm->tm_mon + RelMonth;
Year = Month / 12 + 1900;
Month = Month % 12 + 1;
return DSTcorrect(Start,
Convert(Month, (time_t)tm->tm_mday, Year,
(time_t)tm->tm_hour, (time_t)tm->tm_min, (time_t)tm->tm_sec,
MER24, DSTmaybe, yyTimezone));
}
static void SetPossibleDate(struct Variables * var,
time_t possible_day,
time_t possible_month,
time_t possible_year)
{
int date_order;
if (possible_day > 31) /* test for ymd */
date_order = 2;
else if (possible_day > 12) /* test for dmy */
date_order = 1;
else if (possible_month > 12) /* test for mdy */
date_order = 0;
else {
static int default_date_order = -1;
if (default_date_order < 0)
default_date_order = PTimeGetDateOrder();
date_order = default_date_order;
}
switch (date_order) {
case 0 :
var->yyDay = possible_month;
var->yyMonth = possible_day;
var->yyYear = possible_year;
break;
case 1 :
var->yyDay = possible_day;
var->yyMonth = possible_month;
var->yyYear = possible_year;
break;
default :
var->yyDay = possible_year;
var->yyMonth = possible_month;
var->yyYear = possible_day;
}
}
time_t STDAPICALLTYPE PTimeParse(void * inputStream, struct tm * now, int timezone)
{
time_t Start;
struct Variables var;
var.yyInput = inputStream;
var.yyYear = now->tm_year + 1900;
var.yyMonth = now->tm_mon + 1;
var.yyDay = now->tm_mday;
var.yyTimezone = -timezone;
var.yyDSTmode = DSTmaybe;
var.yyHour = 0;
var.yyMinutes = 0;
var.yySeconds = 0;
var.yyMeridian = MER24;
var.yyRelSeconds = 0;
var.yyRelMonth = 0;
var.yyHaveDate = 0;
var.yyHaveDay = 0;
var.yyHaveRel = 0;
var.yyHaveTime = 0;
var.yyHaveZone = 0;
yyparse(&var);
if (var.yyHaveTime > 1 || var.yyHaveZone > 1 ||
var.yyHaveDate > 1 || var.yyHaveDay > 1)
return -1;
if (var.yyHaveTime == 0 && var.yyHaveZone == 0 &&
var.yyHaveDate == 0 && var.yyHaveDay == 0 && var.yyHaveRel == 0)
return -1;
if (var.yyHaveDate || var.yyHaveTime || var.yyHaveDay) {
Start = Convert(var.yyMonth, var.yyDay, var.yyYear,
var.yyHour, var.yyMinutes, var.yySeconds,
var.yyMeridian, var.yyDSTmode, var.yyTimezone);
if (Start < 0)
return -1;
}
else {
time(&Start);
if (!var.yyHaveRel)
Start -= ((now->tm_hour * 60L + now->tm_min) * 60L) + now->tm_sec;
}
Start += var.yyRelSeconds;
Start += RelativeMonth(Start, var.yyRelMonth, var.yyTimezone);
if (var.yyHaveDay && !var.yyHaveDate)
Start += RelativeDate(Start, var.yyDayOrdinal, var.yyDayNumber);
/* Have to do *something* with a legitimate -1 so it's distinguishable
* from the error return value. (Alternately could set errno on error.) */
return Start == -1 ? 0 : Start;
}
#ifdef _MSC_VER
#pragma warning(disable:4100 4211)
#endif
#ifdef __GNUC__
int yyerror(const char * s)
{
return 0;
}
#else
static void yyerror(const char * s)
{
}
#endif
#ifdef _MSC_VER
#pragma warning(default:4100 4211)
#endif
/* End of file ***************************************************************/
syntax highlighted by Code2HTML, v. 0.9.1