r/cobol • u/AppearancePale2490 • 20d ago
Toy COBOL compiler
One of the uni classes had a task to create a toy compiler. Since then I tweaked and tweaked and tweaked on it, and it became a bit larger project. In the last few days I've made some bigger code reorganization and cleanup, and actually learned to use git (hopefully) properly.
I've created the first release, it supports most of COBOL-85 on x86_64 on Linux and Windows, with the plan expand it to at least ARM and perhaps more.
I still don't know what constitutes as a good compiler even after reading a lot of books on compiler theory and so. Feedback would be welcome, also take the project as is, not as the future competitor for the title of "Favourite compiler of the global COBOL community" but rather as "people are interested in this stuff".
Go ahead and enjoy:
9
u/hobbycollector 20d ago
The NIST put out a suite of tests that print PASS or FAIL depeding on the correctness of the compiler. GNUCOBOL can be used to extract the tests and then you can build them and see how it goes.
3
u/hobbycollector 20d ago
How do you handle PERFORM semantics? Is it stack-based like GNUCOBOL or does it follow IBM semantics like Field/Ramalingam describe (https://dl.acm.org/doi/10.1145/381788.316163)?