Skip to content
getdate.c.cvs 63.3 KiB
Newer Older

/*----------.
| yyparse.  |
`----------*/

#ifdef YYPARSE_PARAM
# if defined (__STDC__) || defined (__cplusplus)
int yyparse (void *YYPARSE_PARAM)
# else
int yyparse (YYPARSE_PARAM)
  void *YYPARSE_PARAM;
# endif
#else /* ! YYPARSE_PARAM */
#if defined (__STDC__) || defined (__cplusplus)
Daniel Stenberg's avatar
Daniel Stenberg committed
int
Daniel Stenberg's avatar
Daniel Stenberg committed
{
  /* The lookahead symbol.  */
int yychar;

/* The semantic value of the lookahead symbol.  */
YYSTYPE yylval;

/* Number of syntax errors so far.  */
int yynerrs;

Daniel Stenberg's avatar
Daniel Stenberg committed
  register int yystate;
  register int yyn;
  int yyresult;
  /* Number of tokens to shift before error messages enabled.  */
  int yyerrstatus;
  /* Lookahead token as an internal (translated) token number.  */
  int yytoken = 0;

  /* Three stacks and their tools:
     `yyss': related to states,
     `yyvs': related to semantic values,
     `yyls': related to locations.

     Refer to the stacks thru separate pointers, to allow yyoverflow
     to reallocate them elsewhere.  */

  /* The state stack.  */
  short	yyssa[YYINITDEPTH];
  short *yyss = yyssa;
Daniel Stenberg's avatar
Daniel Stenberg committed
  register short *yyssp;

  /* The semantic value stack.  */
  YYSTYPE yyvsa[YYINITDEPTH];
  YYSTYPE *yyvs = yyvsa;
  register YYSTYPE *yyvsp;
Daniel Stenberg's avatar
Daniel Stenberg committed



#define YYPOPSTACK   (yyvsp--, yyssp--)

  YYSIZE_T yystacksize = YYINITDEPTH;
Daniel Stenberg's avatar
Daniel Stenberg committed

  /* The variables used to return semantic value and location from the
     action routines.  */
  YYSTYPE yyval;
  /* When reducing, the number of symbols on the RHS of the reduced
     rule.  */
Daniel Stenberg's avatar
Daniel Stenberg committed
  int yylen;

  YYDPRINTF ((stderr, "Starting parse\n"));
Daniel Stenberg's avatar
Daniel Stenberg committed

  yystate = 0;
  yyerrstatus = 0;
  yynerrs = 0;
  yychar = YYEMPTY;		/* Cause a token to be read.  */

  /* Initialize stack pointers.
     Waste one element of value and location stack
     so that they stay on the same level as the state stack.
     The wasted elements are never initialized.  */

Daniel Stenberg's avatar
Daniel Stenberg committed
  yyvsp = yyvs;

Daniel Stenberg's avatar
Daniel Stenberg committed

/*------------------------------------------------------------.
| yynewstate -- Push a new state, which is found in yystate.  |
`------------------------------------------------------------*/
 yynewstate:
  /* In all cases, when you get here, the value and location stacks
     have just been pushed. so pushing a state here evens the stacks.
     */
  yyssp++;
Daniel Stenberg's avatar
Daniel Stenberg committed

Daniel Stenberg's avatar
Daniel Stenberg committed

  if (yyss + yystacksize - 1 <= yyssp)
    {
Daniel Stenberg's avatar
Daniel Stenberg committed
      /* Get the current used size of the three stacks, in elements.  */
      YYSIZE_T yysize = yyssp - yyss + 1;
Daniel Stenberg's avatar
Daniel Stenberg committed

#ifdef yyoverflow
      {
	/* Give user a chance to reallocate the stack. Use copies of
	   these so that the &'s don't force the real ones into
	   memory.  */
	YYSTYPE *yyvs1 = yyvs;
	short *yyss1 = yyss;
Daniel Stenberg's avatar
Daniel Stenberg committed


	/* Each stack pointer address is followed by the size of the
	   data in use in that stack, in bytes.  This used to be a
	   conditional around just the two extra args, but that might
	   be undefined if yyoverflow is a macro.  */
	yyoverflow ("parser stack overflow",
		    &yyss1, yysize * sizeof (*yyssp),
		    &yyvs1, yysize * sizeof (*yyvsp),

		    &yystacksize);

	yyss = yyss1;
	yyvs = yyvs1;
      }
Daniel Stenberg's avatar
Daniel Stenberg committed
#else /* no yyoverflow */
# ifndef YYSTACK_RELOCATE
      goto yyoverflowlab;
# else
Daniel Stenberg's avatar
Daniel Stenberg committed
      /* Extend the stack our own way.  */
      if (YYMAXDEPTH <= yystacksize)
	goto yyoverflowlab;
Daniel Stenberg's avatar
Daniel Stenberg committed
      yystacksize *= 2;
      if (YYMAXDEPTH < yystacksize)
Daniel Stenberg's avatar
Daniel Stenberg committed
	yystacksize = YYMAXDEPTH;

      {
	short *yyss1 = yyss;
	union yyalloc *yyptr =
	  (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
	if (! yyptr)
	  goto yyoverflowlab;
	YYSTACK_RELOCATE (yyss);
	YYSTACK_RELOCATE (yyvs);

#  undef YYSTACK_RELOCATE
	if (yyss1 != yyssa)
	  YYSTACK_FREE (yyss1);
      }
# endif
Daniel Stenberg's avatar
Daniel Stenberg committed
#endif /* no yyoverflow */

      yyssp = yyss + yysize - 1;
      yyvsp = yyvs + yysize - 1;
      YYDPRINTF ((stderr, "Stack size increased to %lu\n",
		  (unsigned long int) yystacksize));

      if (yyss + yystacksize - 1 <= yyssp)
Daniel Stenberg's avatar
Daniel Stenberg committed
	YYABORT;
    }

  YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Daniel Stenberg's avatar
Daniel Stenberg committed

  goto yybackup;

/*-----------.
| yybackup.  |
`-----------*/
yybackup:
Daniel Stenberg's avatar
Daniel Stenberg committed

/* Do appropriate processing given the current state.  */
/* Read a lookahead token if we need one and don't already have one.  */
/* yyresume: */

  /* First try to decide what to do without reference to lookahead token.  */

  yyn = yypact[yystate];
Daniel Stenberg's avatar
Daniel Stenberg committed
    goto yydefault;

  /* Not known => get a lookahead token if don't already have one.  */

  /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol.  */
Daniel Stenberg's avatar
Daniel Stenberg committed
  if (yychar == YYEMPTY)
    {
      YYDPRINTF ((stderr, "Reading a token: "));
Daniel Stenberg's avatar
Daniel Stenberg committed
      yychar = YYLEX;
    }

Daniel Stenberg's avatar
Daniel Stenberg committed
    {
      yychar = yytoken = YYEOF;
      YYDPRINTF ((stderr, "Now at end of input.\n"));
      yytoken = YYTRANSLATE (yychar);
      YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc);
  /* If the proper action on seeing token YYTOKEN is to reduce or to
     detect an error, take that action.  */
  yyn += yytoken;
  if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
Daniel Stenberg's avatar
Daniel Stenberg committed
    goto yydefault;
  yyn = yytable[yyn];
Daniel Stenberg's avatar
Daniel Stenberg committed
    {
      if (yyn == 0 || yyn == YYTABLE_NINF)
Daniel Stenberg's avatar
Daniel Stenberg committed
	goto yyerrlab;
      yyn = -yyn;
      goto yyreduce;
    }

  if (yyn == YYFINAL)
    YYACCEPT;

  /* Shift the lookahead token.  */
  YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken]));
Daniel Stenberg's avatar
Daniel Stenberg committed

  /* Discard the token being shifted unless it is eof.  */
  if (yychar != YYEOF)
    yychar = YYEMPTY;

  *++yyvsp = yylval;


  /* Count tokens shifted since error; after three, turn off error
     status.  */
  if (yyerrstatus)
    yyerrstatus--;
Daniel Stenberg's avatar
Daniel Stenberg committed

  yystate = yyn;
  goto yynewstate;


/*-----------------------------------------------------------.
| yydefault -- do the default action for the current state.  |
`-----------------------------------------------------------*/
yydefault:
Daniel Stenberg's avatar
Daniel Stenberg committed
  yyn = yydefact[yystate];
  if (yyn == 0)
    goto yyerrlab;
Daniel Stenberg's avatar
Daniel Stenberg committed

/*-----------------------------.
| yyreduce -- Do a reduction.  |
`-----------------------------*/
Daniel Stenberg's avatar
Daniel Stenberg committed
yyreduce:
  /* yyn is the number of a rule to reduce with.  */
Daniel Stenberg's avatar
Daniel Stenberg committed
  yylen = yyr2[yyn];

  /* If YYLEN is nonzero, implement the default value of the action:
     `$$ = $1'.
Daniel Stenberg's avatar
Daniel Stenberg committed

     Otherwise, the following line sets YYVAL to garbage.
     This behavior is undocumented and Bison
     users should not rely upon it.  Assigning to YYVAL
     unconditionally makes the parser a bit smaller, and it avoids a
     GCC warning that YYVAL may be used uninitialized.  */
  yyval = yyvsp[1-yylen];
  YY_REDUCE_PRINT (yyn);
  switch (yyn)
    {
        case 4:
#line 248 "getdate.y"
    {
Daniel Stenberg's avatar
Daniel Stenberg committed
	    context->yyHaveTime++;
Daniel Stenberg's avatar
Daniel Stenberg committed
	    context->yyHaveZone++;
Daniel Stenberg's avatar
Daniel Stenberg committed
	    context->yyHaveDate++;
Daniel Stenberg's avatar
Daniel Stenberg committed
	    context->yyHaveDay++;
Daniel Stenberg's avatar
Daniel Stenberg committed
	    context->yyHaveRel++;
Daniel Stenberg's avatar
Daniel Stenberg committed
	    context->yyHour = yyvsp[-1].Number;
	    context->yyMinutes = 0;
	    context->yySeconds = 0;
	    context->yyMeridian = yyvsp[0].Meridian;
Daniel Stenberg's avatar
Daniel Stenberg committed
	    context->yyHour = yyvsp[-3].Number;
	    context->yyMinutes = yyvsp[-1].Number;
	    context->yySeconds = 0;
	    context->yyMeridian = yyvsp[0].Meridian;
Daniel Stenberg's avatar
Daniel Stenberg committed
	    context->yyHour = yyvsp[-3].Number;
	    context->yyMinutes = yyvsp[-1].Number;
	    context->yyMeridian = MER24;
	    context->yyHaveZone++;
	    context->yyTimezone = (yyvsp[0].Number < 0
				   ? -yyvsp[0].Number % 100 + (-yyvsp[0].Number / 100) * 60
				   : - (yyvsp[0].Number % 100 + (yyvsp[0].Number / 100) * 60));
Daniel Stenberg's avatar
Daniel Stenberg committed
	    context->yyHour = yyvsp[-5].Number;
	    context->yyMinutes = yyvsp[-3].Number;
	    context->yySeconds = yyvsp[-1].Number;
	    context->yyMeridian = yyvsp[0].Meridian;
Daniel Stenberg's avatar
Daniel Stenberg committed
	    context->yyHour = yyvsp[-5].Number;
	    context->yyMinutes = yyvsp[-3].Number;
	    context->yySeconds = yyvsp[-1].Number;
	    context->yyMeridian = MER24;
	    context->yyHaveZone++;
	    context->yyTimezone = (yyvsp[0].Number < 0
				   ? -yyvsp[0].Number % 100 + (-yyvsp[0].Number / 100) * 60
				   : - (yyvsp[0].Number % 100 + (yyvsp[0].Number / 100) * 60));
Daniel Stenberg's avatar
Daniel Stenberg committed
	    context->yyTimezone = yyvsp[0].Number;
Daniel Stenberg's avatar
Daniel Stenberg committed
	    context->yyTimezone = yyvsp[0].Number - 60;
Daniel Stenberg's avatar
Daniel Stenberg committed
	    context->yyTimezone = yyvsp[-1].Number - 60;
Daniel Stenberg's avatar
Daniel Stenberg committed
	    context->yyDayOrdinal = 1;
	    context->yyDayNumber = yyvsp[0].Number;
Daniel Stenberg's avatar
Daniel Stenberg committed
	    context->yyDayOrdinal = 1;
	    context->yyDayNumber = yyvsp[-1].Number;
Daniel Stenberg's avatar
Daniel Stenberg committed
	    context->yyDayOrdinal = yyvsp[-1].Number;
	    context->yyDayNumber = yyvsp[0].Number;
Daniel Stenberg's avatar
Daniel Stenberg committed
	    context->yyMonth = yyvsp[-2].Number;
	    context->yyDay = yyvsp[0].Number;
Daniel Stenberg's avatar
Daniel Stenberg committed
	  /* Interpret as YYYY/MM/DD if $1 >= 1000, otherwise as MM/DD/YY.
	     The goal in recognizing YYYY/MM/DD is solely to support legacy
	     machine-generated dates like those in an RCS log listing.  If
	     you want portability, use the ISO 8601 format.  */
	  if (yyvsp[-4].Number >= 1000)
	    {
Daniel Stenberg's avatar
Daniel Stenberg committed
	      context->yyYear = yyvsp[-4].Number;
	      context->yyMonth = yyvsp[-2].Number;
	      context->yyDay = yyvsp[0].Number;
Daniel Stenberg's avatar
Daniel Stenberg committed
	      context->yyMonth = yyvsp[-4].Number;
	      context->yyDay = yyvsp[-2].Number;
	      context->yyYear = yyvsp[0].Number;
Daniel Stenberg's avatar
Daniel Stenberg committed
	    }
Daniel Stenberg's avatar
Daniel Stenberg committed
	    /* ISO 8601 format.  yyyy-mm-dd.  */
Daniel Stenberg's avatar
Daniel Stenberg committed
	    context->yyYear = yyvsp[-2].Number;
	    context->yyMonth = -yyvsp[-1].Number;
	    context->yyDay = -yyvsp[0].Number;
Daniel Stenberg's avatar
Daniel Stenberg committed
	    /* e.g. 17-JUN-1992.  */
Daniel Stenberg's avatar
Daniel Stenberg committed
	    context->yyDay = yyvsp[-2].Number;
	    context->yyMonth = yyvsp[-1].Number;
	    context->yyYear = -yyvsp[0].Number;
Daniel Stenberg's avatar
Daniel Stenberg committed
	    context->yyMonth = yyvsp[-1].Number;
	    context->yyDay = yyvsp[0].Number;
Daniel Stenberg's avatar
Daniel Stenberg committed
	    context->yyMonth = yyvsp[-3].Number;
	    context->yyDay = yyvsp[-2].Number;
	    context->yyYear = yyvsp[0].Number;
Daniel Stenberg's avatar
Daniel Stenberg committed
	    context->yyMonth = yyvsp[0].Number;
	    context->yyDay = yyvsp[-1].Number;
Daniel Stenberg's avatar
Daniel Stenberg committed
	    context->yyMonth = yyvsp[-1].Number;
	    context->yyDay = yyvsp[-2].Number;
	    context->yyYear = yyvsp[0].Number;
Daniel Stenberg's avatar
Daniel Stenberg committed
	    context->yyRelSeconds = -context->yyRelSeconds;
	    context->yyRelMinutes = -context->yyRelMinutes;
	    context->yyRelHour = -context->yyRelHour;
	    context->yyRelDay = -context->yyRelDay;
	    context->yyRelMonth = -context->yyRelMonth;
	    context->yyRelYear = -context->yyRelYear;
Daniel Stenberg's avatar
Daniel Stenberg committed
	    context->yyRelYear += yyvsp[-1].Number * yyvsp[0].Number;
Daniel Stenberg's avatar
Daniel Stenberg committed
	    context->yyRelYear += yyvsp[-1].Number * yyvsp[0].Number;
Daniel Stenberg's avatar
Daniel Stenberg committed
	    context->yyRelYear += yyvsp[0].Number;
Daniel Stenberg's avatar
Daniel Stenberg committed
	    context->yyRelMonth += yyvsp[-1].Number * yyvsp[0].Number;
Daniel Stenberg's avatar
Daniel Stenberg committed
	    context->yyRelMonth += yyvsp[-1].Number * yyvsp[0].Number;
Daniel Stenberg's avatar
Daniel Stenberg committed
	    context->yyRelMonth += yyvsp[0].Number;
Daniel Stenberg's avatar
Daniel Stenberg committed
	    context->yyRelDay += yyvsp[-1].Number * yyvsp[0].Number;
Daniel Stenberg's avatar
Daniel Stenberg committed
	    context->yyRelDay += yyvsp[-1].Number * yyvsp[0].Number;
Daniel Stenberg's avatar
Daniel Stenberg committed
	    context->yyRelDay += yyvsp[0].Number;
Daniel Stenberg's avatar
Daniel Stenberg committed
	    context->yyRelHour += yyvsp[-1].Number * yyvsp[0].Number;
Daniel Stenberg's avatar
Daniel Stenberg committed
	    context->yyRelHour += yyvsp[-1].Number * yyvsp[0].Number;
Daniel Stenberg's avatar
Daniel Stenberg committed
	    context->yyRelHour += yyvsp[0].Number;
Daniel Stenberg's avatar
Daniel Stenberg committed
	    context->yyRelMinutes += yyvsp[-1].Number * yyvsp[0].Number;
Daniel Stenberg's avatar
Daniel Stenberg committed
	    context->yyRelMinutes += yyvsp[-1].Number * yyvsp[0].Number;
Daniel Stenberg's avatar
Daniel Stenberg committed
	    context->yyRelMinutes += yyvsp[0].Number;
Daniel Stenberg's avatar
Daniel Stenberg committed
	    context->yyRelSeconds += yyvsp[-1].Number * yyvsp[0].Number;
Daniel Stenberg's avatar
Daniel Stenberg committed
	    context->yyRelSeconds += yyvsp[-1].Number * yyvsp[0].Number;
Daniel Stenberg's avatar
Daniel Stenberg committed
	    context->yyRelSeconds += yyvsp[0].Number;
Daniel Stenberg's avatar
Daniel Stenberg committed
	    if (context->yyHaveTime && context->yyHaveDate &&
		!context->yyHaveRel)
	      context->yyYear = yyvsp[0].Number;
Daniel Stenberg's avatar
Daniel Stenberg committed
	    else
	      {
		if (yyvsp[0].Number>10000)
		  {
Daniel Stenberg's avatar
Daniel Stenberg committed
		    context->yyHaveDate++;
		    context->yyDay= (yyvsp[0].Number)%100;
		    context->yyMonth= (yyvsp[0].Number/100)%100;
		    context->yyYear = yyvsp[0].Number/10000;
Daniel Stenberg's avatar
Daniel Stenberg committed
		    context->yyHaveTime++;
Daniel Stenberg's avatar
Daniel Stenberg committed
		    if (yyvsp[0].Number < 100)
		      {
Daniel Stenberg's avatar
Daniel Stenberg committed
			context->yyHour = yyvsp[0].Number;
			context->yyMinutes = 0;
Daniel Stenberg's avatar
Daniel Stenberg committed
		    	context->yyHour = yyvsp[0].Number / 100;
		    	context->yyMinutes = yyvsp[0].Number % 100;
Daniel Stenberg's avatar
Daniel Stenberg committed
		      }
Daniel Stenberg's avatar
Daniel Stenberg committed
		    context->yySeconds = 0;
		    context->yyMeridian = MER24;
Daniel Stenberg's avatar
Daniel Stenberg committed
	    yyval.Meridian = MER24;
Daniel Stenberg's avatar
Daniel Stenberg committed
	    yyval.Meridian = yyvsp[0].Meridian;
Daniel Stenberg's avatar
Daniel Stenberg committed

  yyvsp -= yylen;
  yyssp -= yylen;

Daniel Stenberg's avatar
Daniel Stenberg committed

  *++yyvsp = yyval;


  /* Now `shift' the result of the reduction.  Determine what state
     that goes to, based on the state we popped back to and the rule
     number reduced by.  */
Daniel Stenberg's avatar
Daniel Stenberg committed

  yyn = yyr1[yyn];

  yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
  if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Daniel Stenberg's avatar
Daniel Stenberg committed
    yystate = yytable[yystate];
  else
    yystate = yydefgoto[yyn - YYNTOKENS];
Daniel Stenberg's avatar
Daniel Stenberg committed

  goto yynewstate;


/*------------------------------------.
| yyerrlab -- here on detecting error |
`------------------------------------*/
yyerrlab:
  /* If not already recovering from an error, report this error.  */
  if (!yyerrstatus)
Daniel Stenberg's avatar
Daniel Stenberg committed
    {
      ++yynerrs;
Daniel Stenberg's avatar
Daniel Stenberg committed
      yyn = yypact[yystate];

      if (YYPACT_NINF < yyn && yyn < YYLAST)
Daniel Stenberg's avatar
Daniel Stenberg committed
	{
	  YYSIZE_T yysize = 0;
	  int yytype = YYTRANSLATE (yychar);
	  char *yymsg;
	  int yyx, yycount;

	  yycount = 0;
	  /* Start YYX at -YYN if negative to avoid negative indexes in
	     YYCHECK.  */
	  for (yyx = yyn < 0 ? -yyn : 0;
	       yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
	    if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
	      yysize += yystrlen (yytname[yyx]) + 15, yycount++;
	  yysize += yystrlen ("syntax error, unexpected ") + 1;
	  yysize += yystrlen (yytname[yytype]);
	  yymsg = (char *) YYSTACK_ALLOC (yysize);
	  if (yymsg != 0)
Daniel Stenberg's avatar
Daniel Stenberg committed
	    {
	      char *yyp = yystpcpy (yymsg, "syntax error, unexpected ");
	      yyp = yystpcpy (yyp, yytname[yytype]);
Daniel Stenberg's avatar
Daniel Stenberg committed

Daniel Stenberg's avatar
Daniel Stenberg committed
		{
		  yycount = 0;
		  for (yyx = yyn < 0 ? -yyn : 0;
		       yyx < (int) (sizeof (yytname) / sizeof (char *));
		       yyx++)
		    if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
Daniel Stenberg's avatar
Daniel Stenberg committed
		      {
			const char *yyq = ! yycount ? ", expecting " : " or ";
			yyp = yystpcpy (yyp, yyq);
			yyp = yystpcpy (yyp, yytname[yyx]);
			yycount++;
	      yyerror (yymsg);
	      YYSTACK_FREE (yymsg);
Daniel Stenberg's avatar
Daniel Stenberg committed
	    }
	  else
	    yyerror ("syntax error; also virtual memory exhausted");
Daniel Stenberg's avatar
Daniel Stenberg committed
	}
      else
#endif /* YYERROR_VERBOSE */
Daniel Stenberg's avatar
Daniel Stenberg committed

  if (yyerrstatus == 3)
    {
      /* If just tried and failed to reuse lookahead token after an
	 error, discard it.  */
Daniel Stenberg's avatar
Daniel Stenberg committed

      /* Return failure if at end of input.  */
Daniel Stenberg's avatar
Daniel Stenberg committed
      if (yychar == YYEOF)
        {
	  /* Pop the error token.  */
          YYPOPSTACK;
	  /* Pop the rest of the stack.  */
	  while (yyss < yyssp)
	    {
	      YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
	      yydestruct (yystos[*yyssp], yyvsp);
	      YYPOPSTACK;
	    }
	  YYABORT;
        }
Daniel Stenberg's avatar
Daniel Stenberg committed

      YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc);
      yydestruct (yytoken, &yylval);
Daniel Stenberg's avatar
Daniel Stenberg committed
      yychar = YYEMPTY;

Daniel Stenberg's avatar
Daniel Stenberg committed

  /* Else will try to reuse lookahead token after shifting the error
     token.  */
  goto yyerrlab1;
/*----------------------------------------------------.
| yyerrlab1 -- error raised explicitly by an action.  |
`----------------------------------------------------*/
yyerrlab1:
  yyerrstatus = 3;	/* Each real token shifted decrements this.  */
Daniel Stenberg's avatar
Daniel Stenberg committed

Daniel Stenberg's avatar
Daniel Stenberg committed
    {
      yyn = yypact[yystate];
      if (yyn != YYPACT_NINF)
	{
	  yyn += YYTERROR;
	  if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
	    {
	      yyn = yytable[yyn];
	      if (0 < yyn)
		break;
	    }
	}
Daniel Stenberg's avatar
Daniel Stenberg committed

      /* Pop the current state because it cannot handle the error token.  */
      if (yyssp == yyss)
	YYABORT;
Daniel Stenberg's avatar
Daniel Stenberg committed

      YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
      yydestruct (yystos[yystate], yyvsp);
      yyvsp--;
      yystate = *--yyssp;
Daniel Stenberg's avatar
Daniel Stenberg committed

      YY_STACK_PRINT (yyss, yyssp);
Daniel Stenberg's avatar
Daniel Stenberg committed
    }

  if (yyn == YYFINAL)
    YYACCEPT;

  YYDPRINTF ((stderr, "Shifting error token, "));
Daniel Stenberg's avatar
Daniel Stenberg committed

  *++yyvsp = yylval;
Daniel Stenberg's avatar
Daniel Stenberg committed

  yystate = yyn;
  goto yynewstate;
/*-------------------------------------.
| yyacceptlab -- YYACCEPT comes here.  |
`-------------------------------------*/
yyacceptlab:
  yyresult = 0;
  goto yyreturn;

/*-----------------------------------.
| yyabortlab -- YYABORT comes here.  |
`-----------------------------------*/
yyabortlab:
  yyresult = 1;
  goto yyreturn;

#ifndef yyoverflow
/*----------------------------------------------.
| yyoverflowlab -- parser overflow comes here.  |
`----------------------------------------------*/
yyoverflowlab:
  yyerror ("parser stack overflow");
  yyresult = 2;
  /* Fall through.  */
#endif

yyreturn:
#ifndef yyoverflow
  if (yyss != yyssa)
    YYSTACK_FREE (yyss);
#endif
  return yyresult;
Daniel Stenberg's avatar
Daniel Stenberg committed
}
Daniel Stenberg's avatar
Daniel Stenberg committed


/* Include this file down here because bison inserts code above which
   may define-away `const'.  We want the prototype for get_date to have
   the same signature as the function definition does. */
#include "getdate.h"

#ifndef WIN32 /* the windows dudes don't need these, does anyone really? */
extern struct tm	*gmtime (const time_t *);
extern struct tm	*localtime (const time_t *);
extern time_t		mktime (struct tm *);
Daniel Stenberg's avatar
Daniel Stenberg committed

/* Month and day table. */
static TABLE const MonthDayTable[] = {
    { "january",	tMONTH,  1 },
    { "february",	tMONTH,  2 },
    { "march",		tMONTH,  3 },
    { "april",		tMONTH,  4 },
    { "may",		tMONTH,  5 },
    { "june",		tMONTH,  6 },
    { "july",		tMONTH,  7 },
    { "august",		tMONTH,  8 },
    { "september",	tMONTH,  9 },
    { "sept",		tMONTH,  9 },
    { "october",	tMONTH, 10 },
    { "november",	tMONTH, 11 },
    { "december",	tMONTH, 12 },
    { "sunday",		tDAY, 0 },
    { "monday",		tDAY, 1 },
    { "tuesday",	tDAY, 2 },
    { "tues",		tDAY, 2 },
    { "wednesday",	tDAY, 3 },
    { "wednes",		tDAY, 3 },
    { "thursday",	tDAY, 4 },
    { "thur",		tDAY, 4 },
    { "thurs",		tDAY, 4 },
    { "friday",		tDAY, 5 },
    { "saturday",	tDAY, 6 },
    { NULL, 0, 0 }
};

/* Time units table. */
static TABLE const UnitsTable[] = {
    { "year",		tYEAR_UNIT,	1 },
    { "month",		tMONTH_UNIT,	1 },
    { "fortnight",	tDAY_UNIT,	14 },
    { "week",		tDAY_UNIT,	7 },
    { "day",		tDAY_UNIT,	1 },
    { "hour",		tHOUR_UNIT,	1 },
    { "minute",		tMINUTE_UNIT,	1 },
    { "min",		tMINUTE_UNIT,	1 },
    { "second",		tSEC_UNIT,	1 },
    { "sec",		tSEC_UNIT,	1 },
    { NULL, 0, 0 }
};

/* Assorted relative-time words. */
static TABLE const OtherTable[] = {
    { "tomorrow",	tMINUTE_UNIT,	1 * 24 * 60 },
    { "yesterday",	tMINUTE_UNIT,	-1 * 24 * 60 },
    { "today",		tMINUTE_UNIT,	0 },
    { "now",		tMINUTE_UNIT,	0 },
    { "last",		tUNUMBER,	-1 },
    { "this",		tMINUTE_UNIT,	0 },
    { "next",		tUNUMBER,	1 },
    { "first",		tUNUMBER,	1 },
/*  { "second",		tUNUMBER,	2 }, */
    { "third",		tUNUMBER,	3 },
    { "fourth",		tUNUMBER,	4 },
    { "fifth",		tUNUMBER,	5 },
    { "sixth",		tUNUMBER,	6 },
    { "seventh",	tUNUMBER,	7 },
    { "eighth",		tUNUMBER,	8 },
    { "ninth",		tUNUMBER,	9 },
    { "tenth",		tUNUMBER,	10 },
    { "eleventh",	tUNUMBER,	11 },
    { "twelfth",	tUNUMBER,	12 },
    { "ago",		tAGO,	1 },
    { NULL, 0, 0 }
};

/* The timezone table. */
static TABLE const TimezoneTable[] = {
    { "gmt",	tZONE,     HOUR ( 0) },	/* Greenwich Mean */
    { "ut",	tZONE,     HOUR ( 0) },	/* Universal (Coordinated) */
    { "utc",	tZONE,     HOUR ( 0) },
    { "wet",	tZONE,     HOUR ( 0) },	/* Western European */
    { "bst",	tDAYZONE,  HOUR ( 0) },	/* British Summer */
    { "wat",	tZONE,     HOUR ( 1) },	/* West Africa */
    { "at",	tZONE,     HOUR ( 2) },	/* Azores */
#if	0
    /* For completeness.  BST is also British Summer, and GST is
     * also Guam Standard. */
    { "bst",	tZONE,     HOUR ( 3) },	/* Brazil Standard */
    { "gst",	tZONE,     HOUR ( 3) },	/* Greenland Standard */
#endif
#if 0
    { "nft",	tZONE,     HOUR (3.5) },	/* Newfoundland */
    { "nst",	tZONE,     HOUR (3.5) },	/* Newfoundland Standard */
    { "ndt",	tDAYZONE,  HOUR (3.5) },	/* Newfoundland Daylight */
#endif
    { "ast",	tZONE,     HOUR ( 4) },	/* Atlantic Standard */
    { "adt",	tDAYZONE,  HOUR ( 4) },	/* Atlantic Daylight */
    { "est",	tZONE,     HOUR ( 5) },	/* Eastern Standard */
    { "edt",	tDAYZONE,  HOUR ( 5) },	/* Eastern Daylight */
    { "cst",	tZONE,     HOUR ( 6) },	/* Central Standard */
    { "cdt",	tDAYZONE,  HOUR ( 6) },	/* Central Daylight */
    { "mst",	tZONE,     HOUR ( 7) },	/* Mountain Standard */
    { "mdt",	tDAYZONE,  HOUR ( 7) },	/* Mountain Daylight */
    { "pst",	tZONE,     HOUR ( 8) },	/* Pacific Standard */
    { "pdt",	tDAYZONE,  HOUR ( 8) },	/* Pacific Daylight */
    { "yst",	tZONE,     HOUR ( 9) },	/* Yukon Standard */
    { "ydt",	tDAYZONE,  HOUR ( 9) },	/* Yukon Daylight */
    { "hst",	tZONE,     HOUR (10) },	/* Hawaii Standard */
    { "hdt",	tDAYZONE,  HOUR (10) },	/* Hawaii Daylight */
    { "cat",	tZONE,     HOUR (10) },	/* Central Alaska */
    { "ahst",	tZONE,     HOUR (10) },	/* Alaska-Hawaii Standard */
    { "nt",	tZONE,     HOUR (11) },	/* Nome */