⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pl_gram.c

📁 PostgreSQL7.4.6 for Linux
💻 C
📖 第 1 页 / 共 5 页
字号:
`----------*/#ifdef PLPGSQL_YYPARSE_PARAM# if defined (__STDC__) || defined (__cplusplus)int plpgsql_yyparse (void *PLPGSQL_YYPARSE_PARAM)# elseint plpgsql_yyparse (PLPGSQL_YYPARSE_PARAM)  void *PLPGSQL_YYPARSE_PARAM;# endif#else /* ! PLPGSQL_YYPARSE_PARAM */#if defined (__STDC__) || defined (__cplusplus)intplpgsql_yyparse (void)#elseintplpgsql_yyparse ()#endif#endif{    register int plpgsql_yystate;  register int plpgsql_yyn;  int plpgsql_yyresult;  /* Number of tokens to shift before error messages enabled.  */  int plpgsql_yyerrstatus;  /* Lookahead token as an internal (translated) token number.  */  int plpgsql_yytoken = 0;  /* Three stacks and their tools:     `plpgsql_yyss': related to states,     `plpgsql_yyvs': related to semantic values,     `plpgsql_yyls': related to locations.     Refer to the stacks thru separate pointers, to allow plpgsql_yyoverflow     to reallocate them elsewhere.  */  /* The state stack.  */  short	plpgsql_yyssa[PLPGSQL_YYINITDEPTH];  short *plpgsql_yyss = plpgsql_yyssa;  register short *plpgsql_yyssp;  /* The semantic value stack.  */  PLPGSQL_YYSTYPE plpgsql_yyvsa[PLPGSQL_YYINITDEPTH];  PLPGSQL_YYSTYPE *plpgsql_yyvs = plpgsql_yyvsa;  register PLPGSQL_YYSTYPE *plpgsql_yyvsp;#define PLPGSQL_YYPOPSTACK   (plpgsql_yyvsp--, plpgsql_yyssp--)  PLPGSQL_YYSIZE_T plpgsql_yystacksize = PLPGSQL_YYINITDEPTH;  /* The variables used to return semantic value and location from the     action routines.  */  PLPGSQL_YYSTYPE plpgsql_yyval;  /* When reducing, the number of symbols on the RHS of the reduced     rule.  */  int plpgsql_yylen;  PLPGSQL_YYDPRINTF ((stderr, "Starting parse\n"));  plpgsql_yystate = 0;  plpgsql_yyerrstatus = 0;  plpgsql_yynerrs = 0;  plpgsql_yychar = PLPGSQL_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.  */  plpgsql_yyssp = plpgsql_yyss;  plpgsql_yyvsp = plpgsql_yyvs;  goto plpgsql_yysetstate;/*------------------------------------------------------------.| plpgsql_yynewstate -- Push a new state, which is found in plpgsql_yystate.  |`------------------------------------------------------------*/ plpgsql_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.     */  plpgsql_yyssp++; plpgsql_yysetstate:  *plpgsql_yyssp = plpgsql_yystate;  if (plpgsql_yyss + plpgsql_yystacksize - 1 <= plpgsql_yyssp)    {      /* Get the current used size of the three stacks, in elements.  */      PLPGSQL_YYSIZE_T plpgsql_yysize = plpgsql_yyssp - plpgsql_yyss + 1;#ifdef plpgsql_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.  */	PLPGSQL_YYSTYPE *plpgsql_yyvs1 = plpgsql_yyvs;	short *plpgsql_yyss1 = plpgsql_yyss;	/* 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 plpgsql_yyoverflow is a macro.  */	plpgsql_yyoverflow ("parser stack overflow",		    &plpgsql_yyss1, plpgsql_yysize * sizeof (*plpgsql_yyssp),		    &plpgsql_yyvs1, plpgsql_yysize * sizeof (*plpgsql_yyvsp),		    &plpgsql_yystacksize);	plpgsql_yyss = plpgsql_yyss1;	plpgsql_yyvs = plpgsql_yyvs1;      }#else /* no plpgsql_yyoverflow */# ifndef PLPGSQL_YYSTACK_RELOCATE      goto plpgsql_yyoverflowlab;# else      /* Extend the stack our own way.  */      if (PLPGSQL_YYMAXDEPTH <= plpgsql_yystacksize)	goto plpgsql_yyoverflowlab;      plpgsql_yystacksize *= 2;      if (PLPGSQL_YYMAXDEPTH < plpgsql_yystacksize)	plpgsql_yystacksize = PLPGSQL_YYMAXDEPTH;      {	short *plpgsql_yyss1 = plpgsql_yyss;	union plpgsql_yyalloc *plpgsql_yyptr =	  (union plpgsql_yyalloc *) PLPGSQL_YYSTACK_ALLOC (PLPGSQL_YYSTACK_BYTES (plpgsql_yystacksize));	if (! plpgsql_yyptr)	  goto plpgsql_yyoverflowlab;	PLPGSQL_YYSTACK_RELOCATE (plpgsql_yyss);	PLPGSQL_YYSTACK_RELOCATE (plpgsql_yyvs);#  undef PLPGSQL_YYSTACK_RELOCATE	if (plpgsql_yyss1 != plpgsql_yyssa)	  PLPGSQL_YYSTACK_FREE (plpgsql_yyss1);      }# endif#endif /* no plpgsql_yyoverflow */      plpgsql_yyssp = plpgsql_yyss + plpgsql_yysize - 1;      plpgsql_yyvsp = plpgsql_yyvs + plpgsql_yysize - 1;      PLPGSQL_YYDPRINTF ((stderr, "Stack size increased to %lu\n",		  (unsigned long int) plpgsql_yystacksize));      if (plpgsql_yyss + plpgsql_yystacksize - 1 <= plpgsql_yyssp)	PLPGSQL_YYABORT;    }  PLPGSQL_YYDPRINTF ((stderr, "Entering state %d\n", plpgsql_yystate));  goto plpgsql_yybackup;/*-----------.| plpgsql_yybackup.  |`-----------*/plpgsql_yybackup:/* Do appropriate processing given the current state.  *//* Read a lookahead token if we need one and don't already have one.  *//* plpgsql_yyresume: */  /* First try to decide what to do without reference to lookahead token.  */  plpgsql_yyn = plpgsql_yypact[plpgsql_yystate];  if (plpgsql_yyn == PLPGSQL_YYPACT_NINF)    goto plpgsql_yydefault;  /* Not known => get a lookahead token if don't already have one.  */  /* PLPGSQL_YYCHAR is either PLPGSQL_YYEMPTY or PLPGSQL_YYEOF or a valid lookahead symbol.  */  if (plpgsql_yychar == PLPGSQL_YYEMPTY)    {      PLPGSQL_YYDPRINTF ((stderr, "Reading a token: "));      plpgsql_yychar = PLPGSQL_YYLEX;    }  if (plpgsql_yychar <= PLPGSQL_YYEOF)    {      plpgsql_yychar = plpgsql_yytoken = PLPGSQL_YYEOF;      PLPGSQL_YYDPRINTF ((stderr, "Now at end of input.\n"));    }  else    {      plpgsql_yytoken = PLPGSQL_YYTRANSLATE (plpgsql_yychar);      PLPGSQL_YYDSYMPRINTF ("Next token is", plpgsql_yytoken, &plpgsql_yylval, &plpgsql_yylloc);    }  /* If the proper action on seeing token PLPGSQL_YYTOKEN is to reduce or to     detect an error, take that action.  */  plpgsql_yyn += plpgsql_yytoken;  if (plpgsql_yyn < 0 || PLPGSQL_YYLAST < plpgsql_yyn || plpgsql_yycheck[plpgsql_yyn] != plpgsql_yytoken)    goto plpgsql_yydefault;  plpgsql_yyn = plpgsql_yytable[plpgsql_yyn];  if (plpgsql_yyn <= 0)    {      if (plpgsql_yyn == 0 || plpgsql_yyn == PLPGSQL_YYTABLE_NINF)	goto plpgsql_yyerrlab;      plpgsql_yyn = -plpgsql_yyn;      goto plpgsql_yyreduce;    }  if (plpgsql_yyn == PLPGSQL_YYFINAL)    PLPGSQL_YYACCEPT;  /* Shift the lookahead token.  */  PLPGSQL_YYDPRINTF ((stderr, "Shifting token %s, ", plpgsql_yytname[plpgsql_yytoken]));  /* Discard the token being shifted unless it is eof.  */  if (plpgsql_yychar != PLPGSQL_YYEOF)    plpgsql_yychar = PLPGSQL_YYEMPTY;  *++plpgsql_yyvsp = plpgsql_yylval;  /* Count tokens shifted since error; after three, turn off error     status.  */  if (plpgsql_yyerrstatus)    plpgsql_yyerrstatus--;  plpgsql_yystate = plpgsql_yyn;  goto plpgsql_yynewstate;/*-----------------------------------------------------------.| plpgsql_yydefault -- do the default action for the current state.  |`-----------------------------------------------------------*/plpgsql_yydefault:  plpgsql_yyn = plpgsql_yydefact[plpgsql_yystate];  if (plpgsql_yyn == 0)    goto plpgsql_yyerrlab;  goto plpgsql_yyreduce;/*-----------------------------.| plpgsql_yyreduce -- Do a reduction.  |`-----------------------------*/plpgsql_yyreduce:  /* plpgsql_yyn is the number of a rule to reduce with.  */  plpgsql_yylen = plpgsql_yyr2[plpgsql_yyn];  /* If PLPGSQL_YYLEN is nonzero, implement the default value of the action:     `$$ = $1'.     Otherwise, the following line sets PLPGSQL_YYVAL to garbage.     This behavior is undocumented and Bison     users should not rely upon it.  Assigning to PLPGSQL_YYVAL     unconditionally makes the parser a bit smaller, and it avoids a     GCC warning that PLPGSQL_YYVAL may be used uninitialized.  */  plpgsql_yyval = plpgsql_yyvsp[1-plpgsql_yylen];  PLPGSQL_YY_REDUCE_PRINT (plpgsql_yyn);  switch (plpgsql_yyn)    {        case 2:#line 212 "gram.y"    {						plpgsql_yylval.program = (PLpgSQL_stmt_block *)plpgsql_yyvsp[-1].stmt;					}    break;  case 3:#line 216 "gram.y"    {						plpgsql_yylval.program = (PLpgSQL_stmt_block *)plpgsql_yyvsp[-1].stmt;					}    break;  case 8:#line 230 "gram.y"    {						plpgsql_DumpExecTree = 1;					}    break;  case 11:#line 240 "gram.y"    {						PLpgSQL_stmt_block *new;						new = malloc(sizeof(PLpgSQL_stmt_block));						memset(new, 0, sizeof(PLpgSQL_stmt_block));						new->cmd_type	= PLPGSQL_STMT_BLOCK;						new->lineno		= plpgsql_yyvsp[-2].ival;						new->label		= plpgsql_yyvsp[-4].declhdr.label;						new->n_initvars = plpgsql_yyvsp[-4].declhdr.n_initvars;						new->initvarnos = plpgsql_yyvsp[-4].declhdr.initvarnos;						new->body		= plpgsql_yyvsp[-1].stmts;						plpgsql_ns_pop();						plpgsql_yyval.stmt = (PLpgSQL_stmt *)new;					}    break;  case 12:#line 261 "gram.y"    {						plpgsql_ns_setlocal(false);						plpgsql_yyval.declhdr.label	  = plpgsql_yyvsp[0].str;						plpgsql_yyval.declhdr.n_initvars = 0;						plpgsql_yyval.declhdr.initvarnos = NULL;						plpgsql_add_initdatums(NULL);					}    break;  case 13:#line 269 "gram.y"    {						plpgsql_ns_setlocal(false);						plpgsql_yyval.declhdr.label	  = plpgsql_yyvsp[-1].str;						plpgsql_yyval.declhdr.n_initvars = 0;						plpgsql_yyval.declhdr.initvarnos = NULL;						plpgsql_add_initdatums(NULL);					}    break;  case 14:#line 277 "gram.y"    {						plpgsql_ns_setlocal(false);						if (plpgsql_yyvsp[0].str != NULL)							plpgsql_yyval.declhdr.label = plpgsql_yyvsp[0].str;						else							plpgsql_yyval.declhdr.label = plpgsql_yyvsp[-2].str;						plpgsql_yyval.declhdr.n_initvars = plpgsql_add_initdatums(&(plpgsql_yyval.declhdr.initvarnos));					}    break;  case 15:#line 288 "gram.y"    {						plpgsql_ns_setlocal(true);					}    break;  case 16:#line 294 "gram.y"    {	plpgsql_yyval.str = plpgsql_yyvsp[0].str;	}    break;  case 17:#line 296 "gram.y"    {	plpgsql_yyval.str = plpgsql_yyvsp[0].str;	}    break;  case 18:#line 300 "gram.y"    {	plpgsql_yyval.str = plpgsql_yyvsp[-2].str;	}    break;  case 19:#line 302 "gram.y"    {	plpgsql_yyval.str = NULL;	}    break;  case 20:#line 304 "gram.y"    {	plpgsql_yyval.str = NULL;	}    break;  case 21:#line 308 "gram.y"    {						if (!OidIsValid(plpgsql_yyvsp[-2].dtype->typrelid))						{							/* Ordinary scalar datatype */							PLpgSQL_var		*var;							var = malloc(sizeof(PLpgSQL_var));							memset(var, 0, sizeof(PLpgSQL_var));							var->dtype		= PLPGSQL_DTYPE_VAR;							var->refname	= plpgsql_yyvsp[-4].varname.name;							var->lineno		= plpgsql_yyvsp[-4].varname.lineno;							var->datatype	= plpgsql_yyvsp[-2].dtype;

⌨️ 快捷键说明

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