Take the 2-minute tour ×

I am generating C code from a domain-specific language using javacc and I would like a FOSS code reformatter library (jar) that I can invoke on the produced source code to make it readable. Anyone know such a beast?

Brownie points for maven dependency entry in answer :)

share|improve this question
What have you tried so far? –  Thorbjørn Ravn Andersen Mar 16 '12 at 10:21
I have failed to find a suitable library. (I assume that this is due to weak Google-fu; search suggestions welcome.) –  Bittrance Mar 16 '12 at 10:55
Java is source wise pretty close to C. Would a Java reformatting step be ok for your C source? –  Thorbjørn Ravn Andersen Mar 16 '12 at 11:02
I suppose I could try that. There are some macros in there, but not too many. If there is a Java formatter that swallows */&, it might work. –  Bittrance Mar 16 '12 at 11:23
add comment

1 Answer

up vote 0 down vote accepted

Given that you are producing C code, try a C beautifier. If that is suitable, then

Best C++ Code Formatter/Beautifier

is a question that answers which one.

Good luck on the DSL. I've done a bunch of them, but using javacup, yacc and spirit rather than JavaCC if you need help, feel free to contact directly

share|improve this answer
add comment

Your Answer


