with Ada.Text_Io, Ada.Integer_Text_Io, Ada.Characters.Handling, Ada.Strings.Fixed, Ada.Command_Line; use Ada.Text_Io, Ada.Integer_Text_Io, Ada.Characters.Handling, Ada.Strings.Fixed, Ada.Command_Line; procedure Main is ---- DEFINIZIONE DELLE ECCEZZIONI------------ Help_Error: exception; LostArgument_Error: exception; ---- DEFINIZIONE DEI TIPI ------------------------------------------------------------ type Pf_Lines is -- Tipo utilizzato per definire le informazioni sulle le procedure e le funzioni record L_Declaration_Top: Integer; -- Contiene il NO della riga dove inizia la dichiarazione della Procedure o Funzione L_Declaration_End: Integer; -- Contiene il NO della riga dove finisce la dichiarazione della Procedure o Funzione L_Begin: Integer; -- Contiene il NO della riga dove si trova il BEGIN end record; type T_Classification is -- Viene utilizzato per stabilire il tipo di oggetto (Proceduret, Functiont, Variablet, Recordt, Constantt, Typet, Nonet); type R_Line is -- Questo tipo contine una stringa per il testo e un integer per la sua lunghezza. record Text : String (1 .. 1000); Size : Integer; end record; type R_Object is -- R_Object contiene tutte le informazioni necessarie per descrivere un oggetto. record No_Line : Pf_Lines; -- Il numero delle linee (vedi Pf_Lines) No_Character : Integer; -- Il numero del carattere Classification : T_Classification; -- Di che tipo è l'oggetto Description : R_Line; -- La descrizione dell'oggetto end record; type A_Objects is array (1 .. 100) of R_Object; -- Un array di oggetti. ---- DEFINIZIONE DEI PACKAGE ------------------------------------------------------------ package Classification_Io is new Ada.Text_Io.Enumeration_Io(T_Classification); use Classification_Io; ---- DICHIARAZIONE DELLE VARIABILI ------------------------------------------------------------ Objects : A_Objects; -- Contiene tutti gli oggetti (procedure, funzioni, variabili e tipi) Text_File : File_Type; -- Contiene il file da analizzare No_Pro_Fun : Integer; -- Il numero di procedure e funzioni contenute nell'array di oggetti No_Objects : Integer; -- Il numero di oggetti Spaces : Integer; -- Variabile utilizzata durante la scrittura dei dati su file In_File_Path : R_Line; -- Contiene il Path del file da analizzare Out_File_Path : R_Line; -- Contiene il Path del file da scrivere ---- FUNZIONI E PROCEDURE --------------------------------------------------------------------- ------------------------------------------------------------------------------------------ -- Questa funzione permette di spostare un oggetto in un array da una posizione all'altra. -- Ha come parametri d'entrata In_Objects -> l'array con gli oggetti -- From -> La posizione di quale oggetto voglio spostare -- To -> La posizione di dove voglio spostare l'oggetto. function Move_Object (In_Objects:A_Objects; From:Integer; To:Integer) return A_Objects is Temp_Objects : A_Objects; -- Arrai di oggetti temporaneo Temp_Object : R_Object; -- Oggetto temporaneo begin Temp_Objects := In_Objects; Temp_Object := Temp_Objects(From); for I in 0..((From-To)-1) loop Temp_Objects(From-I):= Temp_Objects((From-I)-1); end loop; Temp_Objects(To):=Temp_Object; return(Temp_Objects); end Move_Object; ------------------------------------------------------------------------------------------ -- Una volta eseguito le tre funzioni principali di analisi (Check_Pf, Check_V, Check_Type), -- nell'array degli oggetti avremo in fila prima tutte le procedure e funzioni, poi le variabili e -- alla fine i tipi. Questa funzione è in grado di sistemare gli oggetti, cioè di metterli in ordine -- come si trovavano nel testo analizzato. function Arrange_Objects (In_Objects:A_Objects; In_Array_Size:Integer) return A_Objects is Type_To_Arrange : T_Classification; Temp_Objects : A_Objects; Temp_Objects_Size : Integer; begin Temp_Objects:= In_Objects; Temp_Objects_Size:=In_Array_Size; for F in 1..2 loop if F = 1 then Type_To_Arrange:= Variablet; else Type_To_Arrange:= Typet; end if; for H in 1..Temp_Objects_Size loop Searchtype_Cicle: for T in 0..(Temp_Objects_Size)-1 loop if Temp_Objects(((Temp_Objects_Size)-T)).Classification = Type_To_Arrange then for I in 0..(Temp_Objects_Size-1) loop if Temp_Objects(Temp_Objects_Size-I).Classification = Proceduret or Temp_Objects(Temp_Objects_Size-I).Classification = Functiont then if Temp_Objects(((Temp_Objects_Size)-T)).No_Line.L_Declaration_Top > Temp_Objects(Temp_Objects_Size-I).No_Line.L_Declaration_End then Temp_Objects:=Move_Object(Temp_Objects, ((Temp_Objects_Size)-T), (Temp_Objects_Size-I)+1); exit Searchtype_Cicle; end if; end if; end loop; end if; end loop Searchtype_Cicle; end loop; end loop; return Temp_Objects; end Arrange_Objects; ------------------------------------------------------------------------------------------ -- La funzione Pf_StringToArray è in grado di salvare una stringa nel nostro array di oggetti. function Pf_Stringtoarray (In_Classification : T_Classification; In_Noline_Top : Integer; In_Noline_End : Integer; In_Nochar : Integer; In_Line : String ) return R_Object is Object : R_Object; Cont : Integer; begin --- Inizializzazione delle variabili ---------------- Object.No_Line.L_Declaration_Top:= In_Noline_Top; Object.No_Line.L_Declaration_End:= In_Noline_End; Object.No_Character:= In_Nochar; Object.Classification:= In_Classification; Object.No_Line.L_Begin:=0; Object.Description.Text:=(others=>' '); Object.Description.Size:=0; Cont:=0; for T in 1..In_Line'Last loop if In_Line(T..T) /= " " and In_Line(T) /= Character'Val(9)then for I in T..In_Line'Last loop Cont:=Cont+1; Object.Description.Text(Cont..Cont):=In_Line(I..I); Object.Description.Size:=Cont; if To_Lower(In_Line (I+1..I+3)) = " is" then exit; end if; end loop; exit; end if; end loop; return Object; end Pf_Stringtoarray; ----------------------------------------------------------------------------------------- -- Questa procedura è in grado di trovare una parola contenuta in una stringa, ritornando -- la sua posizione. procedure Find_Word (Line : String; Line_Size : Natural; Word : String; Word_Size : Natural; Status : in out Boolean; Word_Position : out Natural ) is begin Word_Position := (Index(Line(1..Line_Size),Word(1..Word_Size))); if Word_Position /= 0 then Status:= True; else Status:= False; end if; end Find_Word; ---------------------------------------------------------------------------------------- -- Funzione in grado di ritornare la posizione del primo oggetto vuoto contenuto nell'array di oggetti. function Find_Next_Arrayspace (In_Array : A_Objects) return Integer is Array_To_Check : A_Objects; Array_Position : Integer; begin Array_To_Check := In_Array; Array_Position := 0; for T in 1..Array_To_Check'Last loop if Array_To_Check(T).Classification /= Nonet then Array_Position:=Array_Position+1; end if; end loop; Array_Position:=Array_Position+1; return(Array_Position); end Find_Next_Arrayspace; ---------------------------------------------------------------------------------------- -- Questa funzione è in grado di cercare in un determinato numero di righe una definizione -- di un tipo; se la trova, salva tutte le informazioni necessarie nell'array di oggetti. -- Line_Top e Line_End contengono i numeri delle righe del testo dove effettuare la -- ricerca (Line_Top -> da, Line_End -> a). function Check_Type_Inline (File_Text : File_Type; Array_Objects : A_Objects; Line_Top : Integer; Line_End : Integer ) return A_Objects is Cont_Line : Integer; Char_Position : Natural; Text_Line : R_Line; Temp_Objects : A_Objects; Array_Position : Natural; Status : Boolean; Comment: INTEGER; begin Temp_Objects:= Array_Objects; Cont_Line:=0; Comment:=0; while not End_Of_File(File_Text) loop Cont_Line:=Cont_Line+1; Get_Line(File_Text,Text_Line.Text, Text_Line.Size); for L in 1..Text_Line.Size loop if Text_Line.Text(L..L) /= " " and Text_Line.Text(L) /= Character'Val(9)then if Text_Line.Text(L..L+1) = "--" then Comment:=1; exit; else exit; end if; end if; end loop; if Comment = 1 then Comment:=0; else if Cont_Line >= Line_Top and Cont_Line <= Line_End then Find_Word(To_Lower(Text_Line.Text), Text_Line.Size,"type ",5,Status,Char_Position); if Status = True then Array_Position:=Find_Next_Arrayspace(Temp_Objects); Temp_Objects(Array_Position).No_Line.L_Declaration_Top:=Cont_Line; Temp_Objects(Array_Position).No_Character:= Char_Position; Temp_Objects(Array_Position).Classification:=Typet; Temp_Objects(Array_Position).Description.Text(1..(Text_Line.Size-Char_Position)+1):= Text_Line.Text(Char_Position..Text_Line.Size); Temp_Objects(Array_Position).Description.Size:=(Text_Line.Size-Char_Position)+1; end if; end if; end if; end loop; return Temp_Objects; end Check_Type_Inline; ---------------------------------------------------------------------------------------- -- Questa funzione è in grado di cercare in un determinato numero di righe una dichiarazione -- di variabile; se la trova, salva tutte le informazioni necessarie nell'array di oggetti. -- Line_Top e Line_End contengono i numeri delle righe del testo dove effettuare la -- ricerca (Line_Top -> da, Line_End -> a). function Check_V_Inline (File_Text: File_Type; Array_Objects : A_Objects; Line_Top : Integer; Line_End : Integer ) return A_Objects is Cont_Line : Integer; Temp_Objects : A_Objects; Str : R_Line; Comment : Integer; Ivar : Natural; Fvar : Natural; Idich : Natural; Fdich : Natural; Array_Position : Integer; First_Assestament : Integer; Last_Assestament : Integer; Temp_Lung_String : Integer; --- SOTTOFUNZIONI DI "Check_V_InLine" ----------------------------------------------- ------------------------------------------------------------------------------------- -- Questa procedure salva le informazioni riguardanti una variabile, nell'array di oggetti. procedure String_To_Record (Selector: in Integer ) is Comment_String: R_Line; Comment_Cont: INTEGER; begin Comment_Cont:=0; if Selector = 1 then Temp_Objects(Array_Position).No_Line.L_Declaration_Top:=Cont_Line; Temp_Objects(Array_Position).No_Character:=First_Assestament; Temp_Objects(Array_Position).Classification:= Variablet; Temp_Lung_String:= Last_Assestament-First_Assestament+1; Temp_Objects(Array_Position).Description.Text(1..(Temp_Lung_String)):= Str.Text(First_Assestament..Last_Assestament); Temp_Objects(Array_Position).Description.Size:=(Temp_Lung_String); else Temp_Objects(Array_Position).Description.Text(Temp_Lung_String+1..Temp_Lung_String+1):= ":"; Temp_Objects(Array_Position).Description.Size:=Temp_Lung_String+1; Temp_Objects(Array_Position).Description.Text(Temp_Lung_String+2.. Temp_Lung_String+(Last_Assestament-First_Assestament)+2):=Str.Text(First_Assestament..Last_Assestament); Temp_Objects(Array_Position).Description.Size:=Temp_Lung_String+(Last_Assestament-First_Assestament)+2; for T in 1..Str.Size loop if Str.Text(T..T+1) = "--" then for L in 1..T loop if Str.Text(T-L)/= ' ' AND Str.Text(T-L) /= Character'Val(9) then for I in T-L..Str.Size loop Comment_Cont:=Comment_Cont+1; Comment_String.Text(Comment_Cont):=Str.Text(I); Comment_String.Size:=Comment_Cont; end loop; exit; end if; end loop; Temp_Objects(Array_Position).Description.Text(Temp_Objects(Array_Position).Description.Size+1.. Temp_Objects(Array_Position).Description.Size+1+Comment_String.Size-1):= Comment_String.Text(1..Comment_String.Size); Temp_Objects(Array_Position).Description.Size:= Temp_Objects(Array_Position).Description.Size+1+Comment_String.Size-1; end if; end loop; end if; end String_To_Record; ------------------------------------------------------------------------------------- -- La procedura Assestament elimina gli spazi vuoti da una stringa. procedure Assestament (A,B : in out Natural ) is begin while Str.Text(A)=' ' or Str.Text(A) = Character'Val(9) loop A:=A+1; end loop; while Str.Text(B)=' ' or Str.Text(A) = Character'Val(9) loop B:=B-1; end loop; First_Assestament:= A; Last_Assestament:= B; end Assestament; ------------------------------------------------------------------------------------- begin Comment:=0; Array_Position:=0; Cont_Line:=0; Temp_Objects:=Array_Objects; while not End_Of_File(File_Text) loop Get_Line(File_Text, Str.Text, Str.Size); Cont_Line:=Cont_Line+1; if Cont_Line >= Line_Top and Cont_Line <= Line_End then -- Commento --------------------------- for L in 1..Str.Size loop if Str.Text(L..L) /= " " and Str.Text(L) /= Character'Val(9)then if Str.Text(L..L+1) = "--" then Comment:=1; exit; else exit; end if; end if; end loop; if Comment = 1 then Comment:=0; else Ivar:= 1; for I in 1..Str.Size loop if Str.Text(I) = ';' then Fdich:= I-1; for J in Ivar..I loop if Str.Text(J) = ':' then Idich:= J+1; for K in Ivar..J loop Array_Position:=Find_Next_Arrayspace(Temp_Objects); if Str.Text(K) = ',' then Fvar:= K-1; Assestament(Ivar, Fvar); String_To_Record(1); Assestament(Idich, Fdich); String_To_Record(2); Ivar:=K+1; elsif Str.Text(K)=':' then Fvar:= K-1; Assestament(Ivar,Fvar); String_To_Record(1); Assestament(Idich, Fdich); String_To_Record(2); end if; end loop; end if; end loop; Ivar:=I+1; end if; end loop; end if; end if; end loop; return Temp_Objects; end Check_V_Inline; ---------------------------------------------------------------------------------------- -- La funzione Check_V analizza tutto il testo; stabilisce in quali linee di testo potrebbero -- venire dichiarate delle variabili e in quel caso, chiama la funzione "Check_V_InLine" per -- ognuna di queste linee. function Check_V (In_File_Path : R_Line; Objects : A_Objects; No_Pro_Fun : Integer ) return A_Objects is Temp_Objects : A_Objects; Text_File : File_Type; begin Temp_Objects:=Objects; for T in 1..(No_Pro_Fun) loop if T /= No_Pro_Fun then if Temp_Objects(T+1).No_Line.L_Declaration_Top < Temp_Objects(T).No_Line.L_Begin then Open(Text_File, In_File, In_File_Path.Text(1..In_File_Path.Size)); Temp_Objects:=Check_V_Inline(Text_File, Temp_Objects, (Temp_Objects(T).No_Line.L_Declaration_End)+1, (Temp_Objects(T+1).No_Line.L_Declaration_Top)-1); Close(Text_File); else Open(Text_File, In_File, In_File_Path.Text(1..In_File_Path.Size)); Temp_Objects:=Check_V_Inline(Text_File,Temp_Objects, (Temp_Objects(T).No_Line.L_Declaration_End)+1, (Temp_Objects(T).No_Line.L_Begin)-1); Close(Text_File); end if; else Open(Text_File, In_File, In_File_Path.Text(1..In_File_Path.Size)); Temp_Objects:=Check_V_Inline(Text_File, Temp_Objects, (Temp_Objects(T).No_Line.L_Declaration_End)+1, (Temp_Objects(T).No_Line.L_Begin)-1); Close(Text_File); end if; end loop; return(Temp_Objects); end Check_V; ---------------------------------------------------------------------------------------- -- La funzione Check_Type analizza tutto il testo; stabilisce in quali linee di testo potrebbero -- venire dichiarati dei Tipi e in quel caso, chiama la funzione "Check_Type_InLine" per -- ognuna di queste linee. function Check_Type (In_File_Path : R_Line; Objects : A_Objects; No_Pro_Fun : Integer ) return A_Objects is Temp_Objects : A_Objects; Text_File : File_Type; begin Temp_Objects:=Objects; for T in 1..(No_Pro_Fun) loop if T /= No_Pro_Fun then if Temp_Objects(T+1).No_Line.L_Declaration_Top < Temp_Objects(T).No_Line.L_Begin then Open(Text_File, In_File, In_File_Path.Text(1..In_File_Path.Size)); Temp_Objects:=Check_Type_Inline(Text_File, Temp_Objects, (Temp_Objects(T).No_Line.L_Declaration_End)+1, (Temp_Objects(T+1).No_Line.L_Declaration_Top)-1); Close(Text_File); else Open(Text_File, In_File, In_File_Path.Text(1..In_File_Path.Size)); Temp_Objects:=Check_Type_Inline(Text_File,Temp_Objects, (Temp_Objects(T).No_Line.L_Declaration_End)+1, (Temp_Objects(T).No_Line.L_Begin)-1); Close(Text_File); end if; else Open(Text_File, In_File, In_File_Path.Text(1..In_File_Path.Size)); Temp_Objects:=Check_Type_Inline(Text_File, Temp_Objects, (Temp_Objects(T).No_Line.L_Declaration_End)+1, (Temp_Objects(T).No_Line.L_Begin)-1); Close(Text_File); end if; end loop; return(Temp_Objects); end Check_Type; ---------------------------------------------------------------------------------------- -- Questa funzione analizza tutto il testo e salva nell'array di oggetti tutte le -- procedure e le funzioni trovate. function Check_Pf (A_Objectspf : A_Objects; File_Txt : File_Type ) return A_Objects is ---- Inizializzazione variabili ---- Cont_Woc : Integer; Word_On_Cache : String (1 .. 200); Cont_Objects : Integer; Cont_Line : Integer; No_Objects : Integer; Cont_Char : Integer; Objectspf : A_Objects; Text_Line : R_Line; Comment : Integer; Search_Type : T_Classification; String_To_Check : R_Line; Found : Boolean; Cont_Searching : Integer; begin Comment:=0; Found:=False; Search_Type:= Nonet; String_To_Check.Text:= (others => ' '); String_To_Check.Size:=0; Cont_Searching:=0; Cont_Line:=0; Objectspf:=A_Objectspf; Cont_Objects:= 0; Cont_Char:=0; while not End_Of_File(File_Txt) loop Cont_Woc:=0; Cont_Line:= Cont_Line+1; Word_On_Cache:=(others => ' '); Text_Line.Text:= (others=> ' '); No_Objects:=0; for T in 1..100 loop if Objectspf(T).Classification /= Nonet then No_Objects:=No_Objects+1; else exit; end if; end loop; Get_Line(File_Txt, Text_Line.Text, Text_Line.Size); for I in 1..Text_Line.Size loop if Text_Line.Text(I..I) /= " " and Text_Line.Text(I) /=Character'Val(9) then Cont_Woc:=Cont_Woc+1; Word_On_Cache(Cont_Woc..Cont_Woc):=Text_Line.Text(I..I); if Text_Line.Text(I+1..I+1) = " " and Text_Line.Text(I+1) /=Character'Val(9) then -- Commento --------------------------- for L in 1..Cont_Woc loop if Word_On_Cache(L..L) /= " " and Word_On_Cache(L) /=Character'Val(9)then if Word_On_Cache(L..L+1) = "--" then Comment:=1; exit; else exit; end if; end if; end loop; if Comment = 1 then Word_On_Cache:=(others => ' '); Cont_Woc:=0; Comment:=0; exit; end if; -- Controllo Word_On_Cache ---------------- if To_Lower(Word_On_Cache(1..10)) = "procedure " or Search_Type =Proceduret then No_Objects:=No_Objects+1; Search_Type:=Proceduret; end if; if To_Lower(Word_On_Cache(1..9)) = "function " or Search_Type = Functiont then No_Objects:=No_Objects+1; Search_Type:=Proceduret; end if; if Search_Type /= Nonet then Cont_Searching:=Cont_Searching+1; -- Controllo se nella linea ce IS ---------- for W in 1..Text_Line.Size-2 loop if To_Lower(Text_Line.Text(W..W+2)) = " is" then Found:=True; end if; end loop; -- ----------------------------------------- if Found = True then if String_To_Check.Size = 0 then String_To_Check.Text(1..Text_Line.Size):=Text_Line.Text(1..Text_Line.Size); String_To_Check.Size:=Text_Line.Size; else String_To_Check.Text(String_To_Check.Size+1..(String_To_Check.Size)+Text_Line.Size):= Text_Line.Text(1..Text_Line.Size); String_To_Check.Size:=(String_To_Check.Size+1)+Text_Line.Size; end if; -- FUNZIONE PULISCI STRINGA----------------- for E in 1..String_To_Check.Size loop for U in 1..String_To_Check.Size loop if String_To_Check.Text(U..U+1) = " " then String_To_Check.Size:=String_To_Check.Size-1; for Q in U..String_To_Check.Size loop String_To_Check.Text(Q..Q):=String_To_Check.Text(Q+1..Q+1); end loop; exit; end if; if String_To_Check.Text(U) = Character'Val(9) then String_To_Check.Text(U):= ' '; end if; end loop; end loop; String_To_Check.Size:=String_To_Check.Size-2; ------------------------------------------- if Search_Type= Proceduret then Objectspf(No_Objects):=Pf_Stringtoarray(Proceduret,(Cont_Line-Cont_Searching)+1, Cont_Line, I-8, String_To_Check.Text); else Objectspf(No_Objects):=Pf_Stringtoarray(Functiont,(Cont_Line-Cont_Searching)+1, Cont_Line, I-8, String_To_Check.Text); end if; Search_Type:=Nonet; Found:=False; Cont_Searching:=0; String_To_Check.Text:=(others => ' '); String_To_Check.Size:= 0; else String_To_Check.Text(String_To_Check.Size+1..(String_To_Check.Size)+Text_Line.Size):= Text_Line.Text(1..Text_Line.Size); String_To_Check.Size:=(String_To_Check.Size)+Text_Line.Size; end if; exit; end if; if To_Lower(Word_On_Cache(1..5)) = "begin" then for I in 1..No_Objects loop if Objectspf(No_Objects+1 - I).No_Line.L_Begin = 0 then Objectspf(No_Objects+1 - I).No_Line.L_Begin:=Cont_Line; exit; end if; end loop; exit; end if; ------------------------------------ Word_On_Cache:=(others => ' '); Cont_Woc:=0; end if; end if; end loop; Cont_Woc:=0; Word_On_Cache:=(others => ' '); end loop; return Objectspf; end Check_Pf; ------------------------------------------------------------------------------------------------ begin ----- Inizializzazione delle variabili ------------------- for I in 1..100 loop Objects(I).Description.Text:=(others=> ' '); Objects(I).Description.Size:=0; Objects(I).Classification:= Nonet; Objects(I).No_Line.L_Declaration_Top:=0; Objects(I).No_Line.L_Begin:=0; end loop; No_Pro_Fun:=0; ---- Controllo se l'utente ha passato parametri if Argument_Count = 0 then raise Help_Error; end if; ---- Controllo il numero di parametri passati if Argument_Count = 1 then raise LostArgument_Error; end if; ---- Assegno i parametri alle variabili In_File_Path.Text(1..Argument(1)'Last):=Argument(1)(1..Argument(1)'Last); In_File_Path.Size:= Argument(1)'Last; Out_File_Path.Text(1..Argument(2)'Last):=Argument(2)(1..Argument(2)'Last); Out_File_Path.Size:= Argument(2)'Last; ---- Apro il file New_Line; Put("Status ---> Opening file"); Open(Text_File, In_File, In_File_Path.Text(1..In_File_Path.Size)); -- Apertura del file New_Line; Put(" Done"); New_Line(2); ---- Cerco le procedure e le funzioni Put("Status ---> Looking for procedures and functions"); Objects:=Check_Pf(Objects,Text_File); -- Ricerca di tutte le procedure e funzioni New_Line; Close(Text_File); Put(" Done"); New_Line(2); ---- Conto il numero di procedure e funzioni trovate No_Pro_Fun:= Find_Next_ArraySpace(Objects)-1; ---- Cerco le dichiarazioni di variabili Put("Status ---> Looking for variables"); Objects:=Check_V(In_File_Path, Objects, No_Pro_Fun); -- Ricerca delle dichiarazione delle varibili New_Line; Put(" Done"); New_Line(2); ---- Cerco le dichiarazioni di tipi Put("Status ---> Looking for Type definition"); Objects:=Check_Type(In_File_Path, Objects, No_Pro_Fun); -- Ricerca delle dichiarazione dei tipi ---- Ordino l'array di oggetti No_Objects:=(Find_Next_Arrayspace(Objects))-1; Objects:=Arrange_Objects(Objects, No_Objects); -- Riordino l'array di oggetti. Create(Text_File, Out_File, Out_File_Path.Text(1..Out_File_Path.Size)); Spaces:=0; New_Line; Put(" Done"); New_Line(2); ---- Scrittura su file Put("Status ---> Writing output file"); Put(Text_File,"Cross Reference of file '"); Put(Text_File,In_File_Path.Text(1..In_File_Path.Size)); Put(Text_File,"'."); New_Line(Text_File,2); for I in 1..((Find_Next_Arrayspace(Objects))-1) loop Put(Text_File,"("); Put(Text_File,Objects(I).No_Line.L_Declaration_Top,1); Put(Text_File,","); Put(Text_File,Objects(I).No_Character,1); Put(Text_File,") "); Put(Text_File,Objects(I).Description.Text(1..Objects(I).Description.Size)); if Objects(I+1).Classification = Proceduret or Objects(I+1).Classification = Functiont then New_Line(Text_File,2); else New_Line(Text_File,1); end if; for T in 1..I loop if Objects(I+1).No_Line.L_Declaration_Top < Objects(T).No_Line.L_Begin then Spaces:=Spaces+1; end if; end loop; for T in 1..Spaces loop Put(Text_File,Character'Val(9)); end loop; Spaces:=0; end loop; Close(Text_File); New_Line; Put(" Done"); New_Line(2); Put("Completed successfully."); ---------------------------------------------------------------------------------- exception when Name_Error => New_Line; Put(" Error --> Source file non found. Try check the path.");New_Line;Put(" "); when Constraint_Error => New_Line; Put(" Error --> Programm error reported.");New_Line; Put(" Possible cause: The source file was not compiled");New_Line; Put(" correctely, or it is not an Ada95");New_Line; Put(" source file."); New_Line; Put(" "); when Help_Error => New_Line; Put("Usage: crossreference SourceFile.path OutputTextFile.path");New_Line(2); Put(" Where SourceFile.path is the path of the source file to check and");New_Line; Put(" OutputTextFile.path is the path of a text file for writing the Output.");New_Line(2); Put(" If OutputTextFile doesn't exist, will be created.");New_Line; Put(" "); when LostArgument_Error => New_Line; Put("Error --> One argument is missing. For usage, type crossreference");New_Line; Put(" "); end Main;