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?



2 Answers 2


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.

  • 3
    In addition to what @mattnz said, a build pipeline on a builder server should be a superset of a build pipeline on your local machine. I.e. it should do more than your local build process.
    – CodeART
    Sep 1, 2013 at 20:56
  • 3
    I disagree. It's often useful to have generated files (I'm not talking binaries here—just intermediate code) in the source control as well to facilitate finding and understanding bugs as ddyer already said.
    – Dan
    Sep 2, 2013 at 7:21

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.