The "Random Sentence Generator" (or RSG as it is affectionately known) is an assignment that's been shared among many universities. The version here originates from Stanford, courtesy of Julie Zelenski, who gives credit to Mike Cleron, a former Stanford lecturer.
Here try it for yourself in Java on UVa's site. Choose a grammar and then keep hitting the button to produce new legal statements according to that grammar.