1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
| procedure Action
(Item : String;
Index : Positive;
Quit : in out Boolean) is
File : File_Type;
Position : Natural;
Done : Boolean := True;
Unit_Name,
Buffer : String_Access;
begin
Put_Line("Item " & Positive'Image(Index) & ": " & item);
Open(File, In_File, Item);
-- Getting current unit name.
while not End_Of_File(File) loop
declare
Line : String := Get_Line(File);
Is_Comment : Boolean := False;
begin
if Line'length /= 0 then
if Fixed.Index(Line, "--") /= 0 then
if Fixed.Index_Non_Blank(Line) = Fixed.Index(Line, "--") then
Is_Comment := True;
end if;
end if;
if not Is_Comment then
if Fixed.Index(To_Lower(Line), "package ") = 1 then
if Extension(Item) = "adb" then
if Fixed.Index(To_Lower(Line), "is") /= 0 then
Buffer := new String ' (Line(Fixed.Index(To_Lower(Line), "body")+4..Fixed.Index(To_Lower(Line), "is") - 1));
else
Buffer := new String ' (Line(Fixed.Index(To_Lower(Line), "body")+4..Line'last));
end if;
exit;
else
if Fixed.Index(Line, "is") /= 0 then
Buffer := new String ' (Line(Fixed.Index(To_Lower(Line), "package")+7..Fixed.Index(To_Lower(Line), "is") - 1));
else
Buffer := new String ' (Line(Fixed.Index(To_Lower(Line), "package")+7..Line'last));
exit;
end if;
end if;
elsif Fixed.Index(To_Lower(Line), "procedure") = 1 then
if Fixed.Index(To_Lower(Line), "is") /= 0 then
Buffer := new String ' (Line(Fixed.Index(To_Lower(Line), "procedure")+9..Fixed.Index(To_Lower(Line), "is") - 1));
else
Buffer := new String ' (Line(Fixed.Index(To_Lower(Line), "procedure")+9..Line'last));
end if;
exit;
end if;
end if;
end if;
end;
end loop;
Unit_Name := new String ' (Buffer(Index_Non_Blank(Buffer.all)..Index_Non_Blank(Buffer.all, Backward)));
Put_Line("Component named """ & Unit_Name.all & """ will be added to Graph");
Reset(File);
-- Getting all include.
while not End_Of_File(File) loop
declare
Line : String := Get_Line(File);
Is_Comment : Boolean := False;
begin
if Line'length /= 0 then
if Fixed.Index(Line, "--") /= 0 then
if Fixed.Index_Non_Blank(Line) = Fixed.Index(Line, "--") then
Is_Comment := True;
end if;
end if;
if not Is_Comment then
if Done then
if Fixed.Index(To_Lower(Line), "with") /= 0 then
Position := Fixed.Index(To_Lower(Line), "with") + 4;
Done := False;
end if;
else
Position := Line'First;
end if;
if not Done then
while Fixed.Index(Line, ",", Position) /= 0 loop
Buffer := new String ' (Line(Position..Fixed.Index_Non_Blank(Line(Position..Fixed.Index(Line, ",") - 1), backward)));
Unit_Name := new String ' (Buffer(Index_Non_Blank(Buffer.all)..Index_Non_Blank(Buffer.all, Backward)));
Put_Line("Unit named """ & Unit_Name.all & """ will be added to Graph");
Position := Fixed.Index(Line, ",", Position) + 1;
end loop;
if Fixed.Index(Line, ";") /= 0 then
Buffer := new String ' (Line(Position..Fixed.Index_Non_Blank(Line(Position..Fixed.Index(Line, ";") - 1), backward)));
Unit_Name := new String ' (Buffer(Index_Non_Blank(Buffer.all)..Index_Non_Blank(Buffer.all, Backward)));
Put_Line("Unit named """ & Unit_Name.all & """ will be added to Graph");
Done := True;
end if;
end if;
if Fixed.Index(To_Lower(Line), "package") = 1 or
Fixed.Index(To_Lower(Line), "generic") = 1 or
Fixed.Index(To_Lower(Line), "procedure") = 1 then
exit;
end if;
Line := (others => Character'Val(32));
end if;
end if;
end;
end loop;
Close(File);
end Action; |
Partager