edited by
9,520 views
39 votes
39 votes

Match the following according to input (from the left column) to the compiler phase (in the right column) that processes it:
$$\begin{array}{|l|l|}\hline \text{P. Syntax tree}  &  \text{i. Code generator} \\\hline  \text{Q. Character stream} & \text{ii. Syntax analyser} \\\hline  \text{R. Intermediate representation} & \text{iii. Semantic analyser} \\\hline  \text{S. Token stream} & \text{iv. Lexical analyser} \\\hline \end{array}$$

  1. $\text{P-ii; Q-iii; R-iv; S-i}$
  2. $\text{P-ii; Q-i; R-iii; S-iv}$
  3. $\text{P-iii; Q-iv; R-i; S-ii}$
  4. $\text{P-i; Q-iv; R-ii; S-iii}$
edited by

5 Answers

Best answer
38 votes
38 votes

Correct Option: C

  • Q - iv because Character stream is given as input to lexical analyser
  • P - iii Syntax tree is given as input to semantic analyser
  • R - i Intermediate code given as input to code generator
  • S - ii  Token stream  given as input to syntax analyser
edited by
15 votes
15 votes
Answer will be C

Because

1. Syntax tree will be produced by syntax analysis phase and it will be given to semantic analyser

2. Character stream will be taken from source code and given to lexical analyser

3. Intermediate code will be produced by semantic analyser and give to code generator

4. Token stream will be produced by lexical analyser and given to syntax analyser

Hope you got the point and you please refer dragon book I.e. compilers book by Ullman
6 votes
6 votes
(C)

Step1: Lexer uses character stream to create the tokens
Step2: Syntax analyzer takes the tokens to create syntax tree.
Step3: Semantic analyzer is the next phase of the parser which takes syntax tree as input
Step4: Code generator takes the final parse tree and generates the intermediate code.

The matching is done as per the input for each stage.
edited by
4 votes
4 votes
Answer is C

Character stream - LA
Token Strean - Syntax Analyzer

Syntax tree - Semantic Analyzer

Intermediate representation - Code Generator
Answer:

Related questions

22 votes
22 votes
1 answer
1
Akash Kanase asked Feb 12, 2016
5,021 views
Match the following:$$\begin{array}{ll|ll}\hline \text{(P)} & \text{Lexical analysis} & \text{(i)} & \text{Leftmost derivation} \\\hline \text{(Q)} & \text{Top down pars...
25 votes
25 votes
7 answers
2
khushtak asked Feb 14, 2017
6,788 views
Match the algorithms with their time complexities:$$\begin{array}{|l|l|}\hline \textbf{Algorithms} & \textbf{Time Complexity} \\\hline \text{P. Tower of Hanoi with $n$...
34 votes
34 votes
3 answers
4
go_editor asked Feb 12, 2015
6,895 views
Match the following:$$\begin{array}{ll|ll}\hline \text{P.} & \text{Lexical analysis} & \text{1.} & \text{Graph coloring} \\\hline \text{Q.} & \text{Parsing} & \text{2.}&...