Parsing: GATE CS Previous Year Questions

Parsing · Compiler Design

58 questions · asked in 25 of 27 years (2000–2026)

MCQ 46 · MSQ 5 · NAT 71-mark 39 · 2-mark 19

2000Questions per year2026

Questions 6–10 of 58

Q6GATE 2024 (Session 1)1 markMSQ
Which of the following is/are Bottom-Up Parser(s)?

One or more options are correct.

Q7GATE 2024 (Session 1)2 marksMCQ−0.67 if wrong
Consider the following grammar GG, with SS as the start symbol. The grammar GG has three incomplete productions denoted by (1), (2), and (3).

S→daT∣(1)T→aS∣bT∣(2)R→ (3) ∣ϵ\begin{aligned} & S \rightarrow d a T \mid \quad(1) \\ & T \rightarrow a S|b T|(2) \\ & R \rightarrow \text { (3) } \mid \epsilon \end{aligned}

The set of terminals is {a,b,c,d,f}\{a, b, c, d, f\}. The FIRST and FOLLOW sets of the different non-terminals are as follows.

FIRST⁡(S)={c,d,f},FIRST⁡(T)={a,b,ϵ},FIRST⁡(R)={c,ϵ}FOLLOW⁡(S)=FOLLOW⁡(T)={c,f,$},FOLLOW⁡(R)={f}\begin{aligned} & \operatorname{FIRST}(S)=\{c, d, f\}, \operatorname{FIRST}(T)=\{a, b, \epsilon\}, \operatorname{FIRST}(R)=\{c, \epsilon\} \\ & \operatorname{FOLLOW}(S)=\operatorname{FOLLOW}(T)=\{c, f, \$\}, \operatorname{FOLLOW}(R)=\{f\} \end{aligned}

Which one of the following options CORRECTLY fills in the incomplete productions?

Q8GATE 20221 markMCQ−0.33 if wrong
Which one of the following statements is TRUE?

Q9GATE 20221 markNAT
Consider the augmented grammar with {+,∗,(,),id}\{+, *, (, ), id \} as the set of terminals.
S′→SS→S+R∣RR→R∗P∣PP→(S)∣id\begin{aligned}&S' \rightarrow S \\ &S \rightarrow S+R|R \\ &R \rightarrow R*P|P \\ &P \rightarrow (S)|id \end{aligned}
If I0I_0 is the set of two LR(0)LR(0) items {[S′→S.],[S→S.+R]}\{ [S' \rightarrow S.], [S \rightarrow S.+R] \}, then goto(closure(I0),+)goto(closure(I_0 ),+) contains exactly ______ items.

Q10GATE 20222 marksNAT
Consider the following grammar along with translation rules.
S→S1#T{S.val=S1.val∗T.val}S→T{S.val=T.val}T→T1%R{T.val=T1.val÷R.val}T→R{T.val=R.val}R→id{R.val=id.val}\begin{aligned} &S \rightarrow S_1 \# T & & \{S._{val}=S_{1.val}*T._{val} \} \\ &S \rightarrow T & & \{S._{val}=T._{val} \} \\ &T \rightarrow T_1 \% R & & \{T._{val}=T_{1.val} \div R._{val} \} \\ &T \rightarrow R & & \{T._{val}=R._{val} \} \\ &R \rightarrow id & & \{R._{val}=id._{val} \} \\ \end{aligned}
Here #\# and %\% are operators and idid is a token that represents an integer and id.valid_{.val} represents the corresponding integer value. The set of non-terminals is {S,T,R,P}\{S,T,R,P \} and a subscripted non-terminal indicates an instance of the non-terminal.
Using this translation scheme, the computed value of S.valS_{.val} for root of the parse tree for the expression 20#10%5#8%2%220 \# 10 \% 5 \# 8 \% 2 \% 2 is

Keep practising

Topics in Compiler Design

All CS topics ›