* config/xtensa/xtensa.h (GO_IF_MODE_DEPENDENT_ADDRESS): Treat
[official-gcc.git] / gcc / ada / switch.adb
blob1e25cc3a25918c3cdf78242c481b3e6e8f6c5e92
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- S W I T C H --
6 -- --
7 -- B o d y --
8 -- --
9 -- --
10 -- Copyright (C) 1992-2001, Free Software Foundation, Inc. --
11 -- --
12 -- GNAT is free software; you can redistribute it and/or modify it under --
13 -- terms of the GNU General Public License as published by the Free Soft- --
14 -- ware Foundation; either version 2, or (at your option) any later ver- --
15 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
16 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
17 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
18 -- for more details. You should have received a copy of the GNU General --
19 -- Public License distributed with GNAT; see file COPYING. If not, write --
20 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
21 -- MA 02111-1307, USA. --
22 -- --
23 -- GNAT was originally developed by the GNAT team at New York University. --
24 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
25 -- --
26 ------------------------------------------------------------------------------
28 package body Switch is
30 -------------------------
31 -- Is_Front_End_Switch --
32 -------------------------
34 function Is_Front_End_Switch (Switch_Chars : String) return Boolean is
35 Ptr : constant Positive := Switch_Chars'First;
37 begin
38 return Is_Switch (Switch_Chars)
39 and then
40 (Switch_Chars (Ptr + 1) = 'I'
41 or else (Switch_Chars'Length >= 5
42 and then Switch_Chars (Ptr + 1 .. Ptr + 4) = "gnat")
43 or else (Switch_Chars'Length >= 5
44 and then Switch_Chars (Ptr + 1 .. Ptr + 4) = "fRTS"));
45 end Is_Front_End_Switch;
47 ---------------
48 -- Is_Switch --
49 ---------------
51 function Is_Switch (Switch_Chars : String) return Boolean is
52 begin
53 return Switch_Chars'Length > 1
54 and then Switch_Chars (Switch_Chars'First) = '-';
55 end Is_Switch;
57 ------------------------
58 --------------
59 -- Scan_Nat --
60 --------------
62 procedure Scan_Nat
63 (Switch_Chars : String;
64 Max : Integer;
65 Ptr : in out Integer;
66 Result : out Nat)
68 begin
69 Result := 0;
71 if Ptr > Max or else Switch_Chars (Ptr) not in '0' .. '9' then
72 raise Missing_Switch_Value;
73 end if;
75 while Ptr <= Max and then Switch_Chars (Ptr) in '0' .. '9' loop
76 Result := Result * 10 +
77 Character'Pos (Switch_Chars (Ptr)) - Character'Pos ('0');
78 Ptr := Ptr + 1;
80 if Result > Switch_Max_Value then
81 raise Bad_Switch_Value;
82 end if;
83 end loop;
84 end Scan_Nat;
86 --------------
87 -- Scan_Pos --
88 --------------
90 procedure Scan_Pos
91 (Switch_Chars : String;
92 Max : Integer;
93 Ptr : in out Integer;
94 Result : out Pos) is
96 begin
97 Scan_Nat (Switch_Chars, Max, Ptr, Result);
99 if Result = 0 then
100 raise Bad_Switch_Value;
101 end if;
102 end Scan_Pos;
104 end Switch;