Getting started with CLight

Quickly set up and write your first line of CLight code!

What is CLight?

CLight is a programming language developed by third year Epitech students. Based on C, it reproduces several of the core programming concepts and syntax.

Setup the environment

Follow these instructions to setup your environment:

  • Update:

sudo apt-get update
  • Install stack:

curl -sSL https://get.haskellstack.org/ | sh
  • Install ghc:

sudo apt-get install -y ghc
  • Download llvm:

wget https://apt.llvm.org/llvm.sh ; chmod +x llvm.sh ; sudo ./llvm.sh
  • Setup llvm:

sudo ln -s /usr/bin/llvm-config-9 /usr/bin/llvm-config

Installing the CLight compiler

To be able to program in CLight, you'll first have to download the compiler:

cd part2; stack --install-ghc build --dependencies-only
  • Compile the compiler using the Makefile, with the command:

cd part2; make re

You should now find a new binary called glados in the part2 folder.

Compiling CLight

Start by creating a simple script in a new file. For this example, we'll call it example.cl. Let's add a simple function:

int add(int a, int b) {
    return a + b;
}

To compile, use the binary called glados:

./glados example.cl

You should now have an object file called example.o next to your example.cl script.

Create another script in the language you want. For this example, we'll use the C programming language, and create a new file called main.c.

extern int add(int a, int b);

int main(void)
{
    printf("add: %d\n", add(10, 10));
    return (0);
}

Compile both the main.c file and the example.o file:

gcc main.c example.o -o main

Now if you execute the binary, you should see "add: 20" displayed in the terminal:

./main

Last updated