Pre Compiler

A compiler that creates source for another compiler, usually to extend the language understood by the latter as in MetaProgramming.

AnswerMe: How do you do UnitTesting for a precompiler? Obviously, you need some parser for the generated program, assuming you generate source, not binaries. But checking an AbstractSyntaxTree in a unit test is tedious. So what are good strategies/tools? -- HaskoHeinecke

Same way as most other things; your UnitTests generate text output, which you compare (e.g. with diff) against "golden" output. If there's ever any difference, then the regression unit test failed.

There are often complications in practice due to timestamps, trivial changes in the generated text like added/removed white space or comments, etc, but it's usually not too hard to figure that out on a case by case basis. Even if the output is binary, you at least still have the two-way still-the-same-as-before, versus not, comparison.


EditText of this page (last edited January 7, 2004) or FindPage with title or text search