Mark ChangeLog
[official-gcc.git] / gcc / ada / gnatprep.ads
blob99381e1bc6814db66a27924bbe4de630948cea0f
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- G N A T P R E P --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 1992-2002, Free Software Foundation, Inc. --
10 -- --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 2, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, USA. --
21 -- --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 -- --
25 ------------------------------------------------------------------------------
27 -- This program provides a simple preprocessing capability for Ada programs.
28 -- It is designed for use with GNAT, but is not dependent on any special
29 -- features of GNAT.
31 -- To call gnatprep use
33 -- gnatprep infile outfile [deffile] [-v] [-c] [-b] [-r] [-s] [-u]
34 -- [-Dsymbol=value]
36 -- where
38 -- infile is the full name of the input file, which is an Ada source
39 -- file containing preprocessor directives.
41 -- outfile is the full name of the output file, which is an Ada source
42 -- in standard Ada form. When used with GNAT, this file name will
43 -- normally have an ads or adb suffix.
45 -- deffile is the full name of a text file containing definitions of
46 -- symbols to be referenced by the preprocessor. This argument is
47 -- optional.
49 -- The -c switch, causes both preprocessor lines and the lines deleted
50 -- by preprocessing to be retained in the output source as comments marked
51 -- with the special string "--! ". This option will result in line numbers
52 -- being preserved in the output file.
54 -- The -b switch causes both preprocessor lines and the lines deleted by
55 -- preprocessing to be replaced by blank lines in the output source file,
56 -- thus preserving line numbers in the output file.
58 -- The -r switch causes a Source_Reference pragma to be generated that
59 -- references the original input file, so that error messages will use
60 -- the file name of this original file.
62 -- The -u switch causes gnatprep to treat any undefined symbol that it
63 -- encounters as having the value False. Otherwise an undefined symbol
64 -- is a fatal error.
66 -- The -s switch causes a sorted list of symbol names and values to be
67 -- listed on the standard output file.
69 -- The -v switch causes a Copyright notice to be displayed, and
70 -- lines containing errors in the input file or the definition file
71 -- to be displayed before the errors.
73 -- The -D switch causes symbol 'symbol' to be associated with 'value'.
74 -- This symbols can then be referenced by the preprocessor. Several
75 -- -D switches may be specified.
77 -- Note: if neither -b nor -c is present, then preprocessor lines and
78 -- deleted lines are completely removed from the output, unless -r is
79 -- specified, in which case -b is assumed.
81 -- The definitions file contains lines of the form
83 -- symbol := value
85 -- where symbol is an identifier, following normal Ada (case-insensitive)
86 -- rules for its syntax, and value is one of the following:
88 -- Empty, corresponding to a null substitution
90 -- A string literal using normal Ada syntax
92 -- Any sequence of characters from the set
93 -- (letters, digits, period, underline)
95 -- Comment lines may also appear in the definitions file, starting with
96 -- the usual --, and comments may be added to the definitions lines.
98 -- The input text may contain preprocessor conditional inclusion lines,
99 -- and also general symbol substitution sequences.
101 -- The preprocessor conditional inclusion commands have the form
103 -- #if <expression> [then]
104 -- lines
105 -- #elsif <expression> [then]
106 -- lines
107 -- #elsif <expression> [then]
108 -- lines
109 -- ...
110 -- #else
111 -- lines
112 -- #end if;
114 -- Where expression is defined by the following grammar :
115 -- expression ::= <symbol>
116 -- expression ::= <symbol> = "<value>"
117 -- expression ::= <symbol> = <symbol>
118 -- expression ::= <symbol> 'Defined
119 -- expression ::= not <expression>
120 -- expression ::= <expression> and <expression>
121 -- expression ::= <expression> or <expression>
122 -- expression ::= <expression> and then <expression>
123 -- expression ::= <expression> or else <expression>
124 -- expression ::= ( <expression> )
126 -- "or" and "and" may not be used in the same expression without
127 -- using parentheses.
129 -- For these Boolean tests, the symbol must have either the value True or
130 -- False. If the value is True, then the corresponding lines are included,
131 -- and if the value is False, they are excluded. It is an error to
132 -- reference a symbol not defined in the symbol definitions file, or
133 -- to reference a symbol that has a value other than True or False.
135 -- The use of the not operator inverts the sense of this logical test, so
136 -- that the lines are included only if the symbol is not defined.
138 -- The THEN keyword is optional as shown
140 -- Spaces or tabs may appear between the # and the keyword. The keywords
141 -- and the symbols are case insensitive as in normal Ada code. Comments
142 -- may be used on a preprocessor line, but other than that, no other
143 -- tokens may appear on a preprocessor line.
145 -- Any number of #elsif clauses can be present, including none at all.
147 -- The #else is optional, as in Ada.
149 -- The # marking the start of a preprocessor line must be the first
150 -- non-blank character on the line, i.e. it must be preceded only by
151 -- spaces or horizontal tabs.
153 -- Symbol substitution is obtained by using the sequence
155 -- $symbol
157 -- anywhere within a source line, except in a comment. The identifier
158 -- following the $ must match one of the symbols defined in the symbol
159 -- definition file, and the result is to substitute the value of the
160 -- symbol in place of $symbol in the output file.
162 procedure GNATprep;