55
56
Framework.Language,
58
Framework.Rules_Manager,
59
Framework.Specific_Plugs;
59
61
procedure Adactl is
60
62
use Ada.Characters.Handling, Ada.Exceptions, Ada.Calendar;
61
63
use Asis.Exceptions, Asis.Implementation;
62
64
use Utilities, Adactl_Options;
66
Version : constant Wide_String := "1.5r24";
65
69
OK : constant Ada.Command_Line.Exit_Status := 0;
66
70
Checks_Failed : constant Ada.Command_Line.Exit_Status := 1;
72
76
use Framework.Language;
78
Thick_Queries.Set_Error_Procedure (Utilities.Failure'access);
77
if Action /= Help then
82
if Action not in No_Asis_Actions then
81
86
User_Log ("Loading units, please wait...");
82
87
Asis.Implementation.Initialize (Initialize_String);
83
Asis.Ada_Environments.Associate (Ruler.My_Context, "Adactl", Asis_Options);
84
Asis.Ada_Environments.Open (Ruler.My_Context);
88
Asis.Ada_Environments.Associate (Framework.Adactl_Context, "Adactl", Asis_Options);
89
Asis.Ada_Environments.Open (Framework.Adactl_Context);
85
90
Units_List.Register (Unit_Spec => Ada_Units_List,
86
91
Recursive => Recursive_Option,
87
92
Add_Stubs => False,
88
My_Context => Ruler.My_Context);
93
My_Context => Framework.Adactl_Context);
93
null; -- Help message printed from Analyse_Options
99
User_Message ("Rules:");
100
Framework.Rules_Manager.Help_Names;
102
User_Message ("ADACTL v. "
104
& Choose (Framework.Specific_Plugs.Specific_Version = "",
106
'-' & Framework.Specific_Plugs.Specific_Version)
107
& ", ASIS version: " & ASIS_Implementor_Version);
108
User_Message ("Copyright (C) 2004-2006 Eurocontrol/Adalog and others.");
109
User_Message ("This software is covered by the GNU Modified General Public License.");
112
Execute (Command_Line_Commands);
95
114
when Dependents =>
96
115
Execute (Command_Line_Commands); -- For a possible -o option
122
Asis.Ada_Environments.Close (Ruler.My_Context);
123
Asis.Ada_Environments.Dissociate (Ruler.My_Context);
124
Asis.Implementation.Finalize;
144
if Action > Check then
145
Asis.Ada_Environments.Close (Framework.Adactl_Context);
146
Asis.Ada_Environments.Dissociate (Framework.Adactl_Context);
147
Asis.Implementation.Finalize;
129
153
if Framework.Language.Had_Failure then
130
154
Ada.Command_Line.Set_Exit_Status (Failure);
131
elsif Framework.Reports.Error_Reported then
155
elsif Framework.Language.Had_Errors then
156
Ada.Command_Line.Set_Exit_Status (Bad_Command);
157
elsif Framework.Reports.Nb_Errors > 0 then
132
158
Ada.Command_Line.Set_Exit_Status (Checks_Failed);
134
160
Ada.Command_Line.Set_Exit_Status (OK);
138
164
Exec_Time_String : constant Wide_String
139
165
:= Integer'Wide_Image (Integer ((Clock - Start_Time)*10));
141
User_Log ("Execution_Time: "
142
& Choose (Exec_Time_String (2 .. Exec_Time_String'Last - 1), "0")
144
& Exec_Time_String (Exec_Time_String'Last)
167
if Framework.Language.Had_Errors then
168
User_Log ("Syntax errors found");
169
elsif Action = Check then
170
User_Log ("No syntax error");
172
User_Log ("Total execution time: "
173
& Choose (Exec_Time_String (2 .. Exec_Time_String'Last - 1), "0")
175
& Exec_Time_String (Exec_Time_String'Last)
150
182
when Occur : Options_Error | Units_List.Specification_Error =>
151
Ada.Command_Line.Set_Exit_Status (Bad_Command);
152
183
User_Message ("Parameter or option error: " & To_Wide_String (Ada.Exceptions.Exception_Message (Occur)));
153
184
User_Message ("try -h for help");
155
when Occur : Utilities.User_Error =>
156
User_Message ("Error in rule: " & To_Wide_String (Ada.Exceptions.Exception_Message (Occur)));
185
Ada.Command_Line.Set_Exit_Status (Bad_Command);
158
187
when Asis.Exceptions.ASIS_Failed =>
160
189
when Asis.Errors.Use_Error =>
190
User_Message (Diagnosis);
161
191
Ada.Command_Line.Set_Exit_Status (Bad_Command);
162
User_Message (Diagnosis);
164
193
Ada.Command_Line.Set_Exit_Status (Failure);
165
raise; -- To get stack trace
195
-- Unfortunately, GNAT sets the exit status to 1 when terminating on unhandled exception
196
-- Therefore, we reraise the exception (to get stack trace) only with -x option
201
when Occur : Asis.Exceptions.ASIS_Inappropriate_Context
202
| Asis.Exceptions.ASIS_Inappropriate_Compilation_Unit
203
| Asis.Exceptions.ASIS_Inappropriate_Element
204
| Asis.Exceptions.ASIS_Inappropriate_Line
205
| Asis.Exceptions.ASIS_Inappropriate_Line_Number
207
-- Presumably, an Adactl error
208
User_Message ("Unexpected ASIS exception at main level ("
209
& To_Wide_String (Ada.Exceptions.Exception_Name (Occur))
211
& To_Wide_String (Ada.Exceptions.Exception_Message (Occur)));
212
User_Message (Diagnosis);
213
Ada.Command_Line.Set_Exit_Status (Failure);
215
-- Unfortunately, GNAT sets the exit status to 1 when terminating on unhandled exception
216
-- Therefore, we reraise the exception (to get stack trace) only with -x option
220
when Occur : others =>
221
User_Message ("Unexpected exception at main level: "
222
& To_Wide_String (Ada.Exceptions.Exception_Message (Occur)));
223
Ada.Command_Line.Set_Exit_Status (Failure);
225
-- Unfortunately, GNAT sets the exit status to 1 when terminating on unhandled exception
226
-- Therefore, we reraise the exception (to get stack trace) only with -x option