#NEWLINE# def _tgrep_exprs_action( _s , _l , tokens ) : #NEWLINE# #INDENT# '\n    This is the top-lebel node in a tgrep2 search string; the\n    predicate function it returns binds together all the state of a\n    tgrep2 search string.\n\n    Builds a lambda function representing a predicate on a tree node\n    from the disjunction of several tgrep expressions.  Also handles\n    macro definitions and macro name binding, and node label\n    definitions and node label binding.\n    ' #NEWLINE# if ( len ( tokens ) == 1 ) : #NEWLINE# #INDENT# return ( lambda n , m = None , l = None : tokens [ 0 ] ( n , None , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) ) #NEWLINE# #UNINDENT# tokens = [ x for x in tokens if ( x != ';' ) ] #NEWLINE# macro_dict = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# macro_defs = [ tok for tok in tokens if isinstance ( tok , dict ) ] #NEWLINE# for macro_def in macro_defs : #NEWLINE# #INDENT# macro_dict . update ( macro_def ) #NEWLINE# #UNINDENT# tgrep_exprs = [ tok for tok in tokens if ( not isinstance ( tok , dict ) ) ] #NEWLINE# def top_level_pred( n , m = macro_dict , l = None ) : #NEWLINE# #INDENT# label_dict = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# return any ( ( predicate ( n , m , label_dict ) for predicate in tgrep_exprs ) ) #NEWLINE# #UNINDENT# return x