We wrote Flick to explore compiler design. Keep reading to learn how our compiler works, or try writing Flick code in our sandbox.
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.
Key question: how do we go from source code to tokens?
Key question: how do we go from tokens to an abstract syntax tree?
Key question: how do we go from an abstract syntax tree to LLVM code?
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
.)
You can compile Flick programs with flick <SOURCE_PATH>
. For example,
flick examples/factorial.fl