Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
40c61d60
Unverified
提交
40c61d60
authored
3月 16, 2018
作者:
Evgenij Ryazanov
提交者:
GitHub
3月 16, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #984 from katzyn/parser
Minor refactorings in Parser
上级
7c73b37a
695b8413
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
37 行增加
和
54 行删除
+37
-54
Parser.java
h2/src/main/org/h2/command/Parser.java
+37
-54
没有找到文件。
h2/src/main/org/h2/command/Parser.java
浏览文件 @
40c61d60
...
...
@@ -794,8 +794,7 @@ public class Parser {
do
{
Column
column
=
readTableColumn
(
filter
);
columns
.
add
(
column
);
}
while
(
readIf
(
","
));
read
(
")"
);
}
while
(
readIfMore
(
true
));
read
(
"="
);
Expression
expression
=
readExpression
();
if
(
columns
.
size
()
==
1
)
{
...
...
@@ -906,8 +905,7 @@ public class Parser {
column
.
sortType
|=
SortOrder
.
NULLS_LAST
;
}
}
}
while
(
readIf
(
","
));
read
(
")"
);
}
while
(
readIfMore
(
true
));
return
columns
.
toArray
(
new
IndexColumn
[
0
]);
}
...
...
@@ -916,7 +914,7 @@ public class Parser {
do
{
String
columnName
=
readColumnIdentifier
();
columns
.
add
(
columnName
);
}
while
(
readIfMore
());
}
while
(
readIfMore
(
false
));
return
columns
.
toArray
(
new
String
[
0
]);
}
...
...
@@ -931,7 +929,7 @@ public class Parser {
column
.
getSQL
());
}
columns
.
add
(
column
);
}
while
(
readIfMore
());
}
while
(
readIfMore
(
false
));
}
return
columns
.
toArray
(
new
Column
[
0
]);
}
...
...
@@ -944,9 +942,16 @@ public class Parser {
return
table
.
getColumn
(
id
);
}
private
boolean
readIfMore
()
{
/**
* Read comma or closing brace.
*
* @param strict
* if {@code false} additional comma before brace is allowed
* @return {@code true} if comma is read, {@code false} if brace is read
*/
private
boolean
readIfMore
(
boolean
strict
)
{
if
(
readIf
(
","
))
{
return
!
readIf
(
")"
);
return
strict
||
!
readIf
(
")"
);
}
read
(
")"
);
return
false
;
...
...
@@ -1110,7 +1115,7 @@ public class Parser {
}
else
{
values
.
add
(
readExpression
());
}
}
while
(
readIfMore
());
}
while
(
readIfMore
(
false
));
}
command
.
addRow
(
values
.
toArray
(
new
Expression
[
0
]));
}
while
(
readIf
(
","
));
...
...
@@ -1281,7 +1286,7 @@ public class Parser {
}
else
{
values
.
add
(
readExpression
());
}
}
while
(
readIfMore
());
}
while
(
readIfMore
(
false
));
}
command
.
addRow
(
values
.
toArray
(
new
Expression
[
0
]));
// the following condition will allow (..),; and (..);
...
...
@@ -1340,7 +1345,7 @@ public class Parser {
}
else
{
values
.
add
(
readExpression
());
}
}
while
(
readIfMore
());
}
while
(
readIfMore
(
false
));
}
command
.
addRow
(
values
.
toArray
(
new
Expression
[
0
]));
}
while
(
readIf
(
","
));
...
...
@@ -1476,8 +1481,7 @@ public class Parser {
String
indexName
=
readIdentifierWithSchema
();
Index
index
=
table
.
getIndex
(
indexName
);
indexNames
.
add
(
index
.
getName
());
}
while
(
readIf
(
","
));
read
(
")"
);
}
while
(
readIfMore
(
true
));
}
return
IndexHints
.
createUseIndexHints
(
indexNames
);
}
...
...
@@ -1503,8 +1507,7 @@ public class Parser {
ArrayList
<
String
>
derivedColumnNames
=
New
.
arrayList
();
do
{
derivedColumnNames
.
add
(
readAliasIdentifier
());
}
while
(
readIf
(
","
));
read
(
")"
);
}
while
(
readIfMore
(
true
));
return
derivedColumnNames
;
}
return
null
;
...
...
@@ -2722,8 +2725,7 @@ public class Parser {
ArrayList
<
Expression
>
params
=
New
.
arrayList
();
do
{
params
.
add
(
readExpression
());
}
while
(
readIf
(
","
));
read
(
")"
);
}
while
(
readIfMore
(
true
));
Expression
filterCondition
;
if
(
readIf
(
"FILTER"
))
{
read
(
"("
);
...
...
@@ -2894,8 +2896,7 @@ public class Parser {
read
(
"="
);
function
.
setParameter
(
i
,
readExpression
());
i
++;
}
while
(
readIf
(
","
));
read
(
")"
);
}
while
(
readIfMore
(
true
));
TableFunction
tf
=
(
TableFunction
)
function
;
tf
.
setColumns
(
columns
);
break
;
...
...
@@ -2915,8 +2916,7 @@ public class Parser {
int
i
=
0
;
do
{
function
.
setParameter
(
i
++,
readExpression
());
}
while
(
readIf
(
","
));
read
(
")"
);
}
while
(
readIfMore
(
true
));
}
}
function
.
doneWithParameters
();
...
...
@@ -3542,19 +3542,6 @@ public class Parser {
return
false
;
}
/*
* Reads passed token in list, in order and returns true on first match.
* If none of the token matches returns false
*/
private
boolean
readIfOr
(
String
...
tokens
)
{
for
(
String
token:
tokens
)
{
if
(
readIf
(
token
))
{
return
true
;
}
}
return
false
;
}
/*
* Reads every token in list, in order - returns true if all are found.
* If any are not found, returns false - AND resets parsing back to state when called.
...
...
@@ -4154,40 +4141,39 @@ public class Parser {
break
;
}
}
else
if
(
s
.
length
()
==
2
)
{
char
c1
=
s
.
charAt
(
1
);
switch
(
c0
)
{
case
':'
:
if
(
"::"
.
equals
(
s
))
{
return
KEYWORD
;
}
else
if
(
":="
.
equals
(
s
))
{
if
(
c1
==
':'
||
c1
==
'='
)
{
return
KEYWORD
;
}
break
;
case
'>'
:
if
(
">="
.
equals
(
s
)
)
{
if
(
c1
==
'='
)
{
return
BIGGER_EQUAL
;
}
break
;
case
'<'
:
if
(
"<="
.
equals
(
s
)
)
{
if
(
c1
==
'='
)
{
return
SMALLER_EQUAL
;
}
else
if
(
"<>"
.
equals
(
s
)
)
{
}
else
if
(
c1
==
'>'
)
{
return
NOT_EQUAL
;
}
break
;
case
'!'
:
if
(
"!="
.
equals
(
s
)
)
{
if
(
c1
==
'='
)
{
return
NOT_EQUAL
;
}
else
if
(
"!~"
.
equals
(
s
)
)
{
}
else
if
(
c1
==
'~'
)
{
return
KEYWORD
;
}
break
;
case
'|'
:
if
(
"||"
.
equals
(
s
)
)
{
if
(
c1
==
'|'
)
{
return
STRING_CONCAT
;
}
break
;
case
'&'
:
if
(
"&&"
.
equals
(
s
)
)
{
if
(
c1
==
'&'
)
{
return
SPATIAL_INTERSECTS
;
}
break
;
...
...
@@ -4491,7 +4477,9 @@ public class Parser {
}
original
+=
"("
+
p
;
// Oracle syntax
readIfOr
(
"CHAR"
,
"BYTE"
);
if
(!
readIf
(
"CHAR"
))
{
readIf
(
"BYTE"
);
}
if
(
dataType
.
supportsScale
)
{
if
(
readIf
(
","
))
{
scale
=
readInt
();
...
...
@@ -4525,13 +4513,12 @@ public class Parser {
String
enumerator0
=
readString
();
enumeratorList
.
add
(
enumerator0
);
original
+=
"'"
+
enumerator0
+
"'"
;
while
(
readIf
(
","
))
{
while
(
readIf
More
(
true
))
{
original
+=
','
;
String
enumeratorN
=
readString
();
original
+=
"'"
+
enumeratorN
+
"'"
;
enumeratorList
.
add
(
enumeratorN
);
}
read
(
")"
);
original
+=
')'
;
enumerators
=
enumeratorList
.
toArray
(
new
String
[
0
]);
}
...
...
@@ -4851,10 +4838,7 @@ public class Parser {
columns
.
set
(
i
,
column
);
row
.
add
(
expr
);
i
++;
}
while
(
multiColumn
&&
readIf
(
","
));
if
(
multiColumn
)
{
read
(
")"
);
}
}
while
(
multiColumn
&&
readIfMore
(
true
));
rows
.
add
(
row
);
}
while
(
readIf
(
","
));
int
columnCount
=
columns
.
size
();
...
...
@@ -6358,8 +6342,7 @@ public class Parser {
command
.
setIfNotExists
(
false
);
do
{
parseTableColumnDefinition
(
command
,
schema
,
tableName
);
}
while
(
readIf
(
","
));
read
(
")"
);
}
while
(
readIfMore
(
true
));
}
else
{
boolean
ifNotExists
=
readIfNotExists
();
command
.
setIfNotExists
(
ifNotExists
);
...
...
@@ -6610,7 +6593,7 @@ public class Parser {
if
(!
readIf
(
")"
))
{
do
{
parseTableColumnDefinition
(
command
,
schema
,
tableName
);
}
while
(
readIfMore
());
}
while
(
readIfMore
(
false
));
}
}
// Allows "COMMENT='comment'" in DDL statements (MySQL syntax)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论