Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
Shardingsphere
提交
d7aded6e
Shardingsphere
项目概览
apache
/
Shardingsphere
通知
56
Star
3
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Shardingsphere
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d7aded6e
编写于
1月 20, 2020
作者:
Z
Zhang Yonglun
提交者:
Liang Zhang
1月 20, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#4042, Use the two-stage parsing strategy (#4045)
* #4042, Use the two-stage parsing strategy * #4042, for comments
上级
e6b2b97a
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
23 addition
and
6 deletion
+23
-6
shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/core/parser/SQLParserEngine.java
...hardingsphere/sql/parser/core/parser/SQLParserEngine.java
+18
-1
shardingsphere-sql-parser/shardingsphere-sql-parser-mysql/src/main/antlr4/imports/mysql/DMLStatement.g4
...arser-mysql/src/main/antlr4/imports/mysql/DMLStatement.g4
+1
-1
shardingsphere-sql-parser/shardingsphere-sql-parser-oracle/src/main/antlr4/imports/oracle/DMLStatement.g4
...ser-oracle/src/main/antlr4/imports/oracle/DMLStatement.g4
+1
-1
shardingsphere-sql-parser/shardingsphere-sql-parser-postgresql/src/main/antlr4/imports/postgresql/DMLStatement.g4
...gresql/src/main/antlr4/imports/postgresql/DMLStatement.g4
+1
-1
shardingsphere-sql-parser/shardingsphere-sql-parser-sql92/src/main/antlr4/imports/sql92/DMLStatement.g4
...arser-sql92/src/main/antlr4/imports/sql92/DMLStatement.g4
+1
-1
shardingsphere-sql-parser/shardingsphere-sql-parser-sqlserver/src/main/antlr4/imports/sqlserver/DMLStatement.g4
...lserver/src/main/antlr4/imports/sqlserver/DMLStatement.g4
+1
-1
未找到文件。
shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/core/parser/SQLParserEngine.java
浏览文件 @
d7aded6e
...
...
@@ -18,9 +18,15 @@
package
org.apache.shardingsphere.sql.parser.core.parser
;
import
lombok.RequiredArgsConstructor
;
import
org.antlr.v4.runtime.BailErrorStrategy
;
import
org.antlr.v4.runtime.DefaultErrorStrategy
;
import
org.antlr.v4.runtime.Parser
;
import
org.antlr.v4.runtime.ParserRuleContext
;
import
org.antlr.v4.runtime.atn.PredictionMode
;
import
org.antlr.v4.runtime.misc.ParseCancellationException
;
import
org.antlr.v4.runtime.tree.ErrorNode
;
import
org.antlr.v4.runtime.tree.ParseTree
;
import
org.apache.shardingsphere.sql.parser.api.SQLParser
;
import
org.apache.shardingsphere.sql.parser.core.extractor.util.ExtractorUtils
;
import
org.apache.shardingsphere.sql.parser.core.extractor.util.RuleName
;
import
org.apache.shardingsphere.sql.parser.core.rule.registry.ParseRuleRegistry
;
...
...
@@ -51,7 +57,18 @@ public final class SQLParserEngine {
* @return abstract syntax tree of SQL
*/
public
SQLAST
parse
()
{
ParseTree
parseTree
=
SQLParserFactory
.
newInstance
(
databaseTypeName
,
sql
).
execute
().
getChild
(
0
);
SQLParser
sqlParser
=
SQLParserFactory
.
newInstance
(
databaseTypeName
,
sql
);
ParseTree
parseTree
;
try
{
((
Parser
)
sqlParser
).
setErrorHandler
(
new
BailErrorStrategy
());
((
Parser
)
sqlParser
).
getInterpreter
().
setPredictionMode
(
PredictionMode
.
SLL
);
parseTree
=
sqlParser
.
execute
().
getChild
(
0
);
}
catch
(
final
ParseCancellationException
ex
)
{
((
Parser
)
sqlParser
).
reset
();
((
Parser
)
sqlParser
).
setErrorHandler
(
new
DefaultErrorStrategy
());
((
Parser
)
sqlParser
).
getInterpreter
().
setPredictionMode
(
PredictionMode
.
LL
);
parseTree
=
sqlParser
.
execute
().
getChild
(
0
);
}
if
(
parseTree
instanceof
ErrorNode
)
{
throw
new
SQLParsingException
(
String
.
format
(
"Unsupported SQL of `%s`"
,
sql
));
}
...
...
shardingsphere-sql-parser/shardingsphere-sql-parser-mysql/src/main/antlr4/imports/mysql/DMLStatement.g4
浏览文件 @
d7aded6e
...
...
@@ -219,7 +219,7 @@ escapedTableReference_
;
tableReference
:
(tableFactor joinedTable)+ |
tableFactor joinedTable*
: tableFactor joinedTable*
;
tableFactor
...
...
shardingsphere-sql-parser/shardingsphere-sql-parser-oracle/src/main/antlr4/imports/oracle/DMLStatement.g4
浏览文件 @
d7aded6e
...
...
@@ -145,7 +145,7 @@ tableReferences
;
tableReference
:
(tableFactor joinedTable)+ |
tableFactor joinedTable*
: tableFactor joinedTable*
;
tableFactor
...
...
shardingsphere-sql-parser/shardingsphere-sql-parser-postgresql/src/main/antlr4/imports/postgresql/DMLStatement.g4
浏览文件 @
d7aded6e
...
...
@@ -121,7 +121,7 @@ tableReferences
;
tableReference
:
(tableFactor joinedTable)+ |
tableFactor joinedTable*
: tableFactor joinedTable*
;
tableFactor
...
...
shardingsphere-sql-parser/shardingsphere-sql-parser-sql92/src/main/antlr4/imports/sql92/DMLStatement.g4
浏览文件 @
d7aded6e
...
...
@@ -117,7 +117,7 @@ escapedTableReference_
;
tableReference
:
(tableFactor joinedTable)+ |
tableFactor joinedTable*
: tableFactor joinedTable*
;
tableFactor
...
...
shardingsphere-sql-parser/shardingsphere-sql-parser-sqlserver/src/main/antlr4/imports/sqlserver/DMLStatement.g4
浏览文件 @
d7aded6e
...
...
@@ -117,7 +117,7 @@ tableReferences
;
tableReference
:
(tableFactor joinedTable)+ |
tableFactor joinedTable*
: tableFactor joinedTable*
;
tableFactor
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录