A Theory of Syntactic Monoids for Context-Free Languages