pl_gram.c

来自「postgresql8.3.4源码,开源数据库」· C语言 代码 · 共 2,193 行 · 第 1/5 页

C
2,193
字号
/* A Bison parser, made by GNU Bison 1.875.  *//* Skeleton parser for Yacc-like parsing with Bison,   Copyright (C) 1984, 1989, 1990, 2000, 2001, 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.  *//* 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/* If NAME_PREFIX is specified substitute the variables and functions   names.  */#define yyparse plpgsql_yyparse#define yylex   plpgsql_yylex#define yyerror plpgsql_yyerror#define yylval  plpgsql_yylval#define yychar  plpgsql_yychar#define yydebug plpgsql_yydebug#define yynerrs plpgsql_yynerrs/* Tokens.  */#ifndef YYTOKENTYPE# define YYTOKENTYPE   /* Put the tokens into the symbol table, so that GDB and other debuggers      know about them.  */   enum yytokentype {     K_ALIAS = 258,     K_ASSIGN = 259,     K_BEGIN = 260,     K_BY = 261,     K_CLOSE = 262,     K_CONSTANT = 263,     K_CONTINUE = 264,     K_CURSOR = 265,     K_DEBUG = 266,     K_DECLARE = 267,     K_DEFAULT = 268,     K_DIAGNOSTICS = 269,     K_DOTDOT = 270,     K_ELSE = 271,     K_ELSIF = 272,     K_END = 273,     K_EXCEPTION = 274,     K_EXECUTE = 275,     K_EXIT = 276,     K_FOR = 277,     K_FETCH = 278,     K_FROM = 279,     K_GET = 280,     K_IF = 281,     K_IN = 282,     K_INFO = 283,     K_INSERT = 284,     K_INTO = 285,     K_IS = 286,     K_LOG = 287,     K_LOOP = 288,     K_MOVE = 289,     K_NOSCROLL = 290,     K_NOT = 291,     K_NOTICE = 292,     K_NULL = 293,     K_OPEN = 294,     K_OR = 295,     K_PERFORM = 296,     K_ROW_COUNT = 297,     K_RAISE = 298,     K_RENAME = 299,     K_RESULT_OID = 300,     K_RETURN = 301,     K_REVERSE = 302,     K_SCROLL = 303,     K_STRICT = 304,     K_THEN = 305,     K_TO = 306,     K_TYPE = 307,     K_WARNING = 308,     K_WHEN = 309,     K_WHILE = 310,     T_FUNCTION = 311,     T_TRIGGER = 312,     T_STRING = 313,     T_NUMBER = 314,     T_SCALAR = 315,     T_ROW = 316,     T_RECORD = 317,     T_DTYPE = 318,     T_WORD = 319,     T_ERROR = 320,     O_OPTION = 321,     O_DUMP = 322   };#endif#define K_ALIAS 258#define K_ASSIGN 259#define K_BEGIN 260#define K_BY 261#define K_CLOSE 262#define K_CONSTANT 263#define K_CONTINUE 264#define K_CURSOR 265#define K_DEBUG 266#define K_DECLARE 267#define K_DEFAULT 268#define K_DIAGNOSTICS 269#define K_DOTDOT 270#define K_ELSE 271#define K_ELSIF 272#define K_END 273#define K_EXCEPTION 274#define K_EXECUTE 275#define K_EXIT 276#define K_FOR 277#define K_FETCH 278#define K_FROM 279#define K_GET 280#define K_IF 281#define K_IN 282#define K_INFO 283#define K_INSERT 284#define K_INTO 285#define K_IS 286#define K_LOG 287#define K_LOOP 288#define K_MOVE 289#define K_NOSCROLL 290#define K_NOT 291#define K_NOTICE 292#define K_NULL 293#define K_OPEN 294#define K_OR 295#define K_PERFORM 296#define K_ROW_COUNT 297#define K_RAISE 298#define K_RENAME 299#define K_RESULT_OID 300#define K_RETURN 301#define K_REVERSE 302#define K_SCROLL 303#define K_STRICT 304#define K_THEN 305#define K_TO 306#define K_TYPE 307#define K_WARNING 308#define K_WHEN 309#define K_WHILE 310#define T_FUNCTION 311#define T_TRIGGER 312#define T_STRING 313#define T_NUMBER 314#define T_SCALAR 315#define T_ROW 316#define T_RECORD 317#define T_DTYPE 318#define T_WORD 319#define T_ERROR 320#define O_OPTION 321#define O_DUMP 322/* Copy the first part of user declarations.  */#line 1 "gram.y"/*------------------------------------------------------------------------- * * gram.y				- Parser for the PL/pgSQL *						  procedural language * * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * * IDENTIFICATION *	  $PostgreSQL: pgsql/src/pl/plpgsql/src/gram.y,v 1.108 2008/01/01 19:46:00 momjian Exp $ * *------------------------------------------------------------------------- */#include "plpgsql.h"#include "parser/parser.h"static PLpgSQL_expr		*read_sql_construct(int until,											int until2,											const char *expected,											const char *sqlstart,											bool isexpression,											bool valid_sql,											int *endtoken);static	PLpgSQL_expr	*read_sql_stmt(const char *sqlstart);static	PLpgSQL_type	*read_datatype(int tok);static	PLpgSQL_stmt	*make_execsql_stmt(const char *sqlstart, int lineno);static	PLpgSQL_stmt_fetch *read_fetch_direction(void);static	PLpgSQL_stmt	*make_return_stmt(int lineno);static	PLpgSQL_stmt	*make_return_next_stmt(int lineno);static	PLpgSQL_stmt	*make_return_query_stmt(int lineno);static	void			 check_assignable(PLpgSQL_datum *datum);static	void			 read_into_target(PLpgSQL_rec **rec, PLpgSQL_row **row,										  bool *strict);static	PLpgSQL_row		*read_into_scalar_list(const char *initial_name,											   PLpgSQL_datum *initial_datum);static PLpgSQL_row		*make_scalar_list1(const char *initial_name,										   PLpgSQL_datum *initial_datum,										   int lineno);static	void			 check_sql_expr(const char *stmt);static	void			 plpgsql_sql_error_callback(void *arg);static	char			*check_label(const char *yytxt);static	void			 check_labels(const char *start_label,									  const char *end_label);/* 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 54 "gram.y"typedef union YYSTYPE {		int32					ival;		bool					boolean;		char					*str;		struct		{			char *name;			int  lineno;		}						varname;		struct		{			char *name;			int  lineno;			PLpgSQL_datum   *scalar;			PLpgSQL_rec     *rec;			PLpgSQL_row     *row;		}						forvariable;		struct		{			char *label;			int  n_initvars;			int  *initvarnos;		}						declhdr;		struct		{			char *end_label;			List *stmts;		}						loop_body;		List					*list;		PLpgSQL_type			*dtype;		PLpgSQL_datum			*scalar;	/* a VAR, RECFIELD, or TRIGARG */		PLpgSQL_variable		*variable;	/* a VAR, REC, or ROW */		PLpgSQL_var				*var;		PLpgSQL_row				*row;		PLpgSQL_rec				*rec;		PLpgSQL_expr			*expr;		PLpgSQL_stmt			*stmt;		PLpgSQL_stmt_block		*program;		PLpgSQL_condition		*condition;		PLpgSQL_exception		*exception;		PLpgSQL_exception_block	*exception_block;		PLpgSQL_nsitem			*nsitem;		PLpgSQL_diag_item		*diagitem;		PLpgSQL_stmt_fetch		*fetch;} YYSTYPE;/* Line 186 of yacc.c.  */#line 315 "y.tab.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 327 "y.tab.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  9/* YYLAST -- Last index in YYTABLE.  */#define YYLAST   335/* YYNTOKENS -- Number of terminals. */#define YYNTOKENS  75/* YYNNTS -- Number of nonterminals. */#define YYNNTS  77/* YYNRULES -- Number of rules. */#define YYNRULES  144/* YYNRULES -- Number of states. */#define YYNSTATES  241/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */#define YYUNDEFTOK  2#define YYMAXUTOK   322

⌨️ 快捷键说明

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