예제 #1
0
 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()
예제 #2
0
 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()
예제 #3
0
 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
예제 #4
0
 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()
예제 #5
0
 def unary_not_operation(self, expression: UnaryNotOperation):
     if expression.expression.type != BooleanType():
         raise BadOperandException("!", expression.expression.type)
     expression.type = BooleanType()
예제 #6
0
 def unary_minus_operation(self, expression: UnaryMinusOperation):
     if expression.expression.type != IntType():
         raise BadOperandException("-", expression.expression.type)
     expression.type = IntType()
예제 #7
0
 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()
예제 #8
0
 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()
예제 #9
0
 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()