Base-Level Language (OpenC++)

This section addresses the language specification of OpenC++. OpenC++ is identical to C++ except two extensions. To connect a base-level program and a meta-level program, OpenC++ introduces a new kind of declaration into C++. Also, new extended syntax is available in OpenC++ if the syntax is defined by the meta-level program.

Base-level Connection to the MOP

OpenC++ provides a new syntax for metaclass declaration. This declaration form is the only connection between the base level and the meta level. Although the default metaclass is Class, programmers can change it by using this declaration form:

Syntax Extensions

The extended syntax described here is effective if programmers define it by the MOP. By default, it causes a syntax error. To make it available, the programmers must register a new keyword, which is used in one of the following forms:

Loosened Grammar

Besides extended syntax, OpenC++'s grammar is somewhat loosened as compared with C++'s grammar. For example, the next code is semantically wrong in C++:

Point p = { 1, 3, 5 };

The C++ compiler will report that p cannot be initialized by { 1, 3, 5 }. Such an aggregate can be used only to initialize an array. The OpenC++ compiler simply accepts such a semantically-wrong code. It ignores semantical correctness expecting that the code will be translated into valid C++ code.

[First | Prev | Next]