Syntax analysis is the second phase of the compiler. It gets the input from the tokens and generates a syntax tree or parse tree.
Advantages of grammar for syntactic specification :
1. A grammar gives a precise and easy-to-understand syntactic specification of a programming language.
2. An efficient parser can be constructed automatically from a properly designed grammar.
3. A grammar imparts a structure to a source program that is useful for its translation into object code and for the detection of errors.
4. New constructs can be added to a language more easily when there is a grammatical description of the language.