def generate(grammar=None, num=<NUM_LIT:1>, output=sys.stdout, max_recursion=<NUM_LIT:10>, seed=None):
if seed is not None:<EOL><INDENT>gramfuzz.rand.seed(seed)<EOL><DEDENT>fuzzer = gramfuzz.GramFuzzer()<EOL>fuzzer.load_grammar(grammar)<EOL>cat_group = os.path.basename(grammar).replace("<STR_LIT>", "<STR_LIT>")<EOL>results = fuzzer.gen(cat_group=cat_group, num=num, max_recursion=max_recursion)<EOL>for res in results:<EOL><INDENT>output.write(res)<EOL><DEDENT>
Load and generate ``num`` number of top-level rules from the specified grammar.

    :param list grammar: The grammar file to load and generate data from
    :param int num: The number of times to generate data
    :param output: The output destination (an open, writable stream-type object. default=``sys.stdout``)
    :param int max_recursion: The maximum reference-recursion when generating data (default=``10``)
    :param int seed: The seed to initialize the PRNG with. If None, will not initialize it.