This is an automated email from the ASF dual-hosted git repository.
hxd pushed a commit to branch seperate_antlr
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/seperate_antlr by this push:
new d7338fb temporary submit
d7338fb is described below
commit d7338fb57311cae2d4bcb2e3041754d3c370fb51
Author: xiangdong huang <[email protected]>
AuthorDate: Mon Apr 5 11:30:32 2021 +0800
temporary submit
---
.../antlr4/org/apache/iotdb/db/qp/sql/SqlBase.g4 | 71 +++++++++-------------
.../org/apache/iotdb/db/qp/sql/SqlBaseLexer.g4 | 35 +++++++++--
2 files changed, 61 insertions(+), 45 deletions(-)
diff --git a/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlBase.g4
b/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlBase.g4
index 49f6991..4797219 100644
--- a/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlBase.g4
+++ b/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlBase.g4
@@ -45,7 +45,7 @@ statement
| CREATE INDEX ON prefixPath whereClause? indexWithClause #createIndex
//not support yet
| DROP INDEX indexName=ID ON prefixPath #dropIndex //not support yet
| MERGE #merge
- | FLUSH prefixPath? (COMMA prefixPath)* (BooleanClause)?#flush
+ | FLUSH prefixPath? (COMMA prefixPath)* (Boolean)?#flush
| FULL MERGE #fullMerge
| CLEAR CACHE #clearcache
| CREATE USER userName=ID password= StringLiteral#createUser
@@ -189,8 +189,8 @@ aliasClause
;
attributeClauses
- : DATATYPE OPERATOR_EQ dataType (COMMA ENCODING OPERATOR_EQ encoding)?
- (COMMA (COMPRESSOR | COMPRESSION) OPERATOR_EQ compressor)?
+ : K_DATATYPE OPERATOR_EQ DataType (COMMA Encoding OPERATOR_EQ Encoding)?
+ (COMMA (K_COMPRESSOR | COMPRESSION) OPERATOR_EQ Compressor)?
(COMMA property)*
tagClause?
attributeClause?
@@ -324,9 +324,9 @@ groupByLevelClause
;
typeClause
- : (dataType | ALL) LS_BRACKET linearClause RS_BRACKET
- | (dataType | ALL) LS_BRACKET previousClause RS_BRACKET
- | (dataType | ALL) LS_BRACKET previousUntilLastClause RS_BRACKET
+ : (DataType | ALL) LS_BRACKET linearClause RS_BRACKET
+ | (DataType | ALL) LS_BRACKET previousClause RS_BRACKET
+ | (DataType | ALL) LS_BRACKET previousUntilLastClause RS_BRACKET
;
linearClause
@@ -418,10 +418,10 @@ nodeName
| (ID | OPERATOR_IN)? LS_BRACKET INT? ID? RS_BRACKET? ID?
| MINUS? (EXPONENT | INT)
| DURATION
- | encoding
- | dataType
+ | Encoding
+ | DataType
| dateExpression
- | BooleanClause
+ | Boolean
| CREATE
| INSERT
| UPDATE
@@ -452,8 +452,8 @@ nodeName
| TIMESTAMP
| PROPERTY
| WITH
- | DATATYPE
- | COMPRESSOR
+ | K_DATATYPE
+ | K_COMPRESSOR
| STORAGE
| GROUP
| LABEL
@@ -516,7 +516,7 @@ nodeName
| SCHEMA
| TRACING
| OFF
- | compressor
+ | Compressor
| GLOBAL
| PARTITION
| DESC
@@ -529,10 +529,10 @@ nodeNameWithoutStar
| MINUS? ( EXPONENT | INT)
| (ID | OPERATOR_IN)? LS_BRACKET INT? ID? RS_BRACKET? ID?
| DURATION
- | encoding
- | dataType
+ | Encoding
+ | DataType
| dateExpression
- | BooleanClause
+ | Boolean
| CREATE
| INSERT
| UPDATE
@@ -563,8 +563,8 @@ nodeNameWithoutStar
| TIMESTAMP
| PROPERTY
| WITH
- | DATATYPE
- | COMPRESSOR
+ | K_DATATYPE
+ | K_COMPRESSOR
| STORAGE
| GROUP
| LABEL
@@ -627,24 +627,13 @@ nodeNameWithoutStar
| SCHEMA
| TRACING
| OFF
- | compressor
+ | Compressor
| GLOBAL
| PARTITION
| DESC
| ASC
;
-dataType
- : INT32 | INT64 | FLOAT | DOUBLE | BOOLEAN | TEXT
- ;
-
-compressor
- : UNCOMPRESSED
- | SNAPPY
- | LZ4
- | GZIP
- ;
-
dateFormat
: DATETIME
| NOW LR_BRACKET RR_BRACKET
@@ -653,10 +642,10 @@ dateFormat
constant
: dateExpression
| NaN
- | MINUS? realLiteral
+ | MINUS? RealLiteral
| MINUS? INT
| StringLiteral
- | BooleanClause
+ | Boolean
;
@@ -665,23 +654,17 @@ dateExpression
: dateFormat ((PLUS | MINUS) DURATION)*
;
-encoding
- : PLAIN | PLAIN_DICTIONARY | RLE | DIFF | TS_2DIFF | GORILLA | REGULAR
- ;
-realLiteral
- : INT DOT (INT | EXPONENT)?
- | DOT (INT|EXPONENT)
- | EXPONENT
- ;
+
+
property
: name=ID OPERATOR_EQ value=PropertyValue
;
autoCreateSchema
- : BooleanClause
- | BooleanClause INT
+ : Boolean
+ | Boolean INT
;
triggerEventClause
@@ -696,6 +679,12 @@ triggerAttribute
: key=StringLiteral OPERATOR_EQ value=StringLiteral
;
+timeValue
+ : dateFormat
+ | dateExpression
+ | INT
+ ;
+
PropertyValue
: INT
| ID
diff --git a/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlBaseLexer.g4
b/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlBaseLexer.g4
index 258d28f..9e68cd6 100644
--- a/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlBaseLexer.g4
+++ b/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlBaseLexer.g4
@@ -164,11 +164,11 @@ ROOT
: R O O T
;
-DATATYPE
+K_DATATYPE
: D A T A T Y P E
;
-COMPRESSOR
+K_COMPRESSOR
: C O M P R E S S O R
;
@@ -200,7 +200,7 @@ DOUBLE
: D O U B L E
;
-BOOLEAN
+K_BOOLEAN
: B O O L E A N
;
@@ -607,6 +607,8 @@ EXPLAIN
//============================
// End of the keywords list
//============================
+SEMI: ';';
+
COMMA : ',';
STAR : '*';
@@ -667,7 +669,7 @@ UNDERLINE : '_';
NaN : 'NaN';
-BooleanClause
+Boolean
: TRUE
| FALSE
;
@@ -696,6 +698,31 @@ DATETIME
/** Allow unicode rule/token names */
ID : FIRST_NAME_CHAR NAME_CHAR*;
+//======================================
+// Complex
+//======================================
+
+RealLiteral
+ : INT DOT (INT | EXPONENT)?
+ | DOT (INT|EXPONENT)
+ | EXPONENT
+ ;
+
+Encoding
+ : PLAIN | PLAIN_DICTIONARY | RLE | DIFF | TS_2DIFF | GORILLA | REGULAR
+ ;
+
+Compressor
+ : UNCOMPRESSED
+ | SNAPPY
+ | LZ4
+ | GZIP
+ ;
+
+DataType
+ : INT32 | INT64 | FLOAT | DOUBLE | K_BOOLEAN | TEXT
+ ;
+
fragment
NAME_CHAR
: 'A'..'Z'