/clcc

C++ language model and compiler in Common Lisp

Primary LanguageCommon LispApache License 2.0Apache-2.0

Build Status

clcc

C++ language model and compiler in Common Lisp

This library provides a model of the C++ programming language suitable as a target for compilation. Its goal is to both cover a large portion of C++ language features and be readable.

System Requirements

  • A Common Lisp distribution; I tested the following distributions:
  • ASDF comes packaged with the aforementioned CL distributions
  • lang-util
  • Alexandria
  • FiveAM and its dependencies

ASDF looks for system definitions in the ~/common-lisp/ folder. Create it and change to it.

mkdir -p ~/common-lisp
cd ~/common-lisp

Installing Alexandria

git clone http://common-lisp.net/projects/alexandria/alexandria.git

Installing FiveAM

To run the test suite you must have the FiveAM regression testing framework and its dependencies available. We use ASDF to manage systems and their dependencies. In the ~/common-lisp folder run

git clone https://gitlab.common-lisp.net/trivial-backtrace/trivial-backtrace.git/
git clone https://github.com/didierverna/asdf-flv.git
git clone https://github.com/lispci/fiveam.git

Adding clcc and lang-util

The clcc and lang-util libraries also need to be visible to ASDF. Assuming your clone of the lang-util repository resides in ~/git/lang-util/ and clcc resides in ~/git/clcc/ this can be accomplished by creating a symbolic link.

ln -s ~/git/lang-util ~/common-lisp/lang-util
ln -s ~/git/clcc ~/common-lisp/clcc

Eventually, you should end up with a directory structure like this:

~/
+- common-lisp/
   +- alexandria/
   +- asdf-flv/
   +- clcc/
   +- fiveam/
   +- lang-util/
   +- trivial-backtrace/

Loading lang-util

You can load the library using either ASDF or Quicklisp. Below, we give instructions for each method.

Loading with ASDF

Most Common Lisp distributions come with ASDF packaged. Thus, you can simply require ASDF and load the lang-util system like so:

(require :asdf)
(asdf:load-system :clcc)

Loading lang-util with Quicklisp

In addition to ASDF, you can load lang-util using Quicklisp. Assuming, you have Quicklisp loaded you can run

(ql:quickload :clcc)

Testing

Running the Test Suite

With FiveAM and its dependencies in place you can now run:

(require :asdf)
(asdf:test-system :clcc)

Coverage Info

Assuming, that you are running SBCL you can get coverage information using SBCL's sb-cover module.

(require :asdf)
(require :sb-cover)
(declaim (optimize sb-cover:store-coverage-data))

(asdf:test-system :clcc :force t)
(sb-cover:report "coverage/")

Examples

License

Apache 2.0