A general parsing model for language and music