Skip to content

flick-lang/flick

Repository files navigation

The Flick Programming Language

We wrote Flick to explore compiler design. Keep reading to learn how our compiler works, or try writing Flick code in our sandbox.

Table of Contents

How the compiler works

An overview of Flick

Flick's syntax is based on Rust syntax. Here's a simple program:

pub fn main() {
    i64 i = 0
    while i < 10 {
        print(i)
        i += 1
    }
}

You can find other sample programs in the examples/ folder.

Step 1: Lexing/tokenization

Key question: how do we go from source code to tokens?

Step 2: Parsing

Key question: how do we go from tokens to an abstract syntax tree?

Step 3: Compilation

Key question: how do we go from an abstract syntax tree to LLVM code?

Installing the compiler

Assuming Rust is installed, you can install the Flick compiler with

cargo install --git "https://github.com/flick-lang/flick.git"

Before that, though, you will also need to install LLVM 18.1. For example, you could use brew:

brew install llvm@18

You will also need to tell llvm-sys where LLVM is located by adding the following line to ~/.zshrc (or an equivalent). First, run brew info llvm to figure out what the version number is. Then, run

export LLVM_SYS_181_PREFIX=$(brew --prefix llvm@18)

(Note: you should replace 181 in the environment variable with whatever version of LLVM is installed; 17.2, for example, corresponds to the environment variables LLVM_SYS_172_PREFIX.)

Using the compiler

You can compile Flick programs with flick <SOURCE_PATH>. For example,

flick examples/factorial.fl

About

✂️ The Flick programming language

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages