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

📄 pgc.l

📁 PostgreSQL 8.1.4的源码 适用于Linux下的开源数据库系统
💻 L
📖 第 1 页 / 共 3 页
字号:
<C>{exec_sql}{include}{space}*	{ BEGIN(incl); }<C>{informix_special}{include}{space}* { 					  /* are we simulating Informix? */					  if (INFORMIX_MODE)					  {						  BEGIN(incl);					  }					  else					  {						  yyless(1);						  return (S_ANYTHING);					  }					}<C,xskip>{exec_sql}{ifdef}{space}*	{ ifcond = TRUE; BEGIN(xcond); }<C,xskip>{informix_special}{ifdef}{space}* { 					  /* are we simulating Informix? */					  if (INFORMIX_MODE)					  {						  ifcond = TRUE;						  BEGIN(xcond);					  }					  else					  {						  yyless(1);						  return (S_ANYTHING);					  }					}<C,xskip>{exec_sql}{ifndef}{space}* { ifcond = FALSE; BEGIN(xcond); }<C,xskip>{informix_special}{ifndef}{space}* { 					  /* are we simulating Informix? */					  if (INFORMIX_MODE)					  {						  ifcond = FALSE;						  BEGIN(xcond);					  }					  else					  {						  yyless(1);						  return (S_ANYTHING);					  }					}<C,xskip>{exec_sql}{elif}{space}*	{	/* pop stack */						if ( preproc_tos == 0 ) {							mmerror(PARSE_ERROR, ET_FATAL, "Missing matching 'EXEC SQL IFDEF / EXEC SQL IFNDEF'");						}						else if ( stacked_if_value[preproc_tos].else_branch )							mmerror(PARSE_ERROR, ET_FATAL, "Missing 'EXEC SQL ENDIF;'");						else							preproc_tos--;						ifcond = TRUE; BEGIN(xcond);					}<C,xskip>{informix_special}{elif}{space}* { 					  /* are we simulating Informix? */					  if (INFORMIX_MODE)					  {						if ( preproc_tos == 0 ) {							mmerror(PARSE_ERROR, ET_FATAL, "Missing matching 'EXEC SQL IFDEF / EXEC SQL IFNDEF'");						}						else if ( stacked_if_value[preproc_tos].else_branch )							mmerror(PARSE_ERROR, ET_FATAL, "Missing 'EXEC SQL ENDIF;'");						else							preproc_tos--;						ifcond = TRUE; BEGIN(xcond);					  }					  else					  {						  yyless(1);						  return (S_ANYTHING);					  }					}<C,xskip>{exec_sql}{else}{space}*";" {	/* only exec sql endif pops the stack, so take care of duplicated 'else' */						if ( stacked_if_value[preproc_tos].else_branch ) {							mmerror(PARSE_ERROR, ET_FATAL, "Duplicated 'EXEC SQL ELSE;'");						}						else {							stacked_if_value[preproc_tos].else_branch = TRUE;							stacked_if_value[preproc_tos].condition =							(stacked_if_value[preproc_tos-1].condition &&							 ! stacked_if_value[preproc_tos].condition);							if ( stacked_if_value[preproc_tos].condition )								BEGIN(C);							else								BEGIN(xskip);						}					}<C,xskip>{informix_special}{else}{space}*	{					  /* are we simulating Informix? */					  if (INFORMIX_MODE)					  {						if ( stacked_if_value[preproc_tos].else_branch ) {							mmerror(PARSE_ERROR, ET_FATAL, "Duplicated 'EXEC SQL ELSE;'");						}						else {							stacked_if_value[preproc_tos].else_branch = TRUE;							stacked_if_value[preproc_tos].condition =							(stacked_if_value[preproc_tos-1].condition &&							 ! stacked_if_value[preproc_tos].condition);							if ( stacked_if_value[preproc_tos].condition )								BEGIN(C);							else								BEGIN(xskip);						}					  }					  else					  {						  yyless(1);						  return (S_ANYTHING);					  }					}<C,xskip>{exec_sql}{endif}{space}*";" {						if ( preproc_tos == 0 )							mmerror(PARSE_ERROR, ET_FATAL, "Unmatched 'EXEC SQL ENDIF;'");						else							preproc_tos--;						if ( stacked_if_value[preproc_tos].condition )						   BEGIN(C);						else						   BEGIN(xskip);					}<C,xskip>{informix_special}{endif}{space}*";"	{					  /* are we simulating Informix? */					  if (INFORMIX_MODE)					  {						if ( preproc_tos == 0 )							mmerror(PARSE_ERROR, ET_FATAL, "Unmatched 'EXEC SQL ENDIF;'");						else							preproc_tos--;						if ( stacked_if_value[preproc_tos].condition )						   BEGIN(C);						else						   BEGIN(xskip);					  }					  else					  {						  yyless(1);						  return (S_ANYTHING);					  }					}<xskip>{other}		{ /* ignore */ }<xcond>{identifier}{space}*";" {						if ( preproc_tos >= MAX_NESTED_IF-1 ) {							mmerror(PARSE_ERROR, ET_FATAL, "Too many nested 'EXEC SQL IFDEF' conditions");						}						else 						{							struct _defines *defptr;							unsigned int i;							/* skip the ";" and trailing whitespace. Note that yytext contains							   at least one non-space character plus the ";" */							for ( i = strlen(yytext)-2;								  i > 0 && isspace((unsigned char) yytext[i]);								  i-- )							{}							yytext[i+1] = '\0';							for ( defptr = defines; defptr != NULL &&								  ( strcmp(yytext, defptr->old) != 0 ); defptr = defptr->next );							preproc_tos++;							stacked_if_value[preproc_tos].else_branch = FALSE;							stacked_if_value[preproc_tos].condition =							( (defptr ? ifcond : !ifcond) && stacked_if_value[preproc_tos-1].condition );						}						if ( stacked_if_value[preproc_tos].condition )						   BEGIN C;						else						   BEGIN(xskip);					}<def_ident>{identifier} {				old = mm_strdup(yytext);				BEGIN(def);				startlit();			}<def>{space}*";"	{						struct _defines *ptr, *this;						for (ptr = defines; ptr != NULL; ptr = ptr->next)						{							 if (strcmp(old, ptr->old) == 0)							 {								free(ptr->new);								/* ptr->new = mm_strdup(scanstr(literalbuf));*/								ptr->new = mm_strdup(literalbuf);							 }						}						if (ptr == NULL)						{							this = (struct _defines *) mm_alloc(sizeof(struct _defines));							/* initial definition */							this->old = old;							this->new = mm_strdup(literalbuf);							this->next = defines;							this->used = NULL;							defines = this;						}						BEGIN(C);					}<def>[^;]			{ addlit(yytext, yyleng); }<incl>\<[^\>]+\>{space}*";"?		{	parse_include(); }<incl>{dquote}{xdinside}{dquote}{space}*";"?	{	parse_include(); }<incl>[^;\<\>\"]+";"		{ parse_include(); }<<EOF>>				{			  		if (yy_buffer == NULL) {				  		if ( preproc_tos > 0 ) 						{					  		preproc_tos = 0;							mmerror(PARSE_ERROR, ET_FATAL, "Missing 'EXEC SQL ENDIF;'");				  		}							yyterminate();							}				  		else				  		{							struct _yy_buffer *yb = yy_buffer;							int i;							struct _defines *ptr;							for (ptr = defines; ptr; ptr = ptr->next)								if (ptr->used == yy_buffer)								{									ptr->used = NULL;									break;								}																if (yyin != NULL)								fclose(yyin);							yy_delete_buffer( YY_CURRENT_BUFFER );							yy_switch_to_buffer(yy_buffer->buffer);							yylineno = yy_buffer->lineno;							/* We have to output the filename only if we change files here */							i = strcmp(input_filename, yy_buffer->filename);							free(input_filename);							input_filename = yy_buffer->filename;							yy_buffer = yy_buffer->next;							free(yb);							if (i != 0)								output_line_number();											  		}					}%%voidlex_init(void){	braces_open = 0;	preproc_tos = 0;	yylineno = 1;	ifcond = TRUE;	stacked_if_value[preproc_tos].condition = ifcond;	stacked_if_value[preproc_tos].else_branch = FALSE;	/* initialize literal buffer to a reasonable but expansible size */	if (literalbuf == NULL)	{		literalalloc = 128;		literalbuf = (char *) malloc(literalalloc);	}	startlit();	BEGIN C;}static voidaddlit(char *ytext, int yleng){	/* enlarge buffer if needed */	if ((literallen+yleng) >= literalalloc)	{		do 			literalalloc *= 2;		while ((literallen+yleng) >= literalalloc);		literalbuf = (char *) realloc(literalbuf, literalalloc);	}	/* append new data, add trailing null */	memcpy(literalbuf+literallen, ytext, yleng);	literallen += yleng;	literalbuf[literallen] = '\0';}static voidaddlitchar(unsigned char ychar){	/* enlarge buffer if needed */        if ((literallen+1) >= literalalloc)        {                literalalloc *= 2;                literalbuf = (char *) realloc(literalbuf, literalalloc);        }	/* append new data, add trailing null */	literalbuf[literallen] = ychar;	literallen += 1;	literalbuf[literallen] = '\0';}static voidparse_include(void){	/* got the include file name */	struct _yy_buffer *yb;  	struct _include_path *ip;  	char inc_file[MAXPGPATH];  	unsigned int i;  	yb = mm_alloc(sizeof(struct _yy_buffer));  	yb->buffer =	YY_CURRENT_BUFFER;  	yb->lineno = yylineno;  	yb->filename = input_filename;  	yb->next = yy_buffer;  	yy_buffer = yb;  	/*	 * skip the ";" if there is one and trailing whitespace. Note that	 * yytext contains at least one non-space character plus the ";" 	 */  	for ( i = strlen(yytext)-2;		i > 0 && isspace((unsigned char) yytext[i]);		i-- )  		{}	if (yytext[i] == ';')		i--;	yytext[i+1] = '\0';		yyin = NULL;	/* If file name is enclosed in '"' remove these and look only in '.' */	/* Informix does look into all include paths though, except filename starts with '/' */	if ((yytext[0] == '"' && yytext[i] == '"') &&	    ((compat != ECPG_COMPAT_INFORMIX && compat != ECPG_COMPAT_INFORMIX_SE) || yytext[1] == '/'))	{		yytext[i] = '\0';		memmove(yytext, yytext+1, strlen(yytext));			strncpy(inc_file, yytext, sizeof(inc_file));		yyin = fopen(inc_file, "r");		if (!yyin)		{			if (strcmp(inc_file + strlen(inc_file) - 2, ".h"))			{				strcat(inc_file, ".h");				yyin = fopen(inc_file, "r");			}		}			}	else	{		if ((yytext[0] == '"' && yytext[i] == '"') || (yytext[0] == '<' && yytext[i] == '>'))		{			yytext[i] = '\0';			memmove(yytext, yytext+1, strlen(yytext));		}			  	for (ip = include_paths; yyin == NULL && ip != NULL; ip = ip->next)	  	{			if (strlen(ip->path) + strlen(yytext) + 3 > MAXPGPATH)			{				fprintf(stderr, "Error: Path %s/%s is too long in line %d, skipping.\n", ip->path, yytext, yylineno);				continue;			}			snprintf (inc_file, sizeof(inc_file), "%s/%s", ip->path, yytext);			yyin = fopen(inc_file, "r");			if (!yyin)			{				if (strcmp(inc_file + strlen(inc_file) - 2, ".h"))				{					strcat(inc_file, ".h");					yyin = fopen( inc_file, "r" );				}			}		}	}	if (!yyin)		mmerror(NO_INCLUDE_FILE, ET_FATAL, "Cannot open include file %s in line %d\n", yytext, yylineno);	input_filename = mm_strdup(inc_file);	yy_switch_to_buffer(yy_create_buffer(yyin,YY_BUF_SIZE ));	yylineno = 1;	output_line_number();  	BEGIN C;}static voidcheck_escape_warning(void){	if (warn_on_first_escape && escape_string_warning)	       	mmerror (PARSE_ERROR, ET_WARNING, "nonstandard use of escape in a string literal");        warn_on_first_escape = false;   /* warn only once per string */}

⌨️ 快捷键说明

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