Long, long ago in a lab far, far away, I became frustrated with the time
required to write command line parsing routines, even with
getopt (), for all of the new programs that I developed. I felt
that it was tedious work that offered too many opportunities to cut
corners and produce error-prone code. In late 1997, the seeds of
Genparse fell together in my head, and I released version 0.1, written in
C, on New Year’s Day, 1998. The only output language supported was C,
and it did not allow long options. Parameter types were limited to
flags, integers, floats, and strings, and range checking was supported.
It soon became clear that although Genparse was fairly useful (I was
already using it to create parsers for my own projects), it was severely
limited and could use a number of additional features. With the help of
a handful of people who provided feedback and constructive criticism,
version 0.2 was soon released. New features included a more flexible
Genparse file format (essentially, the current format) which was
bison rather than by my C code.
Parameter descriptions and callback functions were now supported.
A few bug fixes later, version 0.2.2 was released. It was to remain
current for over a year. In June 1999, I revisited Genparse to add the
#mandatory directives, as well as to clean
up the code a bit and perform some minor bug stomping. The resulting
version 0.3 was distributed with Debian/GNU Linux.
During my revision that produced 0.3, I became aware of the acute coding slop that had evolved. To call the output functions "spaghetti logic" would have been an understatement. Naturally, I needed to modularize Genparse, and the best way of doing so seemed to be a re-write in C++. In December 1999, I undertook this task. The code became separated into three logical sections:
bisongrammar with supporting code.
This design greatly improved the extensibility of Genparse. In order to support a new output language, one only needs to add appropriate member functions to the C++ class. This implementation became version 0.4.
An important part of 0.4 was support for C++ as an output language.
Rather than returning a
struct containing the command line
parameter values, a C++ command line parser would be encapsulated by a
C++ class. The user would call the member functions of this class to
access parameter values, making for a cleaner interface than C can
Version 0.4 also included a more comprehensive set of test suites along with the documentation that you currently are reading.
In Fall 2000, I revisited Genparse. Version 0.4 did not support options
with no short form, and thus was limited to 52 options at most. Version
0.5 lifted this restriction, included
<stdlib.h> rather than
<malloc.h> in output files, and fixed up
user-defined include files so that they worked with quotes as well as
"<>". Also, I finally figured out how to get Genparse to reliably
compile on systems both with and without the
Version 0.5.1 fixed a few problems with the lexical analyzer that resulted in default values for floats not being used properly. This version also eliminated the mandatory use of the -q option.