def visit_Assign(self, node): if node.op == ':': template = '%s%s %s' else: template = '%s %s %s' if getattr(node, '_parens', False): template = '(%s)' % template assign = E.assign() assign.append(E.left(self.visit(node.left))) assign.append(E.operator(self.visit_Operator(node.op))) assign.append(E.right(self.visit(node.right))) return assign
def visit_UnaryOp(self, node): unary = E.unaryoperation() if node.postfix: unary.append(self.visit(node.value)) unary.append(E.operator(self.visit(node.op))) elif node.op in ('delete', 'void', 'typeof'): #s = '%s %s' % (node.op, s) unary.append(E.operation(node.op)) unary.append(self.visit(node.value)) else: # convert things like "+3.14" and "-22" if node.op in ("-", "+") and isinstance(node.value, ast.Number): node.value.value = "%s%s" % (node.op, node.value.value) return self.visit(node.value) else: unary.append(E.operation(node.op)) unary.append(self.visit(node.value)) return unary
def visit_BinOp(self, node): binop = E.binaryoperation() binop.append(E.left(self.visit(node.left))) binop.append(E.operator(self.visit(node.op))) binop.append(E.right(self.visit(node.right))) return binop