Interactive Evolution of C Program Indentation

To rapidly create options for the gnu indent tailored to your preferences. (indent's manual. Some examples.)

C file:(required)
.indent.pro file:(optional)
Initial indent commands(optional)
Additional types -T(optional)
Described in:
Evo_Indent Interactive Evolution of GNU indent Options, W. B. Langdon, Late Breaking paper at GECCO 2009. PDF

GNU indent is designed to layout C source code but has more than 60 options. After uploading your C file: (or .h file) press START to run indent with four randomly chosen sets of options on your file. The four candidate layouts of your file will be displayed in this window. Red is used to highlight changes from your file.

If you chose one of the 4 which you prefer (by clicking on it) that set of options will be kept and 3 mutants of it will be created and displayed. Red is again used to highlight places where the new layout differs from the previous one.

Repeatedly clicking on your preferred layout will rapidly guide you through the enormous range of possible indent command lines.

The indent options are displayed at the top of each frame.

Saving your preferences

If you have indent installed you can save (e.g. using cut and paste) the evolved indent command line into a gnu indent .indent.pro profile file. Your evolved options can then be re-used on any other file when you use indent.

Alternatively the evolved layout of the file you uploaded can be saved. However this would mean reusing these www pages for each source file.

.indent.pro, initial commands and TEST

Indent takes user options both via the command line and via a .indent.pro file. You can instruct evolution to start in the top left hand frame with particular options. Ie seed the initial population with your commands.

The TEST button allows you to run indent on your file. As usual changes made by indent are highlighted in red.

additional types -T option

ident knows about standard C types (int float etc.). You can use the "additional types -T" field to give a list of other types your program uses. This tells indent they are types and then it uses this when it pretty prints your program.
For example, if your program contains

 
typedef unsigned long CODE_ADDR;
typedef enum {red, blue, green} COLOUR;

you could put CODE_ADDR COLOUR into the "additional types -T" field.

Bugs and features


back
W.Langdon 25 Feb 2009 (last update 7 April)