This is an automated email from the ASF dual-hosted git repository.
zhyee pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new f6a9410 ADD Create datasource g4 definition (#6483)
f6a9410 is described below
commit f6a9410760ae3abd82e32e545a76ff8920c7f5dc
Author: Juan Pan(Trista) <[email protected]>
AuthorDate: Tue Jul 28 13:56:14 2020 +0800
ADD Create datasource g4 definition (#6483)
* ADD Create datasource g4 definition
* MODIFY NUMBER
* CHECK STYLE
* CHECK STYLE
---
.../src/main/antlr4/imports/Alphabet.g4 | 48 +++++++++++++++++
.../src/main/antlr4/imports/Keyword.g4 | 36 +++++++++++++
.../src/main/antlr4/imports/Literals.g4 | 51 ++++++++++++++++++
.../src/main/antlr4/imports/RDLStatement.g4 | 51 ++++++++++++++++++
.../src/main/antlr4/imports/Symbol.g4 | 60 ++++++++++++++++++++++
5 files changed, 246 insertions(+)
diff --git
a/shardingsphere-rdl-parser/shardingsphere-rdl-parser-sql/src/main/antlr4/imports/Alphabet.g4
b/shardingsphere-rdl-parser/shardingsphere-rdl-parser-sql/src/main/antlr4/imports/Alphabet.g4
new file mode 100644
index 0000000..f7603cc
--- /dev/null
+++
b/shardingsphere-rdl-parser/shardingsphere-rdl-parser-sql/src/main/antlr4/imports/Alphabet.g4
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+lexer grammar Alphabet;
+
+FOR_GENERATOR: 'DO NOT MATCH ANY THING, JUST FOR GENERATOR';
+
+fragment A: [Aa];
+fragment B: [Bb];
+fragment C: [Cc];
+fragment D: [Dd];
+fragment E: [Ee];
+fragment F: [Ff];
+fragment G: [Gg];
+fragment H: [Hh];
+fragment I: [Ii];
+fragment J: [Jj];
+fragment K: [Kk];
+fragment L: [Ll];
+fragment M: [Mm];
+fragment N: [Nn];
+fragment O: [Oo];
+fragment P: [Pp];
+fragment Q: [Qq];
+fragment R: [Rr];
+fragment S: [Ss];
+fragment T: [Tt];
+fragment U: [Uu];
+fragment V: [Vv];
+fragment W: [Ww];
+fragment X: [Xx];
+fragment Y: [Yy];
+fragment Z: [Zz];
+fragment UL_: '_';
diff --git
a/shardingsphere-rdl-parser/shardingsphere-rdl-parser-sql/src/main/antlr4/imports/Keyword.g4
b/shardingsphere-rdl-parser/shardingsphere-rdl-parser-sql/src/main/antlr4/imports/Keyword.g4
new file mode 100644
index 0000000..fcb8ead
--- /dev/null
+++
b/shardingsphere-rdl-parser/shardingsphere-rdl-parser-sql/src/main/antlr4/imports/Keyword.g4
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+lexer grammar Keyword;
+
+import Alphabet;
+
+WS
+ : [ \t\r\n] + ->skip
+ ;
+
+CREATE
+ : C R E A T E
+ ;
+
+DATASOURCE
+ : D A T A S O U R C E
+ ;
+
+SHARDINGRULE
+ : S H A R D I N G R U L E
+ ;
diff --git
a/shardingsphere-rdl-parser/shardingsphere-rdl-parser-sql/src/main/antlr4/imports/Literals.g4
b/shardingsphere-rdl-parser/shardingsphere-rdl-parser-sql/src/main/antlr4/imports/Literals.g4
new file mode 100644
index 0000000..263cd93
--- /dev/null
+++
b/shardingsphere-rdl-parser/shardingsphere-rdl-parser-sql/src/main/antlr4/imports/Literals.g4
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+lexer grammar Literals;
+
+import Alphabet, Symbol;
+
+IDENTIFIER
+ : [A-Za-z$0-9]*?[A-Za-z$]+?[A-Za-z$0-9]*
+ | BQ ~'`'+ BQ
+ | (DQ ( '\\'. | '""' | ~('"'| '\\') )* DQ)
+ ;
+
+STRING
+ : (DQ ( '\\'. | '""' | ~('"'| '\\') )* DQ)
+ | (SQ ('\\'. | '\'\'' | ~('\'' | '\\'))* SQ)
+ ;
+
+INT
+ : [0-9]+
+ ;
+
+HEX
+ : [0-9a-fA-F]
+ ;
+
+NUMBER
+ : INT? DOT? INT (E (PLUS | MINUS)? INT)?
+ ;
+
+HEXDIGIT
+ : '0x' HEX+ | 'X' SQ HEX+ SQ
+ ;
+
+BITNUM
+ : '0b' ('0' | '1')+ | B SQ ('0' | '1')+ SQ
+ ;
diff --git
a/shardingsphere-rdl-parser/shardingsphere-rdl-parser-sql/src/main/antlr4/imports/RDLStatement.g4
b/shardingsphere-rdl-parser/shardingsphere-rdl-parser-sql/src/main/antlr4/imports/RDLStatement.g4
new file mode 100644
index 0000000..89fd428
--- /dev/null
+++
b/shardingsphere-rdl-parser/shardingsphere-rdl-parser-sql/src/main/antlr4/imports/RDLStatement.g4
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+grammar RDLStatement;
+
+import Keyword, Literals, Symbol;
+
+createDatasource
+ : CREATE DATASOURCE datasource (COMMA datasource)* SEMI*
+ ;
+
+datasource
+ : key EQ datasourceValue
+ ;
+
+key
+ : IDENTIFIER
+ ;
+
+datasourceValue
+ : hostName COLON port COLON dbName
+ ;
+
+hostName
+ : ip | IDENTIFIER
+ ;
+
+ip
+ : NUMBER+ INT
+ ;
+port
+ : INT
+ ;
+
+dbName
+ : IDENTIFIER | NUMBER
+ ;
diff --git
a/shardingsphere-rdl-parser/shardingsphere-rdl-parser-sql/src/main/antlr4/imports/Symbol.g4
b/shardingsphere-rdl-parser/shardingsphere-rdl-parser-sql/src/main/antlr4/imports/Symbol.g4
new file mode 100644
index 0000000..86d7933
--- /dev/null
+++
b/shardingsphere-rdl-parser/shardingsphere-rdl-parser-sql/src/main/antlr4/imports/Symbol.g4
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+lexer grammar Symbol;
+
+AND: '&&';
+OR: '||';
+NOT: '!';
+TILDE: '~';
+VERTICALBAR: '|';
+AMPERSAND: '&';
+SIGNEDLEFTSHIFT: '<<';
+SIGNEDRIGHTSHIFT: '>>';
+CARET: '^';
+MOD: '%';
+COLON: ':';
+PLUS: '+';
+MINUS: '-';
+ASTERISK: '*';
+SLASH: '/';
+BACKSLASH: '\\';
+DOT: '.';
+DOTASTERISK: '.*';
+SAFEEQ: '<=>';
+DEQ: '==';
+EQ: '=';
+NEQ: '<>' | '!=';
+GT: '>';
+GTE: '>=';
+LT: '<';
+LTE: '<=';
+POUND: '#';
+LP: '(';
+RP: ')';
+LBE: '{';
+RBE: '}';
+LBT: '[';
+RBT: ']';
+COMMA: ',';
+DQ: '"';
+SQ : '\'';
+BQ: '`';
+QUESTION: '?';
+AT: '@';
+SEMI: ';';
+JSONSEPARATOR: '->>';