parser.mly: OCamlyacc parserscanner.mll: Ocamllex scannerhello.ml: Sample "Hello World" programdune: Dune build configurationdune-project: Dune project settingstests/: Directory containing test filesDockerfile: Docker configurationdocker-compose.yml: Docker Compose configuration
- This project uses Docker for containerization. If you don't have it already, download and install Docker Desktop from:
https://docs.docker.com/desktop/
- Docker Compose is included with Docker Desktop. Verify that it is installed by running
docker-compose versionin your terminal.
docker-compose build: Builds the Docker image (run once initially and whenever you change dependencies or Dockerfile)docker-compose up -d ocaml: Starts a persistent container in the backgrounddocker-compose exec ocaml <command>: Runs a command in the already-running containerdocker-compose run --rm ocaml <command>: Creates a temporary container, runs the command, then removes the containerdocker-compose down: Stops and removes the running container
-
Build the Docker image (only needed once, or when changing Docker configuration):
docker-compose build -
Start the container
docker-compose up -d ocaml- Open a shell in the container
docker-compose exec ocaml bash- Compile and Run a P.A.T Test Progran (e.g.,
funky.pat): This command will first build your P.A.T. compiler (plt.exe) if it hasn't been built yet, then use it to compilefunky.pat. The compiler will output the generated LLVM IR to a.llfile and print instructions to compile and run it.dune exec ./plt.exe -- ./tests/test_programs/funky.pat
After running the above, follow the llc-14 and clang-14 commands printed by plt.exe to create and run the executable.
This project uses Dune for building and running tests.
To build the project:
# If you're using a persistent container
docker-compose exec ocaml dune build
# Or for a one-off command
docker-compose run --rm ocaml dune buildThere are several ways to run the tests from the container's shell:
- Run a shell in the docker container. Then perform subsequent steps.
docker-compose exec ocaml bash-
Run all tests:
dune test -
Run a specific test executable:
dune exec tests/test_scanner.exe