Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"Freedom is still the most radical idea of all." -- Nathaniel Branden


devel / comp.lang.c / C23 to C11, C99 transpiler

SubjectAuthor
o C23 to C11, C99 transpilerThiago Adams

1
C23 to C11, C99 transpiler

<379b40e3-0ec5-4b30-a941-e1e8560d8ec2n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=22063&group=comp.lang.c#22063

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:600c:4e09:b0:39c:6c5d:c753 with SMTP id b9-20020a05600c4e0900b0039c6c5dc753mr782201wmq.34.1656436734198;
Tue, 28 Jun 2022 10:18:54 -0700 (PDT)
X-Received: by 2002:ac8:590e:0:b0:317:cc20:8880 with SMTP id
14-20020ac8590e000000b00317cc208880mr13945647qty.513.1656436733545; Tue, 28
Jun 2022 10:18:53 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.128.88.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Tue, 28 Jun 2022 10:18:51 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=189.6.253.35; posting-account=xFcAQAoAAAAoWlfpQ6Hz2n-MU9fthxbY
NNTP-Posting-Host: 189.6.253.35
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <379b40e3-0ec5-4b30-a941-e1e8560d8ec2n@googlegroups.com>
Subject: C23 to C11, C99 transpiler
From: thiago.a...@gmail.com (Thiago Adams)
Injection-Date: Tue, 28 Jun 2022 17:18:54 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Thiago Adams - Tue, 28 Jun 2022 17:18 UTC

As some of you may remember I have a c front end where
I experiment features in C and then I translate the experimental
features to standard C.

With the approach of the new Standard C23 and a
new draft
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2912.pdf

I decided to incorporate the C23 changes in my front end converting
from C23 to C11 or C99. I still have some experimental features.

There is an online version compiled with emcripten here
http://thradams.com/web3/index.html

It is interesting that there is a lot of changes that can be make
at tokenizer level.

For instance:
- binary literals
- digit separators
- #elifdef #elifndef *(some parsing is necessary but not full)
- static assert, bool ,true , false are a keywords..
Other transformation like typeof , _Generic requires compiler inference..

One feature that may be transformed on tokenizer level is attributes.
But attributes don't have a especial token. The [[ is not a single token.
I am removing this at parser visit level.. but the "visit" code is not 100% complete so the attributes are not there yet. But I am considering in doing
this at "token" level then the AST visit is not necessary.

I also added the conversion from u8 literals to C99.
(The input of the compiler is utf8 only so the job is just print the bytes. No need for locales)

The features that are showed are just experimental (this is a hobby project)
and there is bugs..but I am trying to get the front end right and I
need to spend more time in erros and unit tests.
This king of project may be useful or not..I am not sure.

_Generic is missing. I have seen some interest in atomic conversion.

I am also considering to check attributes. Then the front end can be
used as a lint and convert to C99 if necessary.

The transformation tries to preserve the original code comments macros..
this is not always possible. So I have a pragma to expand some macros.
and a mode to compile as the parser phase sees the code.(no preprocessor anymore)

In my previous version I had more experimental features like defer.
http://thradams.com/web2/cprime.html
the new version v3 is a new code more prepared to full semantic
analysis but the code in incomplete yet.

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor