if found , now check for each opening and closing parentheses in this interval
start = i NEW_LINE end = j NEW_LINE for k in range ( start + 1 , end ) : NEW_LINE INDENT if ( X [ k ] == ' ( ' ) : NEW_LINE INDENT x = matchClosing ( X , k , end , ' ( ' , ' ) ' ) NEW_LINE if ( not ( k < x and x < end ) ) : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT elif ( X [ k ] == ' ) ' ) : NEW_LINE INDENT x = matchingOpening ( X , start , k , ' ( ' , ' ) ' ) NEW_LINE if ( not ( start < x and x < k ) ) : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT if ( X [ k ] == ' { ' ) : NEW_LINE INDENT x = matchClosing ( X , k , end , ' { ' , ' } ' ) NEW_LINE if ( not ( k < x and x < end ) ) : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT elif ( X [ k ] == ' } ' ) : NEW_LINE INDENT x = matchingOpening ( X , start , k , ' { ' , ' } ' ) NEW_LINE if ( not ( start < x and x < k ) ) : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT if ( X [ k ] == ' [ ' ) : NEW_LINE INDENT x = matchClosing ( X , k , end , ' [ ' , ' ] ' ) NEW_LINE if ( not ( k < x and x < end ) ) : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT elif ( X [ k ] == ' ] ' ) : NEW_LINE INDENT x = matchingOpening ( X , start , k , ' [ ' , ' ] ' ) NEW_LINE if ( not ( start < x and x < k ) ) : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT DEDENT return True NEW_LINE