Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
0fbfba11
G
Gpdb
项目概览
Greenplum
/
Gpdb
通知
7
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Gpdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0fbfba11
编写于
9月 13, 1997
作者:
T
Thomas G. Lockhart
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use exclusive state to help fix unary minus parsing.
Remove "backdoor" for DEFAULT and CHECK.
上级
c1d3c04d
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
62 addition
and
69 deletion
+62
-69
src/backend/parser/scan.l
src/backend/parser/scan.l
+62
-69
未找到文件。
src/backend/parser/scan.l
浏览文件 @
0fbfba11
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.2
0 1997/09/12 09:01:46 vadim
Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.2
1 1997/09/13 03:12:55 thomas
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -36,10 +36,6 @@
extern char *parseString;
extern char *parseCh;
int CurScanPosition(void);
int DefaultStartPosition;
int CheckStartPosition;
/* some versions of lex define this as a macro */
#if defined(yywrap)
#undef yywrap
...
...
@@ -61,6 +57,7 @@ void unput(char);
extern YYSTYPE yylval;
int llen;
char *ScanString;
char literal[MAX_PARSE_BUFFER];
%}
...
...
@@ -68,19 +65,26 @@ char literal[MAX_PARSE_BUFFER];
* 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 condition, to which all non-conditional rules apply.
* <xc> is an exclusive condition to allow embedded C-style comments.
* When in an exclusive condition, only those rules defined for that condition apply.
* So, when in condition <xc>, only strings which would terminate the "extended comment"
* trigger any action other than "ignore".
*
* Exclusive states change parsing rules while the state is active.
* There are exclusive states for quoted strings, extended comments,
* and to eliminate parsing troubles for numeric strings.
* Exclusive states:
* <xc> extended C-style comments - tgl 1997-07-12
* <xq> quoted strings - tgl 1997-07-30
* <xm> numeric strings with embedded minus sign - tgl 1997-09-05
*
* The "extended comment" syntax closely resembles allowable operator syntax.
* Therefore, be sure to match _any_ candidate comment, including those with appended
* So, when in condition <xc>, only strings which would terminate the
* "extended comment" trigger any action other than "ignore".
* Be sure to match _any_ candidate comment, including those with appended
* operator-like symbols. - thomas 1997-07-14
*/
/* define an exclusive condition to allow extended C-style comments - tgl 1997-07-12 */
%x xc
/* define an exclusive condition for quoted strings - tgl 1997-07-30 */
%x xq
%x xm
/* We used to allow double-quoted strings, but SQL doesn't so we won't either */
quote '
...
...
@@ -97,6 +101,7 @@ xcinside [^*]*
xcstar [^/]
digit [0-9]
number [-+.0-9Ee]
letter [_A-Za-z]
letter_or_digit [_A-Za-z0-9]
...
...
@@ -107,32 +112,30 @@ identifier {letter}{letter_or_digit}*
typecast "::"
self [,()\[\].;$\:\+\-\*\/\<\>\=\|]
selfm {self}[\-][\.0-9]
op_and_self [\~\!\@\#\%\^\&\|\`\?\$\:\+\-\*\/\<\>\=]
operator {op_and_self}+
operatorm {op_and_self}+[\-][\.0-9]
xminteger {integer}/-
xmreal {real}/{space}*-{digit}
xmstop -
integer -?{digit}+
real -?{digit}+\.{digit}+([Ee][-+]?{digit}+)?
param \${integer}
comment "--".*\n
comment2 "//".*\n
comment ("--"|"//").*\n
space [ \t\n\f]
other .
%%
{sysfunc} {
yylval.str = pstrdup(SystemFunctionHandler((char *)yytext));
return (SCONST);
}
/* DO NOT PUT ANY COMMENTS IN THE FOLLOWING SECTION.
* AT&T lex does not properly handle C-style comments in this second lex block.
* So, put comments here. tgl - 1997-09-08
*/
{comment} { /* ignore */ }
{comment
2} { /* ignore */
}
%%
{comment
} { /* ignore */
}
{xcline} { /* ignore */ }
...
...
@@ -167,18 +170,26 @@ other .
llen += yyleng-1;
}
<xm>{space}* { /* ignore */ }
<xm>{xmstop} {
BEGIN(INITIAL);
return (yytext[0]);
}
{sysfunc} {
yylval.str = pstrdup(SystemFunctionHandler((char *)yytext));
return (SCONST);
}
{typecast} { return TYPECAST; }
{selfm} {
yyless(yyleng-2);
{self}/-[\.0-9] {
return (yytext[0]);
}
{self} { return (yytext[0]); }
{operatorm} {
yyless(yyleng-2);
{operator}/-[\.0-9] {
yylval.str = pstrdup((char*)yytext);
return (Op);
return (Op);
}
{operator} {
if (strcmp((char*)yytext,"!=") == 0)
...
...
@@ -191,7 +202,26 @@ other .
yylval.ival = atoi((char*)&yytext[1]);
return (PARAM);
}
{integer}/{space}*-{number} {
BEGIN(xm);
ScanString = pstrdup((char*)yytext);
yylval.ival = atoi((char*)yytext);
return (ICONST);
}
{real}/{space}*-{number} {
char* endptr;
BEGIN(xm);
errno = 0;
ScanString = pstrdup((char*)yytext);
yylval.dval = strtod(((char *)yytext),&endptr);
if (*endptr != '\0' || errno == ERANGE)
elog(WARN,"\tBad float8 input format\n");
CheckFloat8Val(yylval.dval);
return (FCONST);
}
{integer} {
ScanString = pstrdup((char*)yytext);
yylval.ival = atoi((char*)yytext);
return (ICONST);
}
...
...
@@ -199,6 +229,7 @@ other .
char* endptr;
errno = 0;
ScanString = pstrdup((char*)yytext);
yylval.dval = strtod(((char *)yytext),&endptr);
if (*endptr != '\0' || errno == ERANGE)
elog(WARN,"\tBad float8 input format\n");
...
...
@@ -215,16 +246,6 @@ other .
keyword = ScanKeywordLookup((char*)yytext);
if (keyword != NULL) {
if ( keyword->value == DEFAULT )
{
DefaultStartPosition = CurScanPosition () + yyleng + 1;
printf( "default offset is %d\n", DefaultStartPosition);
}
else if ( keyword->value == CHECK )
{
CheckStartPosition = CurScanPosition () + yyleng + 1;
printf( "check offset is %d\n", CheckStartPosition);
}
return (keyword->value);
}
else
...
...
@@ -241,7 +262,7 @@ other .
void yyerror(char message[])
{
elog(WARN, "parser: %s at or near \"%s\"
\n
", message, yytext);
elog(WARN, "parser: %s at or near \"%s\"", message, yytext);
}
int yywrap()
...
...
@@ -267,8 +288,6 @@ init_io()
BEGIN INITIAL;
}
#if !defined(FLEX_SCANNER)
/* get lex input from a string instead of from stdin */
int
...
...
@@ -294,16 +313,9 @@ unput(char c)
else if (c != 0)
*--parseCh = c;
}
int
CurScanPosition(void)
{
return (parseCh - parseString - yyleng);
}
#endif /* !defined(FLEX_SCANNER) */
#ifdef FLEX_SCANNER
static bool end_of_buf = false;
/* input routine for flex to read input from a string instead of a file */
int
myinput(char* buf, int max)
...
...
@@ -321,29 +333,10 @@ myinput(char* buf, int max)
memcpy(buf, parseString, copylen);
buf[copylen] = '\0';
parseCh = parseString;
end_of_buf = false;
return copylen;
}
else
{
end_of_buf = true;
return 0; /* end of string */
}
}
int
CurScanPosition(void)
{
int spos;
if ( end_of_buf )
spos = strlen (parseString) - strlen (yytext);
else
spos = yy_c_buf_p - yy_current_buffer->yy_ch_buf - yyleng;
printf( "current position is %d\n", spos);
return (spos);
}
#endif /* FLEX_SCANNER */
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录