@Override public DataType visitFactor(@NotNull PythonParser.FactorContext ctx) { if (ctx.power() != null) { return visitPower(ctx.power()); } else if (ctx.factor() != null) { DataType type = visitFactor(ctx.factor()); if (type.isInteger()) { if (ctx.PLUS() != null) { return type; } else if (ctx.MINUS() != null) { mv.visitInsn(INEG); return type; } } else if (type.isBoolean()) { if (ctx.PLUS() != null) { return type; } else if (ctx.MINUS() != null) { mv.visitInsn(INEG); return PrimitiveType.INTEGER; } } else { if (ctx.PLUS() != null) { throw new CompileException( String.format("Doing %s with %s is making no sense!", ctx.PLUS().getText(), type)); } else if (ctx.MINUS() != null) { throw new CompileException( String.format("Doing %s with %s is making no sense!", ctx.MINUS().getText(), type)); } } } throw new CompileException( String.format( "Something gone wrong! Please write to [email protected] with example test.")); }