Home

Awesome

Dusk

Documentation

The documentation for dusk can be found here

Description

A simple programming language built from scratch.

The build scripts use CMake and Ninja to find dependencies and build the project.

Uses flex as a tokenizer.

Uses bison as a parser generator.

The AST is generated with C++.

LLVM is used as a backend to generate machine specific object files which are then compiled with a c compiler into an executable.

Dependencies

This project requires flex, bison, llvm, GNU GMP, and a c/c++ compiler.

The examples for building this project also include ninja, but that is an optional dependency.

Installation

Clone the repository, and run deps.sh to automatially install LLVM locally to this project.

git clone --recurse-submodules https://gitlab.com/kian_shepherd/Dusk.git
cd Dusk
./deps.sh

To use the bignum.ds library you also need the GNU Multiple Precision Arithmetic Library You can find the most recent version here.

./configure --disable-shared --enable-fat --enable-cxx
make

Run the tests before installing

make check

Finally install GMP

make install

Ubuntu:

Ensure you have flex and bison and build tools

sudo apt install cmake ninja-build flex libfl-dev bison libbison-dev

Mac OS

Ensure you have flex and bison and build tools

brew install bison flex cmake ninja

An old version of bison is the default version so you must relink a newer version to build Dusk

brew unlink bison
brew link bison --force
echo 'export PATH="/opt/homebrew/opt/bison/bin:$PATH"'>> ~/.zshrc

Development

To generate a compile_commands.json file for use with ccls run

./ccls_file_gen.sh

Building

To build the project run or simply run build.sh.

cmake -G Ninja -S . -B CMake
ninja -C CMake

or

./build.sh

To install the binary run.

ninja -C CMake install

Usage

Once it is installed you can run dusk x, where x is the name of the file you wish to compile.

For example

dusk test.ds

Would compile a file named test.ds into an executable.

The help menu can be viewed like so.

$ dusk -h
Usage: dusk [options] file...
Options:
-h                Display this information.
-d                Print out debug information about the final AST and LLVM IR.
-df               Print out debug information about the AST at each stage and LLVM IR.
-da               Print out debug information about the final AST.
-daf              Print out debug information about the AST at each stage.
-di               Print out debug information about the LLVM IR.
-dc               Print out debug information about the compile commands.
-O                Optimize the generated object / executable.
-c                Only compile the sources do not link into executable.

-o <file>         Set the name of the outputted object / executable.
-cc <compiler>    Set the c / c++ compiler to use (default is g++).

-l<library>       Add library to link to executable at compile time.
-L<path>          Add path to library link paths.
-I<path>          Add path to include file paths.

Current Functionality

Planned Functionality

License

This project is licensed under GNU GPLv3, as this project depends on bison.