A Minimalist TypeScript for C
A Minimalist TypeScript for C. Cp1, or C+1, or C plus 1 programming language adds only the bare essentials to C language that allows you to output C codes and able to use namespaces, modules, methods on enums/structs, auto variable deduction and more.
Github: https://github.com/galileolajara/cp1
Crazy usage of "+". Using "+" as a synonym for "var" seems pretty pointless. Suffix "+" to mean stack allocated (vs not yet allocated?), unless it's an array, in which case "+" means objects not pointers. Or so it seems.
And allowing the minus sign as an identifier character is just asking for errors.
Some nice ideas (member functions!). Love to see the next evolution.
Interesting project, similar to Cake[0]
[0] - https://github.com/thradams/cake
Two different overloads of '+' for a total of 3 different meanings for '+'.
4 if you include ++.
As it should be
The C stands for Cursed.
https://www.assemblyscript.org/ is somehow similar, but targets only webassembly now
https://github.com/galileolajara/cp1
Is it possible to replace LibC? We'd like to test this on bare-metal target using newlib-nano.
Yes you can replace LibC. Just use "cp1 c" command to output C codes and then use appropriate command line arguments to gcc or clang to use newlib-nano. I cannot give direct instructions for you to use newlib-nano because I'm not yet familiar with that library.
This feels to me halfway to reinventing Pascal the long way around. Fascinating
If Pascal had opted for BASIC's string types and phat pointers.
Looks like more of an idea than usable compiler. Generated parser and all.
What's wrong with a generated parser?
Is there another example that show how memory allocation work with pointers and stuff ?
It seems to work similarly as in C, i.e. you call malloc manually, there is some form of automatic size deduction though:
https://github.com/galileolajara/cp1/blob/main/examples/04-v...
nice!