1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2002, Free Software Foundation, Inc. --
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. --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
25 ------------------------------------------------------------------------------
27 package body Switch is
29 -------------------------
30 -- Is_Front_End_Switch --
31 -------------------------
33 function Is_Front_End_Switch (Switch_Chars : String) return Boolean is
34 Ptr : constant Positive := Switch_Chars'First;
37 return Is_Switch (Switch_Chars)
39 (Switch_Chars (Ptr + 1) = 'I'
40 or else (Switch_Chars'Length >= 5
41 and then Switch_Chars (Ptr + 1 .. Ptr + 4) = "gnat")
42 or else (Switch_Chars'Length >= 5
43 and then Switch_Chars (Ptr + 1 .. Ptr + 4) = "fRTS"));
44 end Is_Front_End_Switch;
50 function Is_Switch (Switch_Chars : String) return Boolean is
52 return Switch_Chars'Length > 1
53 and then Switch_Chars (Switch_Chars'First) = '-';
56 ------------------------
62 (Switch_Chars : String;
70 if Ptr > Max or else Switch_Chars (Ptr) not in '0' .. '9' then
71 raise Missing_Switch_Value;
74 while Ptr <= Max and then Switch_Chars (Ptr) in '0' .. '9' loop
75 Result := Result * 10 +
76 Character'Pos (Switch_Chars (Ptr)) - Character'Pos ('0');
79 if Result > Switch_Max_Value then
80 raise Bad_Switch_Value;
90 (Switch_Chars : String;
98 Scan_Nat (Switch_Chars, Max, Ptr, Temp);
101 raise Bad_Switch_Value;