Exemplo n.º 1
0
 def visit_Compare(self, node):
     _internal_assert(len(node.ops) == len(node.comparators), "#compare ops != #comparators")
     ops = [self.visit(node.left)]
     ops += [self.visit(i) for i in node.comparators]
     res = []
     for i in range(len(node.ops)):
         lhs = ops[i]
         rhs = ops[i + 1]
         res.append(HybridParser._binop_maker[type(node.ops[i])](lhs, rhs))
     return _all(*res)
Exemplo n.º 2
0
    def visit_Compare(self, node):
        """Compare visitor
        AST abstract grammar:
            Compare(expr left, expr right, ops=)
        """

        ops = [self.visit(node.left)]
        ops += [self.visit(comparator) for comparator in node.comparators]
        res = []
        for i in range(len(node.ops)):
            lhs = ops[i]
            rhs = ops[i + 1]
            res.append(HybridParser._binop_maker[type(node.ops[i])](lhs, rhs))
        return _all(*res)