Merge pull request #897 from LQZYC/master

修复odps下 sql语句 AS 后面接数字 开头 错误
This commit is contained in:
高铁
2015-07-11 22:59:01 +08:00
3 changed files with 88 additions and 0 deletions
@@ -216,4 +216,88 @@ public class OdpsLexer extends Lexer {
}
}
public void scanNumber() {
mark = pos;
if (ch == '-') {
bufPos++;
ch = charAt(++pos);
}
for (;;) {
if (ch >= '0' && ch <= '9') {
bufPos++;
} else {
break;
}
ch = charAt(++pos);
}
boolean isDouble = false;
if (ch == '.') {
if (charAt(pos + 1) == '.') {
token = Token.LITERAL_INT;
return;
}
bufPos++;
ch = charAt(++pos);
isDouble = true;
for (;;) {
if (ch >= '0' && ch <= '9') {
bufPos++;
} else {
break;
}
ch = charAt(++pos);
}
}
if (ch == 'e' || ch == 'E') {
bufPos++;
ch = charAt(++pos);
if (ch == '+' || ch == '-') {
bufPos++;
ch = charAt(++pos);
}
for (;;) {
if (ch >= '0' && ch <= '9') {
bufPos++;
} else {
break;
}
ch = charAt(++pos);
}
isDouble = true;
}
if (isDouble) {
token = Token.LITERAL_FLOAT;
} else {
if (isFirstIdentifierChar(ch) && !(ch == 'b' && bufPos == 1 && charAt(pos - 1) == '0')) {
bufPos++;
for (;;) {
ch = charAt(++pos);
if (!isIdentifierChar(ch)) {
break;
}
bufPos++;
continue;
}
stringVal = addSymbol();
token = Token.IDENTIFIER;
} else {
token = Token.LITERAL_INT;
}
}
}
}
@@ -47,6 +47,7 @@ public class MySqlParserResourceTest extends TestCase {
exec_test("bvt/parser/mysql-11.txt");
exec_test("bvt/parser/mysql-12.txt");
exec_test("bvt/parser/mysql-13.txt");
exec_test("bvt/parser/mysql-15.txt");
}
public void exec_test(String resource) throws Exception {
@@ -0,0 +1,3 @@
SELECT a.id AS 888appId, a.name AS 999appName
---------------------------
SELECT a.id AS 888appId, a.name AS 999appName