Using a PreprocessorThis chapter describes the use of Ada-ASSURED when code is written for preprocessing. Support for preprocessors involves the optional extension of the Ada language with two constructs discussed below in:
Preprocessor Directives
Preprocessor directives start with a #-sign at the beginning of
a line and include all the text up to the end of the line. Because
the text after column one is uninterpreted, all preprocessors that use
the column-one #-sign syntax are supported. In particular,
Rational's VADS compiler, which is also SunPro's Sun Ada compiler, is
supported.
The availability of this extended syntax is optional. The resource preprocessorOk controls whether the syntax of preprocessor directives is accepted or rejected as a syntax error.
When a program is formatted, all preprocessor directives are displayed in a distinctive style so they are easily distinguished.
Preprocessor directives are only permitted in lists of the following syntactic categories:
X :=must be written as
#if Sparc then
Y
#else
Z
#end if;
;
#if Sparc then
X := Y;
#else
X := Z;
#end if;
The # template command appears in the context pane whenever a preprocessor directive may be inserted. When a preprocessor directive is typed at an indented placeholder, the #-sign need not be typed in the first column of the windowit is sufficient that the #-sign be the first character entered. The formatter will move the text to the first column, as necessary.
Care is needed when using preprocessor directives in lists that require separators (e.g. parameter_specification) as opposed to lists that use terminators (e.g. statement). If the last item in a list is a preprocessor construct, then an extra separator may be inserted. For example, the following enumeration declaration will result in an extra separator:
#Use_Green: constant BOOLEAN := TRUE;
type Color is
(Red,
Blue,
#if Use_Green then
Green,
#end if;
);
This problem can be avoided by putting the conditional parts of the declaration in the middle, as in:
#Use_Green: constant BOOLEAN := TRUE;
type Color is
(Red,
#if Use_Green then
Green,
#end if;
Blue
);
Dollar-prefixed Identifiers
A dollar-prefixed identifier is an Ada identifier that begins with a
$.
The availability of this extended syntax is optional. The resource dollarIdentifiers control whether the syntax of dollar-prefix identifiers is accepted or rejected as a syntax error.
When a program is formatted, all dollar-prefixed identifiers are displayed in a distinctive style so they are easily distinguished.
Dollar-prefixed identifiers are permitted wherever a name or identifier is allowed.