mirror of
https://gitee.com/devlive-community/datacap.git
synced 2024-11-30 11:07:41 +08:00
[Plugin] [Zookeeper] Improve path matching rules
This commit is contained in:
parent
72b7277435
commit
38b161bf15
@ -1,32 +1,37 @@
|
||||
grammar ZookeeperSql;
|
||||
|
||||
singleStatement : statement EOF ;
|
||||
singleStatement:(statement)*;
|
||||
|
||||
statement : 'SELECT' selectElements fromClause ;
|
||||
SELECT: [Ss][Ee][Ll][Ee][Cc][Tt];
|
||||
FROM: [Ff][Rr][Oo][Mm];
|
||||
|
||||
fromClause : 'FROM' qualifiedName;
|
||||
|
||||
selectElements : ID|'*' ;
|
||||
|
||||
ID : [a-zA-Z]+ ;
|
||||
|
||||
WS : [ \r\n\t]+ -> skip ;
|
||||
|
||||
QUOTED_IDENTIFIER
|
||||
: '"' ( ~'"' | '""' )* '"'
|
||||
statement
|
||||
: SELECT columnStatement fromClause
|
||||
;
|
||||
|
||||
columnStatement: identifier;
|
||||
|
||||
fromClause : FROM tableName;
|
||||
|
||||
tableName: identifier ('.' identifier)*;
|
||||
identifier: (IDENTIFIER | STRING | quotedIdentifier)*;
|
||||
quotedIdentifier: BACKQUOTED_IDENTIFIER;
|
||||
|
||||
fragment DIGIT:[0-9];
|
||||
fragment LETTER:[a-zA-Z];
|
||||
STRING
|
||||
: '\'' ( ~('\''|'\\') | ('\\' .) )* '\''
|
||||
| '"' ( ~('"'|'\\') | ('\\' .) )* '"'
|
||||
| '*'
|
||||
;
|
||||
IDENTIFIER
|
||||
: (LETTER | DIGIT | '_')+
|
||||
;
|
||||
BACKQUOTED_IDENTIFIER
|
||||
: '`' ( ~'`' | '``' )* '`'
|
||||
;
|
||||
|
||||
qualifiedName
|
||||
: identifier ('.' identifier)*
|
||||
;
|
||||
|
||||
identifier
|
||||
: IDENTIFIER
|
||||
| QUOTED_IDENTIFIER #quotedIdentifier
|
||||
| BACKQUOTED_IDENTIFIER #backQuotedIdentifier
|
||||
| DIGIT_IDENTIFIER #digitIdentifier
|
||||
;
|
||||
SIMPLE_COMMENT: '--' ~[\r\n]* '\r'? '\n'? -> channel(HIDDEN);
|
||||
BRACKETED_EMPTY_COMMENT: '/**/' -> channel(HIDDEN);
|
||||
BRACKETED_COMMENT : '/*' ~[+] .*? '*/' -> channel(HIDDEN);
|
||||
WS: [ \r\n\t]+ -> channel(HIDDEN);
|
||||
|
@ -74,11 +74,7 @@ public class ZookeeperAdapter
|
||||
ZkClient client = this.zookeeperConnection.getClient();
|
||||
headers.add(node.getColumns().get(0));
|
||||
types.add("String");
|
||||
if (node.getTable().equalsIgnoreCase("all")) {
|
||||
node.setTable("");
|
||||
}
|
||||
|
||||
client.getChildren("/" + node.getTable().replace(".", "/"))
|
||||
client.getChildren(ZookeeperPathConvert.toPath(node.getTable()))
|
||||
.forEach(column -> columns.add(handlerFormatter(configure.getFormat(), headers, Collections.singletonList(column))));
|
||||
response.setIsSuccessful(Boolean.TRUE);
|
||||
}
|
||||
|
@ -0,0 +1,62 @@
|
||||
package io.edurt.datacap.plugin.natived.zookeeper;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class ZookeeperPathConvert
|
||||
{
|
||||
public static final String start = "/";
|
||||
public static final String regex = "`([A-Z|a-z|0-9|_|.|-]*)`";
|
||||
|
||||
private ZookeeperPathConvert()
|
||||
{}
|
||||
|
||||
public static String toPath(String source)
|
||||
{
|
||||
if (source.equalsIgnoreCase("all")) {
|
||||
return start;
|
||||
}
|
||||
// Replace `` tag content
|
||||
Pattern patten = Pattern.compile(regex);
|
||||
Matcher matcher = patten.matcher(source);
|
||||
List<String> matchers = new ArrayList<>();
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
boolean appendStart = true;
|
||||
String withStart = null;
|
||||
while (matcher.find()) {
|
||||
if (matcher.start() == 0) {
|
||||
// "`sd.dd`.a.n.`d_dd`"
|
||||
buffer.append(start);
|
||||
buffer.append(matcher.group());
|
||||
withStart = matcher.group();
|
||||
}
|
||||
else if (matcher.start() > 0) {
|
||||
buffer.append(start);
|
||||
if (appendStart) {
|
||||
if (StringUtils.isNotEmpty(withStart)) {
|
||||
buffer.append(source.replace(withStart, "").substring(0, matcher.start() - withStart.length()).replace(".", start));
|
||||
}
|
||||
else {
|
||||
buffer.append(source.substring(0, matcher.start()).replace(".", start));
|
||||
}
|
||||
buffer.append(matcher.group());
|
||||
appendStart = false;
|
||||
}
|
||||
else {
|
||||
buffer.append(matcher.group());
|
||||
}
|
||||
}
|
||||
matchers.add(matcher.group());
|
||||
}
|
||||
if (matchers.size() > 0) {
|
||||
return buffer.toString().replace("`", "").replace("//", start);
|
||||
}
|
||||
else {
|
||||
return start + source.replace(".", start);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,8 +1,5 @@
|
||||
token literal names:
|
||||
null
|
||||
'SELECT'
|
||||
'FROM'
|
||||
'*'
|
||||
'.'
|
||||
null
|
||||
null
|
||||
@ -10,28 +7,32 @@ null
|
||||
null
|
||||
null
|
||||
null
|
||||
'/**/'
|
||||
null
|
||||
null
|
||||
|
||||
token symbolic names:
|
||||
null
|
||||
null
|
||||
null
|
||||
null
|
||||
null
|
||||
ID
|
||||
WS
|
||||
QUOTED_IDENTIFIER
|
||||
BACKQUOTED_IDENTIFIER
|
||||
SELECT
|
||||
FROM
|
||||
STRING
|
||||
IDENTIFIER
|
||||
DIGIT_IDENTIFIER
|
||||
BACKQUOTED_IDENTIFIER
|
||||
SIMPLE_COMMENT
|
||||
BRACKETED_EMPTY_COMMENT
|
||||
BRACKETED_COMMENT
|
||||
WS
|
||||
|
||||
rule names:
|
||||
singleStatement
|
||||
statement
|
||||
columnStatement
|
||||
fromClause
|
||||
selectElements
|
||||
qualifiedName
|
||||
tableName
|
||||
identifier
|
||||
quotedIdentifier
|
||||
|
||||
|
||||
atn:
|
||||
[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 3, 12, 37, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 3, 2, 3, 2, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 3, 4, 3, 4, 3, 5, 3, 5, 3, 6, 3, 6, 3, 6, 7, 6, 30, 10, 6, 12, 6, 14, 6, 33, 11, 6, 3, 7, 3, 7, 3, 7, 2, 2, 8, 2, 4, 6, 8, 10, 12, 2, 4, 4, 2, 5, 5, 7, 7, 3, 2, 9, 12, 2, 31, 2, 14, 3, 2, 2, 2, 4, 17, 3, 2, 2, 2, 6, 21, 3, 2, 2, 2, 8, 24, 3, 2, 2, 2, 10, 26, 3, 2, 2, 2, 12, 34, 3, 2, 2, 2, 14, 15, 5, 4, 3, 2, 15, 16, 7, 2, 2, 3, 16, 3, 3, 2, 2, 2, 17, 18, 7, 3, 2, 2, 18, 19, 5, 8, 5, 2, 19, 20, 5, 6, 4, 2, 20, 5, 3, 2, 2, 2, 21, 22, 7, 4, 2, 2, 22, 23, 5, 10, 6, 2, 23, 7, 3, 2, 2, 2, 24, 25, 9, 2, 2, 2, 25, 9, 3, 2, 2, 2, 26, 31, 5, 12, 7, 2, 27, 28, 7, 6, 2, 2, 28, 30, 5, 12, 7, 2, 29, 27, 3, 2, 2, 2, 30, 33, 3, 2, 2, 2, 31, 29, 3, 2, 2, 2, 31, 32, 3, 2, 2, 2, 32, 11, 3, 2, 2, 2, 33, 31, 3, 2, 2, 2, 34, 35, 9, 3, 2, 2, 35, 13, 3, 2, 2, 2, 3, 31]
|
||||
[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 3, 12, 50, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 4, 8, 9, 8, 3, 2, 7, 2, 18, 10, 2, 12, 2, 14, 2, 21, 11, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 3, 4, 3, 5, 3, 5, 3, 5, 3, 6, 3, 6, 3, 6, 7, 6, 35, 10, 6, 12, 6, 14, 6, 38, 11, 6, 3, 7, 3, 7, 3, 7, 7, 7, 43, 10, 7, 12, 7, 14, 7, 46, 11, 7, 3, 8, 3, 8, 3, 8, 2, 2, 9, 2, 4, 6, 8, 10, 12, 14, 2, 2, 2, 47, 2, 19, 3, 2, 2, 2, 4, 22, 3, 2, 2, 2, 6, 26, 3, 2, 2, 2, 8, 28, 3, 2, 2, 2, 10, 31, 3, 2, 2, 2, 12, 44, 3, 2, 2, 2, 14, 47, 3, 2, 2, 2, 16, 18, 5, 4, 3, 2, 17, 16, 3, 2, 2, 2, 18, 21, 3, 2, 2, 2, 19, 17, 3, 2, 2, 2, 19, 20, 3, 2, 2, 2, 20, 3, 3, 2, 2, 2, 21, 19, 3, 2, 2, 2, 22, 23, 7, 4, 2, 2, 23, 24, 5, 6, 4, 2, 24, 25, 5, 8, 5, 2, 25, 5, 3, 2, 2, 2, 26, 27, 5, 12, 7, 2, 27, 7, 3, 2, 2, 2, 28, 29, 7, 5, 2, 2, 29, 30, 5, 10, 6, 2, 30, 9, 3, 2, 2, 2, 31, 36, 5, 12, 7, 2, 32, 33, 7, 3, 2, 2, 33, 35, 5, 12, 7, 2, 34, 32, 3, 2, 2, 2, 35, 38, 3, 2, 2, 2, 36, 34, 3, 2, 2, 2, 36, 37, 3, 2, 2, 2, 37, 11, 3, 2, 2, 2, 38, 36, 3, 2, 2, 2, 39, 43, 7, 7, 2, 2, 40, 43, 7, 6, 2, 2, 41, 43, 5, 14, 8, 2, 42, 39, 3, 2, 2, 2, 42, 40, 3, 2, 2, 2, 42, 41, 3, 2, 2, 2, 43, 46, 3, 2, 2, 2, 44, 42, 3, 2, 2, 2, 44, 45, 3, 2, 2, 2, 45, 13, 3, 2, 2, 2, 46, 44, 3, 2, 2, 2, 47, 48, 7, 8, 2, 2, 48, 15, 3, 2, 2, 2, 6, 19, 36, 42, 44]
|
@ -1,14 +1,12 @@
|
||||
T__0=1
|
||||
T__1=2
|
||||
T__2=3
|
||||
T__3=4
|
||||
ID=5
|
||||
WS=6
|
||||
QUOTED_IDENTIFIER=7
|
||||
BACKQUOTED_IDENTIFIER=8
|
||||
IDENTIFIER=9
|
||||
DIGIT_IDENTIFIER=10
|
||||
'SELECT'=1
|
||||
'FROM'=2
|
||||
'*'=3
|
||||
'.'=4
|
||||
SELECT=2
|
||||
FROM=3
|
||||
STRING=4
|
||||
IDENTIFIER=5
|
||||
BACKQUOTED_IDENTIFIER=6
|
||||
SIMPLE_COMMENT=7
|
||||
BRACKETED_EMPTY_COMMENT=8
|
||||
BRACKETED_COMMENT=9
|
||||
WS=10
|
||||
'.'=1
|
||||
'/**/'=8
|
||||
|
@ -45,6 +45,22 @@ public class ZookeeperSqlBaseListener
|
||||
@Override
|
||||
public void exitStatement(ZookeeperSqlParser.StatementContext ctx) {}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override
|
||||
public void enterColumnStatement(ZookeeperSqlParser.ColumnStatementContext ctx) {}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override
|
||||
public void exitColumnStatement(ZookeeperSqlParser.ColumnStatementContext ctx) {}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
@ -67,7 +83,7 @@ public class ZookeeperSqlBaseListener
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override
|
||||
public void enterSelectElements(ZookeeperSqlParser.SelectElementsContext ctx) {}
|
||||
public void enterTableName(ZookeeperSqlParser.TableNameContext ctx) {}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
@ -75,7 +91,7 @@ public class ZookeeperSqlBaseListener
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override
|
||||
public void exitSelectElements(ZookeeperSqlParser.SelectElementsContext ctx) {}
|
||||
public void exitTableName(ZookeeperSqlParser.TableNameContext ctx) {}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
@ -83,7 +99,7 @@ public class ZookeeperSqlBaseListener
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override
|
||||
public void enterQualifiedName(ZookeeperSqlParser.QualifiedNameContext ctx) {}
|
||||
public void enterIdentifier(ZookeeperSqlParser.IdentifierContext ctx) {}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
@ -91,23 +107,7 @@ public class ZookeeperSqlBaseListener
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override
|
||||
public void exitQualifiedName(ZookeeperSqlParser.QualifiedNameContext ctx) {}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override
|
||||
public void enterUnquotedIdentifier(ZookeeperSqlParser.UnquotedIdentifierContext ctx) {}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override
|
||||
public void exitUnquotedIdentifier(ZookeeperSqlParser.UnquotedIdentifierContext ctx) {}
|
||||
public void exitIdentifier(ZookeeperSqlParser.IdentifierContext ctx) {}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
@ -125,38 +125,6 @@ public class ZookeeperSqlBaseListener
|
||||
@Override
|
||||
public void exitQuotedIdentifier(ZookeeperSqlParser.QuotedIdentifierContext ctx) {}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override
|
||||
public void enterBackQuotedIdentifier(ZookeeperSqlParser.BackQuotedIdentifierContext ctx) {}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override
|
||||
public void exitBackQuotedIdentifier(ZookeeperSqlParser.BackQuotedIdentifierContext ctx) {}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override
|
||||
public void enterDigitIdentifier(ZookeeperSqlParser.DigitIdentifierContext ctx) {}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override
|
||||
public void exitDigitIdentifier(ZookeeperSqlParser.DigitIdentifierContext ctx) {}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
|
@ -1,34 +1,42 @@
|
||||
token literal names:
|
||||
null
|
||||
'SELECT'
|
||||
'FROM'
|
||||
'*'
|
||||
'.'
|
||||
null
|
||||
null
|
||||
null
|
||||
null
|
||||
null
|
||||
null
|
||||
'/**/'
|
||||
null
|
||||
null
|
||||
|
||||
token symbolic names:
|
||||
null
|
||||
null
|
||||
null
|
||||
null
|
||||
null
|
||||
ID
|
||||
WS
|
||||
QUOTED_IDENTIFIER
|
||||
SELECT
|
||||
FROM
|
||||
STRING
|
||||
IDENTIFIER
|
||||
BACKQUOTED_IDENTIFIER
|
||||
SIMPLE_COMMENT
|
||||
BRACKETED_EMPTY_COMMENT
|
||||
BRACKETED_COMMENT
|
||||
WS
|
||||
|
||||
rule names:
|
||||
T__0
|
||||
T__1
|
||||
T__2
|
||||
T__3
|
||||
ID
|
||||
WS
|
||||
QUOTED_IDENTIFIER
|
||||
SELECT
|
||||
FROM
|
||||
DIGIT
|
||||
LETTER
|
||||
STRING
|
||||
IDENTIFIER
|
||||
BACKQUOTED_IDENTIFIER
|
||||
SIMPLE_COMMENT
|
||||
BRACKETED_EMPTY_COMMENT
|
||||
BRACKETED_COMMENT
|
||||
WS
|
||||
|
||||
channel names:
|
||||
DEFAULT_TOKEN_CHANNEL
|
||||
@ -38,4 +46,4 @@ mode names:
|
||||
DEFAULT_MODE
|
||||
|
||||
atn:
|
||||
[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 2, 10, 69, 8, 1, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 3, 4, 3, 5, 3, 5, 3, 6, 6, 6, 37, 10, 6, 13, 6, 14, 6, 38, 3, 7, 6, 7, 42, 10, 7, 13, 7, 14, 7, 43, 3, 7, 3, 7, 3, 8, 3, 8, 3, 8, 3, 8, 7, 8, 52, 10, 8, 12, 8, 14, 8, 55, 11, 8, 3, 8, 3, 8, 3, 9, 3, 9, 3, 9, 3, 9, 7, 9, 63, 10, 9, 12, 9, 14, 9, 66, 11, 9, 3, 9, 3, 9, 2, 2, 10, 3, 3, 5, 4, 7, 5, 9, 6, 11, 7, 13, 8, 15, 9, 17, 10, 3, 2, 6, 4, 2, 67, 92, 99, 124, 5, 2, 11, 12, 15, 15, 34, 34, 3, 2, 36, 36, 3, 2, 98, 98, 2, 74, 2, 3, 3, 2, 2, 2, 2, 5, 3, 2, 2, 2, 2, 7, 3, 2, 2, 2, 2, 9, 3, 2, 2, 2, 2, 11, 3, 2, 2, 2, 2, 13, 3, 2, 2, 2, 2, 15, 3, 2, 2, 2, 2, 17, 3, 2, 2, 2, 3, 19, 3, 2, 2, 2, 5, 26, 3, 2, 2, 2, 7, 31, 3, 2, 2, 2, 9, 33, 3, 2, 2, 2, 11, 36, 3, 2, 2, 2, 13, 41, 3, 2, 2, 2, 15, 47, 3, 2, 2, 2, 17, 58, 3, 2, 2, 2, 19, 20, 7, 85, 2, 2, 20, 21, 7, 71, 2, 2, 21, 22, 7, 78, 2, 2, 22, 23, 7, 71, 2, 2, 23, 24, 7, 69, 2, 2, 24, 25, 7, 86, 2, 2, 25, 4, 3, 2, 2, 2, 26, 27, 7, 72, 2, 2, 27, 28, 7, 84, 2, 2, 28, 29, 7, 81, 2, 2, 29, 30, 7, 79, 2, 2, 30, 6, 3, 2, 2, 2, 31, 32, 7, 44, 2, 2, 32, 8, 3, 2, 2, 2, 33, 34, 7, 48, 2, 2, 34, 10, 3, 2, 2, 2, 35, 37, 9, 2, 2, 2, 36, 35, 3, 2, 2, 2, 37, 38, 3, 2, 2, 2, 38, 36, 3, 2, 2, 2, 38, 39, 3, 2, 2, 2, 39, 12, 3, 2, 2, 2, 40, 42, 9, 3, 2, 2, 41, 40, 3, 2, 2, 2, 42, 43, 3, 2, 2, 2, 43, 41, 3, 2, 2, 2, 43, 44, 3, 2, 2, 2, 44, 45, 3, 2, 2, 2, 45, 46, 8, 7, 2, 2, 46, 14, 3, 2, 2, 2, 47, 53, 7, 36, 2, 2, 48, 52, 10, 4, 2, 2, 49, 50, 7, 36, 2, 2, 50, 52, 7, 36, 2, 2, 51, 48, 3, 2, 2, 2, 51, 49, 3, 2, 2, 2, 52, 55, 3, 2, 2, 2, 53, 51, 3, 2, 2, 2, 53, 54, 3, 2, 2, 2, 54, 56, 3, 2, 2, 2, 55, 53, 3, 2, 2, 2, 56, 57, 7, 36, 2, 2, 57, 16, 3, 2, 2, 2, 58, 64, 7, 98, 2, 2, 59, 63, 10, 5, 2, 2, 60, 61, 7, 98, 2, 2, 61, 63, 7, 98, 2, 2, 62, 59, 3, 2, 2, 2, 62, 60, 3, 2, 2, 2, 63, 66, 3, 2, 2, 2, 64, 62, 3, 2, 2, 2, 64, 65, 3, 2, 2, 2, 65, 67, 3, 2, 2, 2, 66, 64, 3, 2, 2, 2, 67, 68, 7, 98, 2, 2, 68, 18, 3, 2, 2, 2, 9, 2, 38, 43, 51, 53, 62, 64, 3, 8, 2, 2]
|
||||
[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 2, 12, 132, 8, 1, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 4, 13, 9, 13, 3, 2, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 5, 3, 5, 3, 6, 3, 6, 3, 7, 3, 7, 3, 7, 3, 7, 7, 7, 50, 10, 7, 12, 7, 14, 7, 53, 11, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 7, 7, 60, 10, 7, 12, 7, 14, 7, 63, 11, 7, 3, 7, 3, 7, 5, 7, 67, 10, 7, 3, 8, 3, 8, 3, 8, 6, 8, 72, 10, 8, 13, 8, 14, 8, 73, 3, 9, 3, 9, 3, 9, 3, 9, 7, 9, 80, 10, 9, 12, 9, 14, 9, 83, 11, 9, 3, 9, 3, 9, 3, 10, 3, 10, 3, 10, 3, 10, 7, 10, 91, 10, 10, 12, 10, 14, 10, 94, 11, 10, 3, 10, 5, 10, 97, 10, 10, 3, 10, 5, 10, 100, 10, 10, 3, 10, 3, 10, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 7, 12, 116, 10, 12, 12, 12, 14, 12, 119, 11, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 13, 6, 13, 127, 10, 13, 13, 13, 14, 13, 128, 3, 13, 3, 13, 3, 117, 2, 14, 3, 3, 5, 4, 7, 5, 9, 2, 11, 2, 13, 6, 15, 7, 17, 8, 19, 9, 21, 10, 23, 11, 25, 12, 3, 2, 19, 4, 2, 85, 85, 117, 117, 4, 2, 71, 71, 103, 103, 4, 2, 78, 78, 110, 110, 4, 2, 69, 69, 101, 101, 4, 2, 86, 86, 118, 118, 4, 2, 72, 72, 104, 104, 4, 2, 84, 84, 116, 116, 4, 2, 81, 81, 113, 113, 4, 2, 79, 79, 111, 111, 3, 2, 50, 59, 4, 2, 67, 92, 99, 124, 4, 2, 41, 41, 94, 94, 4, 2, 36, 36, 94, 94, 3, 2, 98, 98, 4, 2, 12, 12, 15, 15, 3, 2, 45, 45, 5, 2, 11, 12, 15, 15, 34, 34, 2, 145, 2, 3, 3, 2, 2, 2, 2, 5, 3, 2, 2, 2, 2, 7, 3, 2, 2, 2, 2, 13, 3, 2, 2, 2, 2, 15, 3, 2, 2, 2, 2, 17, 3, 2, 2, 2, 2, 19, 3, 2, 2, 2, 2, 21, 3, 2, 2, 2, 2, 23, 3, 2, 2, 2, 2, 25, 3, 2, 2, 2, 3, 27, 3, 2, 2, 2, 5, 29, 3, 2, 2, 2, 7, 36, 3, 2, 2, 2, 9, 41, 3, 2, 2, 2, 11, 43, 3, 2, 2, 2, 13, 66, 3, 2, 2, 2, 15, 71, 3, 2, 2, 2, 17, 75, 3, 2, 2, 2, 19, 86, 3, 2, 2, 2, 21, 103, 3, 2, 2, 2, 23, 110, 3, 2, 2, 2, 25, 126, 3, 2, 2, 2, 27, 28, 7, 48, 2, 2, 28, 4, 3, 2, 2, 2, 29, 30, 9, 2, 2, 2, 30, 31, 9, 3, 2, 2, 31, 32, 9, 4, 2, 2, 32, 33, 9, 3, 2, 2, 33, 34, 9, 5, 2, 2, 34, 35, 9, 6, 2, 2, 35, 6, 3, 2, 2, 2, 36, 37, 9, 7, 2, 2, 37, 38, 9, 8, 2, 2, 38, 39, 9, 9, 2, 2, 39, 40, 9, 10, 2, 2, 40, 8, 3, 2, 2, 2, 41, 42, 9, 11, 2, 2, 42, 10, 3, 2, 2, 2, 43, 44, 9, 12, 2, 2, 44, 12, 3, 2, 2, 2, 45, 51, 7, 41, 2, 2, 46, 50, 10, 13, 2, 2, 47, 48, 7, 94, 2, 2, 48, 50, 11, 2, 2, 2, 49, 46, 3, 2, 2, 2, 49, 47, 3, 2, 2, 2, 50, 53, 3, 2, 2, 2, 51, 49, 3, 2, 2, 2, 51, 52, 3, 2, 2, 2, 52, 54, 3, 2, 2, 2, 53, 51, 3, 2, 2, 2, 54, 67, 7, 41, 2, 2, 55, 61, 7, 36, 2, 2, 56, 60, 10, 14, 2, 2, 57, 58, 7, 94, 2, 2, 58, 60, 11, 2, 2, 2, 59, 56, 3, 2, 2, 2, 59, 57, 3, 2, 2, 2, 60, 63, 3, 2, 2, 2, 61, 59, 3, 2, 2, 2, 61, 62, 3, 2, 2, 2, 62, 64, 3, 2, 2, 2, 63, 61, 3, 2, 2, 2, 64, 67, 7, 36, 2, 2, 65, 67, 7, 44, 2, 2, 66, 45, 3, 2, 2, 2, 66, 55, 3, 2, 2, 2, 66, 65, 3, 2, 2, 2, 67, 14, 3, 2, 2, 2, 68, 72, 5, 11, 6, 2, 69, 72, 5, 9, 5, 2, 70, 72, 7, 97, 2, 2, 71, 68, 3, 2, 2, 2, 71, 69, 3, 2, 2, 2, 71, 70, 3, 2, 2, 2, 72, 73, 3, 2, 2, 2, 73, 71, 3, 2, 2, 2, 73, 74, 3, 2, 2, 2, 74, 16, 3, 2, 2, 2, 75, 81, 7, 98, 2, 2, 76, 80, 10, 15, 2, 2, 77, 78, 7, 98, 2, 2, 78, 80, 7, 98, 2, 2, 79, 76, 3, 2, 2, 2, 79, 77, 3, 2, 2, 2, 80, 83, 3, 2, 2, 2, 81, 79, 3, 2, 2, 2, 81, 82, 3, 2, 2, 2, 82, 84, 3, 2, 2, 2, 83, 81, 3, 2, 2, 2, 84, 85, 7, 98, 2, 2, 85, 18, 3, 2, 2, 2, 86, 87, 7, 47, 2, 2, 87, 88, 7, 47, 2, 2, 88, 92, 3, 2, 2, 2, 89, 91, 10, 16, 2, 2, 90, 89, 3, 2, 2, 2, 91, 94, 3, 2, 2, 2, 92, 90, 3, 2, 2, 2, 92, 93, 3, 2, 2, 2, 93, 96, 3, 2, 2, 2, 94, 92, 3, 2, 2, 2, 95, 97, 7, 15, 2, 2, 96, 95, 3, 2, 2, 2, 96, 97, 3, 2, 2, 2, 97, 99, 3, 2, 2, 2, 98, 100, 7, 12, 2, 2, 99, 98, 3, 2, 2, 2, 99, 100, 3, 2, 2, 2, 100, 101, 3, 2, 2, 2, 101, 102, 8, 10, 2, 2, 102, 20, 3, 2, 2, 2, 103, 104, 7, 49, 2, 2, 104, 105, 7, 44, 2, 2, 105, 106, 7, 44, 2, 2, 106, 107, 7, 49, 2, 2, 107, 108, 3, 2, 2, 2, 108, 109, 8, 11, 2, 2, 109, 22, 3, 2, 2, 2, 110, 111, 7, 49, 2, 2, 111, 112, 7, 44, 2, 2, 112, 113, 3, 2, 2, 2, 113, 117, 10, 17, 2, 2, 114, 116, 11, 2, 2, 2, 115, 114, 3, 2, 2, 2, 116, 119, 3, 2, 2, 2, 117, 118, 3, 2, 2, 2, 117, 115, 3, 2, 2, 2, 118, 120, 3, 2, 2, 2, 119, 117, 3, 2, 2, 2, 120, 121, 7, 44, 2, 2, 121, 122, 7, 49, 2, 2, 122, 123, 3, 2, 2, 2, 123, 124, 8, 12, 2, 2, 124, 24, 3, 2, 2, 2, 125, 127, 9, 18, 2, 2, 126, 125, 3, 2, 2, 2, 127, 128, 3, 2, 2, 2, 128, 126, 3, 2, 2, 2, 128, 129, 3, 2, 2, 2, 129, 130, 3, 2, 2, 2, 130, 131, 8, 13, 2, 2, 131, 26, 3, 2, 2, 2, 17, 2, 49, 51, 59, 61, 66, 71, 73, 79, 81, 92, 96, 99, 117, 128, 3, 2, 3, 2]
|
@ -24,7 +24,8 @@ public class ZookeeperSqlLexer
|
||||
protected static final PredictionContextCache _sharedContextCache =
|
||||
new PredictionContextCache();
|
||||
public static final int
|
||||
T__0 = 1, T__1 = 2, T__2 = 3, T__3 = 4, ID = 5, WS = 6;
|
||||
T__0 = 1, SELECT = 2, FROM = 3, STRING = 4, IDENTIFIER = 5, BACKQUOTED_IDENTIFIER = 6,
|
||||
SIMPLE_COMMENT = 7, BRACKETED_EMPTY_COMMENT = 8, BRACKETED_COMMENT = 9, WS = 10;
|
||||
public static String[] channelNames = {
|
||||
"DEFAULT_TOKEN_CHANNEL", "HIDDEN"
|
||||
};
|
||||
@ -36,7 +37,9 @@ public class ZookeeperSqlLexer
|
||||
private static String[] makeRuleNames()
|
||||
{
|
||||
return new String[] {
|
||||
"T__0", "T__1", "T__2", "T__3", "ID", "WS"
|
||||
"T__0", "SELECT", "FROM", "DIGIT", "LETTER", "STRING", "IDENTIFIER",
|
||||
"BACKQUOTED_IDENTIFIER", "SIMPLE_COMMENT", "BRACKETED_EMPTY_COMMENT",
|
||||
"BRACKETED_COMMENT", "WS"
|
||||
};
|
||||
}
|
||||
|
||||
@ -45,7 +48,7 @@ public class ZookeeperSqlLexer
|
||||
private static String[] makeLiteralNames()
|
||||
{
|
||||
return new String[] {
|
||||
null, "'SELECT'", "'FROM'", "'*'", "'.'"
|
||||
null, "'.'", null, null, null, null, null, null, "'/**/'"
|
||||
};
|
||||
}
|
||||
|
||||
@ -54,7 +57,8 @@ public class ZookeeperSqlLexer
|
||||
private static String[] makeSymbolicNames()
|
||||
{
|
||||
return new String[] {
|
||||
null, null, null, null, null, "ID", "WS"
|
||||
null, null, "SELECT", "FROM", "STRING", "IDENTIFIER", "BACKQUOTED_IDENTIFIER",
|
||||
"SIMPLE_COMMENT", "BRACKETED_EMPTY_COMMENT", "BRACKETED_COMMENT", "WS"
|
||||
};
|
||||
}
|
||||
|
||||
@ -120,18 +124,43 @@ public class ZookeeperSqlLexer
|
||||
public ATN getATN() {return _ATN;}
|
||||
|
||||
public static final String _serializedATN =
|
||||
"\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2\b+\b\1\4\2\t\2\4" +
|
||||
"\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\3" +
|
||||
"\3\3\3\3\3\3\3\3\3\4\3\4\3\5\3\5\3\6\6\6!\n\6\r\6\16\6\"\3\7\6\7&\n\7" +
|
||||
"\r\7\16\7\'\3\7\3\7\2\2\b\3\3\5\4\7\5\t\6\13\7\r\b\3\2\4\4\2C\\c|\5\2" +
|
||||
"\13\f\17\17\"\"\2,\2\3\3\2\2\2\2\5\3\2\2\2\2\7\3\2\2\2\2\t\3\2\2\2\2\13" +
|
||||
"\3\2\2\2\2\r\3\2\2\2\3\17\3\2\2\2\5\26\3\2\2\2\7\33\3\2\2\2\t\35\3\2\2" +
|
||||
"\2\13 \3\2\2\2\r%\3\2\2\2\17\20\7U\2\2\20\21\7G\2\2\21\22\7N\2\2\22\23" +
|
||||
"\7G\2\2\23\24\7E\2\2\24\25\7V\2\2\25\4\3\2\2\2\26\27\7H\2\2\27\30\7T\2" +
|
||||
"\2\30\31\7Q\2\2\31\32\7O\2\2\32\6\3\2\2\2\33\34\7,\2\2\34\b\3\2\2\2\35" +
|
||||
"\36\7\60\2\2\36\n\3\2\2\2\37!\t\2\2\2 \37\3\2\2\2!\"\3\2\2\2\" \3\2\2" +
|
||||
"\2\"#\3\2\2\2#\f\3\2\2\2$&\t\3\2\2%$\3\2\2\2&\'\3\2\2\2\'%\3\2\2\2\'(" +
|
||||
"\3\2\2\2()\3\2\2\2)*\b\7\2\2*\16\3\2\2\2\5\2\"\'\3\b\2\2";
|
||||
"\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2\f\u0084\b\1\4\2\t" +
|
||||
"\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13" +
|
||||
"\t\13\4\f\t\f\4\r\t\r\3\2\3\2\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\4\3\4\3\4" +
|
||||
"\3\4\3\4\3\5\3\5\3\6\3\6\3\7\3\7\3\7\3\7\7\7\62\n\7\f\7\16\7\65\13\7\3" +
|
||||
"\7\3\7\3\7\3\7\3\7\7\7<\n\7\f\7\16\7?\13\7\3\7\3\7\5\7C\n\7\3\b\3\b\3" +
|
||||
"\b\6\bH\n\b\r\b\16\bI\3\t\3\t\3\t\3\t\7\tP\n\t\f\t\16\tS\13\t\3\t\3\t" +
|
||||
"\3\n\3\n\3\n\3\n\7\n[\n\n\f\n\16\n^\13\n\3\n\5\na\n\n\3\n\5\nd\n\n\3\n" +
|
||||
"\3\n\3\13\3\13\3\13\3\13\3\13\3\13\3\13\3\f\3\f\3\f\3\f\3\f\7\ft\n\f\f" +
|
||||
"\f\16\fw\13\f\3\f\3\f\3\f\3\f\3\f\3\r\6\r\177\n\r\r\r\16\r\u0080\3\r\3" +
|
||||
"\r\3u\2\16\3\3\5\4\7\5\t\2\13\2\r\6\17\7\21\b\23\t\25\n\27\13\31\f\3\2" +
|
||||
"\23\4\2UUuu\4\2GGgg\4\2NNnn\4\2EEee\4\2VVvv\4\2HHhh\4\2TTtt\4\2QQqq\4" +
|
||||
"\2OOoo\3\2\62;\4\2C\\c|\4\2))^^\4\2$$^^\3\2bb\4\2\f\f\17\17\3\2--\5\2" +
|
||||
"\13\f\17\17\"\"\2\u0091\2\3\3\2\2\2\2\5\3\2\2\2\2\7\3\2\2\2\2\r\3\2\2" +
|
||||
"\2\2\17\3\2\2\2\2\21\3\2\2\2\2\23\3\2\2\2\2\25\3\2\2\2\2\27\3\2\2\2\2" +
|
||||
"\31\3\2\2\2\3\33\3\2\2\2\5\35\3\2\2\2\7$\3\2\2\2\t)\3\2\2\2\13+\3\2\2" +
|
||||
"\2\rB\3\2\2\2\17G\3\2\2\2\21K\3\2\2\2\23V\3\2\2\2\25g\3\2\2\2\27n\3\2" +
|
||||
"\2\2\31~\3\2\2\2\33\34\7\60\2\2\34\4\3\2\2\2\35\36\t\2\2\2\36\37\t\3\2" +
|
||||
"\2\37 \t\4\2\2 !\t\3\2\2!\"\t\5\2\2\"#\t\6\2\2#\6\3\2\2\2$%\t\7\2\2%&" +
|
||||
"\t\b\2\2&\'\t\t\2\2\'(\t\n\2\2(\b\3\2\2\2)*\t\13\2\2*\n\3\2\2\2+,\t\f" +
|
||||
"\2\2,\f\3\2\2\2-\63\7)\2\2.\62\n\r\2\2/\60\7^\2\2\60\62\13\2\2\2\61.\3" +
|
||||
"\2\2\2\61/\3\2\2\2\62\65\3\2\2\2\63\61\3\2\2\2\63\64\3\2\2\2\64\66\3\2" +
|
||||
"\2\2\65\63\3\2\2\2\66C\7)\2\2\67=\7$\2\28<\n\16\2\29:\7^\2\2:<\13\2\2" +
|
||||
"\2;8\3\2\2\2;9\3\2\2\2<?\3\2\2\2=;\3\2\2\2=>\3\2\2\2>@\3\2\2\2?=\3\2\2" +
|
||||
"\2@C\7$\2\2AC\7,\2\2B-\3\2\2\2B\67\3\2\2\2BA\3\2\2\2C\16\3\2\2\2DH\5\13" +
|
||||
"\6\2EH\5\t\5\2FH\7a\2\2GD\3\2\2\2GE\3\2\2\2GF\3\2\2\2HI\3\2\2\2IG\3\2" +
|
||||
"\2\2IJ\3\2\2\2J\20\3\2\2\2KQ\7b\2\2LP\n\17\2\2MN\7b\2\2NP\7b\2\2OL\3\2" +
|
||||
"\2\2OM\3\2\2\2PS\3\2\2\2QO\3\2\2\2QR\3\2\2\2RT\3\2\2\2SQ\3\2\2\2TU\7b" +
|
||||
"\2\2U\22\3\2\2\2VW\7/\2\2WX\7/\2\2X\\\3\2\2\2Y[\n\20\2\2ZY\3\2\2\2[^\3" +
|
||||
"\2\2\2\\Z\3\2\2\2\\]\3\2\2\2]`\3\2\2\2^\\\3\2\2\2_a\7\17\2\2`_\3\2\2\2" +
|
||||
"`a\3\2\2\2ac\3\2\2\2bd\7\f\2\2cb\3\2\2\2cd\3\2\2\2de\3\2\2\2ef\b\n\2\2" +
|
||||
"f\24\3\2\2\2gh\7\61\2\2hi\7,\2\2ij\7,\2\2jk\7\61\2\2kl\3\2\2\2lm\b\13" +
|
||||
"\2\2m\26\3\2\2\2no\7\61\2\2op\7,\2\2pq\3\2\2\2qu\n\21\2\2rt\13\2\2\2s" +
|
||||
"r\3\2\2\2tw\3\2\2\2uv\3\2\2\2us\3\2\2\2vx\3\2\2\2wu\3\2\2\2xy\7,\2\2y" +
|
||||
"z\7\61\2\2z{\3\2\2\2{|\b\f\2\2|\30\3\2\2\2}\177\t\22\2\2~}\3\2\2\2\177" +
|
||||
"\u0080\3\2\2\2\u0080~\3\2\2\2\u0080\u0081\3\2\2\2\u0081\u0082\3\2\2\2" +
|
||||
"\u0082\u0083\b\r\2\2\u0083\32\3\2\2\2\21\2\61\63;=BGIOQ\\`cu\u0080\3\2" +
|
||||
"\3\2";
|
||||
public static final ATN _ATN =
|
||||
new ATNDeserializer().deserialize(_serializedATN.toCharArray());
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
T__0=1
|
||||
T__1=2
|
||||
T__2=3
|
||||
T__3=4
|
||||
ID=5
|
||||
WS=6
|
||||
QUOTED_IDENTIFIER=7
|
||||
BACKQUOTED_IDENTIFIER=8
|
||||
'SELECT'=1
|
||||
'FROM'=2
|
||||
'*'=3
|
||||
'.'=4
|
||||
SELECT=2
|
||||
FROM=3
|
||||
STRING=4
|
||||
IDENTIFIER=5
|
||||
BACKQUOTED_IDENTIFIER=6
|
||||
SIMPLE_COMMENT=7
|
||||
BRACKETED_EMPTY_COMMENT=8
|
||||
BRACKETED_COMMENT=9
|
||||
WS=10
|
||||
'.'=1
|
||||
'/**/'=8
|
||||
|
@ -38,6 +38,20 @@ public interface ZookeeperSqlListener
|
||||
*/
|
||||
void exitStatement(ZookeeperSqlParser.StatementContext ctx);
|
||||
|
||||
/**
|
||||
* Enter a parse tree produced by {@link ZookeeperSqlParser#columnStatement}.
|
||||
*
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterColumnStatement(ZookeeperSqlParser.ColumnStatementContext ctx);
|
||||
|
||||
/**
|
||||
* Exit a parse tree produced by {@link ZookeeperSqlParser#columnStatement}.
|
||||
*
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitColumnStatement(ZookeeperSqlParser.ColumnStatementContext ctx);
|
||||
|
||||
/**
|
||||
* Enter a parse tree produced by {@link ZookeeperSqlParser#fromClause}.
|
||||
*
|
||||
@ -53,94 +67,44 @@ public interface ZookeeperSqlListener
|
||||
void exitFromClause(ZookeeperSqlParser.FromClauseContext ctx);
|
||||
|
||||
/**
|
||||
* Enter a parse tree produced by {@link ZookeeperSqlParser#selectElements}.
|
||||
* Enter a parse tree produced by {@link ZookeeperSqlParser#tableName}.
|
||||
*
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterSelectElements(ZookeeperSqlParser.SelectElementsContext ctx);
|
||||
void enterTableName(ZookeeperSqlParser.TableNameContext ctx);
|
||||
|
||||
/**
|
||||
* Exit a parse tree produced by {@link ZookeeperSqlParser#selectElements}.
|
||||
* Exit a parse tree produced by {@link ZookeeperSqlParser#tableName}.
|
||||
*
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitSelectElements(ZookeeperSqlParser.SelectElementsContext ctx);
|
||||
void exitTableName(ZookeeperSqlParser.TableNameContext ctx);
|
||||
|
||||
/**
|
||||
* Enter a parse tree produced by {@link ZookeeperSqlParser#qualifiedName}.
|
||||
* Enter a parse tree produced by {@link ZookeeperSqlParser#identifier}.
|
||||
*
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterQualifiedName(ZookeeperSqlParser.QualifiedNameContext ctx);
|
||||
void enterIdentifier(ZookeeperSqlParser.IdentifierContext ctx);
|
||||
|
||||
/**
|
||||
* Exit a parse tree produced by {@link ZookeeperSqlParser#qualifiedName}.
|
||||
* Exit a parse tree produced by {@link ZookeeperSqlParser#identifier}.
|
||||
*
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitQualifiedName(ZookeeperSqlParser.QualifiedNameContext ctx);
|
||||
void exitIdentifier(ZookeeperSqlParser.IdentifierContext ctx);
|
||||
|
||||
/**
|
||||
* Enter a parse tree produced by the {@code unquotedIdentifier}
|
||||
* labeled alternative in {@link ZookeeperSqlParser#identifier}.
|
||||
*
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterUnquotedIdentifier(ZookeeperSqlParser.UnquotedIdentifierContext ctx);
|
||||
|
||||
/**
|
||||
* Exit a parse tree produced by the {@code unquotedIdentifier}
|
||||
* labeled alternative in {@link ZookeeperSqlParser#identifier}.
|
||||
*
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitUnquotedIdentifier(ZookeeperSqlParser.UnquotedIdentifierContext ctx);
|
||||
|
||||
/**
|
||||
* Enter a parse tree produced by the {@code quotedIdentifier}
|
||||
* labeled alternative in {@link ZookeeperSqlParser#identifier}.
|
||||
* Enter a parse tree produced by {@link ZookeeperSqlParser#quotedIdentifier}.
|
||||
*
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterQuotedIdentifier(ZookeeperSqlParser.QuotedIdentifierContext ctx);
|
||||
|
||||
/**
|
||||
* Exit a parse tree produced by the {@code quotedIdentifier}
|
||||
* labeled alternative in {@link ZookeeperSqlParser#identifier}.
|
||||
* Exit a parse tree produced by {@link ZookeeperSqlParser#quotedIdentifier}.
|
||||
*
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitQuotedIdentifier(ZookeeperSqlParser.QuotedIdentifierContext ctx);
|
||||
|
||||
/**
|
||||
* Enter a parse tree produced by the {@code backQuotedIdentifier}
|
||||
* labeled alternative in {@link ZookeeperSqlParser#identifier}.
|
||||
*
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterBackQuotedIdentifier(ZookeeperSqlParser.BackQuotedIdentifierContext ctx);
|
||||
|
||||
/**
|
||||
* Exit a parse tree produced by the {@code backQuotedIdentifier}
|
||||
* labeled alternative in {@link ZookeeperSqlParser#identifier}.
|
||||
*
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitBackQuotedIdentifier(ZookeeperSqlParser.BackQuotedIdentifierContext ctx);
|
||||
|
||||
/**
|
||||
* Enter a parse tree produced by the {@code digitIdentifier}
|
||||
* labeled alternative in {@link ZookeeperSqlParser#identifier}.
|
||||
*
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterDigitIdentifier(ZookeeperSqlParser.DigitIdentifierContext ctx);
|
||||
|
||||
/**
|
||||
* Exit a parse tree produced by the {@code digitIdentifier}
|
||||
* labeled alternative in {@link ZookeeperSqlParser#identifier}.
|
||||
*
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitDigitIdentifier(ZookeeperSqlParser.DigitIdentifierContext ctx);
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ import org.antlr.v4.runtime.Parser;
|
||||
import org.antlr.v4.runtime.ParserRuleContext;
|
||||
import org.antlr.v4.runtime.RecognitionException;
|
||||
import org.antlr.v4.runtime.RuntimeMetaData;
|
||||
import org.antlr.v4.runtime.Token;
|
||||
import org.antlr.v4.runtime.TokenStream;
|
||||
import org.antlr.v4.runtime.Vocabulary;
|
||||
import org.antlr.v4.runtime.VocabularyImpl;
|
||||
@ -32,17 +31,17 @@ public class ZookeeperSqlParser
|
||||
protected static final PredictionContextCache _sharedContextCache =
|
||||
new PredictionContextCache();
|
||||
public static final int
|
||||
T__0 = 1, T__1 = 2, T__2 = 3, T__3 = 4, ID = 5, WS = 6, IDENTIFIER = 7, QUOTED_IDENTIFIER = 8,
|
||||
BACKQUOTED_IDENTIFIER = 9, DIGIT_IDENTIFIER = 10;
|
||||
T__0 = 1, SELECT = 2, FROM = 3, STRING = 4, IDENTIFIER = 5, BACKQUOTED_IDENTIFIER = 6,
|
||||
SIMPLE_COMMENT = 7, BRACKETED_EMPTY_COMMENT = 8, BRACKETED_COMMENT = 9, WS = 10;
|
||||
public static final int
|
||||
RULE_singleStatement = 0, RULE_statement = 1, RULE_fromClause = 2, RULE_selectElements = 3,
|
||||
RULE_qualifiedName = 4, RULE_identifier = 5;
|
||||
RULE_singleStatement = 0, RULE_statement = 1, RULE_columnStatement = 2,
|
||||
RULE_fromClause = 3, RULE_tableName = 4, RULE_identifier = 5, RULE_quotedIdentifier = 6;
|
||||
|
||||
private static String[] makeRuleNames()
|
||||
{
|
||||
return new String[] {
|
||||
"singleStatement", "statement", "fromClause", "selectElements", "qualifiedName",
|
||||
"identifier"
|
||||
"singleStatement", "statement", "columnStatement", "fromClause", "tableName",
|
||||
"identifier", "quotedIdentifier"
|
||||
};
|
||||
}
|
||||
|
||||
@ -51,7 +50,7 @@ public class ZookeeperSqlParser
|
||||
private static String[] makeLiteralNames()
|
||||
{
|
||||
return new String[] {
|
||||
null, "'SELECT'", "'FROM'", "'*'", "'.'"
|
||||
null, "'.'", null, null, null, null, null, null, "'/**/'"
|
||||
};
|
||||
}
|
||||
|
||||
@ -60,8 +59,8 @@ public class ZookeeperSqlParser
|
||||
private static String[] makeSymbolicNames()
|
||||
{
|
||||
return new String[] {
|
||||
null, null, null, null, null, "ID", "WS", "IDENTIFIER", "QUOTED_IDENTIFIER",
|
||||
"BACKQUOTED_IDENTIFIER", "DIGIT_IDENTIFIER"
|
||||
null, null, "SELECT", "FROM", "STRING", "IDENTIFIER", "BACKQUOTED_IDENTIFIER",
|
||||
"SIMPLE_COMMENT", "BRACKETED_EMPTY_COMMENT", "BRACKETED_COMMENT", "WS"
|
||||
};
|
||||
}
|
||||
|
||||
@ -123,12 +122,15 @@ public class ZookeeperSqlParser
|
||||
public static class SingleStatementContext
|
||||
extends ParserRuleContext
|
||||
{
|
||||
public StatementContext statement()
|
||||
public List<StatementContext> statement()
|
||||
{
|
||||
return getRuleContext(StatementContext.class, 0);
|
||||
return getRuleContexts(StatementContext.class);
|
||||
}
|
||||
|
||||
public TerminalNode EOF() {return getToken(ZookeeperSqlParser.EOF, 0);}
|
||||
public StatementContext statement(int i)
|
||||
{
|
||||
return getRuleContext(StatementContext.class, i);
|
||||
}
|
||||
|
||||
public SingleStatementContext(ParserRuleContext parent, int invokingState)
|
||||
{
|
||||
@ -141,17 +143,17 @@ public class ZookeeperSqlParser
|
||||
@Override
|
||||
public void enterRule(ParseTreeListener listener)
|
||||
{
|
||||
if (listener instanceof ZookeeperSqlListener) {
|
||||
((ZookeeperSqlListener) listener).enterSingleStatement(this);
|
||||
}
|
||||
if (listener instanceof ZookeeperSqlListener) {
|
||||
((ZookeeperSqlListener) listener).enterSingleStatement(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exitRule(ParseTreeListener listener)
|
||||
{
|
||||
if (listener instanceof ZookeeperSqlListener) {
|
||||
((ZookeeperSqlListener) listener).exitSingleStatement(this);
|
||||
}
|
||||
if (listener instanceof ZookeeperSqlListener) {
|
||||
((ZookeeperSqlListener) listener).exitSingleStatement(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -160,13 +162,24 @@ public class ZookeeperSqlParser
|
||||
{
|
||||
SingleStatementContext _localctx = new SingleStatementContext(_ctx, getState());
|
||||
enterRule(_localctx, 0, RULE_singleStatement);
|
||||
int _la;
|
||||
try {
|
||||
enterOuterAlt(_localctx, 1);
|
||||
{
|
||||
setState(12);
|
||||
statement();
|
||||
setState(13);
|
||||
match(EOF);
|
||||
setState(17);
|
||||
_errHandler.sync(this);
|
||||
_la = _input.LA(1);
|
||||
while (_la == SELECT) {
|
||||
{
|
||||
{
|
||||
setState(14);
|
||||
statement();
|
||||
}
|
||||
}
|
||||
setState(19);
|
||||
_errHandler.sync(this);
|
||||
_la = _input.LA(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (RecognitionException re) {
|
||||
@ -183,9 +196,11 @@ public class ZookeeperSqlParser
|
||||
public static class StatementContext
|
||||
extends ParserRuleContext
|
||||
{
|
||||
public SelectElementsContext selectElements()
|
||||
public TerminalNode SELECT() {return getToken(ZookeeperSqlParser.SELECT, 0);}
|
||||
|
||||
public ColumnStatementContext columnStatement()
|
||||
{
|
||||
return getRuleContext(SelectElementsContext.class, 0);
|
||||
return getRuleContext(ColumnStatementContext.class, 0);
|
||||
}
|
||||
|
||||
public FromClauseContext fromClause()
|
||||
@ -204,17 +219,17 @@ public class ZookeeperSqlParser
|
||||
@Override
|
||||
public void enterRule(ParseTreeListener listener)
|
||||
{
|
||||
if (listener instanceof ZookeeperSqlListener) {
|
||||
((ZookeeperSqlListener) listener).enterStatement(this);
|
||||
}
|
||||
if (listener instanceof ZookeeperSqlListener) {
|
||||
((ZookeeperSqlListener) listener).enterStatement(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exitRule(ParseTreeListener listener)
|
||||
{
|
||||
if (listener instanceof ZookeeperSqlListener) {
|
||||
((ZookeeperSqlListener) listener).exitStatement(this);
|
||||
}
|
||||
if (listener instanceof ZookeeperSqlListener) {
|
||||
((ZookeeperSqlListener) listener).exitStatement(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -226,11 +241,11 @@ public class ZookeeperSqlParser
|
||||
try {
|
||||
enterOuterAlt(_localctx, 1);
|
||||
{
|
||||
setState(15);
|
||||
match(T__0);
|
||||
setState(16);
|
||||
selectElements();
|
||||
setState(17);
|
||||
setState(20);
|
||||
match(SELECT);
|
||||
setState(21);
|
||||
columnStatement();
|
||||
setState(22);
|
||||
fromClause();
|
||||
}
|
||||
}
|
||||
@ -245,12 +260,70 @@ public class ZookeeperSqlParser
|
||||
return _localctx;
|
||||
}
|
||||
|
||||
public static class ColumnStatementContext
|
||||
extends ParserRuleContext
|
||||
{
|
||||
public IdentifierContext identifier()
|
||||
{
|
||||
return getRuleContext(IdentifierContext.class, 0);
|
||||
}
|
||||
|
||||
public ColumnStatementContext(ParserRuleContext parent, int invokingState)
|
||||
{
|
||||
super(parent, invokingState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRuleIndex() {return RULE_columnStatement;}
|
||||
|
||||
@Override
|
||||
public void enterRule(ParseTreeListener listener)
|
||||
{
|
||||
if (listener instanceof ZookeeperSqlListener) {
|
||||
((ZookeeperSqlListener) listener).enterColumnStatement(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exitRule(ParseTreeListener listener)
|
||||
{
|
||||
if (listener instanceof ZookeeperSqlListener) {
|
||||
((ZookeeperSqlListener) listener).exitColumnStatement(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public final ColumnStatementContext columnStatement()
|
||||
throws RecognitionException
|
||||
{
|
||||
ColumnStatementContext _localctx = new ColumnStatementContext(_ctx, getState());
|
||||
enterRule(_localctx, 4, RULE_columnStatement);
|
||||
try {
|
||||
enterOuterAlt(_localctx, 1);
|
||||
{
|
||||
setState(24);
|
||||
identifier();
|
||||
}
|
||||
}
|
||||
catch (RecognitionException re) {
|
||||
_localctx.exception = re;
|
||||
_errHandler.reportError(this, re);
|
||||
_errHandler.recover(this, re);
|
||||
}
|
||||
finally {
|
||||
exitRule();
|
||||
}
|
||||
return _localctx;
|
||||
}
|
||||
|
||||
public static class FromClauseContext
|
||||
extends ParserRuleContext
|
||||
{
|
||||
public QualifiedNameContext qualifiedName()
|
||||
public TerminalNode FROM() {return getToken(ZookeeperSqlParser.FROM, 0);}
|
||||
|
||||
public TableNameContext tableName()
|
||||
{
|
||||
return getRuleContext(QualifiedNameContext.class, 0);
|
||||
return getRuleContext(TableNameContext.class, 0);
|
||||
}
|
||||
|
||||
public FromClauseContext(ParserRuleContext parent, int invokingState)
|
||||
@ -264,17 +337,17 @@ public class ZookeeperSqlParser
|
||||
@Override
|
||||
public void enterRule(ParseTreeListener listener)
|
||||
{
|
||||
if (listener instanceof ZookeeperSqlListener) {
|
||||
((ZookeeperSqlListener) listener).enterFromClause(this);
|
||||
}
|
||||
if (listener instanceof ZookeeperSqlListener) {
|
||||
((ZookeeperSqlListener) listener).enterFromClause(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exitRule(ParseTreeListener listener)
|
||||
{
|
||||
if (listener instanceof ZookeeperSqlListener) {
|
||||
((ZookeeperSqlListener) listener).exitFromClause(this);
|
||||
}
|
||||
if (listener instanceof ZookeeperSqlListener) {
|
||||
((ZookeeperSqlListener) listener).exitFromClause(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -282,14 +355,14 @@ public class ZookeeperSqlParser
|
||||
throws RecognitionException
|
||||
{
|
||||
FromClauseContext _localctx = new FromClauseContext(_ctx, getState());
|
||||
enterRule(_localctx, 4, RULE_fromClause);
|
||||
enterRule(_localctx, 6, RULE_fromClause);
|
||||
try {
|
||||
enterOuterAlt(_localctx, 1);
|
||||
{
|
||||
setState(19);
|
||||
match(T__1);
|
||||
setState(20);
|
||||
qualifiedName();
|
||||
setState(26);
|
||||
match(FROM);
|
||||
setState(27);
|
||||
tableName();
|
||||
}
|
||||
}
|
||||
catch (RecognitionException re) {
|
||||
@ -303,71 +376,7 @@ public class ZookeeperSqlParser
|
||||
return _localctx;
|
||||
}
|
||||
|
||||
public static class SelectElementsContext
|
||||
extends ParserRuleContext
|
||||
{
|
||||
public TerminalNode ID() {return getToken(ZookeeperSqlParser.ID, 0);}
|
||||
|
||||
public SelectElementsContext(ParserRuleContext parent, int invokingState)
|
||||
{
|
||||
super(parent, invokingState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRuleIndex() {return RULE_selectElements;}
|
||||
|
||||
@Override
|
||||
public void enterRule(ParseTreeListener listener)
|
||||
{
|
||||
if (listener instanceof ZookeeperSqlListener) {
|
||||
((ZookeeperSqlListener) listener).enterSelectElements(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exitRule(ParseTreeListener listener)
|
||||
{
|
||||
if (listener instanceof ZookeeperSqlListener) {
|
||||
((ZookeeperSqlListener) listener).exitSelectElements(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public final SelectElementsContext selectElements()
|
||||
throws RecognitionException
|
||||
{
|
||||
SelectElementsContext _localctx = new SelectElementsContext(_ctx, getState());
|
||||
enterRule(_localctx, 6, RULE_selectElements);
|
||||
int _la;
|
||||
try {
|
||||
enterOuterAlt(_localctx, 1);
|
||||
{
|
||||
setState(22);
|
||||
_la = _input.LA(1);
|
||||
if (!(_la == T__2 || _la == ID)) {
|
||||
_errHandler.recoverInline(this);
|
||||
}
|
||||
else {
|
||||
if (_input.LA(1) == Token.EOF) {
|
||||
matchedEOF = true;
|
||||
}
|
||||
_errHandler.reportMatch(this);
|
||||
consume();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (RecognitionException re) {
|
||||
_localctx.exception = re;
|
||||
_errHandler.reportError(this, re);
|
||||
_errHandler.recover(this, re);
|
||||
}
|
||||
finally {
|
||||
exitRule();
|
||||
}
|
||||
return _localctx;
|
||||
}
|
||||
|
||||
public static class QualifiedNameContext
|
||||
public static class TableNameContext
|
||||
extends ParserRuleContext
|
||||
{
|
||||
public List<IdentifierContext> identifier()
|
||||
@ -380,55 +389,55 @@ public class ZookeeperSqlParser
|
||||
return getRuleContext(IdentifierContext.class, i);
|
||||
}
|
||||
|
||||
public QualifiedNameContext(ParserRuleContext parent, int invokingState)
|
||||
public TableNameContext(ParserRuleContext parent, int invokingState)
|
||||
{
|
||||
super(parent, invokingState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRuleIndex() {return RULE_qualifiedName;}
|
||||
public int getRuleIndex() {return RULE_tableName;}
|
||||
|
||||
@Override
|
||||
public void enterRule(ParseTreeListener listener)
|
||||
{
|
||||
if (listener instanceof ZookeeperSqlListener) {
|
||||
((ZookeeperSqlListener) listener).enterQualifiedName(this);
|
||||
}
|
||||
if (listener instanceof ZookeeperSqlListener) {
|
||||
((ZookeeperSqlListener) listener).enterTableName(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exitRule(ParseTreeListener listener)
|
||||
{
|
||||
if (listener instanceof ZookeeperSqlListener) {
|
||||
((ZookeeperSqlListener) listener).exitQualifiedName(this);
|
||||
}
|
||||
if (listener instanceof ZookeeperSqlListener) {
|
||||
((ZookeeperSqlListener) listener).exitTableName(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public final QualifiedNameContext qualifiedName()
|
||||
public final TableNameContext tableName()
|
||||
throws RecognitionException
|
||||
{
|
||||
QualifiedNameContext _localctx = new QualifiedNameContext(_ctx, getState());
|
||||
enterRule(_localctx, 8, RULE_qualifiedName);
|
||||
TableNameContext _localctx = new TableNameContext(_ctx, getState());
|
||||
enterRule(_localctx, 8, RULE_tableName);
|
||||
int _la;
|
||||
try {
|
||||
enterOuterAlt(_localctx, 1);
|
||||
{
|
||||
setState(24);
|
||||
identifier();
|
||||
setState(29);
|
||||
identifier();
|
||||
setState(34);
|
||||
_errHandler.sync(this);
|
||||
_la = _input.LA(1);
|
||||
while (_la == T__3) {
|
||||
while (_la == T__0) {
|
||||
{
|
||||
{
|
||||
setState(25);
|
||||
match(T__3);
|
||||
setState(26);
|
||||
setState(30);
|
||||
match(T__0);
|
||||
setState(31);
|
||||
identifier();
|
||||
}
|
||||
}
|
||||
setState(31);
|
||||
setState(36);
|
||||
_errHandler.sync(this);
|
||||
_la = _input.LA(1);
|
||||
}
|
||||
@ -448,6 +457,30 @@ public class ZookeeperSqlParser
|
||||
public static class IdentifierContext
|
||||
extends ParserRuleContext
|
||||
{
|
||||
public List<TerminalNode> IDENTIFIER() {return getTokens(ZookeeperSqlParser.IDENTIFIER);}
|
||||
|
||||
public TerminalNode IDENTIFIER(int i)
|
||||
{
|
||||
return getToken(ZookeeperSqlParser.IDENTIFIER, i);
|
||||
}
|
||||
|
||||
public List<TerminalNode> STRING() {return getTokens(ZookeeperSqlParser.STRING);}
|
||||
|
||||
public TerminalNode STRING(int i)
|
||||
{
|
||||
return getToken(ZookeeperSqlParser.STRING, i);
|
||||
}
|
||||
|
||||
public List<QuotedIdentifierContext> quotedIdentifier()
|
||||
{
|
||||
return getRuleContexts(QuotedIdentifierContext.class);
|
||||
}
|
||||
|
||||
public QuotedIdentifierContext quotedIdentifier(int i)
|
||||
{
|
||||
return getRuleContext(QuotedIdentifierContext.class, i);
|
||||
}
|
||||
|
||||
public IdentifierContext(ParserRuleContext parent, int invokingState)
|
||||
{
|
||||
super(parent, invokingState);
|
||||
@ -456,107 +489,20 @@ public class ZookeeperSqlParser
|
||||
@Override
|
||||
public int getRuleIndex() {return RULE_identifier;}
|
||||
|
||||
public IdentifierContext() {}
|
||||
|
||||
public void copyFrom(IdentifierContext ctx)
|
||||
{
|
||||
super.copyFrom(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
public static class BackQuotedIdentifierContext
|
||||
extends IdentifierContext
|
||||
{
|
||||
public TerminalNode BACKQUOTED_IDENTIFIER() {return getToken(ZookeeperSqlParser.BACKQUOTED_IDENTIFIER, 0);}
|
||||
|
||||
public BackQuotedIdentifierContext(IdentifierContext ctx) {copyFrom(ctx);}
|
||||
|
||||
@Override
|
||||
public void enterRule(ParseTreeListener listener)
|
||||
{
|
||||
if (listener instanceof ZookeeperSqlListener) {
|
||||
((ZookeeperSqlListener) listener).enterBackQuotedIdentifier(this);
|
||||
}
|
||||
if (listener instanceof ZookeeperSqlListener) {
|
||||
((ZookeeperSqlListener) listener).enterIdentifier(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exitRule(ParseTreeListener listener)
|
||||
{
|
||||
if (listener instanceof ZookeeperSqlListener) {
|
||||
((ZookeeperSqlListener) listener).exitBackQuotedIdentifier(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class QuotedIdentifierContext
|
||||
extends IdentifierContext
|
||||
{
|
||||
public TerminalNode QUOTED_IDENTIFIER() {return getToken(ZookeeperSqlParser.QUOTED_IDENTIFIER, 0);}
|
||||
|
||||
public QuotedIdentifierContext(IdentifierContext ctx) {copyFrom(ctx);}
|
||||
|
||||
@Override
|
||||
public void enterRule(ParseTreeListener listener)
|
||||
{
|
||||
if (listener instanceof ZookeeperSqlListener) {
|
||||
((ZookeeperSqlListener) listener).enterQuotedIdentifier(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exitRule(ParseTreeListener listener)
|
||||
{
|
||||
if (listener instanceof ZookeeperSqlListener) {
|
||||
((ZookeeperSqlListener) listener).exitQuotedIdentifier(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class DigitIdentifierContext
|
||||
extends IdentifierContext
|
||||
{
|
||||
public TerminalNode DIGIT_IDENTIFIER() {return getToken(ZookeeperSqlParser.DIGIT_IDENTIFIER, 0);}
|
||||
|
||||
public DigitIdentifierContext(IdentifierContext ctx) {copyFrom(ctx);}
|
||||
|
||||
@Override
|
||||
public void enterRule(ParseTreeListener listener)
|
||||
{
|
||||
if (listener instanceof ZookeeperSqlListener) {
|
||||
((ZookeeperSqlListener) listener).enterDigitIdentifier(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exitRule(ParseTreeListener listener)
|
||||
{
|
||||
if (listener instanceof ZookeeperSqlListener) {
|
||||
((ZookeeperSqlListener) listener).exitDigitIdentifier(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class UnquotedIdentifierContext
|
||||
extends IdentifierContext
|
||||
{
|
||||
public TerminalNode IDENTIFIER() {return getToken(ZookeeperSqlParser.IDENTIFIER, 0);}
|
||||
|
||||
public UnquotedIdentifierContext(IdentifierContext ctx) {copyFrom(ctx);}
|
||||
|
||||
@Override
|
||||
public void enterRule(ParseTreeListener listener)
|
||||
{
|
||||
if (listener instanceof ZookeeperSqlListener) {
|
||||
((ZookeeperSqlListener) listener).enterUnquotedIdentifier(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exitRule(ParseTreeListener listener)
|
||||
{
|
||||
if (listener instanceof ZookeeperSqlListener) {
|
||||
((ZookeeperSqlListener) listener).exitUnquotedIdentifier(this);
|
||||
}
|
||||
if (listener instanceof ZookeeperSqlListener) {
|
||||
((ZookeeperSqlListener) listener).exitIdentifier(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -565,44 +511,94 @@ public class ZookeeperSqlParser
|
||||
{
|
||||
IdentifierContext _localctx = new IdentifierContext(_ctx, getState());
|
||||
enterRule(_localctx, 10, RULE_identifier);
|
||||
int _la;
|
||||
try {
|
||||
setState(36);
|
||||
_errHandler.sync(this);
|
||||
switch (_input.LA(1)) {
|
||||
case IDENTIFIER:
|
||||
_localctx = new UnquotedIdentifierContext(_localctx);
|
||||
enterOuterAlt(_localctx, 1);
|
||||
{
|
||||
setState(32);
|
||||
match(IDENTIFIER);
|
||||
enterOuterAlt(_localctx, 1);
|
||||
{
|
||||
setState(42);
|
||||
_errHandler.sync(this);
|
||||
_la = _input.LA(1);
|
||||
while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << STRING) | (1L << IDENTIFIER) | (1L << BACKQUOTED_IDENTIFIER))) != 0)) {
|
||||
{
|
||||
setState(40);
|
||||
_errHandler.sync(this);
|
||||
switch (_input.LA(1)) {
|
||||
case IDENTIFIER: {
|
||||
setState(37);
|
||||
match(IDENTIFIER);
|
||||
}
|
||||
break;
|
||||
case STRING: {
|
||||
setState(38);
|
||||
match(STRING);
|
||||
}
|
||||
break;
|
||||
case BACKQUOTED_IDENTIFIER: {
|
||||
setState(39);
|
||||
quotedIdentifier();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new NoViableAltException(this);
|
||||
}
|
||||
}
|
||||
setState(44);
|
||||
_errHandler.sync(this);
|
||||
_la = _input.LA(1);
|
||||
}
|
||||
break;
|
||||
case QUOTED_IDENTIFIER:
|
||||
_localctx = new QuotedIdentifierContext(_localctx);
|
||||
enterOuterAlt(_localctx, 2);
|
||||
{
|
||||
setState(33);
|
||||
match(QUOTED_IDENTIFIER);
|
||||
}
|
||||
break;
|
||||
case BACKQUOTED_IDENTIFIER:
|
||||
_localctx = new BackQuotedIdentifierContext(_localctx);
|
||||
enterOuterAlt(_localctx, 3);
|
||||
{
|
||||
setState(34);
|
||||
match(BACKQUOTED_IDENTIFIER);
|
||||
}
|
||||
break;
|
||||
case DIGIT_IDENTIFIER:
|
||||
_localctx = new DigitIdentifierContext(_localctx);
|
||||
enterOuterAlt(_localctx, 4);
|
||||
{
|
||||
setState(35);
|
||||
match(DIGIT_IDENTIFIER);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new NoViableAltException(this);
|
||||
}
|
||||
}
|
||||
catch (RecognitionException re) {
|
||||
_localctx.exception = re;
|
||||
_errHandler.reportError(this, re);
|
||||
_errHandler.recover(this, re);
|
||||
}
|
||||
finally {
|
||||
exitRule();
|
||||
}
|
||||
return _localctx;
|
||||
}
|
||||
|
||||
public static class QuotedIdentifierContext
|
||||
extends ParserRuleContext
|
||||
{
|
||||
public TerminalNode BACKQUOTED_IDENTIFIER() {return getToken(ZookeeperSqlParser.BACKQUOTED_IDENTIFIER, 0);}
|
||||
|
||||
public QuotedIdentifierContext(ParserRuleContext parent, int invokingState)
|
||||
{
|
||||
super(parent, invokingState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRuleIndex() {return RULE_quotedIdentifier;}
|
||||
|
||||
@Override
|
||||
public void enterRule(ParseTreeListener listener)
|
||||
{
|
||||
if (listener instanceof ZookeeperSqlListener) {
|
||||
((ZookeeperSqlListener) listener).enterQuotedIdentifier(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exitRule(ParseTreeListener listener)
|
||||
{
|
||||
if (listener instanceof ZookeeperSqlListener) {
|
||||
((ZookeeperSqlListener) listener).exitQuotedIdentifier(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public final QuotedIdentifierContext quotedIdentifier()
|
||||
throws RecognitionException
|
||||
{
|
||||
QuotedIdentifierContext _localctx = new QuotedIdentifierContext(_ctx, getState());
|
||||
enterRule(_localctx, 12, RULE_quotedIdentifier);
|
||||
try {
|
||||
enterOuterAlt(_localctx, 1);
|
||||
{
|
||||
setState(45);
|
||||
match(BACKQUOTED_IDENTIFIER);
|
||||
}
|
||||
}
|
||||
catch (RecognitionException re) {
|
||||
@ -617,17 +613,19 @@ public class ZookeeperSqlParser
|
||||
}
|
||||
|
||||
public static final String _serializedATN =
|
||||
"\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3\f)\4\2\t\2\4\3\t" +
|
||||
"\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\3\2\3\2\3\2\3\3\3\3\3\3\3\3\3\4\3\4" +
|
||||
"\3\4\3\5\3\5\3\6\3\6\3\6\7\6\36\n\6\f\6\16\6!\13\6\3\7\3\7\3\7\3\7\5\7" +
|
||||
"\'\n\7\3\7\2\2\b\2\4\6\b\n\f\2\3\4\2\5\5\7\7\2&\2\16\3\2\2\2\4\21\3\2" +
|
||||
"\2\2\6\25\3\2\2\2\b\30\3\2\2\2\n\32\3\2\2\2\f&\3\2\2\2\16\17\5\4\3\2\17" +
|
||||
"\20\7\2\2\3\20\3\3\2\2\2\21\22\7\3\2\2\22\23\5\b\5\2\23\24\5\6\4\2\24" +
|
||||
"\5\3\2\2\2\25\26\7\4\2\2\26\27\5\n\6\2\27\7\3\2\2\2\30\31\t\2\2\2\31\t" +
|
||||
"\3\2\2\2\32\37\5\f\7\2\33\34\7\6\2\2\34\36\5\f\7\2\35\33\3\2\2\2\36!\3" +
|
||||
"\2\2\2\37\35\3\2\2\2\37 \3\2\2\2 \13\3\2\2\2!\37\3\2\2\2\"\'\7\t\2\2#" +
|
||||
"\'\7\n\2\2$\'\7\13\2\2%\'\7\f\2\2&\"\3\2\2\2&#\3\2\2\2&$\3\2\2\2&%\3\2" +
|
||||
"\2\2\'\r\3\2\2\2\4\37&";
|
||||
"\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3\f\62\4\2\t\2\4\3" +
|
||||
"\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\3\2\7\2\22\n\2\f\2\16\2\25" +
|
||||
"\13\2\3\3\3\3\3\3\3\3\3\4\3\4\3\5\3\5\3\5\3\6\3\6\3\6\7\6#\n\6\f\6\16" +
|
||||
"\6&\13\6\3\7\3\7\3\7\7\7+\n\7\f\7\16\7.\13\7\3\b\3\b\3\b\2\2\t\2\4\6\b" +
|
||||
"\n\f\16\2\2\2/\2\23\3\2\2\2\4\26\3\2\2\2\6\32\3\2\2\2\b\34\3\2\2\2\n\37" +
|
||||
"\3\2\2\2\f,\3\2\2\2\16/\3\2\2\2\20\22\5\4\3\2\21\20\3\2\2\2\22\25\3\2" +
|
||||
"\2\2\23\21\3\2\2\2\23\24\3\2\2\2\24\3\3\2\2\2\25\23\3\2\2\2\26\27\7\4" +
|
||||
"\2\2\27\30\5\6\4\2\30\31\5\b\5\2\31\5\3\2\2\2\32\33\5\f\7\2\33\7\3\2\2" +
|
||||
"\2\34\35\7\5\2\2\35\36\5\n\6\2\36\t\3\2\2\2\37$\5\f\7\2 !\7\3\2\2!#\5" +
|
||||
"\f\7\2\" \3\2\2\2#&\3\2\2\2$\"\3\2\2\2$%\3\2\2\2%\13\3\2\2\2&$\3\2\2\2" +
|
||||
"\'+\7\7\2\2(+\7\6\2\2)+\5\16\b\2*\'\3\2\2\2*(\3\2\2\2*)\3\2\2\2+.\3\2" +
|
||||
"\2\2,*\3\2\2\2,-\3\2\2\2-\r\3\2\2\2.,\3\2\2\2/\60\7\b\2\2\60\17\3\2\2" +
|
||||
"\2\6\23$*,";
|
||||
public static final ATN _ATN =
|
||||
new ATNDeserializer().deserialize(_serializedATN.toCharArray());
|
||||
|
||||
|
@ -38,7 +38,7 @@ public class ZookeeperSqlVisitor
|
||||
int i = 0;
|
||||
for (; i < childCount; i++) {
|
||||
ParseTree child = statementContext.getChild(i);
|
||||
if (child instanceof ZookeeperSqlParser.SelectElementsContext) {
|
||||
if (child instanceof ZookeeperSqlParser.ColumnStatementContext) {
|
||||
configure.setColumns(Arrays.asList(child.getText()));
|
||||
}
|
||||
else if (child instanceof ZookeeperSqlParser.FromClauseContext) {
|
||||
|
@ -0,0 +1,20 @@
|
||||
package io.edurt.datacap.plugin.natived.zookeeper;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ZookeeperPathConvertTest
|
||||
{
|
||||
@Test
|
||||
public void toPath()
|
||||
{
|
||||
String path = "all";
|
||||
Assert.assertEquals(ZookeeperPathConvert.toPath(path), ZookeeperPathConvert.start);
|
||||
path = "a.b";
|
||||
Assert.assertEquals(ZookeeperPathConvert.toPath(path), "/a/b");
|
||||
path = "a.b.`sd.dd`.`d_dd`";
|
||||
Assert.assertEquals(ZookeeperPathConvert.toPath(path), "/a/b/sd.dd/d_dd");
|
||||
path = "`sd.dd`.a.n.`d_dd`";
|
||||
Assert.assertEquals(ZookeeperPathConvert.toPath(path), "/sd.dd/a/n/d_dd");
|
||||
}
|
||||
}
|
@ -46,7 +46,7 @@ public class ZookeeperSqlParserTest
|
||||
Assert.assertTrue(configure.getColumns().size() > 0);
|
||||
Assert.assertNotNull(configure.getTable());
|
||||
|
||||
sql = "Select * FROM test.dd.dd";
|
||||
sql = "Select * FROM test.dd.`dd`";
|
||||
configure = getConfigure(sql);
|
||||
Assert.assertNotNull(configure.getTable());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user