Parsing in Compiler design PYQ QUIZ GATE CS (original) (raw)

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

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

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?

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.

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.

Consider the following grammar

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

Which is FOLLOW(Q)?

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.

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

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.

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(I 0 ), +) contains exactly __________ items.

There are 36 questions to complete.

Take a part in the ongoing discussion