improved odps sql formatter

This commit is contained in:
shaojin.wensj
2015-07-20 06:02:49 +08:00
parent a5811a4f3e
commit eb24ee61fc
16 changed files with 181 additions and 44 deletions
@@ -185,6 +185,11 @@ public class SQLExprParser extends SQLParser {
}
public SQLExpr primary() {
List<String> beforeComments = null;
if (lexer.isKeepComments() && lexer.hasComment()) {
beforeComments = lexer.readAndResetComments();
}
SQLExpr sqlExpr = null;
final Token tok = lexer.token();
@@ -555,7 +560,13 @@ public class SQLExprParser extends SQLParser {
throw new ParserException("ERROR. token : " + tok + ", pos : " + lexer.pos());
}
return primaryRest(sqlExpr);
SQLExpr expr = primaryRest(sqlExpr);
if (beforeComments != null) {
expr.addBeforeComment(beforeComments);
}
return expr;
}
protected SQLExpr parseAll() {
@@ -1184,6 +1195,7 @@ public class SQLExprParser extends SQLParser {
}
lexer.nextToken();
SQLExpr rightExp = relational();
expr = new SQLBinaryOpExpr(expr, SQLBinaryOperator.BooleanAnd, rightExp, getDbType());