Пример #1
0
 def visit_Operator(self, node):
     filename = getfilename(node)
     template = self.get_template(filename)
     order = op2order(node.__class__.__name__)
     lorder = op2order(node.left.__class__.__name__)
     rorder = op2order(node.right.__class__.__name__)
     left = self.visit(node.left)
     right = self.visit(node.right)
     if ((not isinstance(node.left,
                         (Sll, Srl, Sra, LessThan, GreaterThan, LessEq,
                          GreaterEq, Eq, NotEq, Eql, NotEql)))
             and (lorder is not None and lorder <= order)):
         left = del_paren(left)
     if ((not isinstance(node.right,
                         (Sll, Srl, Sra, LessThan, GreaterThan, LessEq,
                          GreaterEq, Eq, NotEq, Eql, NotEql)))
             and (rorder is not None and order > rorder)):
         right = del_paren(right)
     template_dict = {
         'left': left,
         'right': right,
         'op': op2mark(node.__class__.__name__),
     }
     rslt = template.render(template_dict)
     return rslt
Пример #2
0
 def visit_Operator(self, node):
     filename = getfilename(node)
     template = self.get_template(filename)
     order = op2order(node.__class__.__name__)
     lorder = op2order(node.left.__class__.__name__)
     rorder = op2order(node.right.__class__.__name__)
     left = self.visit(node.left)
     right = self.visit(node.right)
     if ((not isinstance(node.left, (Sll, Srl, Sra,
                                     LessThan, GreaterThan, LessEq, GreaterEq,
                                     Eq, NotEq, Eql, NotEql))) and 
         (lorder is not None and lorder <= order)):
         left = del_paren(left)
     if ((not isinstance(node.right, (Sll, Srl, Sra,
                                      LessThan, GreaterThan, LessEq, GreaterEq,
                                      Eq, NotEq, Eql, NotEql))) and 
         (rorder is not None and order > rorder)):
         right = del_paren(right)
     template_dict = {
         'left' : left,
         'right' : right,
         'op' : op2mark(node.__class__.__name__),
         }
     rslt = template.render(template_dict)
     return rslt