Generator-coordinate theory of molecular spectra