You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2020/01/20 07:20:44 UTC

[GitHub] [incubator-shardingsphere] terrymanu commented on a change in pull request #4045: #4042, Use the two-stage parsing strategy

terrymanu commented on a change in pull request #4045: #4042, Use the two-stage parsing strategy
URL: https://github.com/apache/incubator-shardingsphere/pull/4045#discussion_r368395769
 
 

 ##########
 File path: shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/core/parser/SQLParserEngine.java
 ##########
 @@ -51,7 +57,18 @@
      * @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 (ParseCancellationException ex) {
 
 Review comment:
   should add final for exception catch

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services