in Compiler Design edited by
3,116 views
1 vote
1 vote

Let G be a context-free grammar where G = ({S, A, B, C}, {a, b, d}, P, S) with the productions in P given below.

S ABAC

A aA ε

B bB ε

C d

(ε denotes the null string). Transform the grammar G to an equivalent context-free grammar G′ that has no ε productions

and no unit productions. (A unit production is of the form x y, and x and y are non terminals).

in Compiler Design edited by
3.1k views

2 Answers

5 votes
5 votes

The solution is

S ABAC /ABC/BAC/AAC/AC/BC/d

A aA a

B bB b

C d

edited by

4 Comments

There is only one unit production $S\rightarrow C$ after removing null production from grammar, after removing $S\rightarrow C$,grammar will be -

S$\rightarrow$ ABAC/BAC/ABC/AAC/AC/BC/d

A$\rightarrow$aA/a

B$\rightarrow$bB/b

C$\rightarrow$d
2
2
yes ,thanks
1
1
Why not ABACd is not in the answer pls help where I am wrong..  :(
0
0
2 votes
2 votes

Answer given in gatebook  :  C->d is a unit production.

so first production will become S -> ABAd | BAd | AAd | ABd | Bd | d

A -> aA | a

B -> bB | b

A->aA/a ,B->bB/b comes from eliminating epsilon production,why we we remove C->d production(as the question says A unit production is of the form x y, and x and y are non terminals).d is terminal i thing.

2 Comments

is d a non terminal?
0
0
how C->d is a unit production ?

unit productiona of type C->B

Plz correct me if i m wrong
0
0

Related questions