def generate_matches(patterns, nodes):
 if (not patterns):
  (yield (0, {}))
 else:
  (p, rest) = (patterns[0], patterns[1:])
  for (c0, r0) in p.generate_matches(nodes):
   if (not rest):
    (yield (c0, r0))
   else:
    for (c1, r1) in generate_matches(rest, nodes[c0:]):
     r = {}
     r.update(r0)
     r.update(r1)
     (yield ((c0 + c1), r))

def generate_matches ( patterns , nodes ) : if ( not patterns ) : ( yield ( 0 , { } ) ) else : ( p , rest ) = ( patterns [ 0 ] , patterns [ 1 : ] ) for ( c0 , r0 ) in p . generate_matches ( nodes ) : if ( not rest ) : ( yield ( c0 , r0 ) ) else : for ( c1 , r1 ) in generate_matches ( rest , nodes [ c0 : ] ) : r = { } r . update ( r0 ) r . update ( r1 ) ( yield ( ( c0 + c1 ) , r ) )
generator yielding matches for a sequence of patterns and nodes .