private static Variable getCalcSum(expectType theExpectedType, Logic[] logicOrder, int lineNumber) { if (theExpectedType.currentType == VariableTypes.boolean) { Variable sumVar = BooleanSumParser.validBoolSum(logicOrder, lineNumber); if (sumVar.variableType == VariableTypes.boolean) { return(sumVar); } } if (theExpectedType.currentType == VariableTypes.textString) { Variable sumVar = TextSumParser.validTextSum(logicOrder, lineNumber); if (sumVar.variableType == VariableTypes.textString) { return(sumVar); } } if (theExpectedType.currentType == VariableTypes.number) { Variable sumVar = NumberSumParser.validNumberSum(logicOrder, lineNumber); if (sumVar.variableType == VariableTypes.number) { return(sumVar); } } return(new Variable("CalcVar")); }
static void setNewExpectVariable(expectType expect, VariableTypes newType, int lineNumber, Logic[] logicOrder) { if (expect.currentType == VariableTypes.unknown) { return; } if (expect.currentType == VariableTypes.unsigned) { expect.currentType = newType; } else if (expect.currentType != newType) { var firstSumType = SumParser.TypeToString(expect.currentType); var secondSumType = SumParser.TypeToString(newType); string errorMessage; if (firstSumType == "" || secondSumType == "") { errorMessage = "Misslyckades med att para ihop " + expect.currentType + " med " + newType; } else { errorMessage = "Kan inte para ihop " + firstSumType + " med " + secondSumType + "."; } ErrorMessage.sendErrorMessage(lineNumber, errorMessage); } if (expect.currentType == VariableTypes.boolean) { BooleanSumParser.validBoolSum(logicOrder, lineNumber); } }