Time Left - 20:00 mins

GATE CS : Compiler Design Champion Quiz 2

Attempt now to get your rank among 557 students!

Question 1

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 є and A a) to parse a string with n tokens?

Question 2

The grammar A AA | A | epsilon is not suitable for predictive-parsing because the grammar is

Question 3

Which of the following derivations does a top-down parser use while parsing aninput string? The input is assumed to be scanned in left to right order.

Question 4

Assume that the SLR parser for a grammar G has n1 states and the LALR parser for G has n2 states. The relationship between n1 and n2 is

Question 5

Which of the following describes a handle (as applicable to LR-parsing) appropriately?

Question 6

An LALR (1) parser for a grammar G can have shift-reduce (S-R) conflicts if and only if

Question 7

Consider two binary operators ‘ and with the precedence of operator being lower than that of the operator . Operator is right associative while operator is left associative. Which one of the following represents the parse tree for expression (7 3 4 3 2)?

Question 8

Consider the following two sets of LR(1) items of an LR(1) grammar.
Set-1:
X c.X, c/d 
X .cX, c/d 
X .d, c/d 
Set-2:
X → c.X, $
X →.cX, $
X →.d, $
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 heads 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 c will lead to two different sets.

Question 9

Consider the following two statements:
P: Every regular grammar is LL(1)
Q: Every regular set has a LR(1) grammar
Which of the following is TRUE?

Question 10

An LALR (1) parser for a grammar G can have shift–reduce (S–R) conflicts if and only if

  • 557 attempts
  • 1 upvote
  • 33 comments
Jun 25GATE & PSU CS