What syntax analysis cannot do!
. To check whether variables are of types on which operations are allowed
. To check whether a variable has been declared before use
. To check whether a variable has been initialized
. These issues will be handled in semantic analysis
The information which syntax analysis phase gets from the previous phase (lexical analysis) is whether a token is valid or not and which class of tokens does it belong to. Hence it is beyond the capabilities of the syntax analysis phase to settle issues like:
. Whether or not a variable has already been declared?
. Whether or not a variable has been initialized before use?
. Whether or not a variable is of the type on which the operation is allowed?
All such issues are handled in the semantic analysis phase.
|