Which of the following correctly defines the role of a parser?

A)  A Parser reports any syntax error
B)  A Parser creates a parse tree
C)  A Parser recovers from a common error to continue processing of the rest of the program
D)  All of the above

Correct Answer :   All of the above


Explanation : A Parser is a software component which takes text as input and gives structural representation of input after checking it against the grammar of the language. Main roles of a parser are following:

* To report any syntax error.
* To recover from commonly occurring errors to continue parsing of the rest of the program.
* To create a parse tree
* To create a symbol tree
* To produce intermediate representations.