Parsing in Compiler design PYQ QUIZ GATE CS

Last Updated :
Discuss
Comments

Question 1

Consider the date same as above question. The appropriate entries for E1, E2, and E3 are 

 
  • A

  • B

  • C

  • D

Question 2

For the grammar below, a partial LL(1) parsing table is also presented along with the grammar. Entries that need to be filled are indicated as E1, E2, and E3. [Tex]\\epsilon[/Tex] is the empty string, $ indicates end of input, and, | separates alternate right hand sides of productions.

CSE_2012_51
CSE_GATE_20122

  • A

  • B

  • C

  • D

Question 3

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?

  • n/2

  • n-1

  • 2n-1

  • 2n

Question 4

Consider the following two sets of LR(1) items of an LR(1) grammar.

X -> c.X, c/d
X -> .cX, c/d
X -> .d, c/d
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 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 c will lead to two different sets.
  • 1 only

  • 2 only

  • 1 and 4 only

  • 1, 2, 3, and 4

Question 5

Which of the following statements about the 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.
  • I only

  • II only

  • III only

  • II and III only

Question 6

Consider the following grammar

p --> xQRS
Q --> yz|z
R --> w|∈
S -> y

Which is FOLLOW(Q)?

  • {R}

  • {w}

  • {w, y}

  • {w, ∉}

Question 7

Consider the augmented grammar given below:
S′ → S
S → ⏐id
L → L, S⏐S
Let I0 = CLOSURE ({[S′ → S]}). The number of items in the set GOTO (I0, <) is __________.



Note: This was Numerical Type question.

  • 5

  • 4

  • 3

  • 1

Question 8

Which one of the following kinds of derivation is used by LR parsers?

  • Leftmost

  • Leftmost in reverse

  • Rightmost

  • Rightmost in reverse

Question 9

Consider the following given grammar:

S → Aa
A → BD
B → b|ε
D → d|ε

Let a, b, d, and $ be indexed as follows:

60

Compute the FOLLOW set of the non-terminal B and write the index values for the symbols in the FOLLOW set in the descending order. (For example, if the FOLLOW set is {a, b, d, $}, then the answer should be 3210).

Note:

This was Numerical Type question.

  • 31

  • 310

  • 230

  • 23

Question 10

Consider the augmented grammar with { + , *, (, ), id } as the set of terminals.

S` [Tex]\to[/Tex]  S
S [Tex]\to[/Tex]  S + R | R
R [Tex]\to[/Tex]  R* P| P
P [Tex]\to[/Tex]  (S) | id

If I0 is the set of two LR(0) items {[S` ⇢ S.], [S ⇢ S. +R]}, then goto(closure(I0), +) contains exactly __________ items.

  • 3

  • 4

  • 5

  • 6

There are 36 questions to complete.

Take a part in the ongoing discussion