# Getting started with CLight

## 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:

```bash
sudo apt-get update
```

* Install stack:

```bash
curl -sSL https://get.haskellstack.org/ | sh
```

* Install ghc:

```bash
sudo apt-get install -y ghc
```

* Download llvm:

```bash
wget https://apt.llvm.org/llvm.sh ; chmod +x llvm.sh ; sudo ./llvm.sh
```

* Setup llvm:

```bash
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:

* Download the github repository at <https://github.com/EpitechPromo2025/B-FUN-500-MPL-5-2-glados-bastien.boymond>, and extract.&#x20;
* Install the dependencies:

{% code overflow="wrap" %}

```bash
cd part2; stack --install-ghc build --dependencies-only
```

{% endcode %}

* Compile the compiler using the Makefile, with the command:

```sh
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:

<pre class="language-c"><code class="lang-c"><strong>int add(int a, int b) {
</strong>    return a + b;
}
</code></pre>

To compile, use the binary called `glados`:

```bash
./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`.&#x20;

```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:

```bash
gcc main.c example.o -o main
```

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

```bash
./main
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://glados-2.gitbook.io/clight/getting-started-with-clight.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
