Endabgabe #20

Merged
i22035 merged 137 commits from Endabgabe into main 2024-07-05 11:59:47 +00:00
Showing only changes of commit 4ff6854094 - Show all commits

View File

@ -533,7 +533,9 @@ public class SemanticAnalyzer implements SemanticVisitor {
case LESS, LESS_EQUAL, GREATER, GREATER_EQUAL:
if (expResult.getType() instanceof BaseType expResultType && expResultType.getTypeEnum().equals(TypeEnum.INT) &&
unaryResult.getType() instanceof BaseType unaryResultType && unaryResultType.getTypeEnum().equals(TypeEnum.INT)) {
return new TypeCheckResult(true, new BaseType(TypeEnum.BOOL));
ITypeNode type = new BaseType(TypeEnum.BOOL);
nonCalculationNode.setType(type);
return new TypeCheckResult(true, type);
} else {
errors.add(new TypeMismatchException("Both types must be Integer"));
}
@ -541,7 +543,9 @@ public class SemanticAnalyzer implements SemanticVisitor {
case OR, AND:
if (expResult.getType() instanceof BaseType expResultType && expResultType.getTypeEnum().equals(TypeEnum.BOOL) &&
unaryResult.getType() instanceof BaseType unaryResultType && unaryResultType.getTypeEnum().equals(TypeEnum.BOOL)) {
return new TypeCheckResult(true, new BaseType(TypeEnum.BOOL));
ITypeNode type = new BaseType(TypeEnum.BOOL);
nonCalculationNode.setType(type);
return new TypeCheckResult(true, type);
} else {
errors.add(new TypeMismatchException("Both types must be Boolean"));
}
@ -549,7 +553,9 @@ public class SemanticAnalyzer implements SemanticVisitor {
case EQUAL, NOT_EQUAL:
if (expResult.getType() instanceof BaseType expResultType && unaryResult.getType() instanceof BaseType unaryResultType
&& Objects.equals(expResultType, unaryResultType)) {
return new TypeCheckResult(true, new BaseType(TypeEnum.BOOL));
ITypeNode type = new BaseType(TypeEnum.BOOL);
nonCalculationNode.setType(type);
return new TypeCheckResult(true, type);
} else {
errors.add(new TypeMismatchException("Both types must be the same"));
}