📄 getdate.c
字号:
/* A Bison parser, made from getdate.y by GNU Bison version 1.28 */#define YYBISON 1 /* Identify Bison output. */#define tAGO 257#define tDAY 258#define tDAY_UNIT 259#define tDAYZONE 260#define tDST 261#define tHOUR_UNIT 262#define tID 263#define tMERIDIAN 264#define tMINUTE_UNIT 265#define tMONTH 266#define tMONTH_UNIT 267#define tSEC_UNIT 268#define tSNUMBER 269#define tUNUMBER 270#define tYEAR_UNIT 271#define tZONE 272#line 1 "getdate.y"/*** Originally written by Steven M. Bellovin <smb@research.att.com> while** at the University of North Carolina at Chapel Hill. Later tweaked by** a couple of people on Usenet. Completely overhauled by Rich $alz** <rsalz@bbn.com> and Jim Berets <jberets@bbn.com> in August, 1990.**** This code is in the public domain and has no copyright.*/#include "setup.h"# ifdef HAVE_ALLOCA_H# include <alloca.h># endif# ifdef HAVE_TIME_H# include <time.h># endif#ifndef YYDEBUG /* to satisfy gcc -Wundef, we set this to 0 */#define YYDEBUG 0#endif/* Since the code of getdate.y is not included in the Emacs executable itself, there is no need to #define static in this file. Even if the code were included in the Emacs executable, it probably wouldn't do any harm to #undef it here; this will only cause problems if we try to write to a static variable, which I don't think this code needs to do. */#ifdef emacs# undef static#endif#ifdef __APPLE__#include <sys/types.h>#include <sys/malloc.h>#else#endif#include <string.h>#include <stdio.h>#include <ctype.h>#if HAVE_STDLIB_H# include <stdlib.h> /* for `free'; used by Bison 1.27 */#else#ifdef HAVE_MALLOC_H#include <malloc.h>#endif#endif#if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII))# define IN_CTYPE_DOMAIN(c) 1#else# define IN_CTYPE_DOMAIN(c) isascii(c)#endif#define ISSPACE(c) (IN_CTYPE_DOMAIN (c) && isspace (c))#define ISALPHA(c) (IN_CTYPE_DOMAIN (c) && isalpha (c))#define ISUPPER(c) (IN_CTYPE_DOMAIN (c) && isupper (c))#define ISDIGIT_LOCALE(c) (IN_CTYPE_DOMAIN (c) && isdigit (c))/* ISDIGIT differs from ISDIGIT_LOCALE, as follows: - Its arg may be any int or unsigned int; it need not be an unsigned char. - It's guaranteed to evaluate its argument exactly once. - It's typically faster. Posix 1003.2-1992 section 2.5.2.1 page 50 lines 1556-1558 says that only '0' through '9' are digits. Prefer ISDIGIT to ISDIGIT_LOCALE unless it's important to use the locale's definition of `digit' even when the host does not conform to Posix. */#define ISDIGIT(c) ((unsigned) (c) - '0' <= 9)#if defined (STDC_HEADERS) || defined (USG)# include <string.h>#endif/* The last #include file should be: */#ifdef MALLOCDEBUG#include "memdebug.h"#endif#ifndef YYMAXDEPTH#define YYMAXDEPTH 0#endif#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)# define __attribute__(x)#endif#ifndef ATTRIBUTE_UNUSED# define ATTRIBUTE_UNUSED __attribute__ ((__unused__))#endif/* Some old versions of bison generate parsers that use bcopy. That loses on systems that don't provide the function, so we have to redefine it here. */#if !defined (HAVE_BCOPY) && defined (HAVE_MEMCPY) && !defined (bcopy)# define bcopy(from, to, len) memcpy ((to), (from), (len))#endif/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc), as well as gratuitiously global symbol names, so we can have multiple yacc generated parsers in the same program. Note that these are only the variables produced by yacc. If other parser generators (bison, byacc, etc) produce additional global names that conflict at link time, then those parser generators need to be fixed instead of adding those names to this list. */#define yymaxdepth Curl_gd_maxdepth#define yyparse Curl_gd_parse#define yylex Curl_gd_lex#define yyerror Curl_gd_error#define yylval Curl_gd_lval#define yychar Curl_gd_char#define yydebug Curl_gd_debug#define yypact Curl_gd_pact#define yyr1 Curl_gd_r1#define yyr2 Curl_gd_r2#define yydef Curl_gd_def#define yychk Curl_gd_chk#define yypgo Curl_gd_pgo#define yyact Curl_gd_act#define yyexca Curl_gd_exca#define yyerrflag Curl_gd_errflag#define yynerrs Curl_gd_nerrs#define yyps Curl_gd_ps#define yypv Curl_gd_pv#define yys Curl_gd_s#define yy_yys Curl_gd_yys#define yystate Curl_gd_state#define yytmp Curl_gd_tmp#define yyv Curl_gd_v#define yy_yyv Curl_gd_yyv#define yyval Curl_gd_val#define yylloc Curl_gd_lloc#define yyreds Curl_gd_reds /* With YYDEBUG defined */#define yytoks Curl_gd_toks /* With YYDEBUG defined */#define yylhs Curl_gd_yylhs#define yylen Curl_gd_yylen#define yydefred Curl_gd_yydefred#define yydgoto Curl_gd_yydgoto#define yysindex Curl_gd_yysindex#define yyrindex Curl_gd_yyrindex#define yygindex Curl_gd_yygindex#define yytable Curl_gd_yytable#define yycheck Curl_gd_yycheckstatic int yylex ();static int yyerror ();#define EPOCH 1970#define HOUR(x) ((x) * 60)#define MAX_BUFF_LEN 128 /* size of buffer to read the date into *//*** An entry in the lexical lookup table.*/typedef struct _TABLE { const char *name; int type; int value;} TABLE;/*** Meridian: am, pm, or 24-hour style.*/typedef enum _MERIDIAN { MERam, MERpm, MER24} MERIDIAN;/* parse results and input string */typedef struct _CURL_CONTEXT { const char *yyInput; int yyDayOrdinal; int yyDayNumber; int yyHaveDate; int yyHaveDay; int yyHaveRel; int yyHaveTime; int yyHaveZone; int yyTimezone; int yyDay; int yyHour; int yyMinutes; int yyMonth; int yySeconds; int yyYear; MERIDIAN yyMeridian; int yyRelDay; int yyRelHour; int yyRelMinutes; int yyRelMonth; int yyRelSeconds; int yyRelYear;} CURL_CONTEXT;/* enable use of extra argument to yyparse and yylex which can be used to pass** in a user defined value (CURL_CONTEXT struct in our case)*/#define YYPARSE_PARAM cookie#define YYLEX_PARAM cookie#define context ((CURL_CONTEXT *) cookie)#line 219 "getdate.y"typedef union { int Number; enum _MERIDIAN Meridian;} YYSTYPE;#include <stdio.h>#ifndef __cplusplus#ifndef __STDC__#define const#endif#endif#define YYFINAL 61#define YYFLAG -32768#define YYNTBASE 22#define YYTRANSLATE(x) ((unsigned)(x) <= 272 ? yytranslate[x] : 32)static const char yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 20, 2, 2, 21, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 19, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18};#if YYDEBUG != 0static const short yyprhs[] = { 0, 0, 1, 4, 6, 8, 10, 12, 14, 16, 19, 24, 29, 36, 43, 45, 47, 50, 52, 55, 58, 62, 68, 72, 76, 79, 84, 87, 91, 94, 96, 99, 102, 104, 107, 110, 112, 115, 118, 120, 123, 126, 128, 131, 134, 136, 139, 142, 144, 146, 147};static const short yyrhs[] = { -1, 22, 23, 0, 24, 0, 25, 0, 27, 0, 26, 0, 28, 0, 30, 0, 16, 10, 0, 16, 19, 16, 31, 0, 16, 19, 16, 15, 0, 16, 19, 16, 19, 16, 31, 0, 16, 19, 16, 19, 16, 15, 0, 18, 0, 6, 0, 18, 7, 0, 4, 0, 4, 20, 0, 16, 4, 0, 16, 21, 16, 0, 16, 21, 16, 21, 16, 0, 16, 15, 15, 0, 16, 12, 15, 0, 12, 16, 0, 12, 16, 20, 16, 0, 16, 12, 0, 16, 12, 16, 0, 29, 3, 0, 29, 0, 16, 17, 0, 15, 17, 0, 17, 0, 16, 13, 0, 15, 13, 0, 13, 0, 16, 5, 0, 15, 5, 0, 5, 0, 16, 8, 0, 15, 8, 0, 8, 0, 16, 11, 0, 15, 11, 0, 11, 0, 16, 14, 0, 15, 14, 0, 14, 0, 16, 0, 0, 10, 0};#endif#if YYDEBUG != 0static const short yyrline[] = { 0, 235, 236, 239, 242, 245, 248, 251, 254, 257, 263, 269, 278, 284, 296, 299, 302, 308, 312, 316, 322, 326, 344, 350, 356, 360, 365, 369, 376, 384, 387, 390, 393, 396, 399, 402, 405, 408, 411, 414, 417, 420, 423, 426, 429, 432, 435, 438, 443, 477, 481};#endif#if YYDEBUG != 0 || defined (YYERROR_VERBOSE)static const char * const yytname[] = { "$","error","$undefined.","tAGO","tDAY","tDAY_UNIT","tDAYZONE","tDST","tHOUR_UNIT","tID","tMERIDIAN","tMINUTE_UNIT","tMONTH","tMONTH_UNIT","tSEC_UNIT","tSNUMBER","tUNUMBER","tYEAR_UNIT","tZONE","':'","','","'/'","spec","item","time","zone","day","date","rel","relunit","number","o_merid", NULL};#endifstatic const short yyr1[] = { 0, 22, 22, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 25, 25, 25, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 30, 31, 31};static const short yyr2[] = { 0, 0, 2, 1, 1, 1, 1, 1, 1, 2, 4, 4, 6, 6, 1, 1, 2, 1, 2, 2, 3, 5, 3, 3, 2, 4, 2, 3, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 1, 0, 1};static const short yydefact[] = { 1, 0, 17, 38, 15, 41, 44, 0, 35, 47, 0, 48, 32, 14, 2, 3, 4, 6, 5, 7, 29, 8, 18, 24, 37, 40, 43, 34, 46, 31, 19, 36, 39, 9, 42, 26, 33, 45, 0, 30, 0, 0, 16, 28, 0, 23, 27, 22, 49, 20, 25, 50, 11, 0, 10, 0, 49, 21, 13, 12, 0, 0};static const short yydefgoto[] = { 1, 14, 15, 16, 17, 18, 19, 20, 21, 54};static const short yypact[] = {-32768, 0, -19,-32768,-32768,-32768,-32768, -13,-32768,-32768, 30, 15,-32768, 14,-32768,-32768,-32768,-32768,-32768,-32768, 19,-32768,-32768, 4,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, -6,-32768,-32768, 16,-32768, 17, 23,-32768,-32768, 24,-32768,-32768,-32768, 27, 28,-32768,-32768,-32768, 29,-32768, 32, -8,-32768,-32768,-32768, 50,-32768};static const short yypgoto[] = {-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, -5};#define YYLAST 51static const short yytable[] = { 60, 22, 51, 23, 2, 3, 4, 58, 5, 45, 46, 6, 7, 8, 9, 10, 11, 12, 13, 30, 31, 42, 43, 32, 44, 33, 34, 35, 36, 37, 38, 47, 39, 48, 40, 24, 41, 51, 25, 49, 50, 26, 52, 27, 28, 56, 53, 29, 57, 55, 61, 59};static const short yycheck[] = { 0, 20, 10, 16, 4, 5, 6, 15, 8, 15, 16, 11, 12, 13, 14, 15, 16, 17, 18, 4, 5, 7, 3, 8, 20, 10, 11, 12, 13, 14, 15, 15, 17, 16, 19, 5, 21, 10, 8, 16, 16, 11, 15, 13, 14, 16, 19, 17, 16, 21, 0, 56};#define YYPURE 1/* -*-C-*- Note some compilers choke on comments on `#line' lines. */#line 3 "/usr/lib/bison.simple"/* This file comes from bison-1.28. *//* Skeleton output parser for bison, Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *//* As a special exception, when this file is copied by Bison into a Bison output file, you may use that output file without restriction. This special exception was added by the Free Software Foundation in version 1.24 of Bison. *//* This is the parser code that is written into each bison parser when the %semantic_parser declaration is not specified in the grammar. It was written by Richard Stallman by simplifying the hairy parser used when %semantic_parser is specified. */#ifndef YYSTACK_USE_ALLOCA#ifdef alloca#define YYSTACK_USE_ALLOCA#else /* alloca not defined */#ifdef __GNUC__#define YYSTACK_USE_ALLOCA#define alloca __builtin_alloca#else /* not GNU C. */#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))#define YYSTACK_USE_ALLOCA#include <alloca.h>#else /* not sparc *//* We think this test detects Watcom and Microsoft C. *//* This used to test MSDOS, but that is a bad idea since that symbol is in the user namespace. */#if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)#if 0 /* No need for malloc.h, which pollutes the namespace; instead, just don't use alloca. */#include <malloc.h>#endif#else /* not MSDOS, or __TURBOC__ */#if defined(_AIX)/* I don't know what this was needed for, but it pollutes the namespace. So I turned it off. rms, 2 May 1997. *//* #include <malloc.h> */ #pragma alloca#define YYSTACK_USE_ALLOCA#else /* not MSDOS, or __TURBOC__, or _AIX */#if 0#ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up, and on HPUX 10. Eventually we can turn this on. */#define YYSTACK_USE_ALLOCA#define alloca __builtin_alloca#endif /* __hpux */#endif#endif /* not _AIX */#endif /* not MSDOS, or __TURBOC__ */#endif /* not sparc */#endif /* not GNU C */#endif /* alloca not defined */#endif /* YYSTACK_USE_ALLOCA not defined */#ifdef YYSTACK_USE_ALLOCA#define YYSTACK_ALLOC alloca#else#define YYSTACK_ALLOC malloc#endif/* Note: there must be only one dollar sign in this file. It is replaced by the list of actions, each action as one case of the switch. */#define yyerrok (yyerrstatus = 0)#define yyclearin (yychar = YYEMPTY)#define YYEMPTY -2#define YYEOF 0#define YYACCEPT goto yyacceptlab#define YYABORT goto yyabortlab#define YYERROR goto yyerrlab1/* Like YYERROR except do call yyerror. This remains here temporarily to ease the transition to the new meaning of YYERROR, for GCC. Once GCC version 2 has supplanted version 1, this can go. */#define YYFAIL goto yyerrlab#define YYRECOVERING() (!!yyerrstatus)#define YYBACKUP(token, value) \do \ if (yychar == YYEMPTY && yylen == 1) \ { yychar = (token), yylval = (value); \ yychar1 = YYTRANSLATE (yychar); \ YYPOPSTACK; \ goto yybackup; \ } \ else \ { yyerror ("syntax error: cannot back up"); YYERROR; } \while (0)#define YYTERROR 1#define YYERRCODE 256#ifndef YYPURE#define YYLEX yylex()#endif#ifdef YYPURE#ifdef YYLSP_NEEDED#ifdef YYLEX_PARAM#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)#else#define YYLEX yylex(&yylval, &yylloc)#endif#else /* not YYLSP_NEEDED */#ifdef YYLEX_PARAM#define YYLEX yylex(&yylval, YYLEX_PARAM)#else#define YYLEX yylex(&yylval)#endif#endif /* not YYLSP_NEEDED */#endif/* If nonreentrant, generate the variables here */#ifndef YYPUREint yychar; /* the lookahead symbol */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -