Except for a few loose ends, I have now completed a library to translate Modula-2 identifiers to C. It consists of two modules representing a user level and a lower level.
The user level module uses the lower level module and its conversion facility to generate C identifiers for import guards, macro constants including qualified enumeration values in MACRO_CASE; and for types, variables and functions in snake_case; across three use cases: (1) qualified identifiers with the module as a prefix, (2) local identifiers with a local suffix and (3) top scope static identifiers without module prefix nor local suffix.
The lower level module implements a key/value dictionary to store and retrieve unqualified Modula-2 identifiers in any of lower/upper/camel/title/mixed case and their C translations in snake case. Every identifier is automatically converted and checked into the dictionary upon the first retrieval request.
The purpose of this library is to facilitate the generation of authentic human readable C code from Modula-2 source code. I wrote this for my Modula-2 to C translator/via-C compiler, but it could also benefit GM2.
The library is written in C99 and is LGPL licensed.
Due to the license it could be incorporated into GM2 and then facilitate the development of libraries to be used from C but written in Modula-2 and built with GM2. For this, the symbols should conform to C conventions, which at present isn't the case. Note that any such symbol translation could always be switched off by compiler switch. But if the feature is available, it would make GM2 more useful for cases where somebody needs to deliver some C library but would rather write it in Modula-2.
For anybody interested in the actual mapping of identifiers, the specification is here:
I also intend to add a pragma so that one can supply a custom name.
Gaius, I know you have plenty of work already, but perhaps you want to consider incorporating this facility. If you need any adaptation, just drop me a mail.
regards
benjamin