gm2
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Translating Modula-2 identifiers to C


From: Fischlin Andreas
Subject: Re: Translating Modula-2 identifiers to C
Date: Sun, 7 May 2023 17:59:36 +0000

Dear Benjamin,

Sounds very good to me.

Andreas


ETH Zurich
Prof. em. Dr. Andreas Fischlin
IPCC Vice-Chair WGII
Systems Ecology - Institute of Biogeochemistry and Pollutant Dynamics
CHN E 24
Universitaetstrasse 16
8092 Zurich
SWITZERLAND


+41 44 633-6090 phone
+41 44 633-1136 fax
+41 79 595-4050 mobile

             Make it as simple as possible, but distrust it!
________________________________________________________________________









On Sun, 07.05.23, at 17:47, Benjamin Kowarsch <trijezdci@gmail.com> wrote:

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

Attachment: smime.p7s
Description: S/MIME cryptographic signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]