This is a toy language I created to learn how compilers work. The code is not that neat because I focused on getting a working compiler done instead of good code.
It generates asm files which then is compiled with nasm and linked with gcc to get c runtime
extern puts(string fmt): void;
func main() : int {
puts("Hello World!")
return 0;
}extern printf(string fmt, int size): *int;
extern malloc(int size): *int;
// Sets the ptr
func set(*int ptr, int size) {
int i = 0;
while i < size {
ptr[i] = i*2;
i = i + 1;
}
}
func main() : int {
*int age = malloc(10*8);
set(age, 10);
int i = 0;
while i < 10 {
printf("%d\n", age[i])
i = i + 1;
}
return 0;
}odin build ../langer ./main.l -o ./main
./main