/* original parser id follows */
/* gettime_sccsid[] = "@(#)yaccpar	1.9 (Berkeley) 02/21/93" */
/* (use gettime_MAJOR/gettime_MINOR for ifdefs dependent on parser version) */

#define gettime_BYACC 1
#define gettime_MAJOR 1
#define gettime_MINOR 9

#define gettime_EMPTY        (-1)
#define gettime_clearin      (gettime_char = gettime_EMPTY)
#define gettime_errok        (gettime_errflag = 0)
#define gettime_RECOVERING() (gettime_errflag != 0)
#define gettime_ENOMEM       (-2)
#define gettime_EOF          0
#undef gettime_BTYACC
#define gettime_BTYACC 0
#define gettime_DEBUGSTR gettime_PREFIX "debug"
#define gettime_PREFIX "gettime_"

#define gettime_PURE 0

#line 41 "common/gettime.y"

#include <common/ac/stdio.h>
#include <common/ac/stdlib.h>
#include <common/ac/ctype.h>
#include <common/ac/string.h>

#include <common/gettime.h>
#include <common/now.h>
#include <common/str.h>
#include <common/trace.h>

/*
 * This forward declaration needs to be here so that code generated by
 * Sun's yacc doesn't puke.  I'd move the whole gettime_lex function to here,
 * but then the the code generated by Berkeley's yacc will puke.  Sheesh.
 */
static int gettime_lex(void);

#define daysec (24L * 60L * 60L)

#define AM 1
#define PM 2

#define DAYLIGHT 1
#define STANDARD 2
#define MAYBE    3

#define MAX_ID_LENGTH 20

static	int	timeflag;
static	int	zoneflag;
static	int	dateflag;
static	int	dayflag;
static	int	relflag;
static	time_t	relsec;
static	time_t	relmonth;
static	int	hh;
static	int	mm;
static	int	ss;
static	int	merid;
static	int	day_light_flag;
static	int	dayord;
static	int	dayreq;
static	int	month;
static	int	day;
static	int	year;
static	int	ourzone;
static	const char *lptr;
#define gettime_STYPE int
extern	gettime_STYPE	gettime_lval;
extern	int	gettime_debug;


static int mdays[12] =
{
    31, 0, 31,  30, 31, 30,  31, 31, 30,  31, 30, 31
};

#define epoch 1970

int gettime_parse(void); /* forward */


/*
 * NAME
 *	timeconv - convert a time
 *
 * SYNOPSIS
 *	time_t timeconv(int hh, int mm, int ss, int mer);
 *
 * DESCRIPTION
 *	The timeconv function is used to convert a time
 *	specified in hours minutes and seconds, into seconds past midnight.
 *
 * ARGUMENTS
 *	hh	hours, range depends on the meridian
 *	mm	minutes, 0..59
 *	ss	seconds, 0..59
 *	mer	meridian to use: AM, PM or 24
 *
 * RETURNS
 *	time_t; seconds past midnight; -1 on any error.
 */

static time_t
timeconv(int ahh, int amm, int ass, int mer)
{
    time_t          result;

    /*
     * perform sanity checks on input
     */
    trace(("timeconv(ahh = %d, amm = %d, ass = %d, mer = %d)\n{\n",
	ahh, amm, ass, mer));
    result = -1;
    if (amm < 0 || amm > 59 || ass < 0 || ass > 59)
	goto done;

    /*
     * perform range checks depending on the meridian
     */
    switch (mer)
    {
    case AM:
	if (ahh < 1 || ahh > 12)
    	    goto done;
	if (ahh == 12)
    	    ahh = 0;
	break;

    case PM:
	if (ahh < 1 || ahh > 12)
    	    goto done;
	if (ahh == 12)
    	    ahh = 0;
	ahh += 12;
	break;

    case 24:
	if (ahh < 0 || ahh > 23)
    	    goto done;
	break;

    default:
	goto done;
    }
    result = ((ahh * 60L + amm) * 60L + ass);
done:
    trace(("return %ld;\n", (long)result));
    trace(("}\n"));
    return result;
}


static int
is_a_leap_year(int gettime_)
{
    return (gettime_ % 4 == 0 && (gettime_ % 100 != 0 || gettime_ % 400 == 0));
}


/*
 * NAME
 *	dateconv - convert a date
 *
 * SYNOPSIS
 *	time_t dateconv(int mm, int dd, int year, int h, int m, int s,
 *		int mer, int zone, int dayflag);
 *
 * DESCRIPTION
 *	The dateconv function may be used to convert a date after the
 *	date string has been taken apart by gettime_parse.
 *
 * ARGUMENTS
 *	mm	month number, in the range 1..12
 *	year	year number,  in several ranges:
 *		0..37 means 2000..2037
 *		70..99 means 1970..1999
 *		1970..2037 mean themselves.
 *	dd	day of month, in the range 1..max, where max varies for
 *		each month, as per the catchy jingle (except February,
 *		which is a monster).
 *	h	hours since midnight or meridian
 *	m	minutes past hour
 *	s	seconds past minute
 *	mer	meridian, AM or PM.
 *	zone	minutes correction for the time zone.
 *	dayflag	whether to use daylight savings: STANDARD, DAYLIGHT or MAYBE.
 *
 * RETURNS
 *	time_t; the time in seconds past Jan 1 0:00:00 1970 GMT, this will
 *	always be positive or zero; -1 is returned for any error.
 *
 * CAVEAT
 *	The date functions only work between 1970 and 2037,
 *	because 0 is Jan 1 00:00:00 1970 GMT
 *	and (2^31-1) is Jan 19 03:14:07 2038 GMT
 *	hence some if the weir magic number below.
 *
 *	Because -1 is used to represent errors, times before noon Jan 1 1970
 *	in places east of GMT can't always be represented.
 */

static time_t
dateconv(int amm, int dd, int ayear, int h, int m, int s, int mer, int zone,
    int adayflag)
{
    time_t          result;
    time_t	    tod;
    time_t	    jdate;
    int	i;

    /*
     * make corrections for the year
     *
     * If it is 0..99, RFC822 says pick closest century.
     */
    trace(("dateconv(amm = %d, dd = %d, ayear = %d, h = %d, m = %d, "
	"s = %d, mer = %d, zone = %d, adayflag = %d)\n{\n",
	amm, dd, ayear, h, m, s, mer, zone, adayflag));
    result = -1;
    if (ayear < 0)
	ayear = -ayear;
    if (ayear < 38)
	ayear += 2000;
    else if (ayear < 100)
	ayear += 1900;

    /*
     * correct February length once we know the year
     */
    mdays[1] =
	28 + is_a_leap_year(ayear);

    /*
     * perform some sanity checks on the input
     */
    if
    (
	ayear < epoch
    ||
	ayear >= 2038
    ||
	amm < 1
    ||
	amm > 12
    ||
	dd < 1
    ||
	dd > mdays[--amm]
    )
	goto done;

    /*
     * Determine the julian day number of the dd-mm-gettime_ given.
     * Turn it into seconds, and add in the time zone correction.
     */
    jdate = dd - 1;
    for (i = 0; i < amm; i++)
	jdate += mdays[i];
    for (i = epoch; i < ayear; i++)
	jdate += 365 + is_a_leap_year(i);
    jdate *= daysec;
    jdate += zone * 60L;

    /*
     * Determine the time of day.
     * that is, seconds from midnight.
     * Add it into the julian date.
     */
    tod = timeconv(h, m, s, mer);
    if (tod < 0)
	goto done;
    jdate += tod;

    /*
     * Perform daylight savings correction if necessary.
     * (This assumes 1 hour daylite savings, which is probably wrong.)
     */
    if
    (
	adayflag == DAYLIGHT
    ||
	(adayflag == MAYBE && localtime(&jdate)->tm_isdst)
    )
	jdate += -1 * 60 * 60;

    /*
     * there you have it.
     */
    result = jdate;
done:
    trace(("return %ld;\n", (long)result));
    trace(("}\n"));
    return result;
}


/*
 * NAME
 *	daylcorr
 *
 * SYNOPSIS
 *	time_t daylcorr(time_t future, time_t relative_to);
 *
 * DESCRIPTION
 *	The daylcorr function is used to determine the difference in seconds
 *	between two times, taking daylight savings into account.
 *
 * ARGUMENTS
 *	future	- a later time
 *	relative_to - an earlier time
 *
 * RETURNS
 *	time_t; the difference in seconds
 *
 * CAVEAT
 *	Assumes daylight savings is alays an integral number of hours.
 *	This is wrong is Saudi Arabia (time zone changes during the day),
 *	and South Australia (half hour DLS).
 */

static time_t
daylcorr(time_t future, time_t relative_to)
{
    int             fdayl;
    int             nowdayl;
    time_t          result;

    trace(("daylcorr(future = %ld, relative_to = %ld)\n{\n", (long)future,
	(long)relative_to));
    nowdayl = (localtime(&relative_to)->tm_hour + 1) % 24;
    fdayl = (localtime(&future)->tm_hour + 1) % 24;
    result = ((future - relative_to) + 60L * 60L * (nowdayl - fdayl));
    trace(("return %ld;\n", (long)result));
    trace(("}\n"));
    return result;
}


/*
 * NAME
 *	dayconv
 *
 * SYNOPSIS
 *	time_t dayconv(int ord, int day, time_t relative_to);
 *
 * DESCRIPTION
 *	The dayconv function is used to convert a day-of-the-week into
 *	a meaningful time.
 *
 * ARGUMENTS
 *	ord	- the ord'th day from relative_to
 *	day	- which day of the week
 *	relative_to - relative to this
 *
 * RETURNS
 *	time_t; time in seconds from epoch
 */

static time_t
dayconv(int ord, int aday, time_t relative_to)
{
    time_t          tod;
    time_t          result;

    trace(("dayconv(ord = %d, aday = %d, relative_to = %ld)\n{\n",
	ord, aday, (long)relative_to));
    tod = relative_to;
    tod += daysec * ((aday - localtime(&tod)->tm_wday + 7) % 7);
    tod += 7 * daysec * (ord <= 0 ? ord : ord - 1);
    result = daylcorr(tod, relative_to);
    trace(("return %ld;\n", (long)result));
    trace(("}\n"));
    return result;
}


/*
 * NAME
 *	monthadd
 *
 * SYNOPSIS
 *	time_t monthadd(time_t sdate, time_t relmonth);
 *
 * DESCRIPTION
 *	The monthadd function is used to add a given number of
 *	months to a specified time.
 *
 * ARGUMENTS
 *	sdate	- add the months to this
 *	relmonth - add this many months
 *
 * RETURNS
 *	time_t; seconds since the epoch
 */

static time_t
monthadd(time_t sdate, time_t arelmonth)
{
    struct tm       *ltime;
    int             amm;
    int             ayear;
    time_t          result;

    trace(("monthadd(sdate = %ld, arelmonth = %ld)\n{\n",
	(long)sdate, (long)arelmonth));
    if (arelmonth == 0)
	result = 0;
    else
    {
	ltime = localtime(&sdate);
	amm = 12 * (ltime->tm_year + 1900) + ltime->tm_mon + arelmonth;
	ayear = amm / 12;
	amm = amm % 12 + 1;
	result =
	    dateconv
	    (
	       	amm,
	       	ltime->tm_mday,
	       	ayear,
	       	ltime->tm_hour,
	       	ltime->tm_min,
	       	ltime->tm_sec,
	       	24,
	       	ourzone,
	       	MAYBE
	    );
	if (result >= 0)
	    result = daylcorr(result, sdate);
    }
    trace(("return %ld;\n", (long)result));
    trace(("}\n"));
    return result;
}


/*
 * NAME
 *	date_scan
 *
 * SYNOPSIS
 *	time_t date_scan(char *s);
 *
 * DESCRIPTION
 *	The date_scan function is used to scan a string and
 *	return a number of seconds since epoch.
 *
 * ARGUMENTS
 *	s	- string to scan
 *
 * RETURNS
 *	time_t; seconds to epoch, -1 on error.
 *
 * CAVEAT
 *	it isn't psychic
 */

time_t
date_scan(const char *p)
{
    time_t          when;
    struct tm       *lt;
    time_t	    result;
    time_t	    tod;

    /*
     * find time zone info, if not given
     */
    trace(("date_scan(p = \"%s\")\n{\n", p));
    lptr = p;

    /*
     * initialize things
     */
    when = now();
    lt = localtime(&when);
    year = lt->tm_year + 1900;
    month = lt->tm_mon + 1;
    day = lt->tm_mday;
    relsec = 0;
    relmonth = 0;
    timeflag = 0;
    zoneflag = 0;
    dateflag = 0;
    dayflag = 0;
    relflag = 0;
    ourzone = 0;
    day_light_flag = MAYBE;
#ifdef HAVE_tm_zone
    ourzone = -lt->tm_gmtoff/60;
#else
#ifdef HAVE_GETTIMEOFDAY
    {
	struct timeval tv;
	struct timezone tz;
	if (0 == gettimeofday(&tv, &tz))
	{
	    ourzone = tz.tz_minuteswest;
	    /* the tz_timezone field isn't any use */
	}
    }
#endif
#endif
    hh = 0;
    mm = 0;
    ss = 0;
    merid = 24;

    /*
     * parse the string
     */
#ifdef DEBUG
    gettime_debug = trace_pretest_;
#endif
    trace(("gettime_parse()\n{\n"));
    result = gettime_parse();
    trace(("}\n"));
    if (result)
    {
	result = -1;
	goto done;
    }

    /*
     * sanity checks
     */
    result = -1;
    if (timeflag > 1 || zoneflag > 1 || dateflag > 1 || dayflag > 1)
	goto done;

    if (dateflag || timeflag || dayflag)
    {
	result =
    	    dateconv
    	    (
       		month,
       		day,
       		year,
       		hh,
       		mm,
       		ss,
       		merid,
       		ourzone,
       		day_light_flag
    	    );
	if (result < 0)
    	    goto done;
    }
    else
    {
	result = when;
	if (!relflag)
	{
    	    result -=
       		(
	  	    (lt->tm_hour * 60L + lt->tm_min * 60)
       		+
	  	    lt->tm_sec
       		);
	}
    }

    result += relsec;
    relsec = monthadd(result, relmonth);
    if (relsec < 0)
    {
	result = -1;
	goto done;
    }
    result += relsec;

    if (dayflag && !dateflag)
    {
	tod = dayconv(dayord, dayreq, result);
	result += tod;
    }

    /*
     * here for all exits
     */
done:
    trace(("return %ld;\n", (long)result));
    trace(("}\n"));
    return result;
}


/*
 * NAME
 *	date_string - build one
 *
 * SYNOPSIS
 *	char *date_string(time_t when);
 *
 * DESCRIPTION
 *	The date_string function may be used to construct a
 *	string from a given time in seconds.
 *
 *	The string will conform to the RFC822 standard,
 *	which states a definite preference for GMT dates.
 *
 * ARGUMENTS
 *	when	the time to be rendered.
 *
 * RETURNS
 *	Pointer to string containing rendered time.
 *	The contents of this string will remain undisturbed
 *	only until the next call to date_string.
 */

const char *
date_string(time_t when)
{
    struct tm	*the_time;
    static char	buffer[32];

    static const char *weekday_name[] =
    {
	"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat",
    };

    static const char *month_name[] =
    {
	"Jan", "Feb", "Mar", "Apr", "May", "Jun",
	"Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
    };

    /*
     * break the given time down into components
     *	(RFC1036 likes GMT, remember)
     */
    trace(("date_string(when = %ld)\n{\n", (long)when));
    the_time = gmtime(&when);

    /*
     * build the date string
     */
    snprintf
    (
	buffer,
	sizeof(buffer),
	"%s,%3d %s %4.4d %2.2d:%2.2d:%2.2d GMT",
	weekday_name[the_time->tm_wday],
	the_time->tm_mday,
	month_name[the_time->tm_mon],
	the_time->tm_year + 1900,
	the_time->tm_hour,
	the_time->tm_min,
	the_time->tm_sec
    );
    trace(("return \"%s\";\n", buffer));
    trace(("}\n"));
    return buffer;
}


/*
 * NAME
 *	gettime_error
 *
 * SYNOPSIS
 *	void gettime_error(char *);
 *
 * DESCRIPTION
 *	The gettime_error function is invoked by yacc to report
 *	errors, but we just throw it away.
 *
 * ARGUMENTS
 *	s	- error to report
 */

static void
gettime_error(const char *s)
{
    trace(("gettime_error(s = \"%s\")\n{\n", s));
    (void)s;
    trace(("}\n"));
}


/*
 * NAME
 *	gettime_trace - follow parser actions
 *
 * SYNOPSIS
 *	void gettime_trace(char *, ...);
 *
 * DESCRIPTION
 *	The gettime_trace function is used to print the various shifts
 *	and reductions, etc, done by the yacc-generated parser.
 *	lines are accumulated and printed whole,
 *	so as to avoid confusing the trace output.
 *
 * ARGUMENTS
 *	as for printf
 *
 * CAVEAT
 *	only available when DEBUG is defined
 */

#ifdef DEBUG
#define gettime_DEBUG 1

#define printf gettime_trace

static void
gettime_trace(const char *s, ...)
{
    va_list ap;
    va_start(ap, s);
    string_ty *buffer = str_vformat(s, ap);
    va_end(ap);

    static char line[1024];
    static char *line_p = line;
    line_p = strendcpy(line_p, buffer->str_text, line + sizeof(line));
    str_free(buffer);
    if (line_p > line && line_p[-1] == '\n')
    {
	line_p[-1] = '\0';
	trace_printf("%s\n", line);
	line[0] = '\0';
	line_p = line;
    }
}

#endif /* DEBUG */

#line 733 "y.tab.c"

#if ! defined(gettime_STYPE) && ! defined(gettime_STYPE_IS_DECLARED)
/* Default: gettime_STYPE is the semantic value type. */
typedef int gettime_STYPE;
# define gettime_STYPE_IS_DECLARED 1
#endif

/* compatibility with bison */
#ifdef gettime_PARSE_PARAM
/* compatibility with FreeBSD */
# ifdef gettime_PARSE_PARAM_TYPE
#  define gettime_PARSE_DECL() gettime_parse(gettime_PARSE_PARAM_TYPE gettime_PARSE_PARAM)
# else
#  define gettime_PARSE_DECL() gettime_parse(void *gettime_PARSE_PARAM)
# endif
#else
# define gettime_PARSE_DECL() gettime_parse(void)
#endif

/* Parameters sent to lex. */
#ifdef gettime_LEX_PARAM
# define gettime_LEX_DECL() gettime_lex(void *gettime_LEX_PARAM)
# define gettime_LEX gettime_lex(gettime_LEX_PARAM)
#else
# define gettime_LEX_DECL() gettime_lex(void)
# define gettime_LEX gettime_lex()
#endif

#if !(defined(gettime_lex) || defined(gettime_STATE))
int gettime_LEX_DECL();
#endif

/* Parameters sent to gettime_error. */
#ifndef gettime_ERROR_DECL
#define gettime_ERROR_DECL() gettime_error(const char *s)
#endif
#ifndef gettime_ERROR_CALL
#define gettime_ERROR_CALL(msg) gettime_error(msg)
#endif

extern int gettime_PARSE_DECL();

#define AGO 257
#define COLON 258
#define COMMA 259
#define DAY 260
#define DAYZONE 261
#define ID 262
#define JUNK 263
#define MERIDIAN 264
#define MONTH 265
#define MUNIT 266
#define NUMBER 267
#define SLASH 268
#define SUNIT 269
#define UNIT 270
#define ZONE 271
#define gettime_ERRCODE 256
typedef int gettime_INT;
static const gettime_INT gettime_lhs[] = {                           -1,
    0,    0,    0,    1,    1,    1,    1,    1,    1,    7,
    2,    2,    2,    2,    2,    2,    2,    3,    3,    5,
    5,    5,    4,    4,    4,    4,    4,    4,    6,    6,
    6,    6,    6,    6,    6,
};
static const gettime_INT gettime_len[] = {                            2,
    0,    2,    1,    1,    1,    1,    1,    1,    1,    1,
    2,    3,    4,    4,    5,    6,    6,    1,    1,    1,
    2,    2,    3,    5,    2,    4,    2,    3,    2,    2,
    2,    1,    1,    1,    2,
};
static const gettime_INT gettime_defred[] = {                         0,
    3,    0,    0,   19,    0,   33,    0,   34,   32,   18,
    2,    4,    5,    6,    7,    0,    9,   21,    0,    0,
   22,   11,    0,   30,    0,   31,   29,   35,    0,    0,
   28,    0,   26,    0,   13,   14,    0,    0,   24,   16,
   17,
};
#if defined(gettime_DESTRUCT_CALL) || defined(gettime_STYPE_TOSTRING)
static const gettime_INT gettime_stos[] = {                           0,
  256,  273,  260,  261,  265,  266,  267,  269,  270,  271,
  274,  275,  276,  277,  278,  279,  280,  259,  267,  258,
  260,  264,  265,  266,  268,  269,  270,  257,  259,  267,
  267,  267,  267,  258,  264,  267,  268,  267,  267,  264,
  267,
};
#endif /* gettime_DESTRUCT_CALL || gettime_STYPE_TOSTRING */
static const gettime_INT gettime_dgoto[] = {                          2,
   11,   12,   13,   14,   15,   16,   17,
};
static const gettime_INT gettime_sindex[] = {                      -253,
    0, -243, -255,    0, -262,    0, -258,    0,    0,    0,
    0,    0,    0,    0,    0, -242,    0,    0, -250, -247,
    0,    0, -246,    0, -237,    0,    0,    0, -236, -229,
    0, -254,    0, -235,    0,    0, -234, -248,    0,    0,
    0,
};
static const gettime_INT gettime_rindex[] = {                         1,
    0,    0,   13,    0,    0,    0,   81,    0,    0,    0,
    0,    0,    0,    0,    0,   25,    0,    0,   37,    0,
    0,    0,   61,    0,    0,    0,    0,    0,    0,   68,
    0,   49,    0,    0,    0,    0,    0,   75,    0,    0,
    0,
};
#if gettime_BTYACC
static const gettime_INT gettime_cindex[] = {                         0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,
};
#endif
static const gettime_INT gettime_gindex[] = {                         0,
    0,    0,    0,    0,    0,    0,    0,
};
#define gettime_TABLESIZE 352
static const gettime_INT gettime_table[] = {                         20,
    1,   21,    1,   18,   19,   22,   23,   24,   29,   25,
   26,   27,   20,   37,   28,   40,    3,    4,   41,   30,
   31,    5,    6,    7,    8,    8,    9,   10,   34,   32,
   33,   38,   39,    0,   35,    0,   25,   36,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,   23,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
   27,    0,    0,    0,    0,    0,    0,   12,    0,    0,
    0,    0,    0,    0,   15,    0,    0,    0,    0,    0,
   10,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    1,    1,    0,    0,    0,    1,    1,    1,    0,    1,
    1,    1,   20,   20,    0,    0,    0,   20,   20,   20,
    0,   20,   20,   20,    8,    8,    0,    0,    0,    8,
    8,    8,    0,    8,    8,    8,   25,   25,    0,    0,
    0,   25,   25,   25,    0,   25,   25,   25,   23,   23,
    0,    0,    0,   23,   23,   23,    0,   23,   23,   23,
   27,   27,    0,    0,    0,   27,   27,   12,   12,   27,
   27,   27,   12,   12,   15,   15,   12,   12,   12,   15,
   15,   10,    0,   15,   15,   15,    0,   10,    0,    0,
    0,   10,
};
static const gettime_INT gettime_check[] = {                        258,
    0,  260,  256,  259,  267,  264,  265,  266,  259,  268,
  269,  270,    0,  268,  257,  264,  260,  261,  267,  267,
  267,  265,  266,  267,    0,  269,  270,  271,  258,  267,
  267,  267,  267,   -1,  264,   -1,    0,  267,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,    0,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
    0,   -1,   -1,   -1,   -1,   -1,   -1,    0,   -1,   -1,
   -1,   -1,   -1,   -1,    0,   -1,   -1,   -1,   -1,   -1,
    0,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
  260,  261,   -1,   -1,   -1,  265,  266,  267,   -1,  269,
  270,  271,  260,  261,   -1,   -1,   -1,  265,  266,  267,
   -1,  269,  270,  271,  260,  261,   -1,   -1,   -1,  265,
  266,  267,   -1,  269,  270,  271,  260,  261,   -1,   -1,
   -1,  265,  266,  267,   -1,  269,  270,  271,  260,  261,
   -1,   -1,   -1,  265,  266,  267,   -1,  269,  270,  271,
  260,  261,   -1,   -1,   -1,  265,  266,  260,  261,  269,
  270,  271,  265,  266,  260,  261,  269,  270,  271,  265,
  266,  261,   -1,  269,  270,  271,   -1,  267,   -1,   -1,
   -1,  271,
};
#if gettime_BTYACC
static const gettime_INT gettime_ctable[] = {                        -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,
};
#endif
#define gettime_FINAL 2
#ifndef gettime_DEBUG
#define gettime_DEBUG 0
#endif
#define gettime_MAXTOKEN 271
#define gettime_UNDFTOKEN 281
#define gettime_TRANSLATE(a) ((a) > gettime_MAXTOKEN ? gettime_UNDFTOKEN : (a))
#if gettime_DEBUG
static const char *const gettime_name[] = {

"$end",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"error","AGO","COLON","COMMA","DAY",
"DAYZONE","ID","JUNK","MERIDIAN","MONTH","MUNIT","NUMBER","SLASH","SUNIT",
"UNIT","ZONE","$accept","timedate","item","TimeSpecification","TimeZone",
"DateSpecification","DayOfWeekSpecification","RelativeSpecification",
"NumberSpecification","illegal-symbol",
};
static const char *const gettime_rule[] = {
"$accept : timedate",
"timedate :",
"timedate : timedate item",
"timedate : error",
"item : TimeSpecification",
"item : TimeZone",
"item : DateSpecification",
"item : DayOfWeekSpecification",
"item : RelativeSpecification",
"item : NumberSpecification",
"NumberSpecification : NUMBER",
"TimeSpecification : NUMBER MERIDIAN",
"TimeSpecification : NUMBER COLON NUMBER",
"TimeSpecification : NUMBER COLON NUMBER MERIDIAN",
"TimeSpecification : NUMBER COLON NUMBER NUMBER",
"TimeSpecification : NUMBER COLON NUMBER COLON NUMBER",
"TimeSpecification : NUMBER COLON NUMBER COLON NUMBER MERIDIAN",
"TimeSpecification : NUMBER COLON NUMBER COLON NUMBER NUMBER",
"TimeZone : ZONE",
"TimeZone : DAYZONE",
"DayOfWeekSpecification : DAY",
"DayOfWeekSpecification : DAY COMMA",
"DayOfWeekSpecification : NUMBER DAY",
"DateSpecification : NUMBER SLASH NUMBER",
"DateSpecification : NUMBER SLASH NUMBER SLASH NUMBER",
"DateSpecification : MONTH NUMBER",
"DateSpecification : MONTH NUMBER COMMA NUMBER",
"DateSpecification : NUMBER MONTH",
"DateSpecification : NUMBER MONTH NUMBER",
"RelativeSpecification : NUMBER UNIT",
"RelativeSpecification : NUMBER MUNIT",
"RelativeSpecification : NUMBER SUNIT",
"RelativeSpecification : UNIT",
"RelativeSpecification : MUNIT",
"RelativeSpecification : SUNIT",
"RelativeSpecification : RelativeSpecification AGO",

};
#endif

#if gettime_DEBUG
int      gettime_debug;
#endif

int      gettime_errflag;
int      gettime_char;
gettime_STYPE  gettime_val;
gettime_STYPE  gettime_lval;
int      gettime_nerrs;

#if defined(gettime_LTYPE) || defined(gettime_LTYPE_IS_DECLARED)
gettime_LTYPE  gettime_loc; /* position returned by actions */
gettime_LTYPE  gettime_lloc; /* position from the lexer */
#endif

#if defined(gettime_LTYPE) || defined(gettime_LTYPE_IS_DECLARED)
#ifndef gettime_LLOC_DEFAULT
#define gettime_LLOC_DEFAULT(loc, rhs, n) \
do \
{ \
    if (n == 0) \
    { \
        (loc).first_line   = gettime_RHSLOC(rhs, 0).last_line; \
        (loc).first_column = gettime_RHSLOC(rhs, 0).last_column; \
        (loc).last_line    = gettime_RHSLOC(rhs, 0).last_line; \
        (loc).last_column  = gettime_RHSLOC(rhs, 0).last_column; \
    } \
    else \
    { \
        (loc).first_line   = gettime_RHSLOC(rhs, 1).first_line; \
        (loc).first_column = gettime_RHSLOC(rhs, 1).first_column; \
        (loc).last_line    = gettime_RHSLOC(rhs, n).last_line; \
        (loc).last_column  = gettime_RHSLOC(rhs, n).last_column; \
    } \
} while (0)
#endif /* gettime_LLOC_DEFAULT */
#endif /* defined(gettime_LTYPE) || defined(gettime_LTYPE_IS_DECLARED) */
#if gettime_BTYACC

#ifndef gettime_LVQUEUEGROWTH
#define gettime_LVQUEUEGROWTH 32
#endif
#endif /* gettime_BTYACC */

/* define the initial stack-sizes */
#ifdef gettime_STACKSIZE
#undef gettime_MAXDEPTH
#define gettime_MAXDEPTH  gettime_STACKSIZE
#else
#ifdef gettime_MAXDEPTH
#define gettime_STACKSIZE gettime_MAXDEPTH
#else
#define gettime_STACKSIZE 10000
#define gettime_MAXDEPTH  10000
#endif
#endif

#ifndef gettime_INITSTACKSIZE
#define gettime_INITSTACKSIZE 200
#endif

typedef struct {
    unsigned stacksize;
    gettime_INT    *s_base;
    gettime_INT    *s_mark;
    gettime_INT    *s_last;
    gettime_STYPE  *l_base;
    gettime_STYPE  *l_mark;
#if defined(gettime_LTYPE) || defined(gettime_LTYPE_IS_DECLARED)
    gettime_LTYPE  *p_base;
    gettime_LTYPE  *p_mark;
#endif
} gettime_STACKDATA;
#if gettime_BTYACC

struct gettime_ParseState_s
{
    struct gettime_ParseState_s *save;    /* Previously saved parser state */
    gettime_STACKDATA            gettime_stack; /* saved parser stack */
    int                    state;   /* saved parser state */
    int                    errflag; /* saved error recovery status */
    int                    lexeme;  /* saved index of the conflict lexeme in the lexical queue */
    gettime_INT                  ctry;    /* saved index in gettime_ctable[] for this conflict */
};
typedef struct gettime_ParseState_s gettime_ParseState;
#endif /* gettime_BTYACC */
/* variables for the parser stack */
static gettime_STACKDATA gettime_stack;
#if gettime_BTYACC

/* Current parser state */
static gettime_ParseState *gettime_ps = 0;

/* gettime_path != NULL: do the full parse, starting at *gettime_path parser state. */
static gettime_ParseState *gettime_path = 0;

/* Base of the lexical value queue */
static gettime_STYPE *gettime_lvals = 0;

/* Current position at lexical value queue */
static gettime_STYPE *gettime_lvp = 0;

/* End position of lexical value queue */
static gettime_STYPE *gettime_lve = 0;

/* The last allocated position at the lexical value queue */
static gettime_STYPE *gettime_lvlim = 0;

#if defined(gettime_LTYPE) || defined(gettime_LTYPE_IS_DECLARED)
/* Base of the lexical position queue */
static gettime_LTYPE *gettime_lpsns = 0;

/* Current position at lexical position queue */
static gettime_LTYPE *gettime_lpp = 0;

/* End position of lexical position queue */
static gettime_LTYPE *gettime_lpe = 0;

/* The last allocated position at the lexical position queue */
static gettime_LTYPE *gettime_lplim = 0;
#endif

/* Current position at lexical token queue */
static gettime_INT  *gettime_lexp = 0;

static gettime_INT  *gettime_lexemes = 0;
#endif /* gettime_BTYACC */
#line 958 "common/gettime.y"

/* The following needs to be here so Berkeley Yacc doesn't puke.  */


/*
 * NAME
 *	table - list of known names
 *
 * SYNOPSIS
 *	table_t table[];
 *
 * DESCRIPTION
 *	The table is used to hold the list of known names.
 *	This includes time zone names and days of the week, etc.
 *
 * CAVEAT
 *	It is in English.
 *	It is impossible to have a full list of time zones.
 */

struct table_t
{
    const char      *name;
    int             type;
    int             value;
};

#define HRMIN(a, b) ((a) * 60 + (b))

static table_t table[] =
{
    { "a",          ZONE,           HRMIN(1, 0),    },
    { "a.c.s.s.t.", DAYZONE,        -HRMIN(9, 30),  },
    { "a.c.s.t.",   ZONE,           -HRMIN(9, 30),  },
    { "a.d.t.",     DAYZONE,        HRMIN(4, 0),    },
    { "a.e.s.s.t.", DAYZONE,        -HRMIN(10, 0),  },
    { "a.e.s.t.",   ZONE,           -HRMIN(10, 0),  },
    { "a.m.",       MERIDIAN,       AM,             },
    { "a.s.t.",     ZONE,           HRMIN(4, 0),    },
    { "a.w.s.t.",   ZONE,           -HRMIN(8, 0),   }, /* (no daylight time
                                                          there, I'm told */
    { "acsst",      DAYZONE,        -HRMIN(9, 30),  }, /* Australian Central
                                                          Summer Time */
    { "acst",       ZONE,           -HRMIN(9, 30),  }, /* Australian Central
                                                          Time */
    { "adt",        DAYZONE,        HRMIN(4, 0),    },
    { "aesst",      DAYZONE,        -HRMIN(10, 0),  }, /* Australian Eastern
                                                          Summer Time */
    { "aest",       ZONE,           -HRMIN(10, 0),  }, /* Australian Eastern
                                                          Time */
    { "ago",        AGO,            1,              },
    { "am",         MERIDIAN,       AM,             },
    { "apr",        MONTH,          4,              },
    { "apr.",       MONTH,          4,              },
    { "april",      MONTH,          4,              },
    { "ast",        ZONE,           HRMIN(4, 0),    },  /* Atlantic */
    { "aug",        MONTH,          8,              },
    { "aug.",       MONTH,          8,              },
    { "august",     MONTH,          8,              },
    { "awst",       ZONE,           -HRMIN(8, 0),   }, /* Australian Western
                                                          Time */
    { "b",          ZONE,           HRMIN(2, 0),    },
    { "b.s.t.",     DAYZONE,        HRMIN(0, 0),    },
    { "bst",        DAYZONE,        HRMIN(0, 0),    }, /* British Summer
                                                          Time*/
    { "c",          ZONE,           HRMIN(3, 0),    },
    { "c.d.t.",     DAYZONE,        HRMIN(6, 0),    },
    { "c.s.t.",     ZONE,           HRMIN(6, 0),    },
    { "cdt",        DAYZONE,        HRMIN(6, 0),    },
    { "cst",        ZONE,           HRMIN(6, 0),    }, /* Central */
    { "d",          ZONE,           HRMIN(4, 0),    },
    { "day",        UNIT,           1 * 24 * 60,    },
    { "days",       UNIT,           1 * 24 * 60,    },
    { "dec",        MONTH,          12,             },
    { "dec.",       MONTH,          12,             },
    { "december",   MONTH,          12,             },
    { "e",          ZONE,           HRMIN(5, 0),    },
    { "e.d.t.",     DAYZONE,        HRMIN(5, 0),    },
    { "e.e.s.t.",   DAYZONE,        HRMIN(0, 0),    },
    { "e.e.t.",     ZONE,           HRMIN(0, 0),    },
    { "e.s.t.",     ZONE,           HRMIN(5, 0),    },
    { "edt",        DAYZONE,        HRMIN(5, 0),    },
    { "eest",       DAYZONE,        HRMIN(0, 0),    }, /* European Eastern
                                                          Summer Time */
    { "eet",        ZONE,           HRMIN(0, 0),    }, /* European Eastern
                                                          Time */
    { "eigth",      NUMBER,         8,              },
    { "eleventh",   NUMBER,         11,             },
    { "est",        ZONE,           HRMIN(5, 0),    }, /* Eastern */
    { "f",          ZONE,           HRMIN(6, 0),    },
    { "feb",        MONTH,          2,              },
    { "feb.",       MONTH,          2,              },
    { "february",   MONTH,          2,              },
    { "fifth",      NUMBER,         5,              },
    { "first",      NUMBER,         1,              },
    { "fortnight",  UNIT,           14 * 24 * 60,   },
    { "fortnights", UNIT,           14 * 24 * 60,   },
    { "fourth",     NUMBER,         4,              },
    { "fri",        DAY,            5,              },
    { "fri.",       DAY,            5,              },
    { "friday",     DAY,            5,              },
    { "g",          ZONE,           HRMIN(7, 0),    },
    { "g.m.t.",     ZONE,           HRMIN(0, 0),    },
    { "gmt",        ZONE,           HRMIN(0, 0),    },
    { "h",          ZONE,           HRMIN(8, 0),    },
    { "h.d.t.",     DAYZONE,        HRMIN(10, 0),   },
    { "h.s.t.",     ZONE,           HRMIN(10, 0),   },
    { "hdt",        DAYZONE,        HRMIN(10, 0),   },
    { "hour",       UNIT,           60,             },
    { "hours",      UNIT,           60,             },
    { "hr",         UNIT,           60,             },
    { "hrs",        UNIT,           60,             },
    { "hst",        ZONE,           HRMIN(10, 0),   }, /* Hawaii */
    { "i",          ZONE,           HRMIN(9, 0),    },
    { "j.s.t.",     ZONE,           -HRMIN(9, 0),   }, /* Japan Standard
                                                          Time */
    { "jan",        MONTH,          1,              },
    { "jan.",       MONTH,          1,              },
    { "january",    MONTH,          1,              },
    { "jst",        ZONE,           -HRMIN(9, 0),   }, /* Japan Standard
                                                          Time */
    { "jul",        MONTH,          7,              },
    { "jul.",       MONTH,          7,              },
    { "july",       MONTH,          7,              },
    { "jun",        MONTH,          6,              },
    { "jun.",       MONTH,          6,              },
    { "june",       MONTH,          6,              },
    { "k",          ZONE,           HRMIN(10, 0),   },
    { "l",          ZONE,           HRMIN(11, 0),   },
    { "last",       NUMBER,         -1,             },
    { "m",          ZONE,           HRMIN(12, 0),   },
    { "m.d.t.",     DAYZONE,        HRMIN(7, 0),    },
    { "m.e.s.t.",   DAYZONE,        -HRMIN(1, 0),   },
    { "m.e.t.",     ZONE,           -HRMIN(1, 0),   },
    { "m.s.t.",     ZONE,           HRMIN(7, 0),    },
    { "mar",        MONTH,          3,              },
    { "mar.",       MONTH,          3,              },
    { "march",      MONTH,          3,              },
    { "may",        MONTH,          5,              },
    { "mdt",        DAYZONE,        HRMIN(7, 0),    },
    { "mest",       DAYZONE,        -HRMIN(1, 0),   }, /* Middle European
                                                          Summer Time */
    { "met",        ZONE,           -HRMIN(1, 0),   }, /* Middle European
                                                          Time */
    { "min",        UNIT,           1,              },
    { "mins",       UNIT,           1,              },
    { "minute",     UNIT,           1,              },
    { "minutes",    UNIT,           1,              },
    { "mon",        DAY,            1,              },
    { "mon.",       DAY,            1,              },
    { "monday",     DAY,            1,              },
    { "month",      MUNIT,          1,              },
    { "months",     MUNIT,          1,              },
    { "mst",        ZONE,           HRMIN(7, 0),    }, /* Mountain */
    { "n",          ZONE,           -HRMIN(1, 0),   },
    { "n.s.t.",     ZONE,           HRMIN(3, 30),   },
    { "next",       NUMBER,         2,              },
    { "ninth",      NUMBER,         9,              },
    { "nov",        MONTH,          11,             },
    { "nov.",       MONTH,          11,             },
    { "november",   MONTH,          11,             },
    { "now",        UNIT,           0,              },
    { "nst",        ZONE,           HRMIN(3, 30),   }, /* Newfoundland */
    { "o",          ZONE,           -HRMIN(2, 0),   },
    { "oct",        MONTH,          10,             },
    { "oct.",       MONTH,          10,             },
    { "october",    MONTH,          10,             },
    { "p",          ZONE,           -HRMIN(3, 0),   },
    { "p.d.t.",     DAYZONE,        HRMIN(8, 0),    },
    { "p.m.",       MERIDIAN,       PM,             },
    { "p.s.t.",     ZONE,           HRMIN(8, 0),    },
    { "pdt",        DAYZONE,        HRMIN(8, 0),    },
    { "pm",         MERIDIAN,       PM,             },
    { "pst",        ZONE,           HRMIN(8, 0),    }, /* Pacific */
    { "q",          ZONE,           -HRMIN(4, 0),   },
    { "r",          ZONE,           -HRMIN(5, 0),   },
    { "s",          ZONE,           -HRMIN(6, 0),   },
    { "sat",        DAY,            6,              },
    { "sat.",       DAY,            6,              },
    { "saturday",   DAY,            6,              },
    { "sec",        SUNIT,          1,              },
    { "second",     SUNIT,          1,              },
    { "seconds",    SUNIT,          1,              },
    { "secs",       SUNIT,          1,              },
    { "sep",        MONTH,          9,              },
    { "sep.",       MONTH,          9,              },
    { "sept",       MONTH,          9,              },
    { "sept.",      MONTH,          9,              },
    { "september",  MONTH,          9,              },
    { "seventh",    NUMBER,         7,              },
    { "sixth",      NUMBER,         6,              },
    { "sun",        DAY,            0,              },
    { "sun.",       DAY,            0,              },
    { "sunday",     DAY,            0,              },
    { "t",          ZONE,           -HRMIN(7, 0),   },
    { "tenth",      NUMBER,         10,             },
    { "third",      NUMBER,         3,              },
    { "this",       UNIT,           0,              },
    { "thu",        DAY,            4,              },
    { "thu.",       DAY,            4,              },
    { "thur",       DAY,            4,              },
    { "thur.",      DAY,            4,              },
    { "thurs",      DAY,            4,              },
    { "thurs.",     DAY,            4,              },
    { "thursday",   DAY,            4,              },
    { "today",      UNIT,           0,              },
    { "tomorrow",   UNIT,           1 * 24 * 60,    },
    { "tue",        DAY,            2,              },
    { "tue.",       DAY,            2,              },
    { "tues",       DAY,            2,              },
    { "tues.",      DAY,            2,              },
    { "tuesday",    DAY,            2,              },
    { "twelfth",    NUMBER,         12,             },
    { "u",          ZONE,           -HRMIN(8, 0),   },
    { "u.t.",       ZONE,           HRMIN(0, 0),    },
    { "ut",         ZONE,           HRMIN(0, 0),    },
    { "v",          ZONE,           -HRMIN(9, 0),   },
    { "w",          ZONE,           -HRMIN(10, 0),  },
    { "w.e.s.t.",   DAYZONE,        -HRMIN(2, 0),   },
    { "w.e.t.",     ZONE,           -HRMIN(2, 0),   },
    { "wed",        DAY,            3,              },
    { "wed.",       DAY,            3,              },
    { "wednes",     DAY,            3,              },
    { "wednes.",    DAY,            3,              },
    { "wednesday",  DAY,            3,              },
    { "week",       UNIT,           7 * 24 * 60,    },
    { "weeks",      UNIT,           7 * 24 * 60,    },
    { "west",       DAYZONE,        -HRMIN(2, 0),   }, /* Western European
                                                          Summer Time */
    { "wet",        ZONE,           -HRMIN(2, 0),   }, /* Western European
                                                          Time */
    { "x",          ZONE,           -HRMIN(11, 0),  },
    { "y",          ZONE,           -HRMIN(12, 0),  },
    { "y.d.t.",     DAYZONE,        HRMIN(9, 0),    },
    { "y.s.t.",     ZONE,           HRMIN(9, 0),    },
    { "ydt",        DAYZONE,        HRMIN(9, 0),    },
    { "year",       MUNIT,          12,             },
    { "years",      MUNIT,          12,             },
    { "yesterday",  UNIT,           -1*24*60,       },
    { "yst",        ZONE,           HRMIN(9, 0),    }, /* Yukon */
    { "z",          ZONE,           HRMIN(0, 0),    },
};


/*
 * NAME
 *	lookup - find name
 *
 * SYNOPSIS
 *	int lookup(char *id);
 *
 * DESCRIPTION
 *	The lookup function is used to find a token corresponding to
 *	a given name.
 *
 * ARGUMENTS
 *	id	- name to search for.  Assumes already downcased.
 *
 * RETURNS
 *	int; yacc token, ID if not found.
 */

static int
lookup(char *id)
{
    table_t         *tp;
    int             min;
    int             max;
    int             mid;
    int             cmp;
    int             result;

    /*
     * binary chop the table
     */
    trace(("lookup(id = \"%s\")\n{\n", id));
    result = ID;
    min = 0;
    max = SIZEOF(table) - 1;
    while (min <= max)
    {
	mid = (min + max) / 2;
	tp = table + mid;
	cmp = strcmp(id, tp->name);
	if (!cmp)
	{
	    gettime_lval = tp->value;
	    result = tp->type;
	    break;
	}
	if (cmp < 0)
	    max = mid - 1;
	else
	    min = mid + 1;
    }
    trace(("return %d;\n", result));
    trace(("}\n"));
    return result;
}


/*
 * NAME
 *	gettime_lex - lexical analyser
 *
 * SYNOPSIS
 *	int gettime_lex(void);
 *
 * DESCRIPTION
 *	The gettime_lex function is used to scan the input string
 *	and break it into discrete tokens.
 *
 * RETURNS
 *	int; the yacc token, 0 means the-end.
 */

static int
gettime_lex(void)
{
    int             sign;
    int             c;
    char            *p;
    char            idbuf[MAX_ID_LENGTH];
    int             pcnt;
    int             token;

    trace(("gettime_lex()\n{\n"));
    gettime_lval = 0;
    for (;;)
    {
	/*
	 * get the next input character
	 */
	c = *lptr++;

	/*
	 * action depends on the character
	 */
	switch (c)
	{
	case 0:
	    token = 0;
	    lptr--;
	    break;

	case ' ':
	case '\t':
	    /*
	     * ignore white space
	     */
	    continue;

	case ':':
	    token = COLON;
	    break;

	case ',':
	    token = COMMA;
	    break;

	case '/':
	    token = SLASH;
	    break;

	case '.':
	    /* ignore lonely dots */
	    continue;

	case '-':
	    if (!isdigit((unsigned char)*lptr))
	    {
		/*
		 * ignore lonely '-'s
		 */
		continue;
	    }
	    sign = -1;
	    c = *lptr++;
	    goto number;

	case '+':
	    if (!isdigit((unsigned char)*lptr))
	    {
	       	token = c;
	       	break;
	    }
	    sign = 1;
	    c = *lptr++;
	    goto number;

	case '0': case '1': case '2': case '3': case '4':
	case '5': case '6': case '7': case '8': case '9':
	    /*
	     * numbers
	     */
	    sign = 1;
	    number:
	    for (;;)
	    {
		gettime_lval = gettime_lval * 10 + c - '0';
		c = *lptr++;
		switch (c)
		{
		case '0': case '1': case '2': case '3':
		case '4': case '5': case '6': case '7':
		case '8': case '9':
		    continue;
		}
		break;
	    }
	    gettime_lval *= sign;
	    lptr--;
	    token = NUMBER;
	    break;

	case 'a': case 'b': case 'c': case 'd': case 'e':
	case 'f': case 'g': case 'h': case 'i': case 'j':
	case 'k': case 'l': case 'm': case 'n': case 'o':
	case 'p': case 'q': case 'r': case 's': case 't':
	case 'u': case 'v': case 'w': case 'x': case 'y': case 'z':
	case 'A': case 'B': case 'C': case 'D': case 'E':
	case 'F': case 'G': case 'H': case 'I': case 'J':
	case 'K': case 'L': case 'M': case 'N': case 'O':
	case 'P': case 'Q': case 'R': case 'S': case 'T':
	case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z':
	    /*
	     * name
	     */
	    p = idbuf;
	    for (;;)
	    {
		if (isupper((unsigned char)c))
		    c = tolower(c);
		if (p < idbuf + sizeof(idbuf) - 1)
		    *p++ = c;
		c = *lptr++;
		switch (c)
		{
		case 'a': case 'b': case 'c': case 'd':
		case 'e': case 'f': case 'g': case 'h':
		case 'i': case 'j': case 'k': case 'l':
		case 'm': case 'n': case 'o': case 'p':
		case 'q': case 'r': case 's': case 't':
		case 'u': case 'v': case 'w': case 'x':
		case 'y': case 'z':
		case 'A': case 'B': case 'C': case 'D':
		case 'E': case 'F': case 'G': case 'H':
		case 'I': case 'J': case 'K': case 'L':
		case 'M': case 'N': case 'O': case 'P':
		case 'Q': case 'R': case 'S': case 'T':
		case 'U': case 'V': case 'W': case 'X':
		case 'Y': case 'Z':
		case '.':
		    continue;
		}
		break;
	    }
	    *p = 0;
	    lptr--;
	    token = lookup(idbuf);
	    break;

	case '(':
	    /*
	     * comment
	     */
	    for (pcnt = 1; pcnt > 0; )
	    {
		c = *lptr++;
		switch (c)
		{
		case 0:
		    --lptr;
		    pcnt = 0;
		    break;

		case '(':
		    pcnt++;
		    break;

		case ')':
		    pcnt--;
		    break;
		}
	    }
	    continue;

	default:
	    /*
	     * unrecognosed
	     */
	    token = JUNK;
	    break;
	}
	break;
    }
    trace(("gettime_lval = %d;\n", gettime_lval));
    trace(("return %d;\n", token));
    trace(("}\n"));
    return token;
}
#line 1659 "y.tab.c"

/* For use in generated program */
#define gettime_depth (int)(gettime_stack.s_mark - gettime_stack.s_base)
#if gettime_BTYACC
#define gettime_trial (gettime_ps->save)
#endif /* gettime_BTYACC */

#if gettime_DEBUG
#endif

#include <string.h>	/* needed for memset */

/* allocate initial stack or double stack size, up to gettime_MAXDEPTH */
static int gettime_growstack(gettime_STACKDATA *data)
{
    int i;
    unsigned newsize;
    gettime_INT *newss;
    gettime_STYPE *newvs;
#if defined(gettime_LTYPE) || defined(gettime_LTYPE_IS_DECLARED)
    gettime_LTYPE *newps;
#endif

    if ((newsize = data->stacksize) == 0)
        newsize = gettime_INITSTACKSIZE;
    else if (newsize >= gettime_MAXDEPTH)
        return gettime_ENOMEM;
    else if ((newsize *= 2) > gettime_MAXDEPTH)
        newsize = gettime_MAXDEPTH;

    i = (int) (data->s_mark - data->s_base);
    newss = (gettime_INT *)realloc(data->s_base, newsize * sizeof(*newss));
    if (newss == 0)
        return gettime_ENOMEM;

    data->s_base = newss;
    data->s_mark = newss + i;

    newvs = (gettime_STYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
    if (newvs == 0)
        return gettime_ENOMEM;

    data->l_base = newvs;
    data->l_mark = newvs + i;

#if defined(gettime_LTYPE) || defined(gettime_LTYPE_IS_DECLARED)
    newps = (gettime_LTYPE *)realloc(data->p_base, newsize * sizeof(*newps));
    if (newps == 0)
        return gettime_ENOMEM;

    data->p_base = newps;
    data->p_mark = newps + i;
#endif

    data->stacksize = newsize;
    data->s_last = data->s_base + newsize - 1;

#if gettime_DEBUG
    if (gettime_debug)
        fprintf(stderr, "%sdebug: stack size increased to %d\n", gettime_PREFIX, newsize);
#endif
    return 0;
}

#if gettime_PURE || defined(gettime__NO_LEAKS)
static void gettime_freestack(gettime_STACKDATA *data)
{
    free(data->s_base);
    free(data->l_base);
#if defined(gettime_LTYPE) || defined(gettime_LTYPE_IS_DECLARED)
    free(data->p_base);
#endif
    memset(data, 0, sizeof(*data));
}
#else
#define gettime_freestack(data) /* nothing */
#endif /* gettime_PURE || defined(gettime__NO_LEAKS) */
#if gettime_BTYACC

static gettime_ParseState *
gettime_NewState(unsigned size)
{
    gettime_ParseState *p = (gettime_ParseState *) malloc(sizeof(gettime_ParseState));
    if (p == NULL) return NULL;

    p->gettime_stack.stacksize = size;
    if (size == 0)
    {
        p->gettime_stack.s_base = NULL;
        p->gettime_stack.l_base = NULL;
#if defined(gettime_LTYPE) || defined(gettime_LTYPE_IS_DECLARED)
        p->gettime_stack.p_base = NULL;
#endif
        return p;
    }
    p->gettime_stack.s_base    = (gettime_INT *) malloc(size * sizeof(gettime_INT));
    if (p->gettime_stack.s_base == NULL) return NULL;
    p->gettime_stack.l_base    = (gettime_STYPE *) malloc(size * sizeof(gettime_STYPE));
    if (p->gettime_stack.l_base == NULL) return NULL;
    memset(p->gettime_stack.l_base, 0, size * sizeof(gettime_STYPE));
#if defined(gettime_LTYPE) || defined(gettime_LTYPE_IS_DECLARED)
    p->gettime_stack.p_base    = (gettime_LTYPE *) malloc(size * sizeof(gettime_LTYPE));
    if (p->gettime_stack.p_base == NULL) return NULL;
    memset(p->gettime_stack.p_base, 0, size * sizeof(gettime_LTYPE));
#endif

    return p;
}

static void
gettime_FreeState(gettime_ParseState *p)
{
    gettime_freestack(&p->gettime_stack);
    free(p);
}
#endif /* gettime_BTYACC */

#define gettime_ABORT  goto gettime_abort
#define gettime_REJECT goto gettime_abort
#define gettime_ACCEPT goto gettime_accept
#define gettime_ERROR  goto gettime_errlab
#if gettime_BTYACC
#define gettime_VALID        do { if (gettime_ps->save)            goto gettime_valid; } while(0)
#define gettime_VALID_NESTED do { if (gettime_ps->save && \
                                gettime_ps->save->save == 0) goto gettime_valid; } while(0)
#endif /* gettime_BTYACC */

int
gettime_PARSE_DECL()
{
    int gettime_m, gettime_n, gettime_state, gettime_result;
#if gettime_BTYACC
    int gettime_newerrflag;
    gettime_ParseState *gettime_errctx = NULL;
#endif /* gettime_BTYACC */
#if defined(gettime_LTYPE) || defined(gettime_LTYPE_IS_DECLARED)
    gettime_LTYPE  gettime_error_loc_range[3]; /* position of error start/end (0 unused) */
#endif
#if gettime_DEBUG
    const char *gettime_s;

    if ((gettime_s = getenv("gettime_DEBUG")) != 0)
    {
        gettime_n = *gettime_s;
        if (gettime_n >= '0' && gettime_n <= '9')
            gettime_debug = gettime_n - '0';
    }
    if (gettime_debug)
        fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", gettime_PREFIX);
#endif
#if defined(gettime_LTYPE) || defined(gettime_LTYPE_IS_DECLARED)
    memset(gettime_error_loc_range, 0, sizeof(gettime_error_loc_range));
#endif

#if gettime_BTYACC
    gettime_ps = gettime_NewState(0); if (gettime_ps == 0) goto gettime_enomem;
    gettime_ps->save = 0;
#endif /* gettime_BTYACC */
    gettime_m = 0;
    gettime_n = 0;
    gettime_nerrs = 0;
    gettime_errflag = 0;
    gettime_char = gettime_EMPTY;
    gettime_state = 0;

#if gettime_PURE
    memset(&gettime_stack, 0, sizeof(gettime_stack));
#endif

    if (gettime_stack.s_base == NULL && gettime_growstack(&gettime_stack) == gettime_ENOMEM) goto gettime_overflow;
    gettime_stack.s_mark = gettime_stack.s_base;
    gettime_stack.l_mark = gettime_stack.l_base;
#if defined(gettime_LTYPE) || defined(gettime_LTYPE_IS_DECLARED)
    gettime_stack.p_mark = gettime_stack.p_base;
#endif
    gettime_state = 0;
    *gettime_stack.s_mark = 0;

gettime_loop:
    if ((gettime_n = gettime_defred[gettime_state]) != 0) goto gettime_reduce;
    if (gettime_char < 0)
    {
#if gettime_BTYACC
        do {
        if (gettime_lvp < gettime_lve)
        {
            /* we're currently re-reading tokens */
            gettime_lval = *gettime_lvp++;
#if defined(gettime_LTYPE) || defined(gettime_LTYPE_IS_DECLARED)
            gettime_lloc = *gettime_lpp++;
#endif
            gettime_char = *gettime_lexp++;
            break;
        }
        if (gettime_ps->save)
        {
            /* in trial mode; save scanner results for future parse attempts */
            if (gettime_lvp == gettime_lvlim)
            {   /* Enlarge lexical value queue */
                size_t p = (size_t) (gettime_lvp - gettime_lvals);
                size_t s = (size_t) (gettime_lvlim - gettime_lvals);

                s += gettime_LVQUEUEGROWTH;
                if ((gettime_lexemes = (gettime_INT *)realloc(gettime_lexemes, s * sizeof(gettime_INT))) == NULL) goto gettime_enomem;
                if ((gettime_lvals   = (gettime_STYPE *)realloc(gettime_lvals, s * sizeof(gettime_STYPE))) == NULL) goto gettime_enomem;
#if defined(gettime_LTYPE) || defined(gettime_LTYPE_IS_DECLARED)
                if ((gettime_lpsns   = (gettime_LTYPE *)realloc(gettime_lpsns, s * sizeof(gettime_LTYPE))) == NULL) goto gettime_enomem;
#endif
                gettime_lvp   = gettime_lve = gettime_lvals + p;
                gettime_lvlim = gettime_lvals + s;
#if defined(gettime_LTYPE) || defined(gettime_LTYPE_IS_DECLARED)
                gettime_lpp   = gettime_lpe = gettime_lpsns + p;
                gettime_lplim = gettime_lpsns + s;
#endif
                gettime_lexp  = gettime_lexemes + p;
            }
            *gettime_lexp = (gettime_INT) gettime_LEX;
            *gettime_lvp++ = gettime_lval;
            gettime_lve++;
#if defined(gettime_LTYPE) || defined(gettime_LTYPE_IS_DECLARED)
            *gettime_lpp++ = gettime_lloc;
            gettime_lpe++;
#endif
            gettime_char = *gettime_lexp++;
            break;
        }
        /* normal operation, no conflict encountered */
#endif /* gettime_BTYACC */
        gettime_char = gettime_LEX;
#if gettime_BTYACC
        } while (0);
#endif /* gettime_BTYACC */
        if (gettime_char < 0) gettime_char = gettime_EOF;
#if gettime_DEBUG
        if (gettime_debug)
        {
            if ((gettime_s = gettime_name[gettime_TRANSLATE(gettime_char)]) == NULL) gettime_s = gettime_name[gettime_UNDFTOKEN];
            fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)",
                            gettime_DEBUGSTR, gettime_depth, gettime_state, gettime_char, gettime_s);
#ifdef gettime_STYPE_TOSTRING
#if gettime_BTYACC
            if (!gettime_trial)
#endif /* gettime_BTYACC */
                fprintf(stderr, " <%s>", gettime_STYPE_TOSTRING(gettime_char, gettime_lval));
#endif
            fputc('\n', stderr);
        }
#endif
    }
#if gettime_BTYACC

    /* Do we have a conflict? */
    if (((gettime_n = gettime_cindex[gettime_state]) != 0) && (gettime_n += gettime_char) >= 0 &&
        gettime_n <= gettime_TABLESIZE && gettime_check[gettime_n] == (gettime_INT) gettime_char)
    {
        gettime_INT ctry;

        if (gettime_path)
        {
            gettime_ParseState *save;
#if gettime_DEBUG
            if (gettime_debug)
                fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n",
                                gettime_DEBUGSTR, gettime_depth, gettime_state);
#endif
            /* Switch to the next conflict context */
            save = gettime_path;
            gettime_path = save->save;
            save->save = NULL;
            ctry = save->ctry;
            if (save->state != gettime_state) gettime_ABORT;
            gettime_FreeState(save);

        }
        else
        {

            /* Unresolved conflict - start/continue trial parse */
            gettime_ParseState *save;
#if gettime_DEBUG
            if (gettime_debug)
            {
                fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", gettime_DEBUGSTR, gettime_depth, gettime_state);
                if (gettime_ps->save)
                    fputs("ALREADY in conflict, continuing trial parse.\n", stderr);
                else
                    fputs("Starting trial parse.\n", stderr);
            }
#endif
            save                  = gettime_NewState((unsigned)(gettime_stack.s_mark - gettime_stack.s_base + 1));
            if (save == NULL) goto gettime_enomem;
            save->save            = gettime_ps->save;
            save->state           = gettime_state;
            save->errflag         = gettime_errflag;
            save->gettime_stack.s_mark  = save->gettime_stack.s_base + (gettime_stack.s_mark - gettime_stack.s_base);
            memcpy (save->gettime_stack.s_base, gettime_stack.s_base, (size_t) (gettime_stack.s_mark - gettime_stack.s_base + 1) * sizeof(gettime_INT));
            save->gettime_stack.l_mark  = save->gettime_stack.l_base + (gettime_stack.l_mark - gettime_stack.l_base);
            memcpy (save->gettime_stack.l_base, gettime_stack.l_base, (size_t) (gettime_stack.l_mark - gettime_stack.l_base + 1) * sizeof(gettime_STYPE));
#if defined(gettime_LTYPE) || defined(gettime_LTYPE_IS_DECLARED)
            save->gettime_stack.p_mark  = save->gettime_stack.p_base + (gettime_stack.p_mark - gettime_stack.p_base);
            memcpy (save->gettime_stack.p_base, gettime_stack.p_base, (size_t) (gettime_stack.p_mark - gettime_stack.p_base + 1) * sizeof(gettime_LTYPE));
#endif
            ctry                  = gettime_table[gettime_n];
            if (gettime_ctable[ctry] == -1)
            {
#if gettime_DEBUG
                if (gettime_debug && gettime_char >= gettime_EOF)
                    fprintf(stderr, "%s[%d]: backtracking 1 token\n", gettime_DEBUGSTR, gettime_depth);
#endif
                ctry++;
            }
            save->ctry = ctry;
            if (gettime_ps->save == NULL)
            {
                /* If this is a first conflict in the stack, start saving lexemes */
                if (!gettime_lexemes)
                {
                    gettime_lexemes = (gettime_INT *) malloc((gettime_LVQUEUEGROWTH) * sizeof(gettime_INT));
                    if (gettime_lexemes == NULL) goto gettime_enomem;
                    gettime_lvals   = (gettime_STYPE *) malloc((gettime_LVQUEUEGROWTH) * sizeof(gettime_STYPE));
                    if (gettime_lvals == NULL) goto gettime_enomem;
                    gettime_lvlim   = gettime_lvals + gettime_LVQUEUEGROWTH;
#if defined(gettime_LTYPE) || defined(gettime_LTYPE_IS_DECLARED)
                    gettime_lpsns   = (gettime_LTYPE *) malloc((gettime_LVQUEUEGROWTH) * sizeof(gettime_LTYPE));
                    if (gettime_lpsns == NULL) goto gettime_enomem;
                    gettime_lplim   = gettime_lpsns + gettime_LVQUEUEGROWTH;
#endif
                }
                if (gettime_lvp == gettime_lve)
                {
                    gettime_lvp  = gettime_lve = gettime_lvals;
#if defined(gettime_LTYPE) || defined(gettime_LTYPE_IS_DECLARED)
                    gettime_lpp  = gettime_lpe = gettime_lpsns;
#endif
                    gettime_lexp = gettime_lexemes;
                    if (gettime_char >= gettime_EOF)
                    {
                        *gettime_lve++ = gettime_lval;
#if defined(gettime_LTYPE) || defined(gettime_LTYPE_IS_DECLARED)
                        *gettime_lpe++ = gettime_lloc;
#endif
                        *gettime_lexp  = (gettime_INT) gettime_char;
                        gettime_char   = gettime_EMPTY;
                    }
                }
            }
            if (gettime_char >= gettime_EOF)
            {
                gettime_lvp--;
#if defined(gettime_LTYPE) || defined(gettime_LTYPE_IS_DECLARED)
                gettime_lpp--;
#endif
                gettime_lexp--;
                gettime_char = gettime_EMPTY;
            }
            save->lexeme = (int) (gettime_lvp - gettime_lvals);
            gettime_ps->save   = save;
        }
        if (gettime_table[gettime_n] == ctry)
        {
#if gettime_DEBUG
            if (gettime_debug)
                fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
                                gettime_DEBUGSTR, gettime_depth, gettime_state, gettime_ctable[ctry]);
#endif
            if (gettime_char < 0)
            {
                gettime_lvp++;
#if defined(gettime_LTYPE) || defined(gettime_LTYPE_IS_DECLARED)
                gettime_lpp++;
#endif
                gettime_lexp++;
            }
            if (gettime_stack.s_mark >= gettime_stack.s_last && gettime_growstack(&gettime_stack) == gettime_ENOMEM)
                goto gettime_overflow;
            gettime_state = gettime_ctable[ctry];
            *++gettime_stack.s_mark = (gettime_INT) gettime_state;
            *++gettime_stack.l_mark = gettime_lval;
#if defined(gettime_LTYPE) || defined(gettime_LTYPE_IS_DECLARED)
            *++gettime_stack.p_mark = gettime_lloc;
#endif
            gettime_char  = gettime_EMPTY;
            if (gettime_errflag > 0) --gettime_errflag;
            goto gettime_loop;
        }
        else
        {
            gettime_n = gettime_ctable[ctry];
            goto gettime_reduce;
        }
    } /* End of code dealing with conflicts */
#endif /* gettime_BTYACC */
    if (((gettime_n = gettime_sindex[gettime_state]) != 0) && (gettime_n += gettime_char) >= 0 &&
            gettime_n <= gettime_TABLESIZE && gettime_check[gettime_n] == (gettime_INT) gettime_char)
    {
#if gettime_DEBUG
        if (gettime_debug)
            fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
                            gettime_DEBUGSTR, gettime_depth, gettime_state, gettime_table[gettime_n]);
#endif
        if (gettime_stack.s_mark >= gettime_stack.s_last && gettime_growstack(&gettime_stack) == gettime_ENOMEM) goto gettime_overflow;
        gettime_state = gettime_table[gettime_n];
        *++gettime_stack.s_mark = gettime_table[gettime_n];
        *++gettime_stack.l_mark = gettime_lval;
#if defined(gettime_LTYPE) || defined(gettime_LTYPE_IS_DECLARED)
        *++gettime_stack.p_mark = gettime_lloc;
#endif
        gettime_char = gettime_EMPTY;
        if (gettime_errflag > 0)  --gettime_errflag;
        goto gettime_loop;
    }
    if (((gettime_n = gettime_rindex[gettime_state]) != 0) && (gettime_n += gettime_char) >= 0 &&
            gettime_n <= gettime_TABLESIZE && gettime_check[gettime_n] == (gettime_INT) gettime_char)
    {
        gettime_n = gettime_table[gettime_n];
        goto gettime_reduce;
    }
    if (gettime_errflag != 0) goto gettime_inrecovery;
#if gettime_BTYACC

    gettime_newerrflag = 1;
    goto gettime_errhandler;
    goto gettime_errlab; /* redundant goto avoids 'unused label' warning */

gettime_errlab:
    /* explicit gettime_ERROR from an action -- pop the rhs of the rule reduced
     * before looking for error recovery */
    gettime_stack.s_mark -= gettime_m;
    gettime_state = *gettime_stack.s_mark;
    gettime_stack.l_mark -= gettime_m;
#if defined(gettime_LTYPE) || defined(gettime_LTYPE_IS_DECLARED)
    gettime_stack.p_mark -= gettime_m;
#endif

    gettime_newerrflag = 0;
gettime_errhandler:
    while (gettime_ps->save)
    {
        int ctry;
        gettime_ParseState *save = gettime_ps->save;
#if gettime_DEBUG
        if (gettime_debug)
            fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n",
                            gettime_DEBUGSTR, gettime_depth, gettime_state, gettime_ps->save->state,
                    (int)(gettime_lvp - gettime_lvals - gettime_ps->save->lexeme));
#endif
        /* Memorize most forward-looking error state in case it's really an error. */
        if (gettime_errctx == NULL || gettime_errctx->lexeme < gettime_lvp - gettime_lvals)
        {
            /* Free old saved error context state */
            if (gettime_errctx) gettime_FreeState(gettime_errctx);
            /* Create and fill out new saved error context state */
            gettime_errctx                 = gettime_NewState((unsigned)(gettime_stack.s_mark - gettime_stack.s_base + 1));
            if (gettime_errctx == NULL) goto gettime_enomem;
            gettime_errctx->save           = gettime_ps->save;
            gettime_errctx->state          = gettime_state;
            gettime_errctx->errflag        = gettime_errflag;
            gettime_errctx->gettime_stack.s_mark = gettime_errctx->gettime_stack.s_base + (gettime_stack.s_mark - gettime_stack.s_base);
            memcpy (gettime_errctx->gettime_stack.s_base, gettime_stack.s_base, (size_t) (gettime_stack.s_mark - gettime_stack.s_base + 1) * sizeof(gettime_INT));
            gettime_errctx->gettime_stack.l_mark = gettime_errctx->gettime_stack.l_base + (gettime_stack.l_mark - gettime_stack.l_base);
            memcpy (gettime_errctx->gettime_stack.l_base, gettime_stack.l_base, (size_t) (gettime_stack.l_mark - gettime_stack.l_base + 1) * sizeof(gettime_STYPE));
#if defined(gettime_LTYPE) || defined(gettime_LTYPE_IS_DECLARED)
            gettime_errctx->gettime_stack.p_mark = gettime_errctx->gettime_stack.p_base + (gettime_stack.p_mark - gettime_stack.p_base);
            memcpy (gettime_errctx->gettime_stack.p_base, gettime_stack.p_base, (size_t) (gettime_stack.p_mark - gettime_stack.p_base + 1) * sizeof(gettime_LTYPE));
#endif
            gettime_errctx->lexeme         = (int) (gettime_lvp - gettime_lvals);
        }
        gettime_lvp          = gettime_lvals   + save->lexeme;
#if defined(gettime_LTYPE) || defined(gettime_LTYPE_IS_DECLARED)
        gettime_lpp          = gettime_lpsns   + save->lexeme;
#endif
        gettime_lexp         = gettime_lexemes + save->lexeme;
        gettime_char         = gettime_EMPTY;
        gettime_stack.s_mark = gettime_stack.s_base + (save->gettime_stack.s_mark - save->gettime_stack.s_base);
        memcpy (gettime_stack.s_base, save->gettime_stack.s_base, (size_t) (gettime_stack.s_mark - gettime_stack.s_base + 1) * sizeof(gettime_INT));
        gettime_stack.l_mark = gettime_stack.l_base + (save->gettime_stack.l_mark - save->gettime_stack.l_base);
        memcpy (gettime_stack.l_base, save->gettime_stack.l_base, (size_t) (gettime_stack.l_mark - gettime_stack.l_base + 1) * sizeof(gettime_STYPE));
#if defined(gettime_LTYPE) || defined(gettime_LTYPE_IS_DECLARED)
        gettime_stack.p_mark = gettime_stack.p_base + (save->gettime_stack.p_mark - save->gettime_stack.p_base);
        memcpy (gettime_stack.p_base, save->gettime_stack.p_base, (size_t) (gettime_stack.p_mark - gettime_stack.p_base + 1) * sizeof(gettime_LTYPE));
#endif
        ctry           = ++save->ctry;
        gettime_state        = save->state;
        /* We tried shift, try reduce now */
        if ((gettime_n = gettime_ctable[ctry]) >= 0) goto gettime_reduce;
        gettime_ps->save     = save->save;
        save->save     = NULL;
        gettime_FreeState(save);

        /* Nothing left on the stack -- error */
        if (!gettime_ps->save)
        {
#if gettime_DEBUG
            if (gettime_debug)
                fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n",
                                gettime_PREFIX, gettime_depth);
#endif
            /* Restore state as it was in the most forward-advanced error */
            gettime_lvp          = gettime_lvals   + gettime_errctx->lexeme;
#if defined(gettime_LTYPE) || defined(gettime_LTYPE_IS_DECLARED)
            gettime_lpp          = gettime_lpsns   + gettime_errctx->lexeme;
#endif
            gettime_lexp         = gettime_lexemes + gettime_errctx->lexeme;
            gettime_char         = gettime_lexp[-1];
            gettime_lval         = gettime_lvp[-1];
#if defined(gettime_LTYPE) || defined(gettime_LTYPE_IS_DECLARED)
            gettime_lloc         = gettime_lpp[-1];
#endif
            gettime_stack.s_mark = gettime_stack.s_base + (gettime_errctx->gettime_stack.s_mark - gettime_errctx->gettime_stack.s_base);
            memcpy (gettime_stack.s_base, gettime_errctx->gettime_stack.s_base, (size_t) (gettime_stack.s_mark - gettime_stack.s_base + 1) * sizeof(gettime_INT));
            gettime_stack.l_mark = gettime_stack.l_base + (gettime_errctx->gettime_stack.l_mark - gettime_errctx->gettime_stack.l_base);
            memcpy (gettime_stack.l_base, gettime_errctx->gettime_stack.l_base, (size_t) (gettime_stack.l_mark - gettime_stack.l_base + 1) * sizeof(gettime_STYPE));
#if defined(gettime_LTYPE) || defined(gettime_LTYPE_IS_DECLARED)
            gettime_stack.p_mark = gettime_stack.p_base + (gettime_errctx->gettime_stack.p_mark - gettime_errctx->gettime_stack.p_base);
            memcpy (gettime_stack.p_base, gettime_errctx->gettime_stack.p_base, (size_t) (gettime_stack.p_mark - gettime_stack.p_base + 1) * sizeof(gettime_LTYPE));
#endif
            gettime_state        = gettime_errctx->state;
            gettime_FreeState(gettime_errctx);
            gettime_errctx       = NULL;
        }
        gettime_newerrflag = 1;
    }
    if (gettime_newerrflag == 0) goto gettime_inrecovery;
#endif /* gettime_BTYACC */

    gettime_ERROR_CALL("syntax error");
#if defined(gettime_LTYPE) || defined(gettime_LTYPE_IS_DECLARED)
    gettime_error_loc_range[1] = gettime_lloc; /* lookahead position is error start position */
#endif

#if !gettime_BTYACC
    goto gettime_errlab; /* redundant goto avoids 'unused label' warning */
gettime_errlab:
#endif
    ++gettime_nerrs;

gettime_inrecovery:
    if (gettime_errflag < 3)
    {
        gettime_errflag = 3;
        for (;;)
        {
            if (((gettime_n = gettime_sindex[*gettime_stack.s_mark]) != 0) && (gettime_n += gettime_ERRCODE) >= 0 &&
                    gettime_n <= gettime_TABLESIZE && gettime_check[gettime_n] == (gettime_INT) gettime_ERRCODE)
            {
#if gettime_DEBUG
                if (gettime_debug)
                    fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n",
                                    gettime_DEBUGSTR, gettime_depth, *gettime_stack.s_mark, gettime_table[gettime_n]);
#endif
                if (gettime_stack.s_mark >= gettime_stack.s_last && gettime_growstack(&gettime_stack) == gettime_ENOMEM) goto gettime_overflow;
                gettime_state = gettime_table[gettime_n];
                *++gettime_stack.s_mark = gettime_table[gettime_n];
                *++gettime_stack.l_mark = gettime_lval;
#if defined(gettime_LTYPE) || defined(gettime_LTYPE_IS_DECLARED)
                /* lookahead position is error end position */
                gettime_error_loc_range[2] = gettime_lloc;
                gettime_LLOC_DEFAULT(gettime_loc, gettime_error_loc_range, 2); /* position of error span */
                *++gettime_stack.p_mark = gettime_loc;
#endif
                goto gettime_loop;
            }
            else
            {
#if gettime_DEBUG
                if (gettime_debug)
                    fprintf(stderr, "%s[%d]: error recovery discarding state %d\n",
                                    gettime_DEBUGSTR, gettime_depth, *gettime_stack.s_mark);
#endif
                if (gettime_stack.s_mark <= gettime_stack.s_base) goto gettime_abort;
#if defined(gettime_LTYPE) || defined(gettime_LTYPE_IS_DECLARED)
                /* the current TOS position is the error start position */
                gettime_error_loc_range[1] = *gettime_stack.p_mark;
#endif
#if defined(gettime_DESTRUCT_CALL)
#if gettime_BTYACC
                if (!gettime_trial)
#endif /* gettime_BTYACC */
#if defined(gettime_LTYPE) || defined(gettime_LTYPE_IS_DECLARED)
                    gettime_DESTRUCT_CALL("error: discarding state",
                                    gettime_stos[*gettime_stack.s_mark], gettime_stack.l_mark, gettime_stack.p_mark);
#else
                    gettime_DESTRUCT_CALL("error: discarding state",
                                    gettime_stos[*gettime_stack.s_mark], gettime_stack.l_mark);
#endif /* defined(gettime_LTYPE) || defined(gettime_LTYPE_IS_DECLARED) */
#endif /* defined(gettime_DESTRUCT_CALL) */
                --gettime_stack.s_mark;
                --gettime_stack.l_mark;
#if defined(gettime_LTYPE) || defined(gettime_LTYPE_IS_DECLARED)
                --gettime_stack.p_mark;
#endif
            }
        }
    }
    else
    {
        if (gettime_char == gettime_EOF) goto gettime_abort;
#if gettime_DEBUG
        if (gettime_debug)
        {
            if ((gettime_s = gettime_name[gettime_TRANSLATE(gettime_char)]) == NULL) gettime_s = gettime_name[gettime_UNDFTOKEN];
            fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n",
                            gettime_DEBUGSTR, gettime_depth, gettime_state, gettime_char, gettime_s);
        }
#endif
#if defined(gettime_DESTRUCT_CALL)
#if gettime_BTYACC
        if (!gettime_trial)
#endif /* gettime_BTYACC */
#if defined(gettime_LTYPE) || defined(gettime_LTYPE_IS_DECLARED)
            gettime_DESTRUCT_CALL("error: discarding token", gettime_char, &gettime_lval, &gettime_lloc);
#else
            gettime_DESTRUCT_CALL("error: discarding token", gettime_char, &gettime_lval);
#endif /* defined(gettime_LTYPE) || defined(gettime_LTYPE_IS_DECLARED) */
#endif /* defined(gettime_DESTRUCT_CALL) */
        gettime_char = gettime_EMPTY;
        goto gettime_loop;
    }

gettime_reduce:
    gettime_m = gettime_len[gettime_n];
#if gettime_DEBUG
    if (gettime_debug)
    {
        fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)",
                        gettime_DEBUGSTR, gettime_depth, gettime_state, gettime_n, gettime_rule[gettime_n]);
#ifdef gettime_STYPE_TOSTRING
#if gettime_BTYACC
        if (!gettime_trial)
#endif /* gettime_BTYACC */
            if (gettime_m > 0)
            {
                int i;
                fputc('<', stderr);
                for (i = gettime_m; i > 0; i--)
                {
                    if (i != gettime_m) fputs(", ", stderr);
                    fputs(gettime_STYPE_TOSTRING(gettime_stos[gettime_stack.s_mark[1-i]],
                                           gettime_stack.l_mark[1-i]), stderr);
                }
                fputc('>', stderr);
            }
#endif
        fputc('\n', stderr);
    }
#endif
    if (gettime_m > 0)
        gettime_val = gettime_stack.l_mark[1-gettime_m];
    else
        memset(&gettime_val, 0, sizeof gettime_val);
#if defined(gettime_LTYPE) || defined(gettime_LTYPE_IS_DECLARED)

    /* Perform position reduction */
    memset(&gettime_loc, 0, sizeof(gettime_loc));
#if gettime_BTYACC
    if (!gettime_trial)
#endif /* gettime_BTYACC */
    {
        gettime_LLOC_DEFAULT(gettime_loc, &gettime_stack.p_mark[-gettime_m], gettime_m);
        /* just in case gettime_ERROR is invoked within the action, save
           the start of the rhs as the error start position */
        gettime_error_loc_range[1] = gettime_stack.p_mark[1-gettime_m];
    }
#endif

    switch (gettime_n)
    {
case 3:
#line 758 "common/gettime.y"
	{
			/*
			 * Mostly, this production is unnecessary,
			 * however it silences warnings about unused
			 * labels, etc.
			 */
			return -1;
		}
break;
case 4:
#line 770 "common/gettime.y"
	{ timeflag++; }
break;
case 5:
#line 772 "common/gettime.y"
	{ zoneflag++; }
break;
case 6:
#line 774 "common/gettime.y"
	{ dateflag++; }
break;
case 7:
#line 776 "common/gettime.y"
	{ dayflag++; }
break;
case 8:
#line 778 "common/gettime.y"
	{ relflag++; }
break;
case 10:
#line 784 "common/gettime.y"
	{
			if (timeflag && dateflag && !relflag)
				year = gettime_stack.l_mark[0];
			else
			{
				timeflag++;
				hh = gettime_stack.l_mark[0] / 100;
				mm = gettime_stack.l_mark[0] % 100;
				ss = 0;
				merid = 24;
			}
		}
break;
case 11:
#line 800 "common/gettime.y"
	{
			hh = gettime_stack.l_mark[-1];
			mm = 0;
			ss = 0;
			merid = gettime_stack.l_mark[0];
		}
break;
case 12:
#line 807 "common/gettime.y"
	{
			hh = gettime_stack.l_mark[-2];
			mm = gettime_stack.l_mark[0];
			merid = 24;
		}
break;
case 13:
#line 813 "common/gettime.y"
	{
			hh = gettime_stack.l_mark[-3];
			mm = gettime_stack.l_mark[-1];
			merid = gettime_stack.l_mark[0];
		}
break;
case 14:
#line 819 "common/gettime.y"
	{
			hh = gettime_stack.l_mark[-3];
			mm = gettime_stack.l_mark[-1];
			merid = 24;
			day_light_flag = STANDARD;
			gettime_stack.l_mark[0] = -gettime_stack.l_mark[0];
			ourzone = gettime_stack.l_mark[0] % 100 + 60 * gettime_stack.l_mark[0] / 100;
		}
break;
case 15:
#line 828 "common/gettime.y"
	{
			hh = gettime_stack.l_mark[-4];
			mm = gettime_stack.l_mark[-2];
			ss = gettime_stack.l_mark[0];
			merid = 24;
		}
break;
case 16:
#line 835 "common/gettime.y"
	{
			hh = gettime_stack.l_mark[-5];
			mm = gettime_stack.l_mark[-3];
			ss = gettime_stack.l_mark[-1];
			merid = gettime_stack.l_mark[0];
		}
break;
case 17:
#line 842 "common/gettime.y"
	{
			hh = gettime_stack.l_mark[-5];
			mm = gettime_stack.l_mark[-3];
			ss = gettime_stack.l_mark[-1];
			merid = 24;
			day_light_flag = STANDARD;
			gettime_stack.l_mark[0] = -gettime_stack.l_mark[0];
			ourzone = gettime_stack.l_mark[0] % 100 + 60 * gettime_stack.l_mark[0] / 100;
		}
break;
case 18:
#line 855 "common/gettime.y"
	{
			ourzone = gettime_stack.l_mark[0];
			day_light_flag = STANDARD;
		}
break;
case 19:
#line 860 "common/gettime.y"
	{
			ourzone = gettime_stack.l_mark[0];
			day_light_flag = DAYLIGHT;
		}
break;
case 20:
#line 868 "common/gettime.y"
	{
			dayord = 1;
			dayreq = gettime_stack.l_mark[0];
		}
break;
case 21:
#line 873 "common/gettime.y"
	{
			dayord = 1;
			dayreq = gettime_stack.l_mark[-1];
		}
break;
case 22:
#line 878 "common/gettime.y"
	{
			dayord = gettime_stack.l_mark[-1];
			dayreq = gettime_stack.l_mark[0];
		}
break;
case 23:
#line 886 "common/gettime.y"
	{
			if (gettime_stack.l_mark[-2] > 12 && gettime_stack.l_mark[0] <= 12)
			{
				day = gettime_stack.l_mark[-2];
				month = gettime_stack.l_mark[0];
			}
			else
			{
				month = gettime_stack.l_mark[-2];
				day = gettime_stack.l_mark[0];
			}
		}
break;
case 24:
#line 899 "common/gettime.y"
	{
			if (gettime_stack.l_mark[-4] > 12 && gettime_stack.l_mark[-2] <= 12)
			{
				/* european and Australian */
				day = gettime_stack.l_mark[-4];
				month = gettime_stack.l_mark[-2];
			}
			else
			{
				month = gettime_stack.l_mark[-4];
				day = gettime_stack.l_mark[-2];
			}
			year = gettime_stack.l_mark[0];
		}
break;
case 25:
#line 914 "common/gettime.y"
	{
			month = gettime_stack.l_mark[-1];
			day = gettime_stack.l_mark[0];
		}
break;
case 26:
#line 919 "common/gettime.y"
	{
			month = gettime_stack.l_mark[-3];
			day = gettime_stack.l_mark[-2];
			year = gettime_stack.l_mark[0];
		}
break;
case 27:
#line 925 "common/gettime.y"
	{
			month = gettime_stack.l_mark[0];
			day = gettime_stack.l_mark[-1];
		}
break;
case 28:
#line 930 "common/gettime.y"
	{
			month = gettime_stack.l_mark[-1];
			day = gettime_stack.l_mark[-2];
			year = gettime_stack.l_mark[0];
		}
break;
case 29:
#line 939 "common/gettime.y"
	{ relsec +=  60L * gettime_stack.l_mark[-1] * gettime_stack.l_mark[0]; }
break;
case 30:
#line 941 "common/gettime.y"
	{ relmonth += gettime_stack.l_mark[-1] * gettime_stack.l_mark[0]; }
break;
case 31:
#line 943 "common/gettime.y"
	{ relsec += gettime_stack.l_mark[-1]; }
break;
case 32:
#line 945 "common/gettime.y"
	{ relsec +=  60L * gettime_stack.l_mark[0]; }
break;
case 33:
#line 947 "common/gettime.y"
	{ relmonth += gettime_stack.l_mark[0]; }
break;
case 34:
#line 949 "common/gettime.y"
	{ relsec++; }
break;
case 35:
#line 951 "common/gettime.y"
	{
			relsec = -relsec;
			relmonth = -relmonth;
		}
break;
#line 2569 "y.tab.c"
    default:
        break;
    }
    gettime_stack.s_mark -= gettime_m;
    gettime_state = *gettime_stack.s_mark;
    gettime_stack.l_mark -= gettime_m;
#if defined(gettime_LTYPE) || defined(gettime_LTYPE_IS_DECLARED)
    gettime_stack.p_mark -= gettime_m;
#endif
    gettime_m = gettime_lhs[gettime_n];
    if (gettime_state == 0 && gettime_m == 0)
    {
#if gettime_DEBUG
        if (gettime_debug)
        {
            fprintf(stderr, "%s[%d]: after reduction, ", gettime_DEBUGSTR, gettime_depth);
#ifdef gettime_STYPE_TOSTRING
#if gettime_BTYACC
            if (!gettime_trial)
#endif /* gettime_BTYACC */
                fprintf(stderr, "result is <%s>, ", gettime_STYPE_TOSTRING(gettime_stos[gettime_FINAL], gettime_val));
#endif
            fprintf(stderr, "shifting from state 0 to final state %d\n", gettime_FINAL);
        }
#endif
        gettime_state = gettime_FINAL;
        *++gettime_stack.s_mark = gettime_FINAL;
        *++gettime_stack.l_mark = gettime_val;
#if defined(gettime_LTYPE) || defined(gettime_LTYPE_IS_DECLARED)
        *++gettime_stack.p_mark = gettime_loc;
#endif
        if (gettime_char < 0)
        {
#if gettime_BTYACC
            do {
            if (gettime_lvp < gettime_lve)
            {
                /* we're currently re-reading tokens */
                gettime_lval = *gettime_lvp++;
#if defined(gettime_LTYPE) || defined(gettime_LTYPE_IS_DECLARED)
                gettime_lloc = *gettime_lpp++;
#endif
                gettime_char = *gettime_lexp++;
                break;
            }
            if (gettime_ps->save)
            {
                /* in trial mode; save scanner results for future parse attempts */
                if (gettime_lvp == gettime_lvlim)
                {   /* Enlarge lexical value queue */
                    size_t p = (size_t) (gettime_lvp - gettime_lvals);
                    size_t s = (size_t) (gettime_lvlim - gettime_lvals);

                    s += gettime_LVQUEUEGROWTH;
                    if ((gettime_lexemes = (gettime_INT *)realloc(gettime_lexemes, s * sizeof(gettime_INT))) == NULL)
                        goto gettime_enomem;
                    if ((gettime_lvals   = (gettime_STYPE *)realloc(gettime_lvals, s * sizeof(gettime_STYPE))) == NULL)
                        goto gettime_enomem;
#if defined(gettime_LTYPE) || defined(gettime_LTYPE_IS_DECLARED)
                    if ((gettime_lpsns   = (gettime_LTYPE *)realloc(gettime_lpsns, s * sizeof(gettime_LTYPE))) == NULL)
                        goto gettime_enomem;
#endif
                    gettime_lvp   = gettime_lve = gettime_lvals + p;
                    gettime_lvlim = gettime_lvals + s;
#if defined(gettime_LTYPE) || defined(gettime_LTYPE_IS_DECLARED)
                    gettime_lpp   = gettime_lpe = gettime_lpsns + p;
                    gettime_lplim = gettime_lpsns + s;
#endif
                    gettime_lexp  = gettime_lexemes + p;
                }
                *gettime_lexp = (gettime_INT) gettime_LEX;
                *gettime_lvp++ = gettime_lval;
                gettime_lve++;
#if defined(gettime_LTYPE) || defined(gettime_LTYPE_IS_DECLARED)
                *gettime_lpp++ = gettime_lloc;
                gettime_lpe++;
#endif
                gettime_char = *gettime_lexp++;
                break;
            }
            /* normal operation, no conflict encountered */
#endif /* gettime_BTYACC */
            gettime_char = gettime_LEX;
#if gettime_BTYACC
            } while (0);
#endif /* gettime_BTYACC */
            if (gettime_char < 0) gettime_char = gettime_EOF;
#if gettime_DEBUG
            if (gettime_debug)
            {
                if ((gettime_s = gettime_name[gettime_TRANSLATE(gettime_char)]) == NULL) gettime_s = gettime_name[gettime_UNDFTOKEN];
                fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n",
                                gettime_DEBUGSTR, gettime_depth, gettime_FINAL, gettime_char, gettime_s);
            }
#endif
        }
        if (gettime_char == gettime_EOF) goto gettime_accept;
        goto gettime_loop;
    }
    if (((gettime_n = gettime_gindex[gettime_m]) != 0) && (gettime_n += gettime_state) >= 0 &&
            gettime_n <= gettime_TABLESIZE && gettime_check[gettime_n] == (gettime_INT) gettime_state)
        gettime_state = gettime_table[gettime_n];
    else
        gettime_state = gettime_dgoto[gettime_m];
#if gettime_DEBUG
    if (gettime_debug)
    {
        fprintf(stderr, "%s[%d]: after reduction, ", gettime_DEBUGSTR, gettime_depth);
#ifdef gettime_STYPE_TOSTRING
#if gettime_BTYACC
        if (!gettime_trial)
#endif /* gettime_BTYACC */
            fprintf(stderr, "result is <%s>, ", gettime_STYPE_TOSTRING(gettime_stos[gettime_state], gettime_val));
#endif
        fprintf(stderr, "shifting from state %d to state %d\n", *gettime_stack.s_mark, gettime_state);
    }
#endif
    if (gettime_stack.s_mark >= gettime_stack.s_last && gettime_growstack(&gettime_stack) == gettime_ENOMEM) goto gettime_overflow;
    *++gettime_stack.s_mark = (gettime_INT) gettime_state;
    *++gettime_stack.l_mark = gettime_val;
#if defined(gettime_LTYPE) || defined(gettime_LTYPE_IS_DECLARED)
    *++gettime_stack.p_mark = gettime_loc;
#endif
    goto gettime_loop;
#if gettime_BTYACC

    /* Reduction declares that this path is valid. Set gettime_path and do a full parse */
gettime_valid:
    if (gettime_path) gettime_ABORT;
    while (gettime_ps->save)
    {
        gettime_ParseState *save = gettime_ps->save;
        gettime_ps->save = save->save;
        save->save = gettime_path;
        gettime_path = save;
    }
#if gettime_DEBUG
    if (gettime_debug)
        fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n",
                        gettime_DEBUGSTR, gettime_depth, gettime_state, gettime_path->state, (int)(gettime_lvp - gettime_lvals - gettime_path->lexeme));
#endif
    if (gettime_errctx)
    {
        gettime_FreeState(gettime_errctx);
        gettime_errctx = NULL;
    }
    gettime_lvp          = gettime_lvals + gettime_path->lexeme;
#if defined(gettime_LTYPE) || defined(gettime_LTYPE_IS_DECLARED)
    gettime_lpp          = gettime_lpsns + gettime_path->lexeme;
#endif
    gettime_lexp         = gettime_lexemes + gettime_path->lexeme;
    gettime_char         = gettime_EMPTY;
    gettime_stack.s_mark = gettime_stack.s_base + (gettime_path->gettime_stack.s_mark - gettime_path->gettime_stack.s_base);
    memcpy (gettime_stack.s_base, gettime_path->gettime_stack.s_base, (size_t) (gettime_stack.s_mark - gettime_stack.s_base + 1) * sizeof(gettime_INT));
    gettime_stack.l_mark = gettime_stack.l_base + (gettime_path->gettime_stack.l_mark - gettime_path->gettime_stack.l_base);
    memcpy (gettime_stack.l_base, gettime_path->gettime_stack.l_base, (size_t) (gettime_stack.l_mark - gettime_stack.l_base + 1) * sizeof(gettime_STYPE));
#if defined(gettime_LTYPE) || defined(gettime_LTYPE_IS_DECLARED)
    gettime_stack.p_mark = gettime_stack.p_base + (gettime_path->gettime_stack.p_mark - gettime_path->gettime_stack.p_base);
    memcpy (gettime_stack.p_base, gettime_path->gettime_stack.p_base, (size_t) (gettime_stack.p_mark - gettime_stack.p_base + 1) * sizeof(gettime_LTYPE));
#endif
    gettime_state        = gettime_path->state;
    goto gettime_loop;
#endif /* gettime_BTYACC */

gettime_overflow:
    gettime_ERROR_CALL("yacc stack overflow");
#if gettime_BTYACC
    goto gettime_abort_nomem;
gettime_enomem:
    gettime_ERROR_CALL("memory exhausted");
gettime_abort_nomem:
#endif /* gettime_BTYACC */
    gettime_result = 2;
    goto gettime_return;

gettime_abort:
    gettime_result = 1;
    goto gettime_return;

gettime_accept:
#if gettime_BTYACC
    if (gettime_ps->save) goto gettime_valid;
#endif /* gettime_BTYACC */
    gettime_result = 0;

gettime_return:
#if defined(gettime_DESTRUCT_CALL)
    if (gettime_char != gettime_EOF && gettime_char != gettime_EMPTY)
#if defined(gettime_LTYPE) || defined(gettime_LTYPE_IS_DECLARED)
        gettime_DESTRUCT_CALL("cleanup: discarding token", gettime_char, &gettime_lval, &gettime_lloc);
#else
        gettime_DESTRUCT_CALL("cleanup: discarding token", gettime_char, &gettime_lval);
#endif /* defined(gettime_LTYPE) || defined(gettime_LTYPE_IS_DECLARED) */

    {
        gettime_STYPE *pv;
#if defined(gettime_LTYPE) || defined(gettime_LTYPE_IS_DECLARED)
        gettime_LTYPE *pp;

        for (pv = gettime_stack.l_base, pp = gettime_stack.p_base; pv <= gettime_stack.l_mark; ++pv, ++pp)
             gettime_DESTRUCT_CALL("cleanup: discarding state",
                             gettime_stos[*(gettime_stack.s_base + (pv - gettime_stack.l_base))], pv, pp);
#else
        for (pv = gettime_stack.l_base; pv <= gettime_stack.l_mark; ++pv)
             gettime_DESTRUCT_CALL("cleanup: discarding state",
                             gettime_stos[*(gettime_stack.s_base + (pv - gettime_stack.l_base))], pv);
#endif /* defined(gettime_LTYPE) || defined(gettime_LTYPE_IS_DECLARED) */
    }
#endif /* defined(gettime_DESTRUCT_CALL) */

#if gettime_BTYACC
    if (gettime_errctx)
    {
        gettime_FreeState(gettime_errctx);
        gettime_errctx = NULL;
    }
    while (gettime_ps)
    {
        gettime_ParseState *save = gettime_ps;
        gettime_ps = save->save;
        save->save = NULL;
        gettime_FreeState(save);
    }
    while (gettime_path)
    {
        gettime_ParseState *save = gettime_path;
        gettime_path = save->save;
        save->save = NULL;
        gettime_FreeState(save);
    }
#endif /* gettime_BTYACC */
    gettime_freestack(&gettime_stack);
    return (gettime_result);
}
