Commit e8c8f945 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Replace OS_Exit with exception

parent 26af2bc4
......@@ -5,6 +5,8 @@
pragma Warnings (Off);
with Ada.Strings.Unbounded,
Ada.Command_Line,
Ada.Exceptions,
Ada.Text_IO,
Ada.Containers.Indefinite_Vectors,
GNAT.OS_Lib,
......@@ -27,6 +29,7 @@ with Ada.Strings.Unbounded,
use Ada.Strings.Unbounded,
Ada.Text_IO,
Ada.Exceptions,
Locations,
Ocarina.Namet,
Ocarina.Types,
......@@ -146,7 +149,7 @@ procedure AADL_Parser is
-- -- Analyze the tree
--
-- Success := Ocarina.Analyzer.Analyze (AADL_Language, My_Root);
-- Exit_On_Error (not Success, "[ERROR] Deployment view is incorrect");
-- Exit_On_Error (not Success, "Deployment view is incorrect");
-- if Success then
-- -- After making sure that the Deployment view is correct, set
-- -- the Glue flag
......@@ -460,7 +463,7 @@ procedure AADL_Parser is
--
-- else
-- Exit_On_Error (true,
-- "[ERROR] Device configuration is incorrect (" &
-- "Device configuration is incorrect (" &
-- Get_Name_String (Name (Identifier (Tmp_CI))) &
-- ")");
-- end if;
......@@ -841,7 +844,7 @@ procedure AADL_Parser is
:= GNAT.OS_Lib.Locate_Exec_On_Path ("ocarina");
begin
Exit_On_Error (S = null,
"[ERROR] ocarina is not in your PATH");
"Ocarina is not in your PATH");
GNAT.OS_Lib.Setenv ("OCARINA_PATH", S.all (S'First .. S'Last - 12));
end;
......@@ -862,10 +865,10 @@ procedure AADL_Parser is
Parse_Command_Line;
Exit_On_Error (Interface_View = 0, "Error: Missing Interface view!");
Exit_On_Error (Interface_View = 0, "Missing Interface view!");
Set_Str_To_Name_Buffer (Ada.Command_Line.Argument (Interface_View));
FN := Ocarina.Files.Search_File (Name_Find);
Exit_On_Error (FN = No_Name, "Error: Missing Interface view!");
Exit_On_Error (FN = No_Name, "Missing Interface view!");
B := Ocarina.Files.Load_File (FN);
-- C_Set_Interfaceview
-- (Ada.Command_Line.Argument (Interface_View),
......@@ -891,7 +894,7 @@ procedure AADL_Parser is
Deployment_Root := Ocarina.Parser.Parse
(AADL_Language, Deployment_Root, B);
Exit_On_Error (Deployment_Root = No_Node,
"[ERROR] Deployment view is incorrect");
"Deployment view is incorrect");
end if;
-- Missing data view is actually not an error.
......@@ -901,7 +904,7 @@ procedure AADL_Parser is
Set_Str_To_Name_Buffer (Ada.Command_Line.Argument (Data_View));
FN := Ocarina.Files.Search_File (Name_Find);
Exit_On_Error (FN = No_Name, "[ERROR] Cannot find Data View");
Exit_On_Error (FN = No_Name, "Cannot find Data View");
-- C_Set_Dataview
-- (Ada.Command_Line.Argument (Data_View),
-- Ada.Command_Line.Argument (Data_View)'Length);
......@@ -916,13 +919,12 @@ procedure AADL_Parser is
(AADL_Language, Dataview_root, B);
end if;
Exit_On_Error (No (Interface_Root),
"[ERROR] AADL Parser Internal error");
Exit_On_Error (No (Interface_Root), "AADL Parser Internal error");
-- Analyze the tree
Success := Ocarina.Analyzer.Analyze (AADL_Language, Interface_Root);
Exit_On_Error (not Success, "Internal Error, cannot analyze model.");
Exit_On_Error (not Success, "Cannot analyze model.");
end Initialize;
......@@ -960,6 +962,10 @@ begin
Ocarina.Configuration.Reset_Modules;
Ocarina.Reset;
exception
when Error : AADL_Parser_Error =>
Put ("[ERROR] ");
Put_Line (Exception_Message (Error));
OS_Exit (1);
when E : others =>
Errors.Display_Bug_Box (E);
end AADL_Parser;
......@@ -3,7 +3,7 @@
-- LGPL license, see LICENSE file
with Ada.Text_IO,
GNAT.OS_Lib,
-- GNAT.OS_Lib,
Parser_Version,
Ocarina.AADL_Values,
Ocarina.Instances.Queries,
......@@ -15,7 +15,7 @@ with Ada.Text_IO,
package body Parser_Utils is
use Ada.Text_IO,
GNAT.OS_Lib,
-- GNAT.OS_Lib,
Ocarina.Instances.Queries,
Ocarina.ME_AADL.AADL_Instances.Nutils,
Ada.Characters.Latin_1,
......@@ -96,8 +96,7 @@ package body Parser_Utils is
procedure Exit_On_Error (Error : Boolean; Reason : String) is
begin
if Error then
Put_Line (Reason);
OS_Exit (1);
raise AADL_Parser_Error with Reason;
end if;
end Exit_On_Error;
......@@ -377,7 +376,7 @@ package body Parser_Utils is
& Get_Name_String (ASN1_Basic_Type_N);
end if;
end if;
Exit_On_Error (True, "Error: ASN.1 Basic type undefined!");
Exit_On_Error (True, "ASN.1 Basic type undefined!");
return ASN1_Unknown;
end Get_ASN1_Basic_Type;
......@@ -423,7 +422,7 @@ package body Parser_Utils is
-- If RI_Name has no value it means the interface view misses the
-- AADL property "TASTE::InterfaceName". Not supported.
Exit_On_Error (RI_Name = No_Name,
"[ERROR] Interface view contains errors "
"Interface view contains errors "
& "(Missing TASTE::InterfaceName properties)"
& ASCII.CR & ASCII.LF
& " Try updating it with taste-edit-project");
......
......@@ -35,6 +35,8 @@ package Parser_Utils is
procedure Usage;
AADL_Parser_Error : exception;
procedure Exit_On_Error (Error : Boolean; Reason : String);
type Synchronism is (Sync, Async);
......
package Parser_Version is
Parser_Release : constant String :=
"027ef61 ; Commit Date: Mon Nov 27 15:01:23 2017 ";
"26af2bc ; Commit Date: Tue Nov 28 10:15:49 2017 ";
Ocarina_Version : constant String :=
"Ocarina 2017.x (Working Copy from r0b92ed3)";
end Parser_Version;
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment