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

Cleanup a bit

parent 40f12023
......@@ -11,12 +11,8 @@ with GNAT.Command_Line,
Locations,
Ocarina.Namet,
Ocarina.Types,
Ocarina.Analyzer,
Ocarina.Configuration,
Ocarina.Files,
Ocarina.Options,
Ocarina.Instances,
Ocarina.ME_AADL.AADL_Instances.Nodes,
Ocarina.Parser,
Parser_Utils,
Interface_View,
......@@ -28,22 +24,17 @@ use Ada.Text_IO,
Ocarina.Namet,
Ocarina.Types,
Ocarina,
Ocarina.Analyzer,
Ocarina.Instances,
Ocarina.ME_AADL,
Ocarina.ME_AADL.AADL_Instances.Nodes,
Parser_Utils,
Interface_View,
Deployment_View,
GNAT.OS_Lib;
procedure AADL_Parser is
AADL_Language : Name_Id;
Interface_Root : Node_Id := No_Node;
Deployment_root : Node_Id := No_Node;
Dataview_root : Node_ID := No_Node;
Success : Boolean;
IV_AST : Complete_Interface_View;
DV_AST : Complete_Deployment_View;
Interface_Root : Node_Id := No_Node;
Deployment_root : Node_Id := No_Node;
Dataview_root : Node_ID := No_Node;
----------------
-- Initialize --
----------------
......@@ -52,10 +43,16 @@ procedure AADL_Parser is
File_Name : Name_Id;
File_Descr : Location;
begin
AADL_Language := Get_String_Name ("aadl");
Banner;
-- Parse arguments before initializing Ocarina, otherwise Ocarina eats
-- some arguments (all file parameters).
Parse_Command_Line (Current_Config);
Initialize_Ocarina;
Dump_Configuration (Current_Config);
AADL_Language := Get_String_Name ("aadl");
if Current_Config.Interface_View.all'Length = 0 then
Current_Config.Interface_View := Default_Interface_View'Access;
end if;
......@@ -144,47 +141,16 @@ procedure AADL_Parser is
Dataview_root := Ocarina.Parser.Parse
(AADL_Language, Dataview_root, File_Descr);
end if;
if No (Interface_Root) then
raise AADL_Parser_Error with "Internal error - please report.";
end if;
-- Analyze the tree
Success := Ocarina.Analyzer.Analyze (AADL_Language, Interface_Root);
if not Success then
raise AADL_Parser_Error with "Could not analyse model";
end if;
end Initialize;
IV_Root : Node_Id;
IV_AST : Complete_Interface_View;
DV_AST : Complete_Deployment_View;
begin
Banner;
-- Parse arguments before initializing Ocarina, otherwise Ocarina eats
-- some arguments (all file parameters).
Parse_Command_Line (Current_Config);
Initialize_Ocarina;
Initialize;
-- First, we analyze the interface view.
Ocarina.Options.Root_System_Name :=
Get_String_Name ("interfaceview.others");
IV_Root := Root_System (Instantiate_Model (Root => Interface_Root));
IV_AST := Parse_Interface_View (IV_Root);
IV_AST := Parse_Interface_View (Interface_Root);
IV_AST.Debug_Dump;
-- Now, we are done with the interface view. We now analyze the
-- deployment view.
if Current_Config.Deployment_View.all'Length > 0 then
AADL_Lib.Append (Current_Config.Interface_View.all);
DV_AST := Parse_Deployment_View (Deployment_Root);
DV_AST.Debug_Dump;
end if;
......
......@@ -55,9 +55,10 @@ package body Deployment_View is
Ocarina.FE_AADL.Parser.Add_Pre_Prop_Sets := True;
-- Parse all AADL files possibly needed to instantiate the model
-- (Including the Interface View)
for each of AADL_Lib loop
Set_Str_To_Name_Buffer (each);
-- Add the interface view, first...
AADL_Lib.Append (Current_Config.Interface_View.all);
for Each of AADL_Lib loop
Set_Str_To_Name_Buffer (Each);
F := Ocarina.Files.Search_File (Name_Find);
Loc := Ocarina.Files.Load_File (F);
Root_Depl := Ocarina.Parser.Parse (Get_String_Name ("aadl"),
......
......@@ -7,9 +7,12 @@
with Ada.Text_IO,
Ada.Exceptions,
Ocarina.Instances.Queries,
Ocarina.Namet,
Ocarina.Analyzer,
Ocarina.Options,
Ocarina.Instances,
Ocarina.ME_AADL.AADL_Instances.Nodes,
Ocarina.ME_AADL.AADL_Instances.Nutils,
Ocarina.Namet,
Ocarina.ME_AADL.AADL_Instances.Nutils,
Ocarina.ME_AADL.AADL_Instances.Entities,
Ocarina.Backends.Utils;
-- Ada.Characters.Latin_1;
......@@ -20,9 +23,11 @@ package body Interface_View is
Ada.Exceptions,
Ocarina.Instances.Queries,
Ocarina.Namet,
Ocarina.Analyzer,
Ocarina.Options,
Ocarina.Instances,
Ocarina.ME_AADL.AADL_Instances.Nodes,
Ocarina.ME_AADL.AADL_Instances.Nutils,
-- Ada.Characters.Latin_1,
Ocarina.ME_AADL.AADL_Instances.Entities,
Ocarina.ME_AADL,
Ocarina.Backends.Utils;
......@@ -250,7 +255,7 @@ package body Interface_View is
-- AST Builder Functions --
---------------------------
function Parse_Interface_View (System : Node_Id)
function Parse_Interface_View (Interface_Root : Node_Id)
return Complete_Interface_View
is
-- use type Functions.Vector;
......@@ -258,6 +263,8 @@ package body Interface_View is
use type Ctxt_Params.Vector;
use type Parameters.Vector;
use type Connection_Maps.Map;
System : Node_Id;
Success : Boolean;
Functions : Function_Maps.Map;
Routes_Map : Connection_Maps.Map;
Current_Function : Node_Id;
......@@ -596,8 +603,23 @@ package body Interface_View is
return Is_Terminal;
end Rec_Function;
begin
if No (Interface_Root) then
raise Interface_Error with "Interface View parsing error";
end if;
Success := Ocarina.Analyzer.Analyze (AADL_Language, Interface_Root);
if not Success then
raise Interface_Error with "Could not analyse Interface View";
end if;
Ocarina.Options.Root_System_Name :=
Get_String_Name ("interfaceview.others");
System := Root_System (Instantiate_Model (Root => Interface_Root));
if No (System) then
raise Interface_Error with "Missing or erroneous interface view";
raise Interface_Error with "Could not instantiate Interface View";
end if;
Current_Function := AIN.First_Node (AIN.Subcomponents (System));
......
......@@ -161,9 +161,9 @@ package Interface_View is
end record;
-- Function to build up the Ada AST by transforming the one from Ocarina
function Parse_Interface_View (System : Node_Id)
function Parse_Interface_View (Interface_Root : Node_Id)
return Complete_Interface_View
with Pre => System /= No_Node;
with Pre => Interface_Root /= No_Node;
-- Model transformation API: Rename a function
procedure Rename_Function (IV : in out Complete_Interface_View;
......
......@@ -26,6 +26,7 @@ use Ocarina,
package Parser_Utils is
AADL_Language : Name_Id;
Default_Interface_View : aliased String := "InterfaceView.aadl";
Default_Deployment_View : aliased String := "DeploymentView.aadl";
Default_Data_View : aliased String := "DataView.aadl";
......
package Parser_Version is
Parser_Release : constant String :=
"56aed8f ; Commit Date: Thu Dec 21 10:41:52 2017 ";
"40f1202 ; Commit Date: Thu Dec 21 14:57:26 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