Write a recursive program to generate random sentences from a given BNF grammar. A BNF grammar is
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 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
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Related Book For
Building Java Programs A Back To Basics Approach
ISBN: 9780135471944
5th Edition
Authors: Stuart Reges, Marty Stepp
Question Posted: