OSDN Git Service

Mapped location support
[pf3gnuchains/gcc-fork.git] / gcc / ada / switch.ads
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT COMPILER COMPONENTS                         --
4 --                                                                          --
5 --                               S W I T C H                                --
6 --                                                                          --
7 --                                 S p e c                                  --
8 --                                                                          --
9 --          Copyright (C) 1992-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 together with a child package appropriate to the client
27 --  tool scans switches. Note that the body of the appropraite Usage package
28 --  must be coordinated with the switches that are recognized by this package.
29 --  These Usage packages also act as the official documentation for the
30 --  switches that are recognized. In addition, package Debug documents
31 --  the otherwise undocumented debug switches that are also recognized.
32
33 with Gnatvsn;
34 with Types; use Types;
35
36 package Switch is
37
38    --  Common switches for GNU tools
39
40    Version_Switch : constant String := "--version";
41    Help_Switch    : constant String := "--help";
42
43    -----------------
44    -- Subprograms --
45    -----------------
46
47    type Procedure_Ptr is access procedure;
48
49    procedure Check_Version_And_Help
50      (Tool_Name      : String;
51       Initial_Year   : String;
52       Usage          : Procedure_Ptr;
53       Version_String : String := Gnatvsn.Gnat_Version_String);
54    --  Check if switches --version or --help is used. If one of this switch
55    --  is used, issue the proper messages and end the process.
56
57    procedure Display_Version
58      (Tool_Name      : String;
59       Initial_Year   : String;
60       Version_String : String := Gnatvsn.Gnat_Version_String);
61    --  Display version of a tool when switch --version is used
62
63    function Is_Switch (Switch_Chars : String) return Boolean;
64    --  Returns True iff Switch_Chars is at least two characters long,
65    --  and the first character is an hyphen ('-').
66
67    function Is_Front_End_Switch (Switch_Chars : String) return Boolean;
68    --  Returns True iff Switch_Chars represents a front-end switch,
69    --  ie. it starts with -I, -gnat or -?RTS.
70
71 private
72
73    --  This section contains some common routines used by the tool dependent
74    --  child packages (there is one such child package for each tool that
75    --  uses Switches to scan switches - Compiler/gnatbind/gnatmake/.
76
77    Switch_Max_Value : constant := 999_999;
78    --  Maximum value permitted in switches that take a value
79
80    procedure Scan_Nat
81      (Switch_Chars : String;
82       Max          : Integer;
83       Ptr          : in out Integer;
84       Result       : out Nat;
85       Switch       : Character);
86    --  Scan natural integer parameter for switch. On entry, Ptr points
87    --  just past the switch character, on exit it points past the last
88    --  digit of the integer value.
89
90    procedure Scan_Pos
91      (Switch_Chars : String;
92       Max          : Integer;
93       Ptr          : in out Integer;
94       Result       : out Pos;
95       Switch       : Character);
96    --  Scan positive integer parameter for switch. On entry, Ptr points
97    --  just past the switch character, on exit it points past the last
98    --  digit of the integer value.
99
100    procedure Bad_Switch (Switch : Character);
101    procedure Bad_Switch (Switch : String);
102    --  Fail with an appropriate message when a switch is not recognized
103
104 end Switch;