improved sql parser. for issue #1775

This commit is contained in:
wenshao
2017-06-14 10:01:07 +08:00
parent 820d0a2e1a
commit e170df7025
18 changed files with 370 additions and 206 deletions
@@ -61,12 +61,30 @@ public class SQLParser {
}
protected String tableAlias() {
if (lexer.token() == Token.CONNECT || lexer.token() == Token.START) {
return tableAlias(false);
}
protected String tableAlias(boolean must) {
final Token token = lexer.token();
if (token == Token.CONNECT
|| token == Token.START
|| token == Token.SELECT
|| token == Token.FROM
|| token == Token.WHERE) {
if (must) {
throw new ParserException("illegal alias. " + lexer.info());
}
return null;
}
if (identifierEquals("START") || identifierEquals("CONNECT")) {
return null;
if (token == Token.IDENTIFIER) {
String ident = lexer.stringVal;
if (ident.equalsIgnoreCase("START") || ident.equalsIgnoreCase("CONNECT")) {
if (must) {
throw new ParserException("illegal alias. " + lexer.info());
}
return null;
}
}
return this.as();