A semiempirical treatment of molecular structures. II. Molecular terms and application to diatomic molecules