Which is the procedure steps to find the regular expression that accept the same language of a given Grammar?
- S --> b | AA
- A --> aA | Abb | ϵ
I am writing something try to understand (hope it will help):
According to S --> b
, string 'b'
is a string in language of grammar.
Using A
's productions A --> aA | &
we can generate: " A
followed by any number of a
s", or in RE: a*A
(* because of epsilon)
Similarly, Using A ---> Abb | &
we can generate "Any number of bb
s followed by A
", or in RE: A(bb)*
(* because of epsilon)
Using 2 and 3 using A
you can generate: a*(bb)*
Note ultimately a variable has to converted into terminal hence A can be convert into a
, bb
or &
.
From 4, using AA
we can generate: a*(bb)*a(bb)*
.
So in language generated by grammar is b + a*(bb)*a(bb)*
For procedure read this answer : Constructing an equivalent Regular Grammar from a Regular Expression I explained from RE to grammar, I feel that answer will help you to understand better.