Dr. David J. Pearce

A Source File with 72KLOC!?


Yesterday, I was looking at the stats on Ohloh for the Whiley project and noticed that my total line count for the project had increased from around 65KLOCto 143KLOC over a very short amount of time:

Confused, I was pondering this for a while.  Then it struck me: I’d checked in a single file with 72KLOC! How could I forget that? That explains the sudden jump and, I’m sure, will mess with any metrics for the project.  And, you guessed it, that file has no commenting whatsoever!

Anyhow, the question remains: how could I possibly have such a huge file? Well, it’s a fair question that deserves an answer.  The good news is that I didn’t write that file — it was automatically generated for me.  Which explains the lack of comments, and general ugliness of the file.  The file implements a complete automated theorem prover which is generated from a DSL describing rewrite rules (you can see some examples here and here).

Finally, it turns out this is not the first time I’ve done this either!  My last project was building a Java Compiler from scratch (called JKit) which contains a single file with 33KLOC.  Again, this was automatically generated from an ANTLR grammar of the Java language, and is used to parse source files into an Abstract Syntax Tree.