Пример #1
0
 def expression(p):
     left = p[0]
     right = p[2]
     operator = p[1]
     if operator.gettokentype() == 'SUM':
         return Sum(self.builder, self.module, left, right)
     elif operator.gettokentype() == 'SUB':
         return Sub(self.builder, self.module, left, right)
Пример #2
0
 def expression(p):
     left = p[0]
     right = p[2]
     operator = p[1]
     if operator.gettokentype() == 'SUM':
         return Sum(left, right)
     elif operator.gettokentype() == 'SUB':
         return Sub(left, right)
Пример #3
0
 def pro(p):
     if p[1].gettokentype() == 'SUM':
         return Sum(p[0], p[2])
     if p[1].gettokentype() == 'SUB':
         return Sub(p[0], p[2])
     if p[1].gettokentype() == 'MUL':
         return Sub(p[0], p[2])
     if p[1].gettokentype() == 'DIV':
         return Sub(p[0], p[2])
Пример #4
0
 def p_expr(tokens):
     op = tokens[1].gettokentype()
     left = tokens[0]
     right = tokens[2]
     if (op == 'PLUS'):
         return Sum(left, right)
     if (op == 'MINUS'):
         return Sub(left, right)
     else:
         raise Exception(f"{tokens} passaram liso")
Пример #5
0
		def expression(p):
			left = p[0]
			right = p[2]
			operator = p[1]
			if operator.gettokentype() == 'NHAN':
				return Mul(self.builder, self.module, left, right)
			elif operator.gettokentype() == 'CHIA':
				return Div(self.builder, self.module, left, right)
			elif operator.gettokentype() == 'CONG':
				return Sum(self.builder, self.module, left, right)
			elif operator.gettokentype() == 'TRU':
				return Sub(self.builder, self.module, left, right)
Пример #6
0
 def expressao(p):
     left = p[0]
     right = p[2]
     operator = p[1]
     if operator.gettokentype() == 'SOMA':
         return Sum(self.builder, self.module, left, right)
     elif operator.gettokentype() == 'SUB':
         return Sub(self.builder, self.module, left, right)
     elif operator.gettokentype() == 'MUL':
         return Mul(self.builder, self.module, left, right)
     elif operator.gettokentype() == 'DIV':
         return Div(self.builder, self.module, left, right)
Пример #7
0
        def expression(p) -> BinaryOp:
            left = p[0]
            right = p[2]
            operator = p[1]

            t = operator.gettokentype()
            if t == 'SUM':
                return Sum(self.builder, self.module, left, right)
            elif t == 'SUB':
                return Sub(self.builder, self.module, left, right)
            elif t == 'MUL':
                return Mul(self.builder, self.module, left, right)
            elif t == 'DIV':
                return Div(self.builder, self.module, left, right)
Пример #8
0
 def expression(p):
     left = p[0]
     right = p[2]
     operator = p[1]
     if operator.gettokentype() == 'SUM':
         return Sum(left, right)
     elif operator.gettokentype() == 'SUB':
         return Sub(left, right)
     elif operator.gettokentype() == 'MUL':
         return Mul(left, right)
     elif operator.gettokentype() == 'DIV':
         return Div(left, right)
     elif operator.gettokentype() == 'POW':
         return Pow(left, right)
     elif operator.gettokentype() == 'MOD':
         return Mod(left, right)
Пример #9
0
 def expression(p):
     left = p[0]
     right = p[2]
     operator = p[1]
     if operator.gettokentype() == 'PLUS':
         return Sum(left, right)
     elif operator.gettokentype() == 'MINUS':
         return Sub(left, right)
     elif operator.gettokentype() == 'MULT':
         return Mult(left, right)
     elif operator.gettokentype() == 'DIV':
         return Div(left, right)
     elif operator.gettokentype() == 'ASSIGN':
         return Assign(left, right)
     elif operator.gettokentype() == 'GREATERTHAN':
         return GreaterThan(left, right)
     elif operator.gettokentype() == 'LESSTHAN':
         return LessThan(left, right)
     elif operator.gettokentype() == 'EQUAL':
         return Equal(left, right)