Theory-of-Computation
December 6, 2023Finite-Automata
December 6, 2023Theory-of-Computation
|
Question 34
|
The grammar whose productions are
→ if id then → if id then else → id := id
is ambiguous because
|
the sentence
if a then if b then c:=d |
|
|
the left most and right most derivations of the sentence
if a then if b then c:=d give rise top different parse trees |
|
|
the sentence
if a then if b then c:=d else c:=f has more than two parse trees |
|
|
the sentence
if a then if then c:=d else c:=f has two parse trees |
Question 34 Explanation:
We have to generate
“if a then if b then c:=d else c:=f”.
Parse tree 1:

Parse tree 2:

“if a then if b then c:=d else c:=f”.
Parse tree 1:

Parse tree 2:

Correct Answer: D
Question 34 Explanation:
We have to generate
“if a then if b then c:=d else c:=f”.
Parse tree 1:

Parse tree 2:

“if a then if b then c:=d else c:=f”.
Parse tree 1:

Parse tree 2:

