7,134 views

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}$

### Subscribe to GO Classes for GATE CSE 2022

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

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

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.

Intermediate code given as input to code generator.

Isn’t this is code optimiser??

Optimized intermediate code is given input to Target code generation.
Yup, that can also be true. Thanks for telling. :)

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

Is Intermediate code generated by semantic analyser ?

There is Intermediate code generator for generating intermediate code right

you are correct.

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

### 1 comment

Character stream - LA
Token Strean - Syntax Analyzer

Syntax tree - Semantic Analyzer

Intermediate representation - Code Generator
by
2 3 7

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

C is the ans.

1
3,722 views