Metaprogramming in the Ravi System

In a multilanguage system, and even more in an interactive multilanguage system, metaprogramming is crucial to produce various sorts of systematic code - our two main metaprograms are good examples of code that cannot be written by a simple user.

This page gives an overview metaprogramming in Ravi, pointing to a number of real-world examples, giving source files, generated files, and a few comments.

We show two applications, and basic tool within a general framework for metaprogramming in C++. The general framework is based on a conceptually simple principle, (which is really hard to put to practice):

Principle: Metaprograms work with AST structures. (Abstract Syntax Tress).

Whence two major tools, and some auxiliaries:

  • Parser
  • Unparser
  • Source File Reader

Abstract Syntax Example

This example illustrates the AST format. It shows a C++ header file and its translation, as obtained using the Scheme-command

(trad-file "ast.hh" "ast.scm")

AST example

Interface Generation

The example files contains 3 different files:

  • C++ header file
  • Pragma file, in Scheme format
  • Generated file

Example 1
This example includes no pragma file.


Example 1