Skip to content
Snippets Groups Projects
user avatar
FlorianKrull authored
6c97a359
History

mC Compiler

This repository holds a getting started code-base for the compiler construction course.

Be sure to understand the provided code before using it!

Prerequisites

  • Meson in a recent version (0.44.0) (you may want to install it via pip3 install --user meson)
  • Ninja
  • time, typically located at /usr/bin/time, do not confuse this with the Bash built-in
  • flex for generating the lexer
  • bison for generating the parser
  • A compiler supporting C11 — typically GCC or Clang

Build Instructions

First, generate the build directory.

$ meson builddir
$ cd builddir

Meson creates Ninja build files. Let's build.

$ ninja

Unit tests can be run directly with Ninja (or Meson).

$ ninja test

For integration testing we try to compile mC programs and compare their output for a given input.

$ ../scripts/run_integration_tests

Taken from the Meson Documentation:

If you enable coverage measurements by giving Meson the command line flag -Db_coverage=true, you can generate coverage reports. Meson will autodetect what coverage generator tools you have installed and will generate the corresponding targets. These targets are coverage-xml and coverage-text which are both provided by Gcovr and coverage-html, which requires Lcov and GenHTML or Gcovr with html support.

Known Issues

  • Parser leaks memory on invalid inputs.

Sources used

-Blog Post from Nora Sandle "Writing a C Compiler" https://norasandler.com/2017/12/05/Write-a-Compiler-2.html

-Compilers Principles,Techniques, and Tools Alfred V. Aho, Ravi Sethi et al.