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

Start parsing root data views

require update in DMT
work in progress
parent 5cc18f34
-- ************************ TASTE AADL Parser ************************** --
-- Based on Ocarina **************************************************** --
-- (c) 2017 European Space Agency - maxime.perrotin@esa.int
-- (c) 2018 European Space Agency - maxime.perrotin@esa.int
-- LGPL license, see LICENSE file
with GNAT.Command_Line,
......@@ -120,6 +120,7 @@ package body TASTE.AADL_Parser is
Deployment_Root := Ocarina.Parser.Parse
(AADL_Language, Deployment_Root, File_Descr);
end if;
-- Also parse the data view as a root component
Dataview_root := Ocarina.Parser.Parse
(AADL_Language, Dataview_root, File_Descr);
end if;
......@@ -138,6 +139,8 @@ package body TASTE.AADL_Parser is
Result.Deployment_View := Parse_Deployment_View (Deployment_Root);
end if;
Result.Data_View := Parse_Data_View (Dataview_root);
Ocarina.Configuration.Reset_Modules;
Ocarina.Reset;
......@@ -148,6 +151,7 @@ package body TASTE.AADL_Parser is
| Function_Error
| No_RCM_Error
| Deployment_View_Error
| Data_View_Error
| Device_Driver_Error =>
Put (Red_Bold & "[ERROR] " & White_Bold);
Put_Line (Exception_Message (Error) & No_Color);
......@@ -177,6 +181,8 @@ package body TASTE.AADL_Parser is
Put_Line ("==== Dump of the Deployment View ====");
Model.Deployment_View.Debug_Dump;
end if;
Put_Line ("==== Dump of the Data View ====");
Model.Data_View.Debug_Dump;
Put_Line ("==== Dump of the Command Line ====");
Model.Configuration.Debug_Dump;
end Dump;
......
......@@ -6,12 +6,14 @@
with Ocarina.Types,
TASTE.Parser_Utils,
TASTE.Interface_View,
TASTE.Deployment_View;
TASTE.Deployment_View,
TASTE.Data_View;
use Ocarina.Types,
TASTE.Parser_Utils,
TASTE.Interface_View,
TASTE.Deployment_View;
TASTE.Deployment_View,
TASTE.Data_View;
package TASTE.AADL_Parser is
Interface_Root : Node_Id := No_Node;
......@@ -22,6 +24,7 @@ package TASTE.AADL_Parser is
record
Interface_View : Complete_Interface_View;
Deployment_View : Complete_Deployment_View;
Data_View : Taste_Data_View;
Configuration : Taste_Configuration;
end record;
......
-- *************************** taste aadl parser *********************** --
-- (c) 2017 European Space Agency - maxime.perrotin@esa.int
-- LGPL license, see LICENSE file
-- Interface View parser
with Ada.Text_IO,
Locations,
Ocarina.Instances.Queries,
Ocarina.Analyzer,
Ocarina.Backends.Properties,
Ocarina.Options,
Ocarina.Files,
Ocarina.FE_AADL.Parser,
Ocarina.Parser,
Ocarina.Instances,
Ocarina.ME_AADL.AADL_Instances.Nodes,
Ocarina.Namet,
Ocarina.ME_AADL.AADL_Instances.Entities;
package body TASTE.Data_View is
use Ada.Text_IO,
Locations,
Ocarina.Instances.Queries,
Ocarina.Namet,
Ocarina.Analyzer,
Ocarina.Backends.Properties,
Ocarina.Options,
Ocarina.Instances,
Ocarina.ME_AADL.AADL_Instances.Nodes,
Ocarina.ME_AADL.AADL_Instances.Entities,
Ocarina.ME_AADL;
----------------------------
-- AST Builder Functions --
----------------------------
function Parse_Data_View (Dataview_Root : Node_Id) return Taste_Data_View
is
DV_Root : Node_Id := Dataview_Root;
use type ASN1_Maps.Map;
System : Node_Id;
Files : ASN1_Maps.Map;
Current_Type : Node_Id;
function Parse_Type (Data_Type : Node_Id) return ASN1_File is
Asntype : constant Node_Id := Corresponding_Instance (Data_Type);
Name : constant String := Get_Name_String
(Get_Type_Source_Name (Asntype));
begin
Put_Line ("Data type : " & AIN_Case (Data_Type));
Put_Line (" |_" & Name);
Put_Line (" |_ Module : " & Get_Name_String
(Get_String_Property (Asntype,
Get_String_Name ("taste::ada_package_name"))));
Put_Line (" |_ File : " & Get_Name_String
(Get_Source_Text (Asntype)(1)));
return ASN1_File'(Path => US (Name),
Modules => String_Vectors.Empty_Vector); -- TODO
end Parse_Type;
F : Name_Id;
Loc : Location;
begin
Ocarina.FE_AADL.Parser.Add_Pre_Prop_Sets := True;
-- Parse all AADL files possibly needed to instantiate the model
for Each of Data_View_AADL_Lib loop
Set_Str_To_Name_Buffer (Each);
F := Ocarina.Files.Search_File (Name_Find);
Loc := Ocarina.Files.Load_File (F);
DV_Root := Ocarina.Parser.Parse (Get_String_Name ("aadl"),
DV_Root, Loc);
end loop;
if not Ocarina.Analyzer.Analyze (AADL_Language, DV_Root) then
raise Data_View_Error with "Could not analyse Data View";
end if;
Ocarina.Options.Root_System_Name :=
Get_String_Name ("taste_dataview.others");
System := Root_System (Instantiate_Model (Root => DV_Root));
if No (System) then
raise Data_View_Error with "Could not instantiate Data View";
end if;
Current_Type := AIN.First_Node (AIN.Subcomponents (System));
while Present (Current_Type) loop
if Get_Category_Of_Component (Current_Type) /= CC_Data then
raise Data_View_Error with "Component is not a data type!";
end if;
declare
Type_File : constant ASN1_File := Parse_Type (Current_Type);
begin
Files.Insert (Key => To_String (Type_File.Path),
New_Item => Type_File);
Current_Type := AIN.Next_Node (Current_Type);
end;
end loop;
return Data_AST : constant Taste_Data_View := (ASN1_Files => Files);
end Parse_Data_View;
procedure Debug_Dump (DV : Taste_Data_View) is
begin
for Each of DV.ASN1_Files loop
Put_Line ("Name : " & To_String (Each.Path));
for Module of Each.Modules loop
Put_Line (" |_Module : " & Module);
end loop;
end loop;
end Debug_Dump;
end TASTE.Data_View;
-- *************************** taste aadl parser *********************** --
-- (c) 2018 European Space Agency - maxime.perrotin@esa.int
-- LGPL license, see LICENSE file
-- Data View parser
with Ocarina,
Ocarina.Types,
Ada.Containers.Indefinite_Ordered_Maps,
Ada.Strings.Unbounded,
TASTE.Parser_Utils;
use Ocarina,
Ocarina.Types,
Ada.Containers,
Ada.Strings.Unbounded,
TASTE.Parser_Utils;
package TASTE.Data_View is
use String_Vectors;
-- Exceptions specific to the Data View
Data_View_Error : exception;
-- Extra files needed to parse the Data view (dependency hell)
Data_View_AADL_Lib : String_Vectors.Vector := Empty_Vector &
"aadl_project.aadl" &
"taste_properties.aadl" &
"communication_properties.aadl" &
"timing_properties.aadl" &
"programming_properties.aadl" &
"memory_properties.aadl" &
"base_types.aadl" &
"data_model.aadl" &
"deployment.aadl";
type ASN1_File is
record
Path : Unbounded_String;
Modules : String_Vectors.Vector;
end record;
package ASN1_Maps is new Indefinite_Ordered_Maps (String, ASN1_File);
type Taste_Data_View is tagged
record
ASN1_Files : ASN1_Maps.Map;
end record;
function Parse_Data_View (Dataview_Root : Node_Id) return Taste_Data_View
with Pre => Dataview_Root /= No_Node;
procedure Debug_Dump (DV : Taste_Data_View);
end TASTE.Data_View;
package TASTE.Parser_Version is
Parser_Release : constant String :=
"9cc8a70 ; Commit Date: Wed Jan 3 21:04:13 2018 ";
"5cc18f3 ; Commit Date: Thu Jan 4 10:12:46 2018 ";
Ocarina_Version : constant String :=
"Ocarina 2017.x (Working Copy from rd078c54)";
"Ocarina 2017.x (Working Copy from r0b92ed3)";
end TASTE.Parser_Version;
\ No newline at end of file
......@@ -547,4 +547,16 @@ PROPERTIES
Data_Model::Data_Representation => Struct;
END T_Boolean_Buffer.impl;
-- Added manually to allow parsing of the data view even when no interface references a data type
SYSTEM Taste_DataView
END Taste_DataView;
SYSTEM IMPLEMENTATION Taste_DataView.others
SUBCOMPONENTS
T_Boolean : DATA T_BOOLEAN;
My_Enum : DATA MyEnum;
END Taste_DataView.others;
end DataView;
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