Resumption of Work on M2C #4
trijezdci
announced in
Announcements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Work on M2C Resumed
The M2C project was on hold but I have now resumed working on it.
The Backstory
I had the front end working a few years back and it was quite heavily tested by many folks on the Usenet m2 group. The compiler was supposed to be used as a bootstrap and porting tool for our revised Modula-2 language project (M2R10), hence the implementation in C, translation to C and compilation via C. The aim was always to generate C source code that is authentic and human readable, that is to say, it should look mostly as if it had been written by a human programmer.
However, back then many people wanted unrestricted use of lowlines _ in Modula-2 identifiers and the generated C code was to be in
MACRO_CASE
for constants andsnake_case
for everything else. These two aims made collision free identifier translation from Modula-2 to C far too complex and the implementation unwieldy. This ultimately put the entire project on indefinite hold.Instead, I manually transcribed the code to Modula-2, using only a subset available in both PIM and ISO Modula-2 so that the code wouldn't depend on any particular Modula-2 compiler. That project is also on Github:
https://github.com/m2sf/m2bsk
Furthermore, @viegasfh is working on the .NET hosted C# version which will be generating code for .NET.
https://github.com/m2sf/m2sharp
Unfortunately, the two Modula-2 compilers we were using for the Modula-2 hosted version are stuck with 32-bit. In the case of MOCKA it would require very serious work to update it to 64-bit because the backend was generated by a closed source tool, thus an entire new backend would have to be developed from scratch. In the case of p1, the compiler isn't open source and only the older 32-bit version is free of charge. And with GM2, there are always issues getting it to work on the various platforms we want to target.
Before this background, I have taken another look at the identifier conversion issue that put M2C on hold. I have now changed the lexer so that lowline use in Modula-2 identifiers is restricted to non-leading, non-trailing and non-consecutive occurrences. Then I designed a much simpler name translation scheme that assumes that people will by and large stick to the Modula-2 naming convention where module, type and procedure identifiers are in
TitleCase
, variable and function identifiers incamelCase
and constant identifiers consistently in one of those two.https://github.com/trijezdci/m2c/wiki/Identifier-Mapping
I still need to implement this and completely rewrite m2-identconv.c.
After implementing the name conversion, there is still some other work to be done, but the compiler is not all that far from completion. I will first focus on PIM3 and PIM4 and may initially omit some semantic checks, in order to get a usable translator from PIM3/4 to C because that could then be used to continue work on the Modula-2 hosted M2BSK compiler.
benjamin
Beta Was this translation helpful? Give feedback.
All reactions