@Override public Boolean visit(Not exp) { Expr unExpr = exp.getExpr(); if (!(unExpr.typeOf(environment) == new BoolType())) { errorMsgs.add(String.format("Not expression is not a boolean: %s", exp)); return false; } return unExpr.accept(this); }
private boolean isBinaryBooleanOrNumeric(BinaryExpr exp) { Expr left = exp.getLeft(); Expr right = exp.getRight(); if (left.accept(this) && right.accept(this)) return ((left.typeOf(environment).equals(new IntType()) && right.typeOf(environment).equals(new IntType())) || left.typeOf(environment).equals(new BoolType()) && right.typeOf(environment).equals(new BoolType())); else return false; }