#NEWLINE# def _form_master_re( relist , reflags , ldict , toknames ) : #NEWLINE# #INDENT# if ( not relist ) : #NEWLINE# #INDENT# return [ ] #NEWLINE# #UNINDENT# regex = '|' . join ( relist ) #NEWLINE# try : #NEWLINE# #INDENT# lexre = re . compile ( regex , ( re . VERBOSE | reflags ) ) #NEWLINE# lexindexfunc = ( [ None ] * ( max ( lexre . groupindex . values ( ) ) + 1 ) ) #NEWLINE# lexindexnames = lexindexfunc [ : ] #NEWLINE# for ( f , i ) in lexre . groupindex . items ( ) : #NEWLINE# #INDENT# handle = ldict . get ( f , None ) #NEWLINE# if ( type ( handle ) in ( types . FunctionType , types . MethodType ) ) : #NEWLINE# #INDENT# lexindexfunc [ i ] = ( handle , toknames [ f ] ) #NEWLINE# lexindexnames [ i ] = f #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( handle is not None ) : #NEWLINE# #INDENT# lexindexnames [ i ] = f #NEWLINE# if ( f . find ( 'ignore_' ) > 0 ) : #NEWLINE# #INDENT# lexindexfunc [ i ] = ( None , None ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# lexindexfunc [ i ] = ( None , toknames [ f ] ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# return ( [ ( lexre , lexindexfunc ) ] , [ regex ] , [ lexindexnames ] ) #NEWLINE# #UNINDENT# except Exception : #NEWLINE# #INDENT# m = int ( ( len ( relist ) / 2 ) ) #NEWLINE# if ( m == 0 ) : #NEWLINE# #INDENT# m = 1 #NEWLINE# #UNINDENT# ( llist , lre , lnames ) = _form_master_re ( relist [ : m ] , reflags , ldict , toknames ) #NEWLINE# ( rlist , rre , rnames ) = _form_master_re ( relist [ m : ] , reflags , ldict , toknames ) #NEWLINE# return ( ( llist + rlist ) , ( lre + rre ) , ( lnames + rnames ) )