Question: Write a recursive program to generate random sentences from a given BNF grammar. A BNF grammar is a recursively defined file that defines rules for

Write a recursive program to generate random sentences from a given BNF grammar. A BNF grammar is a recursively defined file that defines rules for creating sentences from tokens of text. Rules can be recursively self-similar. The following grammar can generate sentences such as “Fred honored the green wonderful child”:

::= 

::= |

::=the|a

::=| 

::=big|fat|green|wonderful|faulty|subliminal|pretentious

::=dog|cat|man|university|father|mother|child|television

::=John|Jane|Sally|Spot|Fred|Elmo

::= |

::=hit|honored|kissed|helped

::=died|collapsed|laughed|wept

Step by Step Solution

3.45 Rating (168 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

public class Board private int board stores board info private static final int UNASSIGNED 100 unassigned column Constructs an empty sizebysize board param size the size of the board exception Illegal... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Building Java Programs A Back to Basics Approach Questions!