imp.c

来自「db.* (pronounced dee-be star) is an adva」· C语言 代码 · 共 1,636 行 · 第 1/3 页

C
1,636
字号
/* A Bison parser, made by GNU Bison 1.875c.  *//* 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 0/* 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 {     T_DATABASE = 258,     T_FOR = 259,     T_ON = 260,     T_FIELD = 261,     T_CONNECT = 262,     T_END = 263,     T_RECORD = 264,     T_CREATE = 265,     T_UPDATE = 266,     T_FIND = 267,     T_NUMBER = 268,     T_IDENT = 269,     T_STRING = 270   };#endif#define T_DATABASE 258#define T_FOR 259#define T_ON 260#define T_FIELD 261#define T_CONNECT 262#define T_END 263#define T_RECORD 264#define T_CREATE 265#define T_UPDATE 266#define T_FIND 267#define T_NUMBER 268#define T_IDENT 269#define T_STRING 270/* Copy the first part of user declarations.  */#line 1 "imp.y"/*************************************************************************** *                                                                         * * db.*                                                                    * * open source database, dbimp utility                                     * *                                                                         * * Copyright (c) 2000 Centura Software Corporation. All rights reserved.   * *                                                                         * * Use of this software, whether in source code format, or in executable,  * * binary object code form, is governed by the CENTURA OPEN SOURCE LICENSE * * which is fully described in the LICENSE.TXT file, included within this  * * distribution of source code files.                                      *  *                                                                         * **************************************************************************/#include "db.star.h"#include "impdef.h"#include "parser.h"#include "impvar.h"#if defined(UNICODE)#define yyerror(s) yyerror(L ## s)#endif#define DBIMP#include "getnames.h"static int dim[2][MAXDIMS];static int dims[2];static int fsinit;/* Integer to string conversion */char *itos();/* 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 38 "imp.y"typedef union YYSTYPE {    STRTOK tstr;     NUMTOK tnum;} YYSTYPE;/* Line 191 of yacc.c.  */#line 146 "imp.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 158 "imp.c"#if ! defined (yyoverflow) || YYERROR_VERBOSE# ifndef YYFREE#  define YYFREE free# endif# ifndef YYMALLOC#  define YYMALLOC malloc# endif/* The parser invokes alloca or malloc; define the necessary symbols.  */# ifdef YYSTACK_USE_ALLOCA#  if YYSTACK_USE_ALLOCA#   define YYSTACK_ALLOC alloca#  endif# else#  if defined (alloca) || defined (_ALLOCA_H)#   define YYSTACK_ALLOC alloca#  else#   ifdef __GNUC__#    define YYSTACK_ALLOC __builtin_alloca#   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 YYMALLOC#  define YYSTACK_FREE YYFREE# endif#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */#if (! defined (yyoverflow) \     && (! defined (__cplusplus) \	 || (defined (YYSTYPE_IS_TRIVIAL) && 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 defined (__GNUC__) && 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  5/* YYLAST -- Last index in YYTABLE.  */#define YYLAST   70/* YYNTOKENS -- Number of terminals. */#define YYNTOKENS  24/* YYNNTS -- Number of nonterminals. */#define YYNNTS  29/* YYNRULES -- Number of rules. */#define YYNRULES  49/* YYNRULES -- Number of states. */#define YYNSTATES  88/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */#define YYUNDEFTOK  2#define YYMAXUTOK   270#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,    19,     2,    21,     2,     2,     2,       2,     2,     2,     2,     2,     2,     2,     2,     2,    18,       2,    20,     2,     2,     2,     2,     2,     2,     2,     2,       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,       2,    22,     2,    23,     2,     2,     2,     2,     2,     2,       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,       2,     2,     2,    16,     2,    17,     2,     2,     2,     2,       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,       2,     2,     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};#if YYDEBUG/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in   YYRHS.  */static const unsigned char yyprhs[] ={       0,     0,     3,     7,    11,    13,    15,    17,    20,    24,      28,    32,    34,    37,    39,    41,    43,    48,    52,    56,      60,    61,    63,    65,    67,    72,    77,    82,    84,    86,      89,    90,    92,    95,   101,   105,   109,   116,   117,   119,     122,   123,   125,   128,   132,   134,   138,   142,   146,   148};/* YYRHS -- A `-1'-separated list of the rules' RHS. */static const yysigned_char yyrhs[] ={      25,     0,    -1,    26,    28,    52,    -1,     3,    14,    27,      -1,    16,    -1,    18,    -1,    29,    -1,    28,    29,    -1,      30,    31,    17,    -1,    30,     1,    17,    -1,     4,    15,      16,    -1,    32,    -1,    31,    32,    -1,    29,    -1,    33,      -1,    51,    -1,    34,    35,    40,    17,    -1,     9,     1,      17,    -1,     9,    14,    16,    -1,     9,     1,    16,    -1,      -1,    36,    -1,    37,    -1,    38,    -1,    11,     5,    39,      18,    -1,    10,     5,    39,    18,    -1,    12,     5,    39,      18,    -1,    13,    -1,    41,    -1,    41,    42,    -1,    -1,      43,    -1,    43,    42,    -1,     6,    44,    20,    50,    18,      -1,     6,     1,    18,    -1,    45,    14,    46,    -1,    45,      14,    46,    21,    14,    46,    -1,    -1,    47,    -1,    47,      48,    -1,    -1,    49,    -1,    48,    49,    -1,    22,    13,      23,    -1,    13,    -1,    15,    21,    13,    -1,     7,    14,      18,    -1,     7,     1,    18,    -1,    17,    -1,     8,    18,      -1};/* YYRLINE[YYN] -- source line where rule number YYN was defined.  */static const unsigned short yyrline[] ={       0,    55,    55,    57,    82,    83,    85,    86,    88,   100,     105,   131,   132,   134,   135,   136,   138,   173,   178,   184,     190,   191,   193,   195,   198,   200,   202,   204,   212,   213,     216,   220,   221,   223,   228,   233,   240,   249,   253,   254,     257,   264,   265,   267,   275,   281,   288,   307,   312,   316};#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[] ={  "$end", "error", "$undefined", "T_DATABASE", "T_FOR", "T_ON", "T_FIELD",  "T_CONNECT", "T_END", "T_RECORD", "T_CREATE", "T_UPDATE", "T_FIND",  "T_NUMBER", "T_IDENT", "T_STRING", "'{'", "'}'", "';'", "','", "'='",  "'.'", "'['", "']'", "$accept", "import_spec", "db_spec", "open_mark",  "for_loops", "for_loop", "for_id", "stmts", "stmt", "record_spec",  "rec_id", "handling", "update_def", "create_def", "find_def", "key_spec",  "field_defs", "field_init", "fields", "field_def", "field_spec",  "fsinit", "subscripts", "subinit", "ss", "subscript", "line_spec",  "connect_spec", "close_mark", 0};#endif# ifdef YYPRINT/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to   token YYLEX-NUM.  */static const unsigned short yytoknum[] ={       0,   256,   257,   258,   259,   260,   261,   262,   263,   264,     265,   266,   267,   268,   269,   270,   123,   125,    59,    44,      61,    46,    91,    93};# endif/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */static const unsigned char yyr1[] ={       0,    24,    25,    26,    27,    27,    28,    28,    29,    29,      30,    31,    31,    32,    32,    32,    33,    33,    34,    34,      35,    35,    35,    35,    36,    37,    38,    39,    40,    40,      41,    42,    42,    43,    43,    44,    44,    45,    46,    46,      47,    48,    48,    49,    50,    50,    51,    51,    52,    52};/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */static const unsigned char yyr2[] ={       0,     2,     3,     3,     1,     1,     1,     2,     3,     3,       3,     1,     2,     1,     1,     1,     4,     3,     3,     3,       0,     1,     1,     1,     4,     4,     4,     1,     1,     2,       0,     1,     2,     5,     3,     3,     6,     0,     1,     2,       0,     1,     2,     3,     1,     3,     3,     3,     1,     2};/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state   STATE-NUM when YYTABLE doesn't specify something else to do.  Zero   means the default is an error.  */static const unsigned char yydefact[] ={       0,     0,     0,     0,     0,     1,     0,     0,     6,     0,       4,     5,     3,     0,     0,    48,     7,     2,     0,     0,       0,    13,     0,    11,    14,    20,    15,    10,    49,     9,       0,     0,     0,     0,     8,    12,     0,     0,     0,    30,      21,    22,    23,    47,    46,    19,    17,    18,     0,     0,       0,     0,    28,    27,     0,     0,     0,    16,     0,    29,      31,    25,    24,    26,     0,     0,     0,    32,    34,     0,      40,    44,     0,     0,    35,    38,     0,    33,     0,     0,      39,    41,    45,    40,     0,    42,    36,    43};/* YYDEFGOTO[NTERM-NUM]. */static const yysigned_char yydefgoto[] ={      -1,     2,     3,    12,     7,    21,     9,    22,    23,    24,      25,    39,    40,    41,    42,    54,    51,    52,    59,    60,      65,    66,    74,    75,    80,    81,    73,    26,    17};/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing   STATE-NUM.  */#define YYPACT_NINF -34static const yysigned_char yypact[] ={      18,     4,    27,    25,     7,   -34,    19,    -2,   -34,    15,     -34,   -34,   -34,    20,    17,   -34,   -34,   -34,    21,     0,       3,   -34,    -4,   -34,   -34,    -1,   -34,   -34,   -34,   -34,      22,    23,    14,    26,   -34,   -34,    32,    34,    38,   -34,     -34,   -34,   -34,   -34,   -34,   -34,   -34,   -34,    31,    31,      31,    28,    40,   -34,    29,    30,    33,   -34,     6,   -34,      40,   -34,   -34,   -34,    35,    36,    41,   -34,   -34,    13,     -34,   -34,    37,    39,    42,    43,    46,   -34,    47,    49,      43,   -34,   -34,   -34,    44,   -34,   -34,   -34};/* YYPGOTO[NTERM-NUM].  */static const yysigned_char yypgoto[] ={     -34,   -34,   -34,   -34,   -34,     5,   -34,   -34,    48,   -34,     -34,   -34,   -34,   -34,   -34,   -17,   -34,   -34,   -11,   -34,     -34,   -34,   -33,   -34,   -34,   -28,   -34,   -34,   -34};/* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If   positive, shift that token.  If negative, reduce the rule which   number is the opposite.  If zero, do what YYDEFACT says.   If YYTABLE_NINF, syntax error.  */#define YYTABLE_NINF -38static const yysigned_char yytable[] ={       6,    30,     6,    19,    32,    20,    14,    64,     8,    36,      37,    38,    16,    34,    31,    15,    18,    33,     4,     6,     -37,     1,    19,    10,    20,    11,    71,     5,    72,     6,      45,    46,    55,    56,    13,    28,    27,    48,    29,    49,      43,    44,    47,    50,    53,    57,    58,    61,    62,    67,      86,    63,    85,    68,     0,    70,    69,    77,    76,    82,       0,    83,    84,    78,     0,    79,     0,    87,     0,     0,      35};static const yysigned_char yycheck[] ={       4,     1,     4,     7,     1,     9,     8,     1,     3,    10,      11,    12,     7,    17,    14,    17,     1,    14,    14,     4,      14,     3,     7,    16,     9,    18,    13,     0,    15,     4,      16,    17,    49,    50,    15,    18,    16,     5,    17,     5,      18,    18,    16,     5,    13,    17,     6,    18,    18,    60,      83,    18,    80,    18,    -1,    14,    20,    18,    21,    13,      -1,    14,    13,    21,    -1,    22,    -1,    23,    -1,    -1,      22};/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing   symbol of state STATE-NUM.  */static const unsigned char yystos[] ={       0,     3,    25,    26,    14,     0,     4,    28,    29,    30,      16,    18,    27,    15,     8,    17,    29,    52,     1,     7,       9,    29,    31,    32,    33,    34,    51,    16,    18,    17,       1,    14,     1,    14,    17,    32,    10,    11,    12,    35,      36,    37,    38,    18,    18,    16,    17,    16,     5,     5,       5,    40,    41,    13,    39,    39,    39,    17,     6,    42,      43,    18,    18,    18,     1,    44,    45,    42,    18,    20,      14,    13,    15,    50,    46,    47,    21,    18,    21,    22,      48,    49,    13,    14,    13,    49,    46,    23};#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)# define YYSIZE_T __SIZE_TYPE__#endif#if ! defined (YYSIZE_T) && defined (size_t)# define YYSIZE_T size_t#endif#if ! defined (YYSIZE_T)# if defined (__STDC__) || defined (__cplusplus)#  include <stddef.h> /* INFRINGES ON USER NAME SPACE */#  define YYSIZE_T size_t# endif#endif#if ! defined (YYSIZE_T)# define YYSIZE_T unsigned int#endif#define yyerrok		(yyerrstatus = 0)#define yyclearin	(yychar = YYEMPTY)#define YYEMPTY		(-2)#define YYEOF		0#define YYACCEPT	goto yyacceptlab#define YYABORT		goto yyabortlab#define YYERROR		goto yyerrorlab/* 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);						\      yytoken = YYTRANSLATE (yychar);				\      YYPOPSTACK;						\      goto yybackup;						\    }								\  else								\    { 								\      yyerror ("syntax error: cannot back up");\      YYERROR;							\    }								\

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?