in Compiler Design edited by
7,134 views
34 votes
34 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}$
in Compiler Design edited by
by
51 95 101
7.1k views

Subscribe to GO Classes for GATE CSE 2022

5 Answers

34 votes
34 votes
 
Best answer

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
by
26 72 121

5 Comments

3 MATCH IS FOR I/P AND 1 MATCH FOR O/P ..... ACTUALLY WE MUST GO WITH STEPS OF CREATING MACHINE CODE.
0
0

Parse tree is also known as Concrete Syntax Tree. They should have written either Parse tree or Concrete Syntax Tree coz writing simply Syntax Tree means Abstract Syntax Tree which is part of Intermediate Code Generation.

0
0

Intermediate code given as input to code generator.

Isn’t this is code optimiser??

0
0
Optimized intermediate code is given input to Target code generation.
1
1
Yup, that can also be true. Thanks for telling. :)
0
0
13 votes
13 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
by
2 4 11

2 Comments

Is Intermediate code generated by semantic analyser ?

There is Intermediate code generator for generating intermediate code right
0
0

 you are correct.

1
1
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
by
1 4 10

1 comment

Detailed and specific answer! :D
0
0
4 votes
4 votes
Answer is C

Character stream - LA
Token Strean - Syntax Analyzer

Syntax tree - Semantic Analyzer

Intermediate representation - Code Generator
by
2 3 7
1 vote
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

by
1 1 2

1 comment

C is the ans.
0
0
Answer:

Related questions