MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

COMPILER DESIGN

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
What does a Syntactic Analyser do?
A
Maintain Symbol Table
B
Collect type of information
C
Create parse tree
D
None of the mentioned
Explanation: 

Detailed explanation-1: -The parser analyzes the source code (token stream) against the production rules to detect any errors in the code. The output of this phase is a parse tree. This way, the parser accomplishes two tasks, i.e., parsing the code, looking for errors and generating a parse tree as the output of the phase.

Detailed explanation-2: -The parse tree is constructed by using the pre-defined Grammar of the language and the input string. If the given input string can be produced with the help of the syntax tree (in the derivation process), the input string is found to be in the correct syntax. if not, the error is reported by the syntax analyzer.

Detailed explanation-3: -The parser obtains a string of tokens from the scanner (generated by a scanner definition file as shown above) and verifies that the string can be generated by the grammar for the source language. (If not, the source program is not syntactically correct.)

Detailed explanation-4: -Syntax Analyser takes Groups Tokens of source Program into Grammatical Production. Explanation: It Groups Tokens of source Program into Grammatical Production.

Detailed explanation-5: -Semantic analysis is the task of ensuring that the declarations and statements of a program are semantically correct, i.e, that their meaning is clear and consistent with the way in which control structures and data types are supposed to be used.

There is 1 question to complete.