cli can be called from script

I keep finding myself reimplementing the cli script and it would be much
easier if I could simply require it and use it in scripts. The basic
change is that main accepts an options argument. The rest of the
changes: add documentation to the source code, expose a method for
processing grammar files in any combination the cli accepts, and expose
a method for generating a parser as a string. It's all pretty much the
same code as was there, just shifted around so I could expose things to
users and wrapped up so things don't go haywire.

This script can be run through jsdoc-toolkit to produce fancy documentation for the web.