Compiler Design questions

Q9

GATE CS 2013 CSParsingMCQ1 mark−1/3 if wrong
What is the maximum number of reduce moves that can be taken by a bottom-up parser for a grammar with no epsilon- and unit-production (i.e., of type A→ϵA \to \epsilon and A→aA \to a) to parse a string with nn tokens?
Show answer without attempting

Answer: B

Q40

GATE CS 2013 CSParsingMCQ2 marks−2/3 if wrong
Consider the following two sets of LR(1) items of an LR(1) grammar.

<br>X→c⋅X,c/dX→c⋅X,$<br>X→⋅cX,c/dX→⋅cX,$<br>X→⋅d,c/dX→⋅d,$<br>\begin{array}{ll}<br>X \to c\cdot X, c/d & X \to c\cdot X, \$ \\<br>X \to \cdot cX, c/d & X \to \cdot cX, \$ \\<br>X \to \cdot d, c/d & X \to \cdot d, \$<br>\end{array}

Which of the following statements related to merging of the two sets in the corresponding LALR parser is/are FALSE?

1. Cannot be merged since look aheads are different.
2. Can be merged but will result in S-R conflict.
3. Can be merged but will result in R-R conflict.
4. Cannot be merged since goto on cc will lead to two different sets.
Show answer without attempting

Answer: D

Q48

GATE CS 2013 CSOptimization and Data FlowMCQ2 marks−2/3 if wrong
Suppose the instruction set architecture of the processor has only two registers. The only allowed compiler optimization is code motion, which moves statements from one place to another while preserving correctness. What is the minimum number of spills to memory in the compiled code?
Show answer without attempting

Answer: B

Q49

GATE CS 2013 CSOptimization and Data FlowMCQ2 marks−2/3 if wrong
What is the minimum number of registers needed in the instruction set architecture of the processor to compile this code segment without any spill to memory? Do not apply any optimization other than optimizing register allocation.
Show answer without attempting

Answer: B

0/40 correct0 marks

Related topics in GATE CS