Skip to content

rapiz1/cppc

Repository files navigation

cppc

C compiler in C++

Background

This is a learning project for Crafting interpreters.

Most part of C is supported. Support for pointer is hacky. See tests/ for the supported part.

For which part is supported, see test code under tests/.

Dependencies

Graphviz binary and llvm must be installed. llvm headers are required. Linker commands are dependent on platform and distribution. See the link function in object.cc.

Usage

Compile

make

Test

make test

Run

./clox SOURCE

And then ./a.out, ./output.o, ./output.dot and ./output.png are genereated.

./a.out is the executable file.

./output.o is the object file.

./output.dot is the dot description of the AST.

./output.png is the graph generated according to ./output.dot

Leftover

Generally speaking, the type system is a whole mess. Basic types (int, double, char, bool) works, and arrays should work in most case.

Other things are like:

  • Pointer is not supported.
  • Pointer arguments are supported but in a hacky way.
  • Array is partly supported.
  • Struct and unions are not supported.

About

A skeleton C compiler in C++

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages