def unequality_operation(self, expression: UnequalityOperation): self.__default__(expression) if expression.left_expression.type != expression.right_expression.type: raise BadOperandException("!=", expression.left_expression.type, expression.right_expression.type) expression.type = BooleanType()
def less_then_equals_operation(self, expression: LessThenEqualsOperation): self.__default__(expression) if expression.left_expression.type != IntType() or expression.right_expression.type != IntType(): raise BadOperandException("<=", expression.left_expression.type, expression.right_expression.type) expression.type = BooleanType()
def assignment(self, assignment: Assignment): self.__default__(assignment) if assignment.ref.type != assignment.expression.type: raise BadOperandException("=", assignment.ref.type, assignment.expression.type) assignment.type = assignment.ref.type
def and_operation(self, expression: AndOperation): self.__default__(expression) if expression.left_expression.type != BooleanType() or expression.right_expression.type != BooleanType(): raise BadOperandException("&&", expression.left_expression.type, expression.right_expression.type) expression.type = BooleanType()
def unary_not_operation(self, expression: UnaryNotOperation): if expression.expression.type != BooleanType(): raise BadOperandException("!", expression.expression.type) expression.type = BooleanType()
def unary_minus_operation(self, expression: UnaryMinusOperation): if expression.expression.type != IntType(): raise BadOperandException("-", expression.expression.type) expression.type = IntType()
def modulo_operation(self, expression: ModuloOperation): self.__default__(expression) if expression.left_expression.type != IntType() or expression.right_expression.type != IntType(): raise BadOperandException("%", expression.left_expression.type, expression.right_expression.type) expression.type = IntType()
def division_operation(self, expression: DivisionOperation): self.__default__(expression) if expression.left_expression.type != IntType() or expression.right_expression.type != IntType(): raise BadOperandException("/", expression.left_expression.type, expression.right_expression.type) expression.type = IntType()
def greater_then_operation(self, expression: GreaterThenOperation): self.__default__(expression) if expression.left_expression.type != IntType() or expression.right_expression.type != IntType(): raise BadOperandException(">", expression.left_expression.type, expression.right_expression.type) expression.type = BooleanType()