Compiler Design questions

Q12

GATE CS 2017 CS-1Intermediate CodeMCQ1 mark−1/3 if wrong
Consider the following intermediate program in three address code
p = a - b
q = p * c
p = u * v
q = p + q
Which one of the following corresponds to a static single assignment form of the above code?
Show answer without attempting

Answer: B

Q43

GATE CS 2017 CS-1ParsingNAT2 marks
Consider the following grammar:
stmt -> if expr then expr else expr; stmt | ε
expr -> term relop term | term
term -> id | number
id -> a | b | c
number -> [0-9]
where relop is a relational operator (e.g., <,>,…<, >, \dots), ε\varepsilon refers to the empty statement, and if, then, else are terminals.

Consider a program PP following the above grammar containing ten if terminals. The number of control flow paths in PP is ____________. For example, the program
if e1 then e2 else e3
has 2 control flow paths, e1→e2e_1 \to e_2 and e1→e3e_1 \to e_3.
Show answer without attempting

Answer: 1024.0

Q5

GATE CS 2017 CS-2ParsingMCQ1 mark−1/3 if wrong
Match the following according to input (from the left column) to the compiler phase (in the right column) that processes it:

(P) Syntax tree
(Q) Character stream
(R) Intermediate representation
(S) Token stream

(i) Code generator
(ii) Syntax analyzer
(iii) Semantic analyzer
(iv) Lexical analyzer
Show answer without attempting

Answer: C

Q6

GATE CS 2017 CS-2ParsingMCQ1 mark−1/3 if wrong
Which of the following statements about parser is/are CORRECT?

I. Canonical LR is more powerful than SLR.
II. SLR is more powerful than LALR.
III. SLR is more powerful than Canonical LR.
Show answer without attempting

Answer: A

Q32

GATE CS 2017 CS-2ParsingMCQ2 marks−2/3 if wrong
Consider the following expression grammar G:

<br>E→E−T∣T<br>T→T+F∣F<br>F→(E)∣id<br>\begin{aligned}<br>E &\rightarrow E - T \mid T \\<br>T &\rightarrow T + F \mid F \\<br>F &\rightarrow (E) \mid id<br>\end{aligned}

Which of the following grammars is not left recursive, but is equivalent to G?
Show answer without attempting

Answer: C

0/50 correct0 marks

Related topics in GATE CS