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

Parse data view

parent 53a8b63f
...@@ -218,7 +218,7 @@ package body TASTE.AADL_Parser is ...@@ -218,7 +218,7 @@ package body TASTE.AADL_Parser is
Mode => Out_File, Mode => Out_File,
Name => Output_Path & "/commandline.dump"); Name => Output_Path & "/commandline.dump");
Put_Info ("Dump of the Command Line"); Put_Info ("Dump of the Command Line");
Model.Configuration.Debug_Dump; Model.Configuration.Debug_Dump (Output);
Close (Output); Close (Output);
end if; end if;
exception exception
......
...@@ -37,29 +37,12 @@ package body TASTE.Data_View is ...@@ -37,29 +37,12 @@ package body TASTE.Data_View is
function Parse_Data_View (Dataview_Root : Node_Id) return Taste_Data_View function Parse_Data_View (Dataview_Root : Node_Id) return Taste_Data_View
is is
DV_Root : Node_Id := Dataview_Root; DV_Root : Node_Id := Dataview_Root;
use type ASN1_Maps.Map; use ASN1_File_Maps;
System : Node_Id; System : Node_Id;
Files : ASN1_Maps.Map; Files : ASN1_File_Maps.Map;
Current_Type : Node_Id; Current_Type : Node_Id;
F : Name_Id;
-- function Parse_Type (Data_Type : Node_Id) return ASN1_File is Loc : Location;
-- 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 begin
Ocarina.FE_AADL.Parser.Add_Pre_Prop_Sets := True; Ocarina.FE_AADL.Parser.Add_Pre_Prop_Sets := True;
...@@ -69,7 +52,7 @@ package body TASTE.Data_View is ...@@ -69,7 +52,7 @@ package body TASTE.Data_View is
F := Ocarina.Files.Search_File (Name_Find); F := Ocarina.Files.Search_File (Name_Find);
Loc := Ocarina.Files.Load_File (F); Loc := Ocarina.Files.Load_File (F);
DV_Root := Ocarina.Parser.Parse (Get_String_Name ("aadl"), DV_Root := Ocarina.Parser.Parse (Get_String_Name ("aadl"),
DV_Root, Loc); DV_Root, Loc);
end loop; end loop;
if not Ocarina.Analyzer.Analyze (AADL_Language, DV_Root) then if not Ocarina.Analyzer.Analyze (AADL_Language, DV_Root) then
...@@ -91,54 +74,60 @@ package body TASTE.Data_View is ...@@ -91,54 +74,60 @@ package body TASTE.Data_View is
raise Data_View_Error with "Component is not a data type!"; raise Data_View_Error with "Component is not a data type!";
end if; end if;
declare declare
Asntype : constant Node_Id := Corresponding_Instance (Data_Type); Asntype : constant Node_Id :=
Corresponding_Instance (Current_Type);
Sort : constant String := Get_Name_String Sort : constant String := Get_Name_String
(Get_Type_Source_Name (Asntype)); (Get_Type_Source_Name (Asntype));
Module : constant String := Get_Name_String Module : constant String := Get_Name_String
(Get_String_Property (Asntype, (Get_String_Property (Asntype,
Get_String_Name ("taste::ada_package_name"))); Get_String_Name ("taste::ada_package_name")));
Filename : constant String := Get_Name_String Filename : constant String := Get_Name_String
(Get_Source_Text (Asntype (1))); (Get_Source_Text (Asntype) (1));
-- Type_File : constant ASN1_File := Parse_Type (Current_Type); File_Ref : constant ASN1_File_Maps.Cursor := Files.Find (Filename);
begin begin
if Files.Contains (Key => Filename) then if File_Ref = ASN1_File_Maps.No_Element then
declare declare
Current_File : ASN1_File := Files.Element (Filename); New_File : ASN1_File;
begin New_Module : ASN1_Module;
if Current_File.Modules.Contains (Module) then begin
Current_File.Modules.Element (Module).Append (Sort); New_Module.Name := US (Module);
else New_Module.Types := (Empty_Vector & Sort);
declare New_File.Path := US (Filename);
Types : String_Vectors.Vector; New_File.Modules.Insert (Module, New_Module);
begin Files.Insert (Filename, New_File);
Types.Append (Sort); end;
Current_File.Modules.Insert (Key => Module,
New_Item => Types);
end;
end if;
end;
else else
declare declare
New_File : ASN1_File; Curr_File : ASN1_File := Files.Element (Filename);
begin Curr_Module : ASN1_Module;
New_File.Path := Filename; begin
-- etc if Curr_File.Modules.Contains (Module) then
Curr_Module := Curr_File.Modules.Element (Module);
Files.Insert (Key => To_String (Type_File.Path), Curr_Module.Types.Append (Sort);
New_Item => Type_File); Curr_File.Modules.Replace (Module, Curr_Module);
Current_Type := AIN.Next_Node (Current_Type); else
Curr_Module.Name := US (Module);
Curr_Module.Types := (Empty_Vector & Sort);
Curr_File.Modules.Insert (Module, Curr_Module);
end if;
Files.Replace (Filename, Curr_File);
end;
end if;
end; end;
Current_Type := AIN.Next_Node (Current_Type);
end loop; end loop;
return Data_AST : constant Taste_Data_View := (ASN1_Files => Files); return Data_AST : constant Taste_Data_View := (ASN1_Files => Files);
end Parse_Data_View; end Parse_Data_View;
procedure Debug_Dump (DV : Taste_Data_View; Output : File_Type) is procedure Debug_Dump (DV : Taste_Data_View; Output : File_Type) is
begin begin
for Each of DV.ASN1_Files loop for Each of DV.ASN1_Files loop
Put_Line (Output, To_String (Each.Path)); Put_Line (Output, "ASN.1 File : " & To_String (Each.Path));
for Module of Each.Modules loop for Module of Each.Modules loop
Put_Line (Output, " |_Module : " & Module); Put_Line (Output, " |_Module : " & To_String (Module.Name));
for Sort of Module.Types loop
Put_Line (Output, " |_Type : " & Sort);
end loop;
end loop; end loop;
end loop; end loop;
end Debug_Dump; end Debug_Dump;
......
...@@ -36,8 +36,14 @@ package TASTE.Data_View is ...@@ -36,8 +36,14 @@ package TASTE.Data_View is
"data_model.aadl" & "data_model.aadl" &
"deployment.aadl"; "deployment.aadl";
type ASN1_Module is
record
Name : Unbounded_String;
Types : String_Vectors.Vector;
end record;
package ASN1_Module_Maps is new Indefinite_Ordered_Maps package ASN1_Module_Maps is new Indefinite_Ordered_Maps
(String, String_Vectors.Vector); (String, ASN1_Module);
type ASN1_File is type ASN1_File is
record record
......
-- *************************** taste aadl parser ************************* -- -- *************************** taste aadl parser ************************* --
-- (c) 2008-2017 European Space Agency - maxime.perrotin@esa.int -- (c) 2008-2018 European Space Agency - maxime.perrotin@esa.int
-- LGPL license, see LICENSE file -- LGPL license, see LICENSE file
with Ada.Text_IO, with GNAT.OS_Lib,
GNAT.OS_Lib,
GNAT.Command_Line, GNAT.Command_Line,
Templates_Parser, Templates_Parser,
Templates_Parser.Utils, Templates_Parser.Utils,
...@@ -15,8 +14,7 @@ with Ada.Text_IO, ...@@ -15,8 +14,7 @@ with Ada.Text_IO,
package body TASTE.Parser_Utils is package body TASTE.Parser_Utils is
use Ada.Text_IO, use GNAT.OS_Lib,
GNAT.OS_Lib,
GNAT.Command_Line, GNAT.Command_Line,
Templates_Parser, Templates_Parser,
Templates_Parser.Utils, Templates_Parser.Utils,
...@@ -104,7 +102,7 @@ package body TASTE.Parser_Utils is ...@@ -104,7 +102,7 @@ package body TASTE.Parser_Utils is
end if; end if;
end Parse_Command_Line; end Parse_Command_Line;
procedure Debug_Dump (Config : Taste_Configuration) is procedure Debug_Dump (Config : Taste_Configuration; Output : File_Type) is
Vec : Tag; Vec : Tag;
Template : Translate_Set; Template : Translate_Set;
begin begin
...@@ -122,8 +120,8 @@ package body TASTE.Parser_Utils is ...@@ -122,8 +120,8 @@ package body TASTE.Parser_Utils is
Vec := Vec & Each; Vec := Vec & Each;
end loop; end loop;
Template := Template & Assoc ("Other_Files", Vec); Template := Template & Assoc ("Other_Files", Vec);
Put_Line Put_Line (Output,
(Parse (Config.Binary_Path.all & "templates/configuration.tmplt", Parse (Config.Binary_Path.all & "templates/configuration.tmplt",
Template)); Template));
end Debug_Dump; end Debug_Dump;
......
-- *************************** taste aadl parser *********************** -- -- *************************** taste aadl parser *********************** --
-- (c) 2017 European Space Agency - maxime.perrotin@esa.int -- (c) 2008-2018 European Space Agency - maxime.perrotin@esa.int
-- LGPL license, see LICENSE file -- LGPL license, see LICENSE file
-- Set of helper functions for the parser -- Set of helper functions for the parser
with Ocarina, with Ada.Containers.Indefinite_Ordered_Maps,
Ada.Containers.Indefinite_Vectors,
Ada.Strings.Unbounded,
Text_IO,
GNAT.Strings,
Interfaces.C_Streams,
Ocarina,
Ocarina.Types, Ocarina.Types,
Ocarina.Namet, Ocarina.Namet,
Ada.Containers.Indefinite_Ordered_Maps,
Ada.Containers.Indefinite_Vectors,
Ocarina.ME_AADL.AADL_Tree.Nodes, Ocarina.ME_AADL.AADL_Tree.Nodes,
Ocarina.ME_AADL.AADL_Instances.Nodes, Ocarina.ME_AADL.AADL_Instances.Nodes,
Ada.Strings.Unbounded, Option_Type;
Option_Type,
GNAT.Strings,
Interfaces.C_Streams;
use Ocarina, use Ocarina,
Ocarina.Types, Ocarina.Types,
...@@ -22,6 +23,7 @@ use Ocarina, ...@@ -22,6 +23,7 @@ use Ocarina,
Ocarina.ME_AADL.AADL_Instances.Nodes, Ocarina.ME_AADL.AADL_Instances.Nodes,
Ada.Containers, Ada.Containers,
Ada.Strings.Unbounded, Ada.Strings.Unbounded,
Text_IO,
Interfaces.C_Streams; Interfaces.C_Streams;
package TASTE.Parser_Utils is package TASTE.Parser_Utils is
...@@ -115,6 +117,6 @@ package TASTE.Parser_Utils is ...@@ -115,6 +117,6 @@ package TASTE.Parser_Utils is
Other_Files : String_Vectors.Vector; Other_Files : String_Vectors.Vector;
end record; end record;
procedure Debug_Dump (Config : Taste_Configuration); procedure Debug_Dump (Config : Taste_Configuration; Output : File_Type);
procedure Parse_Command_Line (Result : out Taste_Configuration); procedure Parse_Command_Line (Result : out Taste_Configuration);
end TASTE.Parser_Utils; end TASTE.Parser_Utils;
package TASTE.Parser_Version is package TASTE.Parser_Version is
Parser_Release : constant String := Parser_Release : constant String :=
"f0618ef ; Commit Date: Thu Jan 25 14:24:31 2018 "; "53a8b63 ; Commit Author: Maxime Perrotin <Maxime.Perrotin@esa.int>";
Ocarina_Version : constant String := Ocarina_Version : constant String :=
"Ocarina 2017.x (Working Copy from rd078c54)"; "Ocarina 2017.x (Working Copy from r0b92ed3)";
end TASTE.Parser_Version; end TASTE.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