コード例 #1
0
ファイル: node.py プロジェクト: gcarothers/lepl
def node_throw(node):
    '''
    Raise an error, if one exists in the results (AST trees are traversed).
    Otherwise, the results are returned (invoke with ``>>``).
    '''
    for child in postorder(node, Node):
        if isinstance(child, Exception):
            raise child
    return node
コード例 #2
0
def node_throw(node):
    '''
    Raise an error, if one exists in the results (AST trees are traversed).
    Otherwise, the results are returned (invoke with ``>>``).
    '''
    for child in postorder(node, Node):
        if isinstance(child, Exception):
            raise child
    return node
コード例 #3
0
 def test_postorder(self):
     '''
     At first I was surprised about this (compare with SimpleNode results above),
     but these are leaf nodes, so postorder doesn't change anything (there's
     no difference between "before visiting" and "after visiting" a leaf).
     '''
     g = [1, [11, [111, 112], 12]]
     result = [node for node in postorder(g, list) if isinstance(node, int)]
     assert result == [1, 11, 111, 112, 12], result
コード例 #4
0
ファイル: graph.py プロジェクト: GbalsaC/bitnamiP
 def test_postorder(self):
     '''
     At first I was surprised about this (compare with SimpleNode results above),
     but these are leaf nodes, so postorder doesn't change anything (there's
     no difference between "before visiting" and "after visiting" a leaf). 
     '''
     g = [1, [11, [111, 112], 12]]
     result = [node for node in postorder(g, list) if isinstance(node, int)]
     assert result == [1, 11, 111, 112, 12], result
コード例 #5
0
 def test_postorder(self):
     result = [
         node.label for node in postorder(graph(), SimpleNode, exclude=LEAF)
     ]
     assert result == [111, 112, 11, 12, 1], result
コード例 #6
0
ファイル: graph.py プロジェクト: GbalsaC/bitnamiP
 def test_postorder(self):
     result = [node.label for node in postorder(graph(), SimpleNode, exclude=LEAF)]
     assert result == [111, 112, 11, 12, 1], result