-----HOW TO USE THIS ARCHIVE-----

This is a compiler. Its job is to convert .c files (C language files) into .s files (assembly x86 files). The project is written in OCaml. To use it, you first have to build it, as for now you only have the source code.

-----STEP 1: Build the project-----

Open a command line window in the folder petitc.
If it is not done yet, install opam. Depending on your computer, it may be [sudo dnf install opam] or [sudo apt install opam] or something else. Look it up.

Once opam is installed, run, in order, the following commands.
opam switch create . --deps-only
eval "$(opam env)"
opam install dune
opam install menhir

Once this is done, we can build the project. To do so, just run the following single word command:
make

It should have created a new folder called _build, and a bunch of other things.


-----STEP 2: Use the compiler-----

I assume you have a .c file (I assume that it is named mycoolfile.c) that you want to compile and run. If you do not have one, you can test the compiler using the mandelbrot.c provided in place of your own .c file. First go inside the subfolder _build/default/ by running:
cd _build
cd default

Then use the .exe on your file. To do so, first move your mycoolfile.c into the subfolder _build/default/ and then run:
./petitc.exe mycoolfile.c

It should have created a new file called mycoolfile.s in the subfolder _build/default/. This file is an assembly x86 code. You can open it if you want, and read what's inside.

Now if you want to compile this assembly code (which is a translation in assembly of your C code) you can run:
gcc mycoolfile.s -o mycoolfile

It should produce a file plainly named mycoolfile (with no extension). This is an executable. Run it using:
./mycoolfile
