last modified: October 6 2000
The IDL preprocessor
Introduction
JPP is a preprocessor integrated with the idl2java compiler. JPP is heavily
inspired by the Jonas jpp preprocessor : it globally provides the same set of
facilities, contains the same classes, though most methods have been rewritten
(for some stupid reason).
JPP thus implements a subset of the ansi C preprocessor facilities.
In its present version jpp is not available as a standalone tool.
Preprocessor utilization
The syntax of the jpp command is : jpp (option_list | idl_File_List)*. The
command jpp stands here for java org.omg.objectweb.jonathan.tools.pp.JPP. It could
be implemented through a simple shell script (unix, Linux) or .bat file (dos, windows).
Options and file names can appear several times and be intertwinned in the command line. Option values are then
used from their declaration point until they are redefined. Following options are available in the present version :
- -D jpp_variable, where jpp_variable is a variable to be added to the set of
"defined" preprocessor variables used for conditional compilation . This set is initially empty.
- -I directory, where directory is a directory to be added to the "include"
list used by the jpp preprocessor. When the jpp preprocessor encounters a #include directive, it first
looks in the . directory and then continues the search in the "include" list. Search is stopped as soon
as a matching file has been found.
An example is : jpp -D NIRVANA -D BODDHISATVA -I ../BouddhaDir mediation.java
JPP grammar
The directives which can be included in the files should obey to the following simple syntactic rules.
- #define ID : "defined" variables without value
are used by the jpp preprocessor to evaluate #ifdef, #ifndef directives.
In conformance with the cpp standards a defined variable is visible from
the definition point upto the end of the most enclosing file (unless explicitely undefined), i.e. no
scoping rules are used.
such "defined" variables (without a value) are only used in the evaluation of jpp directives
i.e. in #ifdef, #ifndef, #undef directives. They are not used
for token or word replacement in the files.
- #define ID value : "defined" variables with a
value are used by the jpp preprocessor for token or word replacement in the files.
In conformance with the cpp standards a defined variable is visible from
the definition point upto the end of the most enclosing file (unless explicitely undefined), i.e. no
scoping rules are used.
such "defined" variables (with a value) are only used for token
or word replacement in the files. They are not used in the evaluation of jpp directives
i.e. in #ifdef, #ifndef, #undef directives.
- #undef ID : undefinition of a previously defined variable.
- #ifdef ID
- #ifndef ID
- #else
- #endif
- #include "filename" is treated according to the standard. The preprocessor inserts
the file between two line indications # line_number "filename" 1 and
# line_number "filename" 2. the integer value line_number is the line
number where the include directive has been encountered.
- #include <filename> is treated in the same
way as #include "filename"
- #pragma ..... are accepted and left unmodified in the file.
- Line escapes (i.e. \ just before the end of line) are handled.
An example is :
#ifndef GAUTAMA_JAVA
#define GAUTAMA_JAVA
#ifdef NIRVANA
#pragma BODDHINUMBERS 1 2 3 \
4 5 6 7
#include "../BoddhiDir/BoddhiParameters.hh"
.........
.........
#undef NIRVANA
#else
........
........
#endif
#endif
Several simple controls are performed :
- balance checks with conditional directives are performed for #else, #endif
- redefinition of preprocessing variables is detected and reported
- undef-inition of unknown preprocessing variables is detected and reported
- validity checks on the file name delimitors in #include directive
Present limitations are :
- No handling of expression
- No constraint on the ID lexical form
- #if and #elif directives are ignored.
Known bugs
- The preprocessor does not always behave well with Mac files.