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

📄 pgc.c

📁 PostgreSQL7.4.6 for Linux
💻 C
📖 第 1 页 / 共 5 页
字号:
*yy_cp = yy_hold_char; /* undo effects of setting up yytext */ \yy_cp = yy_full_match; /* restore poss. backed-over text */ \++yy_lp; \goto find_rule; \}#define yymore() yymore_used_but_not_detected#define YY_MORE_ADJ 0#define YY_RESTORE_YY_MORE_OFFSETchar *yytext;#line 1 "pgc.l"#define INITIAL 0#line 2 "pgc.l"/*------------------------------------------------------------------------- * * pgc.l *	  lexical scanner for ecpg * * This is a modified version of src/backend/parser/scan.l * * * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * * IDENTIFICATION *	  $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.122.2.3 2004/07/20 18:22:53 meskes Exp $ * *------------------------------------------------------------------------- */#include "postgres_fe.h"#include <ctype.h>#include <sys/types.h>#include <limits.h>#include <errno.h>#include "extern.h"extern YYSTYPE yylval;static int		xcdepth = 0;	/* depth of nesting in slash-star comments *//* * literalbuf is used to accumulate literal values when multiple rules * are needed to parse a single literal.  Call startlit to reset buffer * to empty, addlit to add text.  Note that the buffer is permanently * malloc'd to the largest size needed so far in the current run. */static char    *literalbuf = NULL;		/* expandable buffer */static int		literallen;				/* actual current length */static int		literalalloc;			/* current allocated buffer size */#define startlit()	(literalbuf[0] = '\0', literallen = 0)static void addlit(char *ytext, int yleng);static void addlitchar (unsigned char);static void parse_include (void);char *token_start;int state_before;struct _yy_buffer { 	YY_BUFFER_STATE		buffer;	long				lineno;	char		  		*filename;	struct _yy_buffer 	*next;} *yy_buffer = NULL;static char *old;#define MAX_NESTED_IF 128static short preproc_tos;static short ifcond;static struct _if_value {	short condition;	short else_branch;} stacked_if_value[MAX_NESTED_IF];#define YY_NEVER_INTERACTIVE 1#define C 1#define SQL 2#define incl 3#define def 4#define def_ident 5/* * OK, here is a short description of lex/flex rules behavior. * The longest pattern which matches an input string is always chosen. * For equal-length patterns, the first occurring in the rules list is chosen. * INITIAL is the starting state, to which all non-conditional rules apply. * Exclusive states change parsing rules while the state is active.  When in * an exclusive state, only those rules defined for that state apply. * * We use exclusive states for quoted strings, extended comments, * and to eliminate parsing troubles for numeric strings. * Exclusive states: *	<xb> bit string literal *	<xc> extended C-style comments - thomas 1997-07-12 *	<xd> delimited identifiers (double-quoted identifiers) - thomas 1997-10-27 *	<xh> hexadecimal numeric string - thomas 1997-11-16 *	<xq> quoted strings - thomas 1997-07-30 */#define xb 6#define xc 7#define xd 8#define xdc 9#define xh 10#define xq 11#define xpre 12#define xcond 13#define xskip 14/* Bit string *//* Hexadecimal number *//* National character *//* C version of hex number *//* Extended quote * xqdouble implements SQL92 embedded quote * xqcat allows strings to cross input lines *//* Double quote * Allows embedded spaces and other special characters into identifiers. *//* special stuff for C strings *//* C-style comments * * The "extended comment" syntax closely resembles allowable operator syntax. * The tricky part here is to get lex to recognize a string starting with * slash-star as a comment, when interpreting it as an operator would produce * a longer match --- remember lex will prefer a longer match!	Also, if we * have something like plus-slash-star, lex will think this is a 3-character * operator whereas we want to see it as a + operator and a comment start. * The solution is two-fold: * 1. append {op_chars}* to xcstart so that it matches as much text as *	  {operator} would. Then the tie-breaker (first matching rule of same *	  length) ensures xcstart wins.  We put back the extra stuff with yyless() *	  in case it contains a star-slash that should terminate the comment. * 2. In the operator rule, check for slash-star within the operator, and *	  if found throw it back with yyless().  This handles the plus-slash-star *	  problem. * SQL92-style comments, which start with dash-dash, have similar interactions * with the operator rule. *//* * "self" is the set of chars that should be returned as single-character * tokens.	"op_chars" is the set of chars that can make up "Op" tokens, * which can be one or more characters long (but if a single-char token * appears in the "self" set, it is not to be returned as an Op).  Note * that the sets overlap, but each has some chars that are not in the other. * * If you change either set, adjust the character lists appearing in the * rule for "operator"! *//* we no longer allow unary minus in numbers. * instead we pass it separately to parser. there it gets * coerced via doNegate() -- Leon aug 20 1999 *//* * In order to make the world safe for Windows and Mac clients as well as * Unix ones, we accept either \n or \r as a newline.  A DOS-style \r\n * sequence will be seen as two successive newlines, but that doesn't cause * any problems.  SQL92-style comments, which start with -- and extend to the * next newline, are treated as equivalent to a single whitespace character. * * NOTE a fine point: if there is no newline following --, we will absorb * everything to the end of the input as a comment.  This is correct.  Older * versions of Postgres failed to recognize -- as a comment if the input * did not end with a newline. * * XXX perhaps \f (formfeed) should be treated as a newline as well? *//* * SQL92 requires at least one newline in the whitespace separating * string literals that are to be concatenated.  Silly, but who are we * to argue?  Note that {whitespace_with_newline} should not have * after * it, whereas {whitespace} should generally have a * after it... *//* special characters for other dbms *//* we have to react differently in compat mode *//* some stuff needed for ecpg *//* we might want to parse all cpp include files *//* Take care of cpp continuation lines *//* * Quoted strings must allow some special characters such as single-quote *	and newline. * Embedded single-quotes are implemented both in the SQL92-standard *	style of two adjacent single quotes "''" and in the Postgres/Java style *	of escaped-quote "\'". * Other embedded escaped characters are matched explicitly and the leading *	backslash is dropped from the string. - thomas 1997-09-24 * Note that xcstart must appear before operator, as explained above! *	Also whitespace (comment) must appear before operator. */#line 1222 "pgc.c"/* Macros after this point can all be overridden by user definitions in * section 1. */#ifndef YY_SKIP_YYWRAP#ifdef __cplusplusextern "C" int yywrap YY_PROTO(( void ));#elseextern int yywrap YY_PROTO(( void ));#endif#endif#ifndef YY_NO_UNPUTstatic void yyunput YY_PROTO(( int c, char *buf_ptr ));#endif#ifndef yytext_ptrstatic void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int ));#endif#ifdef YY_NEED_STRLENstatic int yy_flex_strlen YY_PROTO(( yyconst char * ));#endif#ifndef YY_NO_INPUT#ifdef __cplusplusstatic int yyinput YY_PROTO(( void ));#elsestatic int input YY_PROTO(( void ));#endif#endif#if YY_STACK_USEDstatic int yy_start_stack_ptr = 0;static int yy_start_stack_depth = 0;static int *yy_start_stack = 0;#ifndef YY_NO_PUSH_STATEstatic void yy_push_state YY_PROTO(( int new_state ));#endif#ifndef YY_NO_POP_STATEstatic void yy_pop_state YY_PROTO(( void ));#endif#ifndef YY_NO_TOP_STATEstatic int yy_top_state YY_PROTO(( void ));#endif#else#define YY_NO_PUSH_STATE 1#define YY_NO_POP_STATE 1#define YY_NO_TOP_STATE 1#endif#ifdef YY_MALLOC_DECLYY_MALLOC_DECL#else#if __STDC__#ifndef __cplusplus#include <stdlib.h>#endif#else/* Just try to get by without declaring the routines.  This will fail * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int) * or sizeof(void*) != sizeof(int). */#endif#endif/* Amount of stuff to slurp up with each read. */#ifndef YY_READ_BUF_SIZE#define YY_READ_BUF_SIZE 8192#endif/* Copy whatever the last rule matched to the standard output. */#ifndef ECHO/* This used to be an fputs(), but since the string might contain NUL's, * we now use fwrite(). */#define ECHO (void) fwrite( yytext, yyleng, 1, yyout )#endif/* Gets input and stuffs it into "buf".  number of characters read, or YY_NULL, * is returned in "result". */#ifndef YY_INPUT#define YY_INPUT(buf,result,max_size) \	if ( yy_current_buffer->yy_is_interactive ) \		{ \		int c = '*', n; \		for ( n = 0; n < max_size && \			     (c = getc( yyin )) != EOF && c != '\n'; ++n ) \			buf[n] = (char) c; \		if ( c == '\n' ) \			buf[n++] = (char) c; \		if ( c == EOF && ferror( yyin ) ) \			YY_FATAL_ERROR( "input in flex scanner failed" ); \		result = n; \		} \	else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \		  && ferror( yyin ) ) \		YY_FATAL_ERROR( "input in flex scanner failed" );#endif/* No semi-colon after return; correct usage is to write "yyterminate();" - * we don't want an extra ';' after the "return" because that will cause * some compilers to complain about unreachable statements. */#ifndef yyterminate#define yyterminate() return YY_NULL#endif/* Number of entries by which start-condition stack grows. */#ifndef YY_START_STACK_INCR#define YY_START_STACK_INCR 25#endif/* Report a fatal error. */#ifndef YY_FATAL_ERROR#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )#endif/* Default declaration of generated scanner - a define so the user can * easily add parameters. */#ifndef YY_DECL#define YY_DECL int yylex YY_PROTO(( void ))#endif/* Code executed at the beginning of each rule, after yytext and yyleng * have been set up.

⌨️ 快捷键说明

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