Contributor Documentation

4. Subsystems

4.1. Preprocessor

The preprocessor is a functor: scalpel::cpp::preprocessor.

Since the source code preprocessing job is entirely delegated to Boost.Wave, there is little to say about it. Just read the source code, it's a typical use case.

4.2. Syntax analyzer

The syntax analyzer is also a functor: scalpel::cpp::syntax_analyzer.

The syntax analysis is powered by Boost.Spirit Classic.

[Note]Why not Spirit v2?

When the Scalpel project started, Spirit v2 wasn't stable yet. The (painful) migration just has to be done!

First of all, the syntax analyzer generates a parse tree, using one of the Boost.Spirit's parse functions. This function takes two arguments: the input pure C++ source code and an instance of the grammar class.

The grammar class defines the whole C++ grammar (in the Boost.Spirit's BNF-like format). This is the main submodule of the syntax analyzer (and even one of the biggest pieces of code of Scalpel). It is located in the scalpel::cpp::detail::syntax_analysis namespace. It's terribly huge. Keep out of reach of children. No kidding.

In order to keep a loose coupling with Boost.Spirit, the Spirit-formatted parse tree is converted into a syntax_tree object. The set of functions related to this conversion is located in the scalpel::cpp::detail::syntax_analysis::parse_tree_to_syntax_tree namespace.

Finally, the syntax_tree object is outputted by the syntax analyzer.

4.3. Semantic analyzer

Following the example of the preprocessor and the syntax analyzer, the semantic analyzer is a functor: scalpel::cpp::semantic_analyzer.

The semantic analysis is the most complex part of Scalpel. It is still under development. Consequently, it's not possible for now to write a documentation about it. The best way to understand it is to read the source code and to subscribe to the mailing list.