This is the compiler for my language, Petal. The plan for this compiler is for it to provide enough features to build a self-hosted compiler.
// This is the main function, it is called similar to how it would be called in C.
// Petal programs are linked with libc, meaning `main` is called from the `__start`
// symbol.
//
// This function expects an `i32` to be returned.
func main() -> i32 {
// This is a variable declaration. Since it is in a function block, it can only
// be accessed from within this function block.
i32 my_variable = 100;
// Values can be returned either by referencing a variable name, or writing the value inline.
return my_variable;
}
- Clone this git repository.
- Build the compiler using
cargo build
This project is licensed under the MIT license. See the LICENSE file for more information.