* config/rs6000/predicates.md (branch_comparison_operator): Change
[official-gcc.git] / gcc / ada / xsnames.adb
blobd93cfbd8d3e351efe4679ddd1b3cbbba732a3e1b
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT SYSTEM UTILITIES --
4 -- --
5 -- X S N A M E S --
6 -- --
7 -- B o d y --
8 -- --
9 -- Copyright (C) 1992-2005 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 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. --
21 -- --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 -- --
25 ------------------------------------------------------------------------------
27 -- This utility is used to make a new version of the Snames package when
28 -- new names are added to the spec, the existing versions of snames.ads and
29 -- snames.adb are read, and updated to match the set of names in snames.ads.
30 -- The updated versions are written to snames.ns and snames.nb (new spec/body)
32 with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
33 with Ada.Strings.Unbounded.Text_IO; use Ada.Strings.Unbounded.Text_IO;
34 with Ada.Strings.Maps; use Ada.Strings.Maps;
35 with Ada.Strings.Maps.Constants; use Ada.Strings.Maps.Constants;
36 with Ada.Text_IO; use Ada.Text_IO;
38 with GNAT.Spitbol; use GNAT.Spitbol;
39 with GNAT.Spitbol.Patterns; use GNAT.Spitbol.Patterns;
41 procedure XSnames is
43 InB : File_Type;
44 InS : File_Type;
45 OutS : File_Type;
46 OutB : File_Type;
48 A, B : VString := Nul;
49 Line : VString := Nul;
50 Name : VString := Nul;
51 Name1 : VString := Nul;
52 Oname : VString := Nul;
53 Oval : VString := Nul;
54 Restl : VString := Nul;
56 Tdigs : Pattern := Any (Decimal_Digit_Set) &
57 Any (Decimal_Digit_Set) &
58 Any (Decimal_Digit_Set);
60 Name_Ref : Pattern := Span (' ') * A & Break (' ') * Name
61 & Span (' ') * B
62 & ": constant Name_Id := N + " & Tdigs
63 & ';' & Rest * Restl;
65 Get_Name : Pattern := "Name_" & Rest * Name1;
67 Chk_Low : Pattern := Pos (0) & Any (Lower_Set) & Rest & Pos (1);
69 Findu : Pattern := Span ('u') * A;
71 Val : Natural;
73 Xlate_U_Und : Character_Mapping := To_Mapping ("u", "_");
75 M : Match_Result;
77 begin
78 Open (InB, In_File, "snames.adb");
79 Open (InS, In_File, "snames.ads");
81 Create (OutS, Out_File, "snames.ns");
82 Create (OutB, Out_File, "snames.nb");
84 Anchored_Mode := True;
85 Oname := Nul;
86 Val := 0;
88 loop
89 Line := Get_Line (InB);
90 exit when Match (Line, " Preset_Names");
91 Put_Line (OutB, Line);
92 end loop;
94 Put_Line (OutB, Line);
96 LoopN : while not End_Of_File (InS) loop
97 Line := Get_Line (InS);
99 if not Match (Line, Name_Ref) then
100 Put_Line (OutS, Line);
102 else
103 Oval := Lpad (V (Val), 3, '0');
105 if Match (Name, "Last_") then
106 Oval := Lpad (V (Val - 1), 3, '0');
107 end if;
109 Put_Line
110 (OutS, A & Name & B & ": constant Name_Id := N + "
111 & Oval & ';' & Restl);
113 if Match (Name, Get_Name) then
114 Name := Name1;
115 Val := Val + 1;
117 if Match (Name, Findu, M) then
118 Replace (M, Translate (A, Xlate_U_Und));
119 Translate (Name, Lower_Case_Map);
121 elsif not Match (Name, "Op_", "") then
122 Translate (Name, Lower_Case_Map);
124 else
125 Name := 'O' & Translate (Name, Lower_Case_Map);
126 end if;
128 if Name = "error" then
129 Name := V ("<error>");
130 end if;
132 if not Match (Name, Chk_Low) then
133 Put_Line (OutB, " """ & Name & "#"" &");
134 end if;
135 end if;
136 end if;
137 end loop LoopN;
139 loop
140 Line := Get_Line (InB);
141 exit when Match (Line, " ""#"";");
142 end loop;
144 Put_Line (OutB, Line);
146 while not End_Of_File (InB) loop
147 Put_Line (OutB, Get_Line (InB));
148 end loop;
149 end XSnames;