I’m using a parser generator to build a compiler. Should I commit the source files produced by the parser generator?
I want to commit them to avoid a dependency on the parser generator during the build process and tests.
However, if I commit them, it is tempting never to update the parser generator for fear of backwards-incompatible changes.
Are there other advantages or disadvantages that I have not thought of?
References:
- Do I check generated code in to source control or not?
- What Part of Your Project Should be in Source Code Control?
1
My suggestion is no, you should not commit machine generated files. Source control should be reserved for original (source) material only, not intermediate files. Do you commit compiled objects to source in case the compiler changes? You problem almost certainly lies in configuration management (of the tool chain), not source management. Unfortunately source control is too often used to achieve both.
In the first instance I would look closely at build configuration. Is it possible to treat the parser outputs as another tool the build process used, and have a project to build the parser outputs. Look for solutions in this space first
If other options have been explored and deemed too expensive or technically difficult etc, it is not the worst evil in the world to commit the files to source control – the sun will still rise in the east tomorrow morning.
2
You should commit all three components (parser generator, input language, and output language) to source control, to help disentangle the blame when unexpected problems arise.