Class SentenceGenerator

java.lang.Object
  extended by SentenceGenerator

public class SentenceGenerator
extends java.lang.Object

This is my version of a CIT594 assignment to read in a BNF grammar and produce sentences from that grammar.


Field Summary
(package private)  java.util.Random random
           
 
Constructor Summary
SentenceGenerator()
           
 
Method Summary
static void main(java.lang.String[] args)
          Prompts the user for a file containing a BNF grammar, then generates several sentences from that grammar.
(package private)  void readGrammar()
          Prompts the user to choose an input file, then reads and parses a BNF grammar from that file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

random

java.util.Random random
Constructor Detail

SentenceGenerator

public SentenceGenerator()
Method Detail

main

public static void main(java.lang.String[] args)
Prompts the user for a file containing a BNF grammar, then generates several sentences from that grammar.

Parameters:
args - Unused.

readGrammar

void readGrammar()
           throws java.io.IOException
Prompts the user to choose an input file, then reads and parses a BNF grammar from that file. Each grammar rule must be on a single line, but may have multiple alternatives. The same nonterminal may be defined in multiple rules. Example:
 <np> ::= <det> <n> | <det> <adjs> <n>
 <np> ::= <det> <n> <pp>

Throws:
java.io.IOException - If there is an error reading the file.