i had problem with my homework, can someone explane me for the question below. thank you
Construct a CFG for RE below :
- a* b* (a│c)*
- (a│c)* ba
i had problem with my homework, can someone explane me for the question below. thank you
Construct a CFG for RE below :
If you want to write CFG for regular expression, try to understand what regular expression is saying.
For e.g. in 1. ab(a|c)*, we are given with regular expression for any number of a's followed by any number b's followed by any number of a or c's. To write CGF for this,
S--> ABC
A--> aA | ^
B--> bB | ^
C--> aC | cC | ^
Where variable A will take care of a*, variable B will take care of b*, C will take care of (a|c)*
Similarly, for 2. (a|c)*ba, we are given with regular expression for any number of a or c followed by substring ba. CGF for this will be,
S--> Aba
A--> aA | cA | ^