Syntactic analysis checks whether the code follows the correct grammar and syntax of the programming language. If not, it generates an error message.