| test | ||
| _c | ||
| _cc | ||
| manuale.md | ||
| readme.md | ||
_c — a minimal language that transpiles to C
_c is a tiny language designed to write simple, linear, and readable code.
The translator converts . _c files into standard C, then compiles them with gcc.
⚙️ Installation
Clone the repo and make the scripts executable:
chmod +x _c _cc
Run a . _c file:
./_cc test._c
This generates test.c, test (the binary), and runs it.
🌍 Global installation
You can install _c and _cc globally by creating symlinks in /usr/local/bin:
sudo ln -s /path/to/project/_c /usr/local/bin/_c
sudo ln -s /path/to/project/_cc /usr/local/bin/_cc
Now you can run _cc file._c anywhere on your system.
💡 Tip: If you use Midnight Commander (mc), you can quickly create symlinks with
Ctrl + x s (while inside /usr/local/bin).
📝 Basic types
-
i8, i16, i32, i64→ signed integers -
u8, u16, u32, u64→ unsigned integers -
f32, f64→ float/double -
$ name→ string (char *) managed withmalloc/free
🔹 Declarations
i32 i = 0
$ name = "hello"
$ copy = name # dynamic clone
copy += " world" # concatenation
free copy
free name
Generated C:
i32 i = 0;
char *name = malloc(strlen("hello")+1);
strcpy(name, "hello");
char *copy = malloc(strlen(name)+1);
strcpy(copy, name);
copy = realloc(copy, strlen(copy)+strlen(" world")+1);
strcat(copy, " world");
free(copy);
free(name);
🔹 Input
$ name = ?
or:
? name
-
If
IN == stdin→ reads one line (buffer size 1024). -
If
IN != stdin→ reads the entire stream until EOF.
The string is dynamically allocated.
🔹 Output
. "hello %s %d\n", name, i
Alias for fprintf(OUT, ...).
Default OUT = stdout.
You can also use the alias:
print "hello %s %d\n", name, i
🔹 I/O streams
Redirecting input/output:
out "file.txt" # append mode
print "hello\n"
out stdout # back to terminal
in "file.txt"
$ line = ?
print "read: %s\n", line
free line
in stdin
in "https://example.com" # fetched via curl
? page
print "page:\n%$\n", page
free page
Supported protocols: http, https, ftp, ftps
(via curl -s).
🔹 Functions
Definition:
: i32 sum(i32 a, i32 b)
a + b;
Void function:
: void greet($ name)
print "hello %$\n", name
;
🔹 Control blocks
if (i < 10)
print "smaller\n"
else
print "greater\n"
end
while (i < 5)
print "loop %d\n", i
i++
end
🔹 Minimal program
File hello._c:
: i32 main()
print "hello from my language!\n"
0;
Compile & run:
./_cc hello._c
✨ Features
-
Minimal syntax, inspired by BASIC and Forth but linear
-
Simple string handling with
$ -
Input/Output based on streams (
IN,OUT) -
If input comes from stdin → reads a line, otherwise → reads the full stream
-
Automatic URL/FTP support via
curl -
Translates into standard C → portable everywhere
-
Functions, if/else, while, and strict types
📜 License
MIT