PR target/16201
[official-gcc.git] / gcc / ada / vms_conv.ads
blob1682c879142f6960cf0c3e512c7378b8f5fdd473
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- V M S _ C O N V --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 2003-2004 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 package is part of the GNAT driver. It contains the procedure
28 -- VMS_Conversion to convert a VMS command line to the equivalent command
29 -- line with switches for the GNAT tools that the GNAT driver will invoke.
30 -- The qualifier declarations are contained in package VMS_Data.
32 with Table;
33 with VMS_Data; use VMS_Data;
35 with GNAT.OS_Lib; use GNAT.OS_Lib;
37 package VMS_Conv is
39 -- A table to keep the switches on the command line
41 package Last_Switches is new Table.Table
42 (Table_Component_Type => String_Access,
43 Table_Index_Type => Integer,
44 Table_Low_Bound => 1,
45 Table_Initial => 20,
46 Table_Increment => 100,
47 Table_Name => "Gnatcmd.Last_Switches");
49 Normal_Exit : exception;
50 -- Raise this exception for normal program termination
52 Error_Exit : exception;
53 -- Raise this exception if error detected
55 Errors : Natural := 0;
56 -- Count errors detected
58 Display_Command : Boolean := False;
59 -- Set true if /? switch causes display of generated command (on VMS)
61 -------------------
62 -- Command Table --
63 -------------------
65 -- The command table contains an entry for each command recognized by
66 -- GNATCmd. The entries are represented by an array of records.
68 type Parameter_Type is
69 -- A parameter is defined as a whitespace bounded string, not begining
70 -- with a slash. (But see note under FILES_OR_WILDCARD).
71 (File,
72 -- A required file or directory parameter
74 Optional_File,
75 -- An optional file or directory parameter
77 Other_As_Is,
78 -- A parameter that's passed through as is (not canonicalized)
80 Unlimited_Files,
81 -- An unlimited number of whitespace separate file or directory
82 -- parameters including wildcard specifications.
84 Unlimited_As_Is,
85 -- Un unlimited number of whitespace separated paameters that are
86 -- passed through as is (not canonicalized).
88 Files_Or_Wildcard);
89 -- A comma separated list of files and/or wildcard file specifications.
90 -- A comma preceded by or followed by whitespace is considered as a
91 -- single comma character w/o whitespace.
93 type Parameter_Array is array (Natural range <>) of Parameter_Type;
94 type Parameter_Ref is access all Parameter_Array;
96 type Command_Type is
97 (Bind,
98 Chop,
99 Clean,
100 Compile,
101 Elim,
102 Find,
103 Krunch,
104 Library,
105 Link,
106 List,
107 Make,
108 Metric,
109 Name,
110 Preprocess,
111 Pretty,
112 Setup,
113 Shared,
114 Stub,
115 Xref,
116 Undefined);
118 type Alternate_Command is (Comp, Ls, Kr, Pp, Prep);
119 -- Alternate command label for non VMS system use
121 Corresponding_To : constant array (Alternate_Command) of Command_Type :=
122 (Comp => Compile,
123 Ls => List,
124 Kr => Krunch,
125 Prep => Preprocess,
126 Pp => Pretty);
127 -- Mapping of alternate commands to commands
129 subtype Real_Command_Type is Command_Type range Bind .. Xref;
131 type Command_Entry is record
132 Cname : String_Ptr;
133 -- Command name for GNAT xxx command
135 Usage : String_Ptr;
136 -- A usage string, used for error messages
138 Unixcmd : String_Ptr;
139 -- Corresponding Unix command
141 Unixsws : Argument_List_Access;
142 -- Switches for the Unix command
144 VMS_Only : Boolean;
145 -- When True, the command can only be used on VMS
147 Switches : Switches_Ptr;
148 -- Pointer to array of switch strings
150 Params : Parameter_Ref;
151 -- Describes the allowable types of parameters.
152 -- Params (1) is the type of the first parameter, etc.
153 -- An empty parameter array means this command takes no parameters.
155 Defext : String (1 .. 3);
156 -- Default extension. If non-blank, then this extension is supplied by
157 -- default as the extension for any file parameter which does not have
158 -- an extension already.
159 end record;
161 -------------------------
162 -- Internal Structures --
163 -------------------------
165 -- The switches and commands are defined by strings in the previous
166 -- section so that they are easy to modify, but internally, they are
167 -- kept in a more conveniently accessible form described in this
168 -- section.
170 -- Commands, command qualifers and options have a similar common format
171 -- so that searching for matching names can be done in a common manner.
173 type Item_Id is (Id_Command, Id_Switch, Id_Option);
175 type Translation_Type is
177 T_Direct,
178 -- A qualifier with no options.
179 -- Example: GNAT MAKE /VERBOSE
181 T_Directories,
182 -- A qualifier followed by a list of directories
183 -- Example: GNAT COMPILE /SEARCH=([], [.FOO], [.BAR])
185 T_Directory,
186 -- A qualifier followed by one directory
187 -- Example: GNAT LIBRARY /SET=[.VAXFLOATLIB]
189 T_File,
190 -- A qualifier followed by a filename
191 -- Example: GNAT LINK /EXECUTABLE=FOO.EXE
193 T_No_Space_File,
194 -- A qualifier followed by a filename
195 -- Example: GNAT MAKE /PROJECT_FILE=PRJ.GPR
197 T_Numeric,
198 -- A qualifier followed by a numeric value.
199 -- Example: GNAT CHOP /FILE_NAME_MAX_LENGTH=39
201 T_String,
202 -- A qualifier followed by a quoted string. Only used by
203 -- /IDENTIFICATION qualifier.
204 -- Example: GNAT LINK /IDENTIFICATION="3.14a1 version"
206 T_Options,
207 -- A qualifier followed by a list of options.
208 -- Example: GNAT COMPILE /REPRESENTATION_INFO=(ARRAYS,OBJECTS)
210 T_Commands,
211 -- A qualifier followed by a list. Only used for
212 -- MAKE /COMPILER_QUALIFIERS /BINDER_QUALIFIERS /LINKER_QUALIFIERS
213 -- (gnatmake -cargs -bargs -largs )
214 -- Example: GNAT MAKE ... /LINKER_QUALIFIERS /VERBOSE FOOBAR.OBJ
216 T_Other,
217 -- A qualifier passed directly to the linker. Only used
218 -- for LINK and SHARED if no other match is found.
219 -- Example: GNAT LINK FOO.ALI /SYSSHR
221 T_Alphanumplus
222 -- A qualifier followed by a legal linker symbol prefix. Only used
223 -- for BIND /BUILD_LIBRARY (gnatbind -Lxyz).
224 -- Example: GNAT BIND /BUILD_LIBRARY=foobar
227 type Item (Id : Item_Id);
228 type Item_Ptr is access all Item;
230 type Item (Id : Item_Id) is record
231 Name : String_Ptr;
232 -- Name of the command, switch (with slash) or option
234 Next : Item_Ptr;
235 -- Pointer to next item on list, always has the same Id value
237 Command : Command_Type := Undefined;
239 Unix_String : String_Ptr := null;
240 -- Corresponding Unix string. For a command, this is the unix command
241 -- name and possible default switches. For a switch or option it is
242 -- the unix switch string.
244 case Id is
246 when Id_Command =>
248 Switches : Item_Ptr;
249 -- Pointer to list of switch items for the command, linked
250 -- through the Next fields with null terminating the list.
252 Usage : String_Ptr;
253 -- Usage information, used only for errors and the default
254 -- list of commands output.
256 Params : Parameter_Ref;
257 -- Array of parameters
259 Defext : String (1 .. 3);
260 -- Default extension. If non-blank, then this extension is
261 -- supplied by default as the extension for any file parameter
262 -- which does not have an extension already.
264 when Id_Switch =>
266 Translation : Translation_Type;
267 -- Type of switch translation. For all cases, except Options,
268 -- this is the only field needed, since the Unix translation
269 -- is found in Unix_String.
271 Options : Item_Ptr;
272 -- For the Options case, this field is set to point to a list
273 -- of options item (for this case Unix_String is null in the
274 -- main switch item). The end of the list is marked by null.
276 when Id_Option =>
278 null;
279 -- No special fields needed, since Name and Unix_String are
280 -- sufficient to completely described an option.
282 end case;
283 end record;
285 subtype Command_Item is Item (Id_Command);
286 subtype Switch_Item is Item (Id_Switch);
287 subtype Option_Item is Item (Id_Option);
289 -------------------
290 -- Switch Tables --
291 -------------------
293 -- The switch tables contain an entry for each switch recognized by the
294 -- command processor. It is initialized by procedure Initialize.
296 Command_List : array (Real_Command_Type) of Command_Entry;
298 ----------------
299 -- Procedures --
300 ----------------
302 procedure Initialize;
303 -- Initialized the switch table Command_List
305 procedure Output_Version;
306 -- Output the version of this program
308 procedure VMS_Conversion (The_Command : out Command_Type);
309 -- Converts VMS command line to equivalent Unix command line
311 end VMS_Conv;