Greetings
I am making a free tool and releasing it under the GPL. I hope you like it.
http://freshmeat.net/projects/anchorThis adds missing brackets and semicolons (and remove extra ones.) It does not know anything about languages or tokens, so it ought to work with other languages like C++, D, PHP, Java, too, without much trouble.
http://freshmeat.net/projects/anchorCode must be indented for the bracket adder to work. If lots of brackets and punctuation are left out it seems like a pseudo code compiler.
It is sort of its own language, almost. For example, this will compile with it:
#include <stdio.h>
/* Print command line arguments and exit. */
int main int c, char **v
while c--
printf "Argument %i is \"%s\"\n",c,v[c]
return 0
It fixes markup to standard C (or other "curly bracket" languages). But it does not (yet) do any fancy code conversion. It only looks at indentation levels and adds missing "{}" and ";" characters. It has one macro to put parenthesis around things: The two spaces after main and after printf expands to (parenthesis until the end of the line). I'm not sure of any other way to tell it where parenthesis go in a
language-independent way. I suppose other clever macros could be added.
This is the output so you can see how the parenthesis expand. Comments and string literals are ignored.
#include <stdio.h>
/* Print command line arguments and exit. */
int main (int c, char **v){
while (c--){
printf ("Argument %i is \"%s\"\n",c,v[c]);
} return 0;
}
Because of the "two spaces" macro, the code has to not have extra spaces in it. Also whitespace at the end of a line makes semicolons not get repaired on that line. On the other hand, this is good, because you can prevent an extra semicolon from being automatically removed by putting a space after it. There are a couple places in C code where an extra semicolon is needed, such as after anonymous structs.
Anyway, I hope you find this useful and fun. You can help me test the windows version. I have not tested it much on large projects and it will truncate comment blocks over 8K in length (and emit a warning).