improve parser ddl support

This commit is contained in:
wenshao
2013-03-23 22:38:16 +08:00
parent cc2e9793fa
commit 8ae7a29ca6
15 changed files with 248 additions and 21 deletions
@@ -129,6 +129,11 @@ public class SQLServerExprParser extends SQLExprParser {
accept(Token.RPAREN);
}
if (lexer.token() == Token.PERCENT) {
lexer.nextToken();
top.setPercent(true);
}
return top;
}
@@ -39,6 +39,7 @@ public class SQLServerLexer extends Lexer {
map.put("TOP", Token.TOP);
map.put("USE", Token.USE);
map.put("WITH", Token.WITH);
map.put("PERCENT", Token.PERCENT);
DEFAULT_SQL_SERVER_KEYWORDS = new Keywords(map);
}
@@ -76,9 +76,7 @@ public class SQLServerSelectParser extends SQLSelectParser {
}
if (lexer.token() == Token.TOP) {
SQLServerTop top = new SQLServerTop();
lexer.nextToken();
top.setExpr(createExprParser().primary());
SQLServerTop top = this.createExprParser().parseTop();
queryBlock.setTop(top);
}
@@ -101,7 +99,7 @@ public class SQLServerSelectParser extends SQLSelectParser {
return queryRest(queryBlock);
}
protected SQLExprParser createExprParser() {
protected SQLServerExprParser createExprParser() {
return new SQLServerExprParser(lexer);
}
}
@@ -96,6 +96,10 @@ public class SQLServerOutputVisitor extends SQLASTOutputVisitor implements SQLSe
print(")");
}
if (x.isPercent()) {
print(" PERCENT");
}
return false;
}