Hello everyone, I'm Noah, I live an belgium and I'm 14 years old. I've always wanted to make my own compiler from scratch. Of course this is very difficult but I'm just going to try and we will see what happens.
My idea is to make a C like programming language. The compiler will be written in C.
!! IMPORTANT !! The language is in a very early stage of development, this means the language is basicly useless at the moment. I would say wait a year and come back, then I hope to have a functional compiler.
You will need to compile the compiler yourself. This is not that hard.
If you have clang installed, you can just run the command below inside the main directory.
$ makeIf you don't have clang installed you need to install it first, for Debian-based linux distros you can type the command below in the terminal to install clang.
$ sudo apt install clangfor Arch-based distros
$ sudo pacman -S clangTo compile your own apollo source files, you need to have the apollo compiler executable. If you don't know how to compile it, check out the section above this one 'The compiler itself'.
Now to compile your own files, this command in the terminal.
$ ./bin/apollo filepath.apo Ofcourse there are flags you can enable. To get some help with all the flags you can always just run this.
$ ./bin/apollo -hThis will give you some information about the compiler.
The compiler has flags you can enable, here is a list with the available flags.
- Flags
-
-h Prints a little help message. -
-v Verbose output (while assembling and linking the file). -
-asm Only generates the assembly. -
-mac-arm64 Generates code for arm64 (m1) with macOS. -
-linux-x64 Generates code for intel x64 with Linux.
-
Now I'm going to talk about the syntax of the language.
func name() {
<statement>
<statement>
<statement>
...
}
name();
One thing to notice, you need to write an entry-point for the program, like in C. You basicly just define a function called main.
func main() {
}
Every program should have an entry point like the example above.
let variable: uint32 = 10;
For now only uint32 is supported. Variables also can be used yet, but a variable definition can't be compiled on arm64 and x64.
If you just declare a variable, like down below.
let variable: uint32;
The variable will just be created an will have the value 0, unlike in c where variables are not zero-inialized.
-
Platforms
- Linux
- macOS (arm64)
- Windows
-
Architectures
- x64
- aarch64 (arm64)