annotate gcc/ada/switch.ads @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children 84e7813d76e9
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 -- S W I T C H --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- S p e c --
kono
parents:
diff changeset
8 -- --
kono
parents:
diff changeset
9 -- Copyright (C) 1992-2012, Free Software Foundation, Inc. --
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 package together with a child package appropriate to the client tool
kono
parents:
diff changeset
27 -- scans switches. Note that the body of the appropriate Usage package must be
kono
parents:
diff changeset
28 -- coordinated with the switches that are recognized by this package. These
kono
parents:
diff changeset
29 -- Usage packages also act as the official documentation for the switches
kono
parents:
diff changeset
30 -- that are recognized. In addition, package Debug documents the otherwise
kono
parents:
diff changeset
31 -- undocumented debug switches that are also recognized.
kono
parents:
diff changeset
32
kono
parents:
diff changeset
33 with Gnatvsn;
kono
parents:
diff changeset
34 with Types; use Types;
kono
parents:
diff changeset
35
kono
parents:
diff changeset
36 ------------
kono
parents:
diff changeset
37 -- Switch --
kono
parents:
diff changeset
38 ------------
kono
parents:
diff changeset
39
kono
parents:
diff changeset
40 package Switch is
kono
parents:
diff changeset
41
kono
parents:
diff changeset
42 -- Common switches for GNU tools
kono
parents:
diff changeset
43
kono
parents:
diff changeset
44 Version_Switch : constant String := "--version";
kono
parents:
diff changeset
45 Help_Switch : constant String := "--help";
kono
parents:
diff changeset
46
kono
parents:
diff changeset
47 -----------------
kono
parents:
diff changeset
48 -- Subprograms --
kono
parents:
diff changeset
49 -----------------
kono
parents:
diff changeset
50
kono
parents:
diff changeset
51 generic
kono
parents:
diff changeset
52 with procedure Usage;
kono
parents:
diff changeset
53 -- Print tool-specific part of --help message
kono
parents:
diff changeset
54 procedure Check_Version_And_Help_G
kono
parents:
diff changeset
55 (Tool_Name : String;
kono
parents:
diff changeset
56 Initial_Year : String;
kono
parents:
diff changeset
57 Version_String : String := Gnatvsn.Gnat_Version_String);
kono
parents:
diff changeset
58 -- Check if switches --version or --help is used. If one of this switch is
kono
parents:
diff changeset
59 -- used, issue the proper messages and end the process.
kono
parents:
diff changeset
60
kono
parents:
diff changeset
61 procedure Display_Version
kono
parents:
diff changeset
62 (Tool_Name : String;
kono
parents:
diff changeset
63 Initial_Year : String;
kono
parents:
diff changeset
64 Version_String : String := Gnatvsn.Gnat_Version_String);
kono
parents:
diff changeset
65 -- Display version of a tool when switch --version is used
kono
parents:
diff changeset
66
kono
parents:
diff changeset
67 procedure Display_Usage_Version_And_Help;
kono
parents:
diff changeset
68 -- Output the two lines of usage for switches --version and --help
kono
parents:
diff changeset
69
kono
parents:
diff changeset
70 function Is_Switch (Switch_Chars : String) return Boolean;
kono
parents:
diff changeset
71 -- Returns True iff Switch_Chars is at least two characters long, and the
kono
parents:
diff changeset
72 -- first character is an hyphen ('-').
kono
parents:
diff changeset
73
kono
parents:
diff changeset
74 function Is_Front_End_Switch (Switch_Chars : String) return Boolean;
kono
parents:
diff changeset
75 -- Returns True iff Switch_Chars represents a front-end switch, i.e. it
kono
parents:
diff changeset
76 -- starts with -I, -gnat or -?RTS.
kono
parents:
diff changeset
77
kono
parents:
diff changeset
78 function Is_Internal_GCC_Switch (Switch_Chars : String) return Boolean;
kono
parents:
diff changeset
79 -- Returns True iff Switch_Chars represents an internal GCC switch to be
kono
parents:
diff changeset
80 -- followed by a single argument, such as -dumpbase, --param or -auxbase.
kono
parents:
diff changeset
81 -- Even though passed by the "gcc" driver, these need not be stored in ALI
kono
parents:
diff changeset
82 -- files and may safely be ignored by non GCC back-ends.
kono
parents:
diff changeset
83
kono
parents:
diff changeset
84 function Switch_Last (Switch_Chars : String) return Natural;
kono
parents:
diff changeset
85 -- Index in Switch_Chars of the last relevant character for later string
kono
parents:
diff changeset
86 -- comparison purposes. This is typically 'Last, minus one if there is a
kono
parents:
diff changeset
87 -- terminating ASCII.NUL.
kono
parents:
diff changeset
88
kono
parents:
diff changeset
89 private
kono
parents:
diff changeset
90 -- This section contains some common routines used by the tool dependent
kono
parents:
diff changeset
91 -- child packages (there is one such child package for each tool that uses
kono
parents:
diff changeset
92 -- Switches to scan switches - Compiler/gnatbind/gnatmake/.
kono
parents:
diff changeset
93
kono
parents:
diff changeset
94 Switch_Max_Value : constant := 999_999;
kono
parents:
diff changeset
95 -- Maximum value permitted in switches that take a value
kono
parents:
diff changeset
96
kono
parents:
diff changeset
97 function Nat_Present
kono
parents:
diff changeset
98 (Switch_Chars : String;
kono
parents:
diff changeset
99 Max : Integer;
kono
parents:
diff changeset
100 Ptr : Integer) return Boolean;
kono
parents:
diff changeset
101 -- Returns True if an integer is at the current scan location or an equal
kono
parents:
diff changeset
102 -- sign. This is used as a guard for calling Scan_Nat. Switch_Chars is the
kono
parents:
diff changeset
103 -- string containing the switch, and Ptr points just past the switch
kono
parents:
diff changeset
104 -- character. Max is the maximum allowed value of Ptr.
kono
parents:
diff changeset
105
kono
parents:
diff changeset
106 procedure Scan_Nat
kono
parents:
diff changeset
107 (Switch_Chars : String;
kono
parents:
diff changeset
108 Max : Integer;
kono
parents:
diff changeset
109 Ptr : in out Integer;
kono
parents:
diff changeset
110 Result : out Nat;
kono
parents:
diff changeset
111 Switch : Character);
kono
parents:
diff changeset
112 -- Scan natural integer parameter for switch. On entry, Ptr points just
kono
parents:
diff changeset
113 -- past the switch character, on exit it points past the last digit of the
kono
parents:
diff changeset
114 -- integer value. Max is the maximum allowed value of Ptr, so the scan is
kono
parents:
diff changeset
115 -- restricted to Switch_Chars (Ptr .. Max). It is possible for Ptr to be
kono
parents:
diff changeset
116 -- one greater than Max on return if the entire string is digits. Scan_Nat
kono
parents:
diff changeset
117 -- will skip an optional equal sign if it is present. Nat_Present must be
kono
parents:
diff changeset
118 -- True, or an error will be signalled.
kono
parents:
diff changeset
119
kono
parents:
diff changeset
120 procedure Scan_Pos
kono
parents:
diff changeset
121 (Switch_Chars : String;
kono
parents:
diff changeset
122 Max : Integer;
kono
parents:
diff changeset
123 Ptr : in out Integer;
kono
parents:
diff changeset
124 Result : out Pos;
kono
parents:
diff changeset
125 Switch : Character);
kono
parents:
diff changeset
126 -- Scan positive integer parameter for switch. Identical to Scan_Nat with
kono
parents:
diff changeset
127 -- same parameters except that zero is considered out of range.
kono
parents:
diff changeset
128
kono
parents:
diff changeset
129 procedure Bad_Switch (Switch : Character);
kono
parents:
diff changeset
130 procedure Bad_Switch (Switch : String);
kono
parents:
diff changeset
131 pragma No_Return (Bad_Switch);
kono
parents:
diff changeset
132 -- Fail with an appropriate message when a switch is not recognized
kono
parents:
diff changeset
133
kono
parents:
diff changeset
134 end Switch;