/** * Combines this parser position with an array of positions to create a * position that spans from the first point in the first to the last point * in the other. */ public SqlParserPos plusAll(SqlNode[] nodes) { return plusAll(Arrays.asList(nodes)); }
/** * Combines this parser position with an array of positions to create a * position that spans from the first point in the first to the last point * in the other. */ public SqlParserPos plusAll(SqlNode[] nodes) { return plusAll(Arrays.asList(nodes)); }
/** * Creates a call to this operand with an array of operands. * * <p>The position of the resulting call is the union of the <code> * pos</code> and the positions of all of the operands. * * @param functionQualifier function qualifier (e.g. "DISTINCT"), may be * @param pos parser position of the identifier of the call * @param operands array of operands */ public SqlCall createCall( SqlLiteral functionQualifier, SqlParserPos pos, SqlNode... operands) { pos = pos.plusAll(Arrays.asList(operands)); return new SqlBasicCall(this, operands, pos, false, functionQualifier); }
/** * Creates a call to this operand with an array of operands. * * <p>The position of the resulting call is the union of the <code> * pos</code> and the positions of all of the operands. * * @param functionQualifier function qualifier (e.g. "DISTINCT"), may be * @param pos parser position of the identifier of the call * @param operands array of operands */ public SqlCall createCall( SqlLiteral functionQualifier, SqlParserPos pos, SqlNode... operands) { pos = pos.plusAll(Arrays.asList(operands)); return new SqlBasicCall(this, operands, pos, false, functionQualifier); }
private static SqlNode convert(PrecedenceClimbingParser.Token token) { switch (token.type) { case ATOM: return (SqlNode) token.o; case CALL: final PrecedenceClimbingParser.Call call = (PrecedenceClimbingParser.Call) token; final List<SqlNode> list = new ArrayList<>(); for (PrecedenceClimbingParser.Token arg : call.args) { list.add(convert(arg)); } final ToTreeListItem item = (ToTreeListItem) call.op.o; if (item.op == SqlStdOperatorTable.UNARY_MINUS && list.size() == 1 && list.get(0) instanceof SqlNumericLiteral) { return SqlLiteral.createNegative((SqlNumericLiteral) list.get(0), item.pos.plusAll(list)); } if (item.op == SqlStdOperatorTable.UNARY_PLUS && list.size() == 1 && list.get(0) instanceof SqlNumericLiteral) { return list.get(0); } return item.op.createCall(item.pos.plusAll(list), list); default: throw new AssertionError(token); } }
private static SqlNode convert(PrecedenceClimbingParser.Token token) { switch (token.type) { case ATOM: return (SqlNode) token.o; case CALL: final PrecedenceClimbingParser.Call call = (PrecedenceClimbingParser.Call) token; final List<SqlNode> list = new ArrayList<>(); for (PrecedenceClimbingParser.Token arg : call.args) { list.add(convert(arg)); } final ToTreeListItem item = (ToTreeListItem) call.op.o; if (item.op == SqlStdOperatorTable.UNARY_MINUS && list.size() == 1 && list.get(0) instanceof SqlNumericLiteral) { return SqlLiteral.createNegative((SqlNumericLiteral) list.get(0), item.pos.plusAll(list)); } if (item.op == SqlStdOperatorTable.UNARY_PLUS && list.size() == 1 && list.get(0) instanceof SqlNumericLiteral) { return list.get(0); } return item.op.createCall(item.pos.plusAll(list), list); default: throw new AssertionError(token); } }
/** * Parses the optional GROUP BY clause for SELECT. */ final public SqlNodeList GroupByOpt() throws ParseException { List<SqlNode> list = Lists.newArrayList(); SqlNode e; SqlParserPos pos; if (jj_2_155(2)) { jj_consume_token(GROUP); pos = getPos(); jj_consume_token(BY); list = GroupingElementList(); {if (true) return new SqlNodeList(list, pos.plusAll(list));} } else { {if (true) return null;} } throw new Error("Missing return statement in function"); }
list.add(e); {if (true) return new SqlNodeList(list, pos.plusAll(list));} throw new Error("Missing return statement in function");
/** * Parses the optional GROUP BY clause for SELECT. */ final public SqlNodeList GroupByOpt() throws ParseException { List<SqlNode> list = Lists.newArrayList(); SqlNode e; SqlParserPos pos; if (jj_2_155(2)) { jj_consume_token(GROUP); pos = getPos(); jj_consume_token(BY); list = GroupingElementList(); {if (true) return new SqlNodeList(list, pos.plusAll(list));} } else { {if (true) return null;} } throw new Error("Missing return statement in function"); }
{if (true) return new SqlSelect(pos.plus(getPos()), new SqlNodeList(keywords, pos), new SqlNodeList(selectList, selectListPos.plusAll(selectList)), fromClause, where, groupBy, having, windowDecls, null, null, null);} throw new Error("Missing return statement in function");
list.add(e); {if (true) return new SqlNodeList(list, pos.plusAll(list));} throw new Error("Missing return statement in function");
{if (true) return new SqlSelect(pos.plus(getPos()), new SqlNodeList(keywords, pos), new SqlNodeList(selectList, selectListPos.plusAll(selectList)), fromClause, where, groupBy, having, windowDecls, null, null, null);} throw new Error("Missing return statement in function");