@Override public void check(Catagory enclosingCategory, ConstructedASTree enclosingTree) { // TODO this might be able to take variety arguments, :/ lExpr.check(enclosingCategory, enclosingTree); rExpr.check(enclosingCategory, enclosingTree); AmbientVariableTables varTables = AmbientVariableTables.getTables(); Type floatType = (Type) varTables.checkTypeTable("$float"); if (lExpr.getExprType() != floatType) { enclosingTree.addSemanticException( new SemanticCheckException("First argument does not evaluate to a float", line_number)); return; } if (rExpr.getExprType() != floatType) { enclosingTree.addSemanticException( new SemanticCheckException("Second argument does not evalute to a float", line_number)); return; } setExprType(floatType); if (!UnitChecker.getUnitChecker().CheckUnitCompatability(rExpr.getUnits(), lExpr.getUnits())) { enclosingTree.addWarning("Comparison of two different unit types on line " + line_number); this.units = UnitChecker.null_collection; } else { this.units = UnitChecker.getUnitChecker().add_units(rExpr.getUnits(), lExpr.getUnits()); } }
@Override public void check() throws SemanticCheckException { Catagory cata = getCatagory(); if (cata instanceof Chemical) { throw new SemanticCheckException( "Special functions cannot be called within chemical equations"); } VarietyConcentration foodSet = cata.checkVarietyConcTable(identifier.getName()); if (foodSet == null) { throw new SemanticCheckException(identifier.getName() + " is not a known food set"); } threshold.check(); rate.check(); // TODO: Check that if things are varieties that they link back to appropriate food set }