Skip to content

A language with a compiler written in C, generating binaries using LLVM

License

Notifications You must be signed in to change notification settings

caoimhebyrne/petal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

74 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

petal 🌸

This is a compiler/runtime for my language, called Petal. The plan is for this compiler to provide enough basic features to build a self-hosted compiler.

This compiler uses LLVM to generate binaries.

// This is the main function, it is called similar to how it would be called in C.
// Petal is 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;
}

Building

  1. Clone this git repository.
  2. Build the compiler using the Makefile.
    $ make build

Installation

You can install the Petal compiler for your user through the install target.

$ make install

License

This project is licensed under the MIT license. See the LICENSE file for more information.

About

A language with a compiler written in C, generating binaries using LLVM

Topics

Resources

License

Stars

Watchers

Forks