예제 #1
0
파일: list.py 프로젝트: woo-lang/woolang
 def multed_by(self, other):
     if isinstance(other, List):
         new_list = self.copy()
         new_list.elements.extend(other.elements)
         return new_list, None
     else:
         return None, Value.illegal_operation(self, other)
예제 #2
0
파일: number.py 프로젝트: woo-lang/woolang
 def get_comparison_gte(self, other):
     if isinstance(other, Number):
         return (
             Number(int(self.value >= other.value)).set_context(
                 self.context),
             None,
         )
     else:
         return None, Value.illegal_operation(self, other)
예제 #3
0
파일: number.py 프로젝트: woo-lang/woolang
 def ored_by(self, other):
     if isinstance(other, Number):
         return (
             Number(int(self.value
                        or other.value)).set_context(self.context),
             None,
         )
     else:
         return None, Value.illegal_operation(self, other)
예제 #4
0
파일: number.py 프로젝트: woo-lang/woolang
    def dived_by(self, other):
        if isinstance(other, Number):
            if other.value == 0:
                return None, RTError(other.pos_start, other.pos_end,
                                     "Division by zero", self.context)

            return Number(self.value / other.value).set_context(
                self.context), None
        else:
            return None, Value.illegal_operation(self, other)
예제 #5
0
파일: list.py 프로젝트: woo-lang/woolang
 def dived_by(self, other):
     if isinstance(other, Number):
         try:
             return self.elements[other.value], None
         except:
             return None, RTError(
                 other.pos_start,
                 other.pos_end,
                 "Element at this index could not be retrieved from list because index is out of bounds",
                 self.context,
             )
     else:
         return None, Value.illegal_operation(self, other)
예제 #6
0
파일: list.py 프로젝트: woo-lang/woolang
 def subbed_by(self, other):
     if isinstance(other, Number):
         new_list = self.copy()
         try:
             new_list.elements.pop(other.value)
             return new_list, None
         except:
             return None, RTError(
                 other.pos_start,
                 other.pos_end,
                 "Element at this index could not be removed from list because index is out of bounds",
                 self.context,
             )
     else:
         return None, Value.illegal_operation(self, other)
예제 #7
0
파일: string.py 프로젝트: woo-lang/woolang
 def added_to(self, other):
     if isinstance(other, String):
         return String(self.value + other.value).set_context(
             self.context), None
     else:
         return None, Value.illegal_operation(self, other)
예제 #8
0
파일: string.py 프로젝트: woo-lang/woolang
 def multed_by(self, other):
     if isinstance(other, Number):
         return String(self.value * other.value).set_context(
             self.context), None
     else:
         return None, Value.illegal_operation(self, other)
예제 #9
0
파일: number.py 프로젝트: woo-lang/woolang
 def subbed_by(self, other):
     if isinstance(other, Number):
         return Number(self.value - other.value).set_context(
             self.context), None
     else:
         return None, Value.illegal_operation(self, other)