@Override protected com.yahoo.bullet.parsing.Expression visitBooleanLiteral(BooleanLiteral node, Void context) { LeafExpression leafExpression = new LeafExpression(); leafExpression.setValue(new Value(Value.Kind.VALUE, node.toFormatlessString(), Type.BOOLEAN)); return leafExpression; }
@Override protected com.yahoo.bullet.parsing.Expression visitIdentifier(Identifier node, Void context) { LeafExpression leafExpression = new LeafExpression(); leafExpression.setValue(new Value(Value.Kind.FIELD, node.toFormatlessString())); return leafExpression; } }
@Override protected com.yahoo.bullet.parsing.Expression visitDecimalLiteral(DecimalLiteral node, Void context) { LeafExpression leafExpression = new LeafExpression(); leafExpression.setValue(new Value(Value.Kind.VALUE, node.toFormatlessString(), Type.DOUBLE)); return leafExpression; }
@Override protected com.yahoo.bullet.parsing.Expression visitLongLiteral(LongLiteral node, Void context) { LeafExpression leafExpression = new LeafExpression(); leafExpression.setValue(new Value(Value.Kind.VALUE, node.toFormatlessString(), Type.LONG)); return leafExpression; }
@Override protected com.yahoo.bullet.parsing.Expression visitDoubleLiteral(DoubleLiteral node, Void context) { LeafExpression leafExpression = new LeafExpression(); leafExpression.setValue(new Value(Value.Kind.VALUE, node.toFormatlessString(), Type.DOUBLE)); return leafExpression; }
@Override protected com.yahoo.bullet.parsing.Expression visitStringLiteral(StringLiteral node, Void context) { LeafExpression leafExpression = new LeafExpression(); leafExpression.setValue(new Value(Value.Kind.VALUE, node.toFormatlessString(), Type.STRING)); return leafExpression; }
@Override protected com.yahoo.bullet.parsing.Expression visitArithmeticUnary(ArithmeticUnaryExpression node, Void context) { LeafExpression leafExpression = new LeafExpression(); Type type; if (node.getValue() instanceof LongLiteral) { type = Type.LONG; } else { type = Type.DOUBLE; } leafExpression.setValue(new Value(Value.Kind.VALUE, node.toFormatlessString(), type)); return leafExpression; }
protected com.yahoo.bullet.parsing.Expression visitCastExpression(CastExpression node, Void context) throws ParsingException { if (containsCastExpression(node.getExpression())) { throw new ParsingException("Casting of cast expressions is not supported"); } com.yahoo.bullet.parsing.Expression expression = process(node.getExpression()); if (expression instanceof BinaryExpression) { ((BinaryExpression) expression).setType(Type.valueOf(node.getCastType().toUpperCase())); } else { Value value = ((LeafExpression) expression).getValue(); ((LeafExpression) expression).setValue(new Value(value.getKind(), value.getValue(), Type.valueOf(node.getCastType().toUpperCase()))); } return expression; }