示例#1
0
 def visit_BinaryExpressionNode(self, node):
     assert len(node.children) == 3
     children = []
     for child_index in [1, 0, 2]:
         child = node.children[child_index]
         child_str = self.visit(child)[0]
         if (isinstance(child, BinaryExpressionNode) and
             precedence(node.children[0]) < precedence(child.children[0])):
             child_str = "(%s)" % child_str
         children.append(child_str)
     return [" ".join(children)]
示例#2
0
 def visit_BinaryExpressionNode(self, node):
     assert len(node.children) == 3
     children = []
     for child_index in [1, 0, 2]:
         child = node.children[child_index]
         child_str = self.visit(child)[0]
         if (isinstance(child, BinaryExpressionNode) and precedence(
                 node.children[0]) < precedence(child.children[0])):
             child_str = "(%s)" % child_str
         children.append(child_str)
     return [" ".join(children)]