Download

I do not distribute Windows binaries anymore; since, they can be
easily built by using Cygwin C/C++ compiler,
available at http://www.cygwin.com/.
However, if
you don't feel like downloading such compiler, you can request such
binaries directly to me, by e-mail (please find my e-mail address at my
home page) and I can send them to you.

The steps to perform for the installation are standard for
packages
in source form: once you have unpacked the sources in a directory, `cd'
to the directory containing the package's source code and execute the
following
steps:

./configuremakemake install

Note: unless you specify a different install directory by
--prefix
option of configure (e.g. ./configure --prefix=<your
home>),
you must be root to 'make install'.

Anonymous Git Access

This project's git repository can be checked out through the following
clone instruction:

Since version 1.4.2 of Gengen the
CVS repository was dismissed in favor of Git
(http://git-scm.com/).

Please note that this way you will get the latest development sources
of Gengen, which may also be unstable. This solution is the
best if you intend to correct/extend this program: you should send me
patches against the latest git repository sources.

If, on the contrary, you want to get the sources of a given release,
through git, say, e.g., version X.Y.Z, you must specify the tag
rel_X_Y_Z.

When you compile the sources that you get from the git repository,
before running the configure and make commands, for the
first time, you must run the command:

autoreconf -i

This will run the autotools commands in the correct order, and also copy
possibly missing files. You should have installed recent versions of
automake and autoconf in order for this to
succeed.

Simple example

Say you are writing a C/C++ program and at some point your program
has to generate the following code:

provided that you remember to escape the " (and in the
C code, also the %).

Suppose now that the previous piece of code has to be generated many
times by your program, and every time instead of i another
symbol has to be generated (decided at run time). In this case,
supposing that this value is contained in a variable symb,
the code for generating this code would be a little bit more
complex:

Probably you didn't even realize that you forgot to leave
a space before the < 10; basically this is due to the fact
that this piece of code mixes the code that has to be generated
with the code that generates it, and this tends to make this part
of program less easy to maintain. Especially if some day you
have to change the code that has to be generated, you'll have
to act on this part of the program, and probably you'll have to
execute some tests in order to be sure that you did it right.

If the code that you have to generate is a slightly more complex,
the task may easily become a pain in the neck!

Wouldn't it be nice if you could write the code to be generated in a
separate file, let's call it template, say test1.cc_skel
this way

if (@i@ < 10) printf("the value of @i@ is %d", @i@);

and have a tool that generates a generator, that you
can instantiate at run-time with the value that has to be substituted to
the parameteri? If such a tool existed, and it generated
a file test1_c.h with a C struct test1_gen_struct, then
you could write simply this code, in another file, say
test1_gen_c.c:

Well, Gengen does right this! Now the code that has to
be generated and the code that generates it are separated and they can
be maintained more easily: if you want to change the code that has to be
generated you act on the file test1.cc_skel; alternatively, say
you need to change the value that will be substituted for i, you
just change the file test1_gen.cc or test1_gen_c.c.

Notice that the method generate_test1 accepts an output stream
(indeed in this example the standard output stream cout is used),
thus the stream abstraction facilities can be exploited. Similarly, the
C function generate_test1 accepts a FILE*, so you can use
the C file abstraction.

Indeed in order to generate the C++ file test1.h with the class
test1_gen_class, I simply had to run the following command:

gengen -i test1.cc_skel --file-name test1.h --gen-name test1

and in order to generate the C file test1_c.h with the structure
test1_gen_struct, I simply had to run the following command: