trijezdci
2015-12-11 11:03:25 UTC
I have now rewritten the front-end of Makarov's M2C Modula-2 compiler.
The front end can be downloaded from:
https://bitbucket.org/trijezdci/m2c-rework/src
Simply type make and hit return to build it.
m2c -h will print a help with available options.
All OS dependencies are in a single module called m2-fileutils. For this module there is at present no Windows/DOS implementation. It is a small module with only a handful of functions and most are wrappers. It shouldn't be difficult to modify this to derive a Windows/DOS version. With a bit of luck somebody may volunteer to contribute an Windows/DOS implementation of the module.
For those who don't know, M2C is a "via-C" Modula-2 compiler and translator that supports PIM3 and PIM4 plus some extensions. In translator mode it generates C output. In compiler mode it generates executables by calling the resident C compiler on the intermediate C code.
We are using M2C for our initial bootstrap compiler for Modula-2 R10. There are some annoyances with M2C however and its source code is rather incomprehensible due to the way it is structured and because the comments are all in Russian pidgin English. Since I am doing the same kind of work for our own compiler anyway (although in M2, not C) I decided to simply rewrite it, or at least the front end.
At present I am leaning towards rewriting the back end as well, but will take another look to assess the prospect of marrying the new front end with the existing back end at least in the interim. It may however, be less effort to just rewrite the back end cleanly than wading through all that mud.
Anyway, it would be very much appreciated if folks here could test drive the front end on their real world PIM Modula-2 sources to give the parser plenty of scrutiny.
I added an undocumented flag --parser-debug which if set prints the current production rule, line, column and lookahead symbol which is useful to asses what the parser is doing when it doesn't report any errors (as will be the case with error free code).
Note that by default the front end expects C-style prefix literals and Oberon-style extensible record types. It can be put into strict PIM mode by flags --pim3 and --pim4. The help screen explains all the option flags.
The front end can be downloaded from:
https://bitbucket.org/trijezdci/m2c-rework/src
Simply type make and hit return to build it.
m2c -h will print a help with available options.
All OS dependencies are in a single module called m2-fileutils. For this module there is at present no Windows/DOS implementation. It is a small module with only a handful of functions and most are wrappers. It shouldn't be difficult to modify this to derive a Windows/DOS version. With a bit of luck somebody may volunteer to contribute an Windows/DOS implementation of the module.
For those who don't know, M2C is a "via-C" Modula-2 compiler and translator that supports PIM3 and PIM4 plus some extensions. In translator mode it generates C output. In compiler mode it generates executables by calling the resident C compiler on the intermediate C code.
We are using M2C for our initial bootstrap compiler for Modula-2 R10. There are some annoyances with M2C however and its source code is rather incomprehensible due to the way it is structured and because the comments are all in Russian pidgin English. Since I am doing the same kind of work for our own compiler anyway (although in M2, not C) I decided to simply rewrite it, or at least the front end.
At present I am leaning towards rewriting the back end as well, but will take another look to assess the prospect of marrying the new front end with the existing back end at least in the interim. It may however, be less effort to just rewrite the back end cleanly than wading through all that mud.
Anyway, it would be very much appreciated if folks here could test drive the front end on their real world PIM Modula-2 sources to give the parser plenty of scrutiny.
I added an undocumented flag --parser-debug which if set prints the current production rule, line, column and lookahead symbol which is useful to asses what the parser is doing when it doesn't report any errors (as will be the case with error free code).
Note that by default the front end expects C-style prefix literals and Oberon-style extensible record types. It can be put into strict PIM mode by flags --pim3 and --pim4. The help screen explains all the option flags.