Skip to content

refu-lang/refu

Repository files navigation

Refulang

Travis Coveralls Join chat in gitter Read The Docs

This is the code repository for refu, a hybrid language with a strong type system based on algebraic data types.

For a language reference, tutorial and overall documentation visit here.

Dependencies

The required dependencies are:

  • For building we need cmake
  • For the backend code generation we need llvm
  • For hash table generation we use gperf
  • For units tests we need libcheck

The optional dependencies are:

  • For generating dependency graphs, we can use graphviz
  • For extra memory checks during unit testing, we can use valgrind
  • For generating a json file of the AST, we can use json-c
  • For regular expressions (not yet used anywhere yet), we can use pcre2
  • For generating code coverage reports we can use lcov

Dependencies in Linux

Use your distribution's package manager

Dependencies in Macosx

brew install cmake
brew install pkg-config
brew install check
brew install llvm
brew install lcov

Installing llvm does not place it into the PATH and as such you will also need to put its path there manually. In recent versions this means adding the following to .profile.

export PATH="$PATH:/usr/local/opt/llvm/bin/"

Building

git clone --recursive https://github.com/refu-lang/refu
cd refu
mkdir build
cd build
cmake ..
make

Run the tests

In order to run the tests you have to also build them. This is done by providing an extra option to cmake.

cmake -DCMAKE_BUILD_TYPE=Debug .. -DTEST=1

There is a convenience test script that runs all of the tests for refu and its rfbase submodule.

./test.sh --rfbase

Usage

You can invoke refu --help in order to get all the possible arguments along with their description.

Example:

 --help                                                  display this help and exit
 --version                                               display version info and exit
 -v, --verbose-level=1-4                                 Set compiler verbosity level
 --backend=GCC|LLVM                                      The backend connection the refu compiler will user
 --backend-debug                                         If given then some debug information about the backend code will be printed
 --output-ast                                            If given then after analysis state the AST will be output in JSON format
 -o, --output=name                                       output file name. Defaults to input.exe if not given
 --rir                                                   Interpret the input file as a RIR file and parse it.
 -r, --print-rir                                         If given will output the intermediate representation in a file
 <file>                                                  input files

At the moment these are the important arguments.

  • --verbose-level Will determine how verbose the output of the compiler will be.

  • --backend-debug Will print out to the stdout the LLVM IR for debugging purposes.

  • --output-ast Will output the Abstract Syntax Tree in a .json format

  • --print-rir Will print the generated Refu Intermediate Format (RIR) for deugging purposes.

Contributing

You are more than welcome to open a Pull Request here in Github if you would like to contribute to the development of refu.

Coding Style and Best Practises

TODO