MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

COMPILER DESIGN

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
A parse tree is generated as the output of
A
Lexical Analysis
B
Semantic Analysis
C
Syntax Analysis
D
Code Generation
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: -A parse tree is created by a parser, which is a component of a compiler that processes the source code and checks it for syntactic correctness. A syntax tree is created by the compiler based on the parse tree after the parser has finished processing the source code.

Detailed explanation-4: -Explanation: Short Syntax Analysis generates a parse tree.

Detailed explanation-5: -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.)

There is 1 question to complete.