use of org.elasticsearch.painless.antlr.PainlessParser.DynamicContext in project elasticsearch by elastic.
the class Walker method visitOperator.
@Override
public ANode visitOperator(OperatorContext ctx) {
AExpression expression = (AExpression) visit(ctx.unary());
final Operation operation;
if (ctx.BOOLNOT() != null) {
operation = Operation.NOT;
} else if (ctx.BWNOT() != null) {
operation = Operation.BWNOT;
} else if (ctx.ADD() != null) {
operation = Operation.ADD;
} else if (ctx.SUB() != null) {
if (ctx.unary() instanceof ReadContext && ((ReadContext) ctx.unary()).chain() instanceof DynamicContext && ((DynamicContext) ((ReadContext) ctx.unary()).chain()).primary() instanceof NumericContext && ((DynamicContext) ((ReadContext) ctx.unary()).chain()).postfix().isEmpty()) {
return expression;
}
operation = Operation.SUB;
} else {
throw location(ctx).createError(new IllegalStateException("Illegal tree structure."));
}
return new EUnary(location(ctx), operation, expression);
}
Aggregations