made easy test series - parsing - context-free grammar
in Compiler Design
147 views
0 votes
0 votes

Consider the following context-free grammar:

Find the number of unique productions in {Goto (A → D.BC, B) U Goto (A → .DBC, D)}

in Compiler Design
by
147 views

2 Comments

In the union, we’ll get A → DB.C and A → D.BC. Will they be considered as different productions? The answer key has taken them as two different productions. I think that they shouldn’t be considered different because the root production in both cases is the same i.e., A → DBC.

0
0

Will they be considered as different productions?

Yes. 

1
1

Subscribe to GO Classes for GATE CSE 2022

1 Answer

3 votes
3 votes

Goto (A → D.BC, B) = {A → DB.C , C→ .c , C→ eps}

Goto (A → .DBC, D) = {A → D.BC , B→ .Bb, B→ eps}

Goto (A → D.BC, B) U Goto (A → .DBC, D) =  {A → DB.C , C→ .c , C→ eps} U {A → D.BC , B→ .Bb, B→ eps}

There is no duplicate production , so answer is 6.


X→ eps. = X→ .eps = X→ .   because all are having same meaning.

Related questions