
gittech. site
for different kinds of informations and explorations.
A self-hosted programming language inspired by HolyC
Published at
Dec 29, 2024
Main Article
The Ibu programming language
Key Features of Ibu
- No strict type checker
- No C-like pointer arithmetic
- No function-like macros
- No variable shadowing
- No
break
,continue
stmt. Usegoto
- No libc dependency
- No hidden control flow
- No hidden memory allocations
- Allows
13 <= age < 20
instead of13 <= age && age < 20
- Variable length args
func(...)
can be accessed with built-in variablesargc i64
andargv *i64
- All values are extended to 64-bit when accessed
- The compiler is written in itself
- Default args don't have to be on the end (WIP)
#include "std/header.ibu"
func main() i32 {
printf("Hello, world!\n");
return 0;
}
[!IMPORTANT] Supports x86-64 Linux only
Build the language
$ git clone [email protected]:v420v/ibu.git
$ cd ibu
$ make init
Build the language with docker
$ git clone [email protected]:v420v/ibu.git
$ cd ibu
$ make up
$ make ibu
$ make init
Command | Execution |
---|---|
make up |
docker compose up -d |
make ibu |
docker compose exec ibulang bash |
make down |
docker compose down |
Usage
$ ./ibuc <filename>.ibu
Currently, the compiler outputs assembly to stdout.
Example: Compile Hello world!
$ ./ibuc main.ibu | as - -o main.o
$ as -o lib/runtime.o lib/runtime.s
$ ./ibuc lib/linux-syscall/linux-syscall.ibu | as - -o lib/linux-syscall.o
$ ./ibuc lib/std/std.ibu | as - -o lib/std.o
$ ld -o main main.o lib/runtime.o lib/linux-syscall.o lib/std.o
$ ./main
π The Ibu Programming Language Documentation
Compiler implementation
File | Content |
---|---|
src/ibu.ibu |
Entry point |
src/tokenizer/tokenizer.ibu |
Lexical analyzer |
src/preprocessor/preprocessor.ibu |
Preprocessor |
src/parser/parser.ibu |
Parser |
src/codegen/codegen.ibu |
Code generator |
lib/linux-syscall/linux-syscall.ibu |
Linux system call library |
lib/std/std.ibu |
Standard library |
lib/runtime/runtime.ibu |
Runtime library |
Contribution
contribution is welcome!
License
This project is licensed under the MIT License - see the LICENSE file for details.