Fli/o is a programming language for easily working with file I/O
The idea behind Fli/o is to simplify the process of working with files-- this includes everything from moving / copying files to reading and writing to files.
Most of this functionality is offered through the standard library of built-in functions included in this project.
NOTE: The language reference manual for Fli/o can be found here.
Features:
- Primitive data types (e.g. int, char, string)
- For loops, if/else statements
- Functions
- Arithmetic operators (e.g. +, -, *, /)
- Logical operators (e.g. <, >, ==, !=)
- Standard library of built-in file I/O functions
Here is a brief explanation of the compilation pipeline for this project.
- A Fli/o program is passed through the scanner (
scanner.mll
) where it's broken up into "tokens" or words (if it's easier to think of that way) separated by whitespace. - These tokens get passed into the parser (
parser.mly
) which generates an abstract syntax tree(AST) based onast.ml
. This is basically a tree representation of the program. - The AST is checked for semantic integrity via
semant.ml
and if any syntax or type errors are detected, the program will fail to compile. - The LLVM code is generated from the AST via
codegen.ml
.
The compiler for Fli/o is designed to compile to LLVM IR because whole idea behind the LLVM project is to have an intermediate representation of code that can be compiled down to architecture-specific machine code.
LLVM, OCaml (including ocamlfind / ocamlbuild), and cc are required to build the front-end and back-end of the compiler for Fli/o.
To build the compiler, simply run make
from the src directory.
To compile your program written in Fli/o, run the following commands:
# Step 1. Compile Fli/o into LLVM IR
$flio.native < my_program.f > myprogram.s
# Step 2. Generate Assembly code from LLVM IR
$llc my_program.ll
# Step 3. Link in the library of Fli/o built-in functions and generate an executable
$clang my_program.s stdlib.c -o my_program
# Step 4. Run your program
$./my_program
Note: You can use other C compilers instead of clang for step 3 (e.g. gcc, cc)
Fli/o contains an extensive test suite (located under the test directory) to ensure that all of the features of the language work as expected.
To run all tests, simply run bash testall.sh
.
Distributed under the GNU GPL v3.0 license. See LICENSE
for more information.
- Fork the repo
- Create a feature branch (e.g.
git checkout -b feature/new_feature
) - Add & commit your changes
- Push to your feature branch (e.g.
git push origin feature/new_feature
) - Create a new pull request