提交 212e02a0 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Split Parser.getSpecialType() into two methods for different arguments

上级 7bb789ff
...@@ -3915,14 +3915,17 @@ public class Parser { ...@@ -3915,14 +3915,17 @@ public class Parser {
case CHAR_SPECIAL_2: case CHAR_SPECIAL_2:
if (types[i] == CHAR_SPECIAL_2) { if (types[i] == CHAR_SPECIAL_2) {
i++; i++;
currentToken = sqlCommand.substring(start, i);
currentTokenType = getSpecialType2(currentToken);
} else {
currentToken = sqlCommand.substring(start, i);
currentTokenType = getSpecialType1(currentToken);
} }
currentToken = sqlCommand.substring(start, i);
currentTokenType = getSpecialType(currentToken);
parseIndex = i; parseIndex = i;
return; return;
case CHAR_SPECIAL_1: case CHAR_SPECIAL_1:
currentToken = sqlCommand.substring(start, i); currentToken = sqlCommand.substring(start, i);
currentTokenType = getSpecialType(currentToken); currentTokenType = getSpecialType1(currentToken);
parseIndex = i; parseIndex = i;
return; return;
case CHAR_VALUE: case CHAR_VALUE:
...@@ -4352,84 +4355,83 @@ public class Parser { ...@@ -4352,84 +4355,83 @@ public class Parser {
} }
} }
private int getSpecialType(String s) { private int getSpecialType1(String s) {
char c0 = s.charAt(0); switch (s.charAt(0)) {
if (s.length() == 1) { case '?':
switch (c0) { case '$':
case '?': return PARAMETER;
case '$': case '@':
return PARAMETER; return AT;
case '@': case '+':
return AT; return PLUS_SIGN;
case '+': case '-':
return PLUS_SIGN; return MINUS_SIGN;
case '-': case '*':
return MINUS_SIGN; return ASTERISK;
case '*': case ',':
return ASTERISK; return COMMA;
case ',': case '{':
return COMMA; case '}':
case '{': case '/':
case '}': case '%':
case '/': case ';':
case '%': case ':':
case ';': case '[':
case ':': case ']':
case '[': case '~':
case ']': return KEYWORD;
case '~': case '(':
return OPEN_PAREN;
case ')':
return CLOSE_PAREN;
case '<':
return SMALLER;
case '>':
return BIGGER;
case '=':
return EQUAL;
default:
throw getSyntaxError();
}
}
private int getSpecialType2(String s) {
char c1 = s.charAt(1);
switch (s.charAt(0)) {
case ':':
if (c1 == ':' || c1 == '=') {
return KEYWORD; return KEYWORD;
case '(':
return OPEN_PAREN;
case ')':
return CLOSE_PAREN;
case '<':
return SMALLER;
case '>':
return BIGGER;
case '=':
return EQUAL;
default:
break;
} }
} else if (s.length() == 2) { break;
char c1 = s.charAt(1); case '>':
switch (c0) { if (c1 == '=') {
case ':': return BIGGER_EQUAL;
if (c1 == ':' || c1 == '=') { }
return KEYWORD; break;
} case '<':
break; if (c1 == '=') {
case '>': return SMALLER_EQUAL;
if (c1 == '=') { } else if (c1 == '>') {
return BIGGER_EQUAL; return NOT_EQUAL;
} }
break; break;
case '<': case '!':
if (c1 == '=') { if (c1 == '=') {
return SMALLER_EQUAL; return NOT_EQUAL;
} else if (c1 == '>') { } else if (c1 == '~') {
return NOT_EQUAL; return KEYWORD;
} }
break; break;
case '!': case '|':
if (c1 == '=') { if (c1 == '|') {
return NOT_EQUAL; return STRING_CONCAT;
} else if (c1 == '~') {
return KEYWORD;
}
break;
case '|':
if (c1 == '|') {
return STRING_CONCAT;
}
break;
case '&':
if (c1 == '&') {
return SPATIAL_INTERSECTS;
}
break;
} }
break;
case '&':
if (c1 == '&') {
return SPATIAL_INTERSECTS;
}
break;
} }
throw getSyntaxError(); throw getSyntaxError();
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论