Skip to content

Latest commit

 

History

104 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Readme

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

Hello World

extern puts(string fmt): void;
 
func main() : int {
  puts("Hello World!")
  return 0;
}

Ptr example

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;
}

Building compiler

odin build .

Using compiler

./langer ./main.l -o ./main
./main

About

A toy systems programing language using llvm irl

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages