annotate gcc/ada/gnatprep.ads @ 158:494b0b89df80 default tip

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