Improved missing `(` and `{` error detection.

Improved missing `(` and `{` error detection (#1839).