Exemple #1
0
 def accept_derivation(self, bundle):
     root = bundle.derivation
     for (pattern, name) in self.Patterns:
         # print pattern, name
         for node, ctx in find_all(root, pattern, with_context=True):
             toks = self.toks.get(bundle.label(), None)
             cn_toks = text(root)
             
             trace = ctx.t
             
             if not (toks and cn_toks):
                 print >>sys.stderr, bundle.label()
                 if trace:
                     self.results[name].not_discharged += 1
             
             alignment = align(cn_toks, toks)
             
             if trace is not None:
                 trace_index = get_index_of_leaf(root, trace)
                 if alignment.get(trace_index, None) is not None:
                     self.results[name].not_discharged += 1
                 else:
                     self.results[name].discharged += 1
             else:
                 print >>sys.stderr, "t was not bound to a trace node"
Exemple #2
0
    def accept_derivation(self, bundle):
        root = bundle.derivation
        for (pattern, name) in self.Patterns:
            # print pattern, name
            for node, ctx in find_all(root, pattern, with_context=True):
                toks = self.toks.get(bundle.label(), None)
                cn_toks = text(root)

                trace = ctx.t

                if not (toks and cn_toks):
                    print >> sys.stderr, bundle.label()
                    if trace:
                        self.results[name].not_discharged += 1

                alignment = align(cn_toks, toks)

                if trace is not None:
                    trace_index = get_index_of_leaf(root, trace)
                    if alignment.get(trace_index, None) is not None:
                        self.results[name].not_discharged += 1
                    else:
                        self.results[name].discharged += 1
                else:
                    print >> sys.stderr, "t was not bound to a trace node"
Exemple #3
0
def Precedes(candidate, node, context):
    if not node.is_leaf(): return False
    
    root = get_root(node)
    
    node_index = get_index_of_leaf(root, node)
    
    for successor in islice(leaves(root), node_index+1):
        if candidate.is_satisfied_by(successor, context): 
            return True
            
    return False
Exemple #4
0
def ImmediatelyPrecedes(candidate, node, context):
    if not node.is_leaf(): return False
    
    # does a node which matches 'candidate' occur immediately before _node_?
    root = get_root(node)
    
    node_index = get_index_of_leaf(root, node)
    
    successor = get_leaf(root, node_index+1)
    if not successor: return False
    if candidate.is_satisfied_by(successor, context): return True
    
    return False