private void parsePivot(OracleSelectTableSource tableSource) {
OracleSelectPivot.Item item;
if (identifierEquals("PIVOT")) {
lexer.nextToken();
OracleSelectPivot pivot = new OracleSelectPivot();
if (identifierEquals("XML")) {
lexer.nextToken();
pivot.setXml(true);
}
accept(Token.LPAREN);
while (true) {
item = new OracleSelectPivot.Item();
item.setExpr((OracleAggregateExpr) this.createExprParser().expr());
item.setAlias(as());
pivot.getItems().add(item);
if (!(lexer.token() == (Token.COMMA))) break;
lexer.nextToken();
}
accept(Token.FOR);
if (lexer.token() == (Token.LPAREN)) {
lexer.nextToken();
while (true) {
pivot.getPivotFor().add(new SQLIdentifierExpr(lexer.stringVal()));
lexer.nextToken();
if (!(lexer.token() == (Token.COMMA))) break;
lexer.nextToken();
}
accept(Token.RPAREN);
} else {
pivot.getPivotFor().add(new SQLIdentifierExpr(lexer.stringVal()));
lexer.nextToken();
}
accept(Token.IN);
accept(Token.LPAREN);
if (lexer.token() == (Token.LPAREN)) {
throw new ParserException("TODO");
}
if (lexer.token() == (Token.SELECT)) {
throw new ParserException("TODO");
}
for (;;) {
item = new OracleSelectPivot.Item();
item.setExpr(this.createExprParser().expr());
item.setAlias(as());
pivot.getPivotIn().add(item);
if (lexer.token() != Token.COMMA) {
break;
}