Repository: calcite
Updated Branches:
  refs/heads/master a850c41e2 -> 47e0e7c95


[CALCITE-459] When parsing SQL, allow single line comment on last line (Zhen 
Wang)

Close apache/calcite#175

Unrelated PR I forgot to close in a previous change:

Close apache/calcite#172


Project: http://git-wip-us.apache.org/repos/asf/calcite/repo
Commit: http://git-wip-us.apache.org/repos/asf/calcite/commit/fa08c46d
Tree: http://git-wip-us.apache.org/repos/asf/calcite/tree/fa08c46d
Diff: http://git-wip-us.apache.org/repos/asf/calcite/diff/fa08c46d

Branch: refs/heads/master
Commit: fa08c46d3f9b1d5bb6f8f2772effb76d02cecb9a
Parents: a850c41
Author: awang <[email protected]>
Authored: Wed Dec 9 22:34:00 2015 +0800
Committer: Julian Hyde <[email protected]>
Committed: Wed Dec 9 10:07:12 2015 -0800

----------------------------------------------------------------------
 core/src/main/codegen/templates/Parser.jj                | 11 +++--------
 .../org/apache/calcite/sql/parser/SqlParserTest.java     |  4 ++++
 2 files changed, 7 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/calcite/blob/fa08c46d/core/src/main/codegen/templates/Parser.jj
----------------------------------------------------------------------
diff --git a/core/src/main/codegen/templates/Parser.jj 
b/core/src/main/codegen/templates/Parser.jj
index 121de48..fe509af 100644
--- a/core/src/main/codegen/templates/Parser.jj
+++ b/core/src/main/codegen/templates/Parser.jj
@@ -5550,17 +5550,12 @@ of the 'normal states'.
 
 <DEFAULT, DQID, BTID> MORE :
 {
-    "//" { pushState(); } : IN_SINGLE_LINE_COMMENT
-    |
-    "--" { pushState(); } : IN_SINGLE_LINE_COMMENT
-    |
     "/*" { pushState(); } : IN_MULTI_LINE_COMMENT
 }
 
-<IN_SINGLE_LINE_COMMENT>
-SPECIAL_TOKEN :
+<DEFAULT, DQID, BTID> SKIP :
 {
-    <SINGLE_LINE_COMMENT: "\n" | "\r" | "\r\n" > { popState(); }
+    <SINGLE_LINE_COMMENT: ("//"|"--")(~["\n","\r"])* ("\n"|"\r"|"\r\n")? >
 }
 
 <IN_FORMAL_COMMENT>
@@ -5575,7 +5570,7 @@ SPECIAL_TOKEN :
     <MULTI_LINE_COMMENT: "*/" > { popState(); }
 }
 
-<IN_SINGLE_LINE_COMMENT,IN_FORMAL_COMMENT,IN_MULTI_LINE_COMMENT>
+<IN_FORMAL_COMMENT,IN_MULTI_LINE_COMMENT>
 MORE :
 {
     < ~[] >

http://git-wip-us.apache.org/repos/asf/calcite/blob/fa08c46d/core/src/test/java/org/apache/calcite/sql/parser/SqlParserTest.java
----------------------------------------------------------------------
diff --git 
a/core/src/test/java/org/apache/calcite/sql/parser/SqlParserTest.java 
b/core/src/test/java/org/apache/calcite/sql/parser/SqlParserTest.java
index 365d16b..c1c8f3b 100644
--- a/core/src/test/java/org/apache/calcite/sql/parser/SqlParserTest.java
+++ b/core/src/test/java/org/apache/calcite/sql/parser/SqlParserTest.java
@@ -1660,6 +1660,10 @@ public class SqlParserTest {
         "SELECT 1\n"
             + "FROM `T`\n"
             + "WHERE (`A` > `B`)");
+    check(
+          "select 1 from t\n--select",
+          "SELECT 1\n"
+                  + "FROM `T`");
   }
 
   @Test public void testMultilineComment() {

Reply via email to