// Primary Expressions @Override public Boolean visit(Ident id) { if (!environment.containsKey(id)) { errorMsgs.add(String.format("Undefined variable: %s", id)); return false; } return true; }
@Override public Boolean visit(NEq exp) { if (!isBinaryBooleanOrNumeric(exp)) { errorMsgs.add(String.format("Incorrect NEq operation: %s", exp)); return false; } return true; }
@Override public Boolean visit(LT exp) { if (!isBinaryNumeric(exp)) { errorMsgs.add(String.format("Non-numeric LT operation: %s", exp)); return false; } return true; }
@Override public Boolean visit(Or exp) { if (!isBinaryBoolean(exp)) { errorMsgs.add(String.format("Incorrect Or expression: %s", exp)); return false; } return true; }
@Override public Boolean visit(Sub exp) { if (!isBinaryNumeric(exp)) { errorMsgs.add(String.format("Incorrect subtraction: %s", exp)); return false; } return true; }
@Override public Boolean visit(Bool exp) { if (!exp.typeOf(environment).equals(new BoolType())) { errorMsgs.add(String.format("Incorrect Bool: %s", exp)); ; return false; } return true; }
@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); }