Compiler for the Flo programming language.
The Flo programming language is an imperative and statically-typed language designed by Florian Bridoux as part of the "Langages, Compilation et Automates" course at Polytech Nice Sophia. The final project of this course involves creating a compiler (in Python or C) that compiles Flo code to ARMv7. The code generation part of this project is rather simple and the compiled programs are unoptimized. I took the initiative to recreate the compiler in Rust, using LLVM to enable excellent run-time performance of programs and availability on a wide range of systems and architectures.
What you need:
- Rust
- LLVM 18 with
clang
in path
$ cargo build --release
(if you are building on Alpine Linux you need to run RUSTFLAGS="-C target-feature=-crt-static" cargo b -r
)
$ target/release/floc[.exe] flo_examples/factorial.flo
Note: If you are on Windows, make sure you are in a MSVC x64 native tools command prompt, or clang will fail to compile programs.
There is an AUR package called floc-git btw.
Some cool stuff to do:
- Render the AST as a dot graph:
$ floc --emit-ast-as-dot flo_examples/prime.flo | dot -Tsvg > ast.svg
- Dump the generated LLVM IR:
$ floc --emit-ir flo_examples/prime.flo
- Dump the generated LLVM IR after optimization passes:
$ floc --emit-optimized-ir flo_examples/prime.flo
(use --help
to get all available options)
See some example programs here