Cling

What is Cling

Cling is an interactive C++ interpreter, built on the top of LLVM and Clang libraries. Its advantages over the standard interpreters are that it has command line prompt and uses just-in-time (JIT) compiler for compilation. Many of the developers (e.g. Mono in their project called CSharpRepl) of such kind of software applications name them interactive compilers.

One of Cling's main goals is to provide contemporary, high-performance alternative of the current C++ interpreter in the ROOT project - CINT. The backward-compatibility with CINT is major priority during the development.

Download

To get the sources and build it yourself, see here. To get a binary snapshot, see here.

Command Line

Cling has its own command line, which looks like any other Unix shell. The emacs-like command line editor is what we call interactive command line or interactive shell.

Once we start Cling it automatically includes several header files and its own runtime universe. Thus it creates the minimal environment for the user to start.

Grammar

Cling is capable to parse everything that Clang can do. Current clang status can be found here

In addition Cling will be able to parse the CINT specific C++ extensions.

Metaprocessor

Cling Metaprocessor provides convenient and easy to use interface for changing the interpreter's internal state or for executing handy commands. Cling provides the following metaprocessor commands:

syntax: .(command), where command is:

  • .x filename.cxx - loads filename and calls void filename() if defined
  • .L library | filename.cxx - loads library or filename.cxx
  • .printAST - shows the abstract syntax tree after each processed entity
  • .I path - adds an include path

Resources

Used Technologies

The Low Level Virtual Machine (LLVM) is a compiler infrastructure, written in C++, which is designed for compile-time, link-time, run-time, and "idle-time" optimization of programs written in arbitrary programming languages. Originally implemented for C/C++, the language-independent design (and the success) of LLVM has since spawned a wide variety of front ends, including Objective-C, Fortran, Ada, Haskell, Java bytecode, Python, Ruby, ActionScript, GLSL, and others.

Clang is a compiler front end for the C, C++, Objective-C and Objective-C++ programming languages. It uses the Low Level Virtual Machine (LLVM) as its back end, and as such Clang is part of LLVM releases since LLVM 2.6. Its goal is to offer a replacement to the GNU Compiler Collection (GCC). Development is sponsored by Apple. Clang is available under a free software licence.