0% found this document useful (0 votes)
25 views8 pages

CT2 Part B Questions

The document discusses various parsing concepts across 10 groups including left recursion elimination, FIRST and FOLLOW computation, parsing techniques like shift-reduce and predictive parsing, and construction of parsing tables. Example grammars and strings are provided for techniques like left recursion removal, FIRST/FOLLOW computation, parsing, and LR parsing.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views8 pages

CT2 Part B Questions

The document discusses various parsing concepts across 10 groups including left recursion elimination, FIRST and FOLLOW computation, parsing techniques like shift-reduce and predictive parsing, and construction of parsing tables. Example grammars and strings are provided for techniques like left recursion removal, FIRST/FOLLOW computation, parsing, and LR parsing.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Group-I

1. Consider the following grammar and eliminate left recursion


P →Pab | Pa | a
Q → Qc | b
2. Consider the following grammar and eliminate left recursion
bexpr → bexpr or bterm | bterm
bterm → bterm and bfactor | bfactor
bfactor → not bfactor | (bexpr) | t | f

3. Remove Left recursion and left factoring for the following grammars
S→Aa/Ab A→Ad/Sc/€
4. Consider the following Grammar
P → PP+ | PP* | b
Give a left most derivation and parse tree for the string bb+b*.
5. Consider the following Grammar
P → PP+ | PP* | b
Give a Right most derivation and parse tree for the string bb+b*.
Group-II

1. Compute the FIRST of Non Terminals in the following grammar


stmt → if exp then stmt stmtTail
| while exp do stmt
| begin list end
|a
stmtTail→ else stmt

|∈

list →stmt listTail

listTail→; list

|∈

2. For the given grammar S→ 0S1 | 01 , Write a derivation and draw parse tree for the
string w= 0515

3. Compute FOLLOW for the following grammar

R→R-T | T
T→T / F| F
F→ P ^ F | P
P→(R) | a | b

4. Compute FIRST for the following grammar


S→A∈B | bA | ∈
A→aAb | ∈
B → bB | ∈

5. Compute FOLLOW for the following grammar


S→A∈B | bA | ∈
A→aAb | ∈
B → bB | ∈
Group-III

1. Find leading and trailing for all the non-terminals from the following grammar
S→Aa|bAc|Bc|bBa
A→d
B→d
2. Find leading and trailing for all the non-terminals from the following grammar
R→R-T|T
T→T/F|T
F→F*P|P
P→(R)|a|b

3. Find leading and trailing for all the non-terminals from the following grammar
A→B |ApqA
B →qB|q

4. Find leading and trailing for all the non-terminals from the following grammar
P → (Q) | x
Q → Q,P | P
5. Find leading and trailing for all the non-terminals from the following grammar
C →A=L
C →L
A →*L
A→i
L →A
Group-IV

1. Derive a string " (a,a) " using RMD for the following grammar and identify all the
handles for the same.

S→a | ↑ | (T)
T→T,S | S

2. Derive a string " id=*id " using RMD for the following grammar and identify all the
handles for the same.

S→L=R
S→R
L→*R
L→id
R→L

3. Derive a string " abab " using RMD for the following grammar and identify all the
handles for the same.

S →AS | b
A →SA | a

4. Derive a string " dcccd " using RMD for the following grammar and identify all the
handles for the same.

S → CC

C →cC | d

5. Derive a string " xbbcb " using RMD for the following grammar and identify all the
handles for the same.

S→xABC
A→a|bbD
B→a|ε
C→b|ε
D→c|ε
Group-V

1. Parse the input string “ccdd” using shift reduce parsing for the following grammar

S → CC

C →cC | d
2. Parse the input string “(a,a)” using shift reduce parsing for the following grammar

S→a | ↑ | (T)
T→T,S | S

3. Parse the input string “xbbcab” using shift reduce parsing for the following grammar

S→xABC
A→a|bbD
B→a|ε
C→b|ε
D→c

4. Parse the input string “aabbd” using shift reduce parsing for the following grammar

S→aSA|a
A→bB|cc
B→bd|a

5. Parse the input string “ibtaea” using shift reduce parsing for the following grammar
S→iEtS|iEtSeS| a
E→b

Group-VI

1. Check whether the grammar is LL(1) or not by constructing predictive parsing table
E→ idE'
E' → +EE'|*EE'| ∈

2. Check whether the grammar is LL(1) or not by constructing predictive parsing table
S→aSS'
S'→aS'| ∈
3. Check whether the grammar is LL(1) or not by constructing predictive parsing table
A → (A)A' | aA'
A' → AA' | ∈
4. Check whether the grammar is LL(1) or not by constructing predictive parsing table
X→aXX'
X'→aX'| ∈

Group-VII

1. Using the predictive parsing table constructed for the grammar


P→ +PP | *PP | b
Parse the input w = +*bbb

Non Input Symbol


Terminal
+ * b $
P P→ +PP P→ *PP P→b
2. Using the predictive parsing table constructed for the grammar
P → (Q) | d
Q→Q,P|P
Parse the input (d,d)

Non Input Symbol


Terminal
( ) d , $
P P → (Q) P→d
Q Q → PQ’ Q → PQ’
Q’ Q’ →∈ Q’→,PQ’

3. Using the predictive parsing table constructed for the grammar


R→ +RR | *RR | c
Parse the input w = +*ccc

Non Input Symbol


Terminal
+ * c $
R R→ +RR R→ *RR R→c
4. Using the predictive parsing table constructed for the grammar

X→ (Y) | e
Y→Y ,X | X
Parse the input (e,e)

Non Input Symbol


Terminal
( ) e , $
X X→ (Y) X→e
Y Y→XY’ Y→XY’
Y’ Y’ →∈ Y’→,XY’

Group-VIII

1. Construct operator precedence parsing table for the following grammar


S→aAde

A→Abc

A→b

2. Construct operator precedence parsing table for the following grammar


S →aSd| aAd

A→bAc| bc

3. Construct operator precedence parsing table for the following grammar


X →Ma
X →bMc
X →dc
X →bMa
M →d
Group-IX

1. Construct canonical LR(0) collection for the following grammar


S →aSa

S →bSb

S→ a

S →b

S→Ɛ

2. Construct canonical LR(0) collection for the following grammar

S→aSb

S→ab

3. Construct canonical LR(0) collection for the following grammar

S →aSa

S →bSb

S→c

4. Construct canonical LR(0) collection for the following grammar

S →B

S →SabS

B→bB

B→ Ɛ

Group X

1. Explain the Role of Parser with a neat diagram.


2. Explain any three Error-Recovery Strategies of a parser.
3. Write down the algorithm for eliminating left recursion.
4. Write down the algorithm for eliminating left factoring.
5. Write the procedure for computing FIRST and FOLLOW.
6. Write down the algorithm for the Construction of a predictive parsing table.
7. What are the Conflicts during Shift-Reduce Parsing and give an example for each.

You might also like