def _tgrep_bind_node_label_action(_s, _l, tokens):
 if (len(tokens) == 1):
  return tokens[0]
 else:
  assert (len(tokens) == 3)
  assert (tokens[1] == u'=')
  node_pred = tokens[0]
  node_label = tokens[2]
  def node_label_bind_pred(n, m=None, l=None):
   if node_pred(n, m, l):
    if (l is None):
     raise TgrepException(u'cannot bind node_label {0}: label_dict is None'.format(node_label))
    l[node_label] = n
    return True
   else:
    return False
  return node_label_bind_pred

def _tgrep_bind_node_label_action ( _s , _l , tokens ) : if ( len ( tokens ) == 1 ) : return tokens [ 0 ] else : assert ( len ( tokens ) == 3 ) assert ( tokens [ 1 ] == u'=' ) node_pred = tokens [ 0 ] node_label = tokens [ 2 ] def node_label_bind_pred ( n , m = None , l = None ) : if node_pred ( n , m , l ) : if ( l is None ) : raise TgrepException ( u'cannot bind node_label {0}: label_dict is None' . format ( node_label ) ) l [ node_label ] = n return True else : return False return node_label_bind_pred
builds a lambda function representing a predicate on a tree node which can optionally bind a matching node into the tgrep2 strings label_dict .