Click here to Skip to main content
15,888,461 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
The CFG is as following:
S -> SD|SB
B -> b|c
D -> a|dB

The method which I tried is as following:

I removed non-determinism from the first production (S->SD|SB) by left-factoring method. So, the CFG after applying left-factoring is as following:
S -> SS' 
S'-> D|B 
B -> b|c 
D -> a|dB 

I need to find the 'FIRST' of S for the production i.e. S -> SS' in order to proceed further. Could some one please help or advise? Thank you.
Posted
Updated 20-Dec-15 2:00am
v4
Comments
[no name] 19-Dec-15 15:30pm    
Wiki: Given two CFGs, can the first one generate all strings that the second one can generate?[18][19]

If this problem was decidable, then language equality could be decided too: two CFGs G1 and G2 generate the same language if L(G1) is a subset of L(G2) and L(G2) is a subset of L(G1).
Tomas Takac 20-Dec-15 8:56am    
Your real problem is the left recursion. But in your case I don't think you can remove it as there are no production rules of S that don't start with S.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900