• edited by
16,485 views
50 50 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}$

5 Answers

Best answer
50 50 votes

Correct Option: $C$

  • $\text{Q - iv}$ because Character stream is given as input to lexical analyser
  • $\text{P - iii}$ Syntax tree is given as input to semantic analyser
  • $\text{R - i }$Intermediate code given as input to code generator
  • $\text{S - ii }$ Token stream  given as input to syntax analyser
• edited by
19 19 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 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 4 votes
Answer is C

Character stream - LA
Token Strean - Syntax Analyzer

Syntax tree - Semantic Analyzer

Intermediate representation - Code Generator
1 1 vote

C. P-iii; Q-iv; R-i; S-ii;

because Syntax tree come from Syntax analyzer process by Semantic analyzer

             Character stream is input to Lexical analyzer

              Intermediate representation is input to Code generator

              token stream come from Lexical analyzer is input to Syntax analyzer

Answer:
Position:
Show:

Related questions

23 23 votes
6 6 answers
12.2k
12.2k views
Arjun asked Feb 16, 2024
12,185 views
​​​Consider the following two sets:$$\begin{array}{|ll|ll|}\hline & \textbf{Set X} & & \textbf{Set Y} \\\hline \text{ P.} & \text{Lexical Analyzer } & \text{1.}& \text...
34 34 votes
1 answers 1 answer
8.5k
8.5k views
Akash Kanase asked Feb 12, 2016
8,544 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 pa...
47 47 votes
3 answers 3 answers
13.5k
13.5k views
Kathleen asked Sep 22, 2014
13,528 views
Match all items in Group 1 with the correct options from those given in Group 2.$$\begin{array}{|ll|ll|}\hline \rlap{\textbf{Group 1}} & & \rlap{\textbf{Group 2}} \\\hli...