📄 getdate.c
字号:
/* A Bison parser, made by GNU Bison 1.875a. *//* Skeleton parser for Yacc-like parsing with Bison, Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 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. *//* Written by Richard Stallman by simplifying the original so called ``semantic'' parser. *//* All symbols defined below should begin with yy or YY, to avoid infringing on user name space. This should be done even for local variables, as they might otherwise be expanded by user macros. There are some unavoidable exceptions within include files to define necessary library symbols; they are noted "INFRINGES ON USER NAME SPACE" below. *//* Identify Bison output. */#define YYBISON 1/* Skeleton name. */#define YYSKELETON_NAME "yacc.c"/* Pure parsers. */#define YYPURE 1/* Using locations. */#define YYLSP_NEEDED 0/* Tokens. */#ifndef YYTOKENTYPE# define YYTOKENTYPE /* Put the tokens into the symbol table, so that GDB and other debuggers know about them. */ enum yytokentype { tAGO = 258, tDST = 259, tDAY = 260, tDAY_UNIT = 261, tDAYZONE = 262, tHOUR_UNIT = 263, tLOCAL_ZONE = 264, tMERIDIAN = 265, tMINUTE_UNIT = 266, tMONTH = 267, tMONTH_UNIT = 268, tSEC_UNIT = 269, tYEAR_UNIT = 270, tZONE = 271, tSNUMBER = 272, tUNUMBER = 273 };#endif#define tAGO 258#define tDST 259#define tDAY 260#define tDAY_UNIT 261#define tDAYZONE 262#define tHOUR_UNIT 263#define tLOCAL_ZONE 264#define tMERIDIAN 265#define tMINUTE_UNIT 266#define tMONTH 267#define tMONTH_UNIT 268#define tSEC_UNIT 269#define tYEAR_UNIT 270#define tZONE 271#define tSNUMBER 272#define tUNUMBER 273/* Copy the first part of user declarations. */#line 1 "getdate.y"/* Parse a string into an internal time stamp. Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *//* 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. Modified by Paul Eggert <eggert@twinsun.com> in August 1999 to do the right thing about local DST. Unlike previous versions, this version is reentrant. */#ifdef HAVE_CONFIG_H# include <config.h># ifdef HAVE_ALLOCA_H# include <alloca.h># endif#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#include <ctype.h>#include <string.h>#if HAVE_STDLIB_H# include <stdlib.h> /* for `free'; used by Bison 1.27 */#endif#if STDC_HEADERS || (! defined isascii && ! 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 ISLOWER(c) (IN_CTYPE_DOMAIN (c) && islower (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 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 STDC_HEADERS || HAVE_STRING_H# include <string.h>#endif#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) || __STRICT_ANSI__# define __attribute__(x)#endif#ifndef ATTRIBUTE_UNUSED# define ATTRIBUTE_UNUSED __attribute__ ((__unused__))#endif#define EPOCH_YEAR 1970#define TM_YEAR_BASE 1900#define HOUR(x) ((x) * 60)/* An integer value, and the number of digits in its textual representation. */typedef struct{ int value; int digits;} textint;/* An entry in the lexical lookup table. */typedef struct{ char const *name; int type; int value;} table;/* Meridian: am, pm, or 24-hour style. */enum { MERam, MERpm, MER24 };/* Information passed to and from the parser. */typedef struct{ /* The input string remaining to be parsed. */ const char *input; /* N, if this is the Nth Tuesday. */ int day_ordinal; /* Day of week; Sunday is 0. */ int day_number; /* tm_isdst flag for the local zone. */ int local_isdst; /* Time zone, in minutes east of UTC. */ int time_zone; /* Style used for time. */ int meridian; /* Gregorian year, month, day, hour, minutes, and seconds. */ textint year; int month; int day; int hour; int minutes; int seconds; /* Relative year, month, day, hour, minutes, and seconds. */ int rel_year; int rel_month; int rel_day; int rel_hour; int rel_minutes; int rel_seconds; /* Counts of nonterminals of various flavors parsed so far. */ int dates_seen; int days_seen; int local_zones_seen; int rels_seen; int times_seen; int zones_seen; /* Table of local time zone abbrevations, terminated by a null entry. */ table local_time_zone_table[3];} parser_control;#define PC (* (parser_control *) parm)#define YYLEX_PARAM parm#define YYPARSE_PARAM parmstatic int yyerror ();static int yylex ();/* Enabling traces. */#ifndef YYDEBUG# define YYDEBUG 0#endif/* Enabling verbose error messages. */#ifdef YYERROR_VERBOSE# undef YYERROR_VERBOSE# define YYERROR_VERBOSE 1#else# define YYERROR_VERBOSE 0#endif#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)#line 172 "getdate.y"typedef union YYSTYPE { int intval; textint textintval;} YYSTYPE;/* Line 191 of yacc.c. */#line 281 "getdate.c"# define yystype YYSTYPE /* obsolescent; will be withdrawn */# define YYSTYPE_IS_DECLARED 1# define YYSTYPE_IS_TRIVIAL 1#endif/* Copy the second part of user declarations. *//* Line 214 of yacc.c. */#line 293 "getdate.c"#if ! defined (yyoverflow) || YYERROR_VERBOSE/* The parser invokes alloca or malloc; define the necessary symbols. */# if YYSTACK_USE_ALLOCA# define YYSTACK_ALLOC alloca# else# ifndef YYSTACK_USE_ALLOCA# if defined (alloca) || defined (_ALLOCA_H)# define YYSTACK_ALLOC alloca# else# ifdef __GNUC__# define YYSTACK_ALLOC __builtin_alloca# endif# endif# endif# endif# ifdef YYSTACK_ALLOC /* Pacify GCC's `empty if-body' warning. */# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)# else# if defined (__STDC__) || defined (__cplusplus)# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */# define YYSIZE_T size_t# endif# define YYSTACK_ALLOC malloc# define YYSTACK_FREE free# endif#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */#if (! defined (yyoverflow) \ && (! defined (__cplusplus) \ || (YYSTYPE_IS_TRIVIAL)))/* A type that is properly aligned for any stack member. */union yyalloc{ short yyss; YYSTYPE yyvs; };/* The size of the maximum gap between one aligned stack and the next. */# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)/* The size of an array large to enough to hold all stacks, each with N elements. */# define YYSTACK_BYTES(N) \ ((N) * (sizeof (short) + sizeof (YYSTYPE)) \ + YYSTACK_GAP_MAXIMUM)/* Copy COUNT objects from FROM to TO. The source and destination do not overlap. */# ifndef YYCOPY# if 1 < __GNUC__# define YYCOPY(To, From, Count) \ __builtin_memcpy (To, From, (Count) * sizeof (*(From)))# else# define YYCOPY(To, From, Count) \ do \ { \ register YYSIZE_T yyi; \ for (yyi = 0; yyi < (Count); yyi++) \ (To)[yyi] = (From)[yyi]; \ } \ while (0)# endif# endif/* Relocate STACK from its old location to the new one. The local variables YYSIZE and YYSTACKSIZE give the old and new number of elements in the stack, and YYPTR gives the new location of the stack. Advance YYPTR to a properly aligned location for the next stack. */# define YYSTACK_RELOCATE(Stack) \ do \ { \ YYSIZE_T yynewbytes; \ YYCOPY (&yyptr->Stack, Stack, yysize); \ Stack = &yyptr->Stack; \ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ yyptr += yynewbytes / sizeof (*yyptr); \ } \ while (0)#endif#if defined (__STDC__) || defined (__cplusplus) typedef signed char yysigned_char;#else typedef short yysigned_char;#endif/* YYFINAL -- State number of the termination state. */#define YYFINAL 2/* YYLAST -- Last index in YYTABLE. */#define YYLAST 52/* YYNTOKENS -- Number of terminals. */#define YYNTOKENS 22/* YYNNTS -- Number of nonterminals. */#define YYNNTS 12/* YYNRULES -- Number of rules. */#define YYNRULES 54/* YYNRULES -- Number of states. */#define YYNSTATES 64/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */#define YYUNDEFTOK 2#define YYMAXUTOK 273#define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */static const unsigned 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, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18};#if YYDEBUG/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in YYRHS. */static const unsigned char yyprhs[] ={ 0, 0, 3, 4, 7, 9, 11, 13, 15, 17, 19, 21, 24, 29, 34, 41, 48, 50, 53, 55, 57, 60, 62, 65, 68, 72, 78, 82, 86, 89, 94, 97, 101, 104, 106, 109, 112, 114, 117, 120, 122, 125, 128, 130, 133, 136, 138, 141, 144, 146, 149, 152, 154, 156, 157};/* YYRHS -- A `-1'-separated list of the rules' RHS. */static const yysigned_char yyrhs[] ={ 23, 0, -1, -1, 23, 24, -1, 25, -1, 26, -1, 27, -1, 29, -1, 28, -1, 30, -1, 32, -1, 18, 10, -1, 18, 19, 18, 33, -1, 18, 19, 18, 17, -1, 18, 19, 18, 19, 18, 33, -1, 18, 19, 18, 19, 18, 17, -1, 9, -1, 9, 4, -1, 16, -1, 7, -1, 16, 4, -1, 5, -1, 5, 20, -1, 18, 5, -1, 18, 21, 18, -1, 18, 21, 18, 21, 18, -1, 18, 17, 17, -1, 18, 12, 17, -1, 12, 18, -1, 12, 18, 20, 18, -1, 18, 12, -1, 18, 12, 18, -1, 31, 3, -1, 31, -1, 18, 15, -1, 17, 15, -1, 15, -1, 18, 13, -1, 17, 13, -1, 13, -1, 18, 6, -1, 17, 6, -1, 6, -1, 18, 8, -1, 17, 8, -1, 8, -1, 18, 11, -1, 17, 11, -1, 11, -1, 18, 14, -1, 17, 14, -1, 14, -1, 18, -1, -1, 10, -1};/* YYRLINE[YYN] -- source line where rule number YYN was defined. */static const unsigned short yyrline[] ={ 0, 188, 188, 190, 194, 196, 198, 200, 202, 204, 206, 210, 217, 224, 232, 239, 251, 253, 258, 260, 262, 267, 272, 277, 285, 290, 310, 317, 325, 330, 336, 341, 350, 359, 363, 365, 367, 369, 371, 373, 375, 377, 379, 381, 383, 385, 387, 389, 391, 393, 395, 397, 402, 439, 440};#endif#if YYDEBUG || YYERROR_VERBOSE/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. First, the terminals, then, starting at YYNTOKENS, nonterminals. */static const char *const yytname[] ={
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -