OSDN Git Service

2007-09-10 Robert Dewar <dewar@adacore.com>
[pf3gnuchains/gcc-fork.git] / gcc / ada / vms_conv.ads
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-2007, 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 3,  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 COPYING3.  If not, go to --
19 -- http://www.gnu.org/licenses for a complete copy of the license.          --
20 --                                                                          --
21 -- GNAT was originally developed  by the GNAT team at  New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
23 --                                                                          --
24 ------------------------------------------------------------------------------
25
26 --  This package is part of the GNAT driver. It contains the procedure
27 --  VMS_Conversion to convert a VMS command line to the equivalent command
28 --  line with switches for the GNAT tools that the GNAT driver will invoke.
29 --  The qualifier declarations are contained in package VMS_Data.
30
31 with Table;
32 with VMS_Data; use VMS_Data;
33
34 with GNAT.OS_Lib; use GNAT.OS_Lib;
35
36 package VMS_Conv is
37
38    --  A table to keep the switches on the command line
39
40    package Last_Switches is new Table.Table
41      (Table_Component_Type => String_Access,
42       Table_Index_Type     => Integer,
43       Table_Low_Bound      => 1,
44       Table_Initial        => 20,
45       Table_Increment      => 100,
46       Table_Name           => "Gnatcmd.Last_Switches");
47
48    Normal_Exit : exception;
49    --  Raise this exception for normal program termination
50
51    Error_Exit : exception;
52    --  Raise this exception if error detected
53
54    Errors : Natural := 0;
55    --  Count errors detected
56
57    Display_Command : Boolean := False;
58    --  Set true if /? switch causes display of generated command (on VMS)
59
60    -------------------
61    -- Command Table --
62    -------------------
63
64    --  The command table contains an entry for each command recognized by
65    --  GNATCmd. The entries are represented by an array of records.
66
67    type Parameter_Type is
68    --  A parameter is defined as a whitespace bounded string, not begining
69    --   with a slash. (But see note under FILES_OR_WILDCARD).
70      (File,
71       --  A required file or directory parameter
72
73       Optional_File,
74       --  An optional file or directory parameter
75
76       Other_As_Is,
77       --  A parameter that's passed through as is (not canonicalized)
78
79       Unlimited_Files,
80       --  An unlimited number of whitespace separate file or directory
81       --  parameters including wildcard specifications.
82
83       Unlimited_As_Is,
84       --  Un unlimited number of whitespace separated paameters that are
85       --  passed through as is (not canonicalized).
86
87       Files_Or_Wildcard);
88       --  A comma separated list of files and/or wildcard file specifications.
89       --  A comma preceded by or followed by whitespace is considered as a
90       --  single comma character w/o whitespace.
91
92    type Parameter_Array is array (Natural range <>) of Parameter_Type;
93    type Parameter_Ref is access all Parameter_Array;
94
95    type Command_Type is
96      (Bind,
97       Chop,
98       Clean,
99       Compile,
100       Check,
101       Elim,
102       Find,
103       Krunch,
104       Link,
105       List,
106       Make,
107       Metric,
108       Name,
109       Preprocess,
110       Pretty,
111       Shared,
112       Stack,
113       Stub,
114       Xref,
115       Undefined);
116
117    type Alternate_Command is (Comp, Ls, Kr, Pp, Prep);
118    --  Alternate command label for non VMS system use
119
120    Corresponding_To : constant array (Alternate_Command) of Command_Type :=
121      (Comp  => Compile,
122       Ls    => List,
123       Kr    => Krunch,
124       Prep  => Preprocess,
125       Pp    => Pretty);
126    --  Mapping of alternate commands to commands
127
128    subtype Real_Command_Type is Command_Type range Bind .. Xref;
129
130    type Command_Entry is record
131       Cname : String_Ptr;
132       --  Command name for GNAT xxx command
133
134       Usage : String_Ptr;
135       --  A usage string, used for error messages
136
137       Unixcmd : String_Ptr;
138       --  Corresponding Unix command
139
140       Unixsws : Argument_List_Access;
141       --  Switches for the Unix command
142
143       VMS_Only : Boolean;
144       --  When True, the command can only be used on VMS
145
146       Switches : Switches_Ptr;
147       --  Pointer to array of switch strings
148
149       Params : Parameter_Ref;
150       --  Describes the allowable types of parameters.
151       --  Params (1) is the type of the first parameter, etc.
152       --  An empty parameter array means this command takes no parameters.
153
154       Defext : String (1 .. 3);
155       --  Default extension. If non-blank, then this extension is supplied by
156       --  default as the extension for any file parameter which does not have
157       --  an extension already.
158    end record;
159
160    -------------------
161    -- Switch Tables --
162    -------------------
163
164    --  The switch tables contain an entry for each switch recognized by the
165    --  command processor. It is initialized by procedure Initialize.
166
167    Command_List : array (Real_Command_Type) of Command_Entry;
168
169    ----------------
170    -- Procedures --
171    ----------------
172
173    procedure Initialize;
174    --  Initialized the switch table Command_List
175
176    procedure Output_Version;
177    --  Output the version of this program
178
179    procedure VMS_Conversion (The_Command : out Command_Type);
180    --  Converts VMS command line to equivalent Unix command line
181
182 end VMS_Conv;