1 ------------------------------------------------------------------------------
3 -- GNAT SYSTEM UTILITIES --
9 -- Copyright (C) 1998 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 -- Program to check consistency of einfo.ads and einfo.adb. Checks that
28 -- field name usage is consistent, including comments mentioning fields.
30 with Ada
.Strings
.Unbounded
; use Ada
.Strings
.Unbounded
;
31 with Ada
.Strings
.Unbounded
.Text_IO
; use Ada
.Strings
.Unbounded
.Text_IO
;
32 with Ada
.Text_IO
; use Ada
.Text_IO
;
34 with GNAT
.Spitbol
; use GNAT
.Spitbol
;
35 with GNAT
.Spitbol
.Patterns
; use GNAT
.Spitbol
.Patterns
;
36 with GNAT
.Spitbol
.Table_VString
;
40 package TV
renames GNAT
.Spitbol
.Table_VString
;
44 Lineno
: Natural := 0;
47 -- Raised on fatal error
53 Fields
: GNAT
.Spitbol
.Table_VString
.Table
(500);
54 -- Maps field names to underlying field access name
56 UC
: Pattern
:= Any
("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
58 Fnam
: Pattern
:= (UC
& Break
(' ')) * Fieldnm
;
60 Field_Def
: Pattern
:= "-- " & Fnam
& " (" & Break
(')') * Accessfunc
;
62 Field_Ref
: Pattern
:= " -- " & Fnam
& Break
('(') & Len
(1) &
63 Break
(')') * Accessfunc
;
65 Field_Com
: Pattern
:= " -- " & Fnam
& Span
(' ') &
66 (Break
(' ') or Rest
) * Accessfunc
;
68 Func_Hedr
: Pattern
:= " function " & Fnam
;
70 Func_Retn
: Pattern
:= " return " & Break
(' ') * Accessfunc
;
72 Proc_Hedr
: Pattern
:= " procedure " & Fnam
;
74 Proc_Setf
: Pattern
:= " Set_" & Break
(' ') * Accessfunc
;
77 -- Read next line trimmed from Infil into Line and bump Lineno
79 procedure Next_Line
is
81 Line
:= Get_Line
(Infil
);
86 -- Start of processing for CEinfo
89 Anchored_Mode
:= True;
91 Open
(Infil
, In_File
, "einfo.ads");
93 Put_Line
("Acquiring field names from spec");
97 exit when Match
(Line
, " -- Access Kinds --");
99 if Match
(Line
, Field_Def
) then
100 Set
(Fields
, Fieldnm
, Accessfunc
);
104 Put_Line
("Checking consistent references in spec");
108 exit when Match
(Line
, " -- Description of Defined");
113 exit when Match
(Line
, " -- Component_Alignment Control");
115 if Match
(Line
, Field_Ref
) then
116 if Accessfunc
/= "synth"
118 Accessfunc
/= "special"
120 Accessfunc
/= Get
(Fields
, Fieldnm
)
122 if Present
(Fields
, Fieldnm
) then
123 Put_Line
("*** field name incorrect at line " & Lineno
);
124 Put_Line
(" found field " & Accessfunc
);
125 Put_Line
(" expecting field " & Get
(Fields
, Fieldnm
));
129 ("*** unknown field name " & Fieldnm
& " at line " & Lineno
);
136 Open
(Infil
, In_File
, "einfo.adb");
139 Put_Line
("Check listing of fields in body");
143 exit when Match
(Line
, " -- Attribute Access Functions --");
145 if Match
(Line
, Field_Com
)
146 and then Fieldnm
/= "(unused)"
147 and then Accessfunc
/= Get
(Fields
, Fieldnm
)
149 if Present
(Fields
, Fieldnm
) then
150 Put_Line
("*** field name incorrect at line " & Lineno
);
151 Put_Line
(" found field " & Accessfunc
);
152 Put_Line
(" expecting field " & Get
(Fields
, Fieldnm
));
156 ("*** unknown field name " & Fieldnm
& " at line " & Lineno
);
161 Put_Line
("Check references in access routines in body");
165 exit when Match
(Line
, " -- Classification Functions --");
167 if Match
(Line
, Func_Hedr
) then
170 elsif Match
(Line
, Func_Retn
)
171 and then Accessfunc
/= Get
(Fields
, Fieldnm
)
172 and then Fieldnm
/= "Mechanism"
174 Put_Line
("*** incorrect field at line " & Lineno
);
175 Put_Line
(" found field " & Accessfunc
);
176 Put_Line
(" expecting field " & Get
(Fields
, Fieldnm
));
180 Put_Line
("Check references in set routines in body");
184 exit when Match
(Line
, " -- Attribute Set Procedures");
189 exit when Match
(Line
, " ------------");
191 if Match
(Line
, Proc_Hedr
) then
194 elsif Match
(Line
, Proc_Setf
)
195 and then Accessfunc
/= Get
(Fields
, Fieldnm
)
196 and then Fieldnm
/= "Mechanism"
198 Put_Line
("*** incorrect field at line " & Lineno
);
199 Put_Line
(" found field " & Accessfunc
);
200 Put_Line
(" expecting field " & Get
(Fields
, Fieldnm
));
204 Put_Line
("All tests completed successfully, no errors detected");