#NEWLINE# def apply( self , chart , grammar , edge ) : #NEWLINE# #INDENT# if edge . is_complete ( ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# ( nextsym , index ) = ( edge . nextsym ( ) , edge . end ( ) ) #NEWLINE# if ( not is_nonterminal ( nextsym ) ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# done = self . _done . get ( ( nextsym , index ) , ( None , None ) ) #NEWLINE# if ( ( done [ 0 ] is chart ) and ( done [ 1 ] is grammar ) ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# for prod in grammar . productions ( lhs = nextsym ) : #NEWLINE# #INDENT# if prod . rhs ( ) : #NEWLINE# #INDENT# first = prod . rhs ( ) [ 0 ] #NEWLINE# if is_terminal ( first ) : #NEWLINE# #INDENT# if ( ( index >= chart . num_leaves ( ) ) or ( first != chart . leaf ( index ) ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# new_edge = TreeEdge . from_production ( prod , index ) #NEWLINE# if chart . insert ( new_edge , ( ) ) : #NEWLINE# #INDENT# ( yield new_edge ) #NEWLINE# #UNINDENT# #UNINDENT# self . _done [ ( nextsym , index ) ] = ( chart , grammar )