Commit ffe5d888 authored by Bechir Zalila's avatar Bechir Zalila
Browse files

* (*aadl_ba*): Reimplementation of the behaviour_annex parser.

	(By Yossra Rekik)
parent ac85d4f2
This diff is collapsed.
......@@ -6,7 +6,7 @@
-- --
-- S p e c --
-- --
-- Copyright (C) 2009 Telecom ParisTech, 2010-2015 ESA & ISAE. --
-- Copyright (C) 2009 Telecom ParisTech, 2010-2016 ESA & ISAE. --
-- --
-- Ocarina is free software; you can redistribute it and/or modify under --
-- terms of the GNU General Public License as published by the Free Soft- --
......@@ -31,10 +31,10 @@
package Ocarina.BE_AADL_BA.Actions is
procedure Print_Behavior_Actions (List : List_Id);
procedure Print_Behavior_Action_Block (Node : Node_Id);
procedure Print_Data_Component_Reference (Node : Node_Id);
procedure Print_Id (Node : Node_Id);
procedure Print_Name (Node : Node_Id);
end Ocarina.BE_AADL_BA.Actions;
......@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
-- Copyright (C) 2009 Telecom ParisTech, 2010-2015 ESA & ISAE. --
-- Copyright (C) 2009 Telecom ParisTech, 2010-2016 ESA & ISAE. --
-- --
-- Ocarina is free software; you can redistribute it and/or modify under --
-- terms of the GNU General Public License as published by the Free Soft- --
......@@ -52,35 +52,31 @@ package body Ocarina.BE_AADL_BA.Expressions is
package BAN renames Ocarina.ME_AADL_BA.BA_Tree.Nodes;
procedure Print_Relation (Node : Node_Id);
procedure Print_Relation (Node : Node_Id);
procedure Print_Simple_Expression (Node : Node_Id);
procedure Print_Term (Node : Node_Id);
procedure Print_Factor (Node : Node_Id);
procedure Print_Primary (Node : Node_Id);
procedure Print_Operator (Node : Node_Id);
procedure Print_Term (Node : Node_Id);
procedure Print_Factor (Node : Node_Id);
procedure Print_Value (Node : Node_Id);
------------------------
-- Print_Value_Holder --
------------------------
--------------------------
-- Print_Value_Variable --
--------------------------
procedure Print_Value_Holder (Node : Node_Id) is
pragma Assert (Kind (Node) = K_Value_Holder);
procedure Print_Value_Variable (Node : Node_Id) is
pragma Assert (Kind (Node) = K_Value_Variable);
Ident : constant Node_Id := BAN.Identifier (Node);
begin
case Kind (Ident) is
when K_Id =>
Print_Id (Ident);
when K_Name => Print_Name (Ident);
when K_Data_Component_Reference =>
Print_Data_Component_Reference (Ident);
when others =>
Write_Line (Bug_Str);
when others => Write_Line (Bug_Str);
end case;
if Is_Interrogative (Node) then
Write_Space;
Print_Token (T_Interrogative);
end if;
......@@ -90,8 +86,11 @@ package body Ocarina.BE_AADL_BA.Expressions is
elsif Is_Fresh (Node) then
Print_Token (T_Tick);
Print_Token (T_Fresh);
elsif Is_Updated (Node) then
Print_Token (T_Tick);
Print_Token (T_Updated);
end if;
end Print_Value_Holder;
end Print_Value_Variable;
----------------------------
-- Print_Value_Expression --
......@@ -111,12 +110,9 @@ package body Ocarina.BE_AADL_BA.Expressions is
Write_Space;
case Kind (List_Node) is
when K_Relation =>
Print_Relation (List_Node);
when K_Operator =>
Print_Operator (List_Node);
when others =>
Write_Line (Bug_Str);
when K_Relation => Print_Relation (List_Node);
when K_Operator => Print_Operator (List_Node);
when others => Write_Line (Bug_Str);
end case;
List_Node := Next_Node (List_Node);
......@@ -132,13 +128,13 @@ package body Ocarina.BE_AADL_BA.Expressions is
List_Node : Node_Id;
begin
if Is_Empty (Simple_Exprs (Node)) then
if Boolean_Value (Node) then
Print_Token (T_True);
else
Print_Token (T_False);
end if;
else
if not Is_Empty (Simple_Exprs (Node)) then
-- if Boolean_Value (Node) then
-- Print_Token (T_True);
-- else
-- Print_Token (T_False);
-- end if;
-- else
List_Node := First_Node (Simple_Exprs (Node));
Print_Simple_Expression (List_Node);
......@@ -147,12 +143,9 @@ package body Ocarina.BE_AADL_BA.Expressions is
Write_Space;
case Kind (List_Node) is
when K_Simple_Expression =>
Print_Simple_Expression (List_Node);
when K_Operator =>
Print_Operator (List_Node);
when others =>
Write_Line (Bug_Str);
when K_Simple_Expression => Print_Simple_Expression (List_Node);
when K_Operator => Print_Operator (List_Node);
when others => Write_Line (Bug_Str);
end case;
List_Node := Next_Node (List_Node);
......@@ -168,7 +161,7 @@ package body Ocarina.BE_AADL_BA.Expressions is
pragma Assert (Kind (Node) = K_Simple_Expression);
pragma Assert (not Is_Empty (Term_And_Operator (Node)));
No_First : Boolean := False;
No_First : Boolean := False;
List_Node : Node_Id;
begin
List_Node := First_Node (Term_And_Operator (Node));
......@@ -180,12 +173,9 @@ package body Ocarina.BE_AADL_BA.Expressions is
No_First := True;
case Kind (List_Node) is
when K_Operator =>
Print_Operator (List_Node);
when K_Term =>
Print_Term (List_Node);
when others =>
Write_Line (Bug_Str);
when K_Operator => Print_Operator (List_Node);
when K_Term => Print_Term (List_Node);
when others => Write_Line (Bug_Str);
end case;
List_Node := Next_Node (List_Node);
......@@ -212,12 +202,9 @@ package body Ocarina.BE_AADL_BA.Expressions is
No_First := True;
case Kind (List_Node) is
when K_Operator =>
Print_Operator (List_Node);
when K_Factor =>
Print_Factor (List_Node);
when others =>
Write_Line (Bug_Str);
when K_Operator => Print_Operator (List_Node);
when K_Factor => Print_Factor (List_Node);
when others => Write_Line (Bug_Str);
end case;
List_Node := Next_Node (List_Node);
......@@ -240,45 +227,43 @@ package body Ocarina.BE_AADL_BA.Expressions is
Write_Space;
end if;
Print_Primary (Lower_Primary (Node));
Print_Value (Lower_Value (Node));
if Present (Upper_Primary (Node)) then
if Present (Upper_Value (Node)) then
Write_Space;
Print_Token (T_Exponent);
Write_Space;
Print_Primary (Upper_Primary (Node));
Print_Value (Upper_Value (Node));
end if;
end Print_Factor;
-------------------
-- Print_Primary --
-------------------
procedure Print_Primary (Node : Node_Id) is
pragma Assert
(Kind (Node) = K_Value_Holder
or else Kind (Node) = K_Value_Expression
or else Kind (Node) = K_Literal
or else Kind (Node) = K_Property_Constant
or else Kind (Node) = K_Identifier);
-----------------
-- Print_Value --
-----------------
procedure Print_Value (Node : Node_Id) is
pragma Assert (Kind (Node) = K_Value_Variable
or else Kind (Node) = K_Value_Expression
or else Kind (Node) = K_Literal
or else Kind (Node) = K_Boolean_Literal
or else Kind (Node) = K_Property_Constant
or else Kind (Node) = K_Property_Reference
or else Kind (Node) = K_Identifier);
begin
case Kind (Node) is
when K_Value_Holder =>
Print_Value_Holder (Node);
when K_Literal =>
Print_Literal (Node);
when K_Property_Constant =>
Print_Property_Constant (Node);
when K_Value_Expression =>
when K_Value_Variable => Print_Value_Variable (Node);
when K_Literal => Print_Literal (Node);
when K_Boolean_Literal => Print_Boolean_Literal (Node);
when K_Property_Constant => Print_Property_Constant (Node);
when K_Property_Reference => Print_Property_Reference (Node);
when K_Value_Expression =>
Print_Token (T_Left_Parenthesis);
Print_Value_Expression (Node);
Print_Token (T_Right_Parenthesis);
when K_Identifier =>
Print_Identifier (Node);
when others =>
Write_Line (Bug_Str);
when K_Identifier => Print_Identifier (Node);
when others => Write_Line (Bug_Str);
end case;
end Print_Primary;
end Print_Value;
-----------------------------
-- Print_Property_Constant --
......@@ -296,6 +281,101 @@ package body Ocarina.BE_AADL_BA.Expressions is
Print_Identifier (BAN.Identifier (Node));
end Print_Property_Constant;
-----------------------------
-- Print_Property_Reference --
-----------------------------
procedure Print_Property_Reference (Node : Node_Id) is
pragma Assert (Kind (Node) = K_Property_Reference);
begin
if Present (Property_Set_Idt (Node)) then
Print_Token (T_Number_Sign);
Print_Identifier (Property_Set_Idt (Node));
Print_Token (T_Colon_Colon);
end if;
if Present (Entity (Node)) then
Print_Component_Element_Ref (Entity (Node));
Print_Token (T_Number_Sign);
end if;
Print_Property_Name (Property_Name (Node));
end Print_Property_Reference;
-------------------------
-- Print_Property_Name --
-------------------------
procedure Print_Property_Name (Node : Node_Id) is
pragma Assert (Kind (Node) = K_Property_Name);
List_Node : Node_Id;
begin
Print_Identifier (Property_Idt (Node));
if not Is_Empty (Property_Field (Node)) then
List_Node := First_Node (Property_Field (Node));
Print_Property_Field (List_Node);
List_Node := Next_Node (List_Node);
while Present (List_Node) loop
Write_Space;
Print_Property_Field (List_Node);
List_Node := Next_Node (List_Node);
end loop;
end if;
end Print_Property_Name;
--------------------------
-- Print_Property_Field --
--------------------------
procedure Print_Property_Field (Node : Node_Id) is
pragma Assert (Kind (Node) = K_Property_Field);
begin
if Is_Upper_Bound (Node) then
Print_Token (T_Dot);
Print_Token (T_Upper_Bound);
Write_Space;
elsif Is_Lower_Bound (Node) then
Print_Token (T_Dot);
Print_Token (T_Lower_Bound);
Write_Space;
end if;
if Present (Entity (Node)) then
case Kind (Entity (Node)) is
when K_Identifier =>
Print_Token (T_Dot);
Print_Identifier (Entity (Node));
when K_Integer_Value =>
Print_Token (T_Left_Square_Bracket);
Print_Integer_Value (Entity (Node));
Print_Token (T_Right_Square_Bracket);
when others => Write_Line (Bug_Str);
end case;
end if;
end Print_Property_Field;
---------------------------------
-- Print_Component_Element_Ref --
---------------------------------
procedure Print_Component_Element_Ref (Node : Node_Id) is
pragma Assert (Kind (Node) = K_Component_Element_Reference);
begin
if Is_Self (Node) then
Print_Token (T_Self);
Write_Space;
end if;
if Present (Ident (Node)) then
Write_Space;
Print_Identifier (Ident (Node));
end if;
end Print_Component_Element_Ref;
--------------------
-- Print_Operator --
--------------------
......@@ -307,60 +387,37 @@ package body Ocarina.BE_AADL_BA.Expressions is
case Operator_Kind'Val (Operator_Category (Node)) is
-- logical operator
when OK_And =>
Print_Token (T_And);
when OK_Or =>
Print_Token (T_Or);
when OK_Xor =>
Print_Token (T_Xor);
when OK_Cand =>
Print_Token (T_Cand);
when OK_Cor =>
Print_Token (T_Cor);
when OK_And => Print_Token (T_And);
when OK_Or => Print_Token (T_Or);
when OK_Xor => Print_Token (T_Xor);
when OK_Or_Else => Print_Tokens ((T_Or, T_Else));
when OK_And_Then => Print_Tokens ((T_And, T_Then));
-- relational_operator
when OK_Equal =>
Print_Token (T_Equals_Sign);
when OK_Non_Equal =>
Print_Token (T_Non_Equal);
when OK_Less_Than =>
Print_Token (T_Less_Than_Sign);
when OK_Less_Or_Equal =>
Print_Token (T_Less_Or_Equal);
when OK_Greater_Than =>
Print_Token (T_Greater_Than_Sign);
when OK_Greater_Or_Equal =>
Print_Token (T_Greater_Or_Equal);
when OK_Equal => Print_Token (T_Equals_Sign);
when OK_Non_Equal => Print_Token (T_Non_Equal);
when OK_Less_Than => Print_Token (T_Less_Than_Sign);
when OK_Less_Or_Equal => Print_Token (T_Less_Or_Equal);
when OK_Greater_Than => Print_Token (T_Greater_Than_Sign);
when OK_Greater_Or_Equal => Print_Token (T_Greater_Or_Equal);
-- unary_adding_opetor
-- binary_adding_operator
when OK_Plus =>
Print_Token (T_Plus);
when OK_Minus =>
Print_Token (T_Minus);
when OK_Concat =>
Print_Token (T_Concat);
when OK_Plus => Print_Token (T_Plus);
when OK_Minus => Print_Token (T_Minus);
-- multiplying operator
when OK_Multiply =>
Print_Token (T_Multiply);
when OK_Divide =>
Print_Token (T_Divide);
when OK_Mod =>
Print_Token (T_Mod);
when OK_Rem =>
Print_Token (T_Rem);
when OK_Multiply => Print_Token (T_Multiply);
when OK_Divide => Print_Token (T_Divide);
when OK_Mod => Print_Token (T_Mod);
when OK_Rem => Print_Token (T_Rem);
-- highest precedence operator
when OK_Exponent =>
Print_Token (T_Exponent);
when OK_Abs =>
Print_Token (T_Abs);
when OK_Not =>
Print_Token (T_Not);
when others =>
Write_Line (Bug_Str);
when OK_Exponent => Print_Token (T_Exponent);
when OK_Abs => Print_Token (T_Abs);
when OK_Not => Print_Token (T_Not);
when others => Write_Line (Bug_Str);
end case;
end Print_Operator;
......@@ -388,22 +445,17 @@ package body Ocarina.BE_AADL_BA.Expressions is
procedure Print_Integer_Value (Node : Node_Id) is
pragma Assert (Kind (Node) = K_Integer_Value);
pragma Assert
(Kind (Entity (Node)) = K_Value_Holder
or else Kind (Entity (Node)) = K_Literal
or else Kind (Entity (Node)) = K_Property_Constant);
pragma Assert (Kind (Entity (Node)) = K_Value_Variable
or else Kind (Entity (Node)) = K_Literal
or else Kind (Entity (Node)) = K_Property_Constant);
Entity_Node : constant Node_Id := Entity (Node);
begin
case Kind (Entity_Node) is
when K_Value_Holder =>
Print_Value_Holder (Entity_Node);
when K_Literal =>
Print_Literal (Entity_Node);
when K_Property_Constant =>
Print_Property_Constant (Entity_Node);
when others =>
Write_Line (Bug_Str);
when K_Value_Variable => Print_Value_Variable (Entity_Node);
when K_Literal => Print_Literal (Entity_Node);
when K_Property_Constant => Print_Property_Constant (Entity_Node);
when others => Write_Line (Bug_Str);
end case;
end Print_Integer_Value;
......@@ -432,4 +484,22 @@ package body Ocarina.BE_AADL_BA.Expressions is
Write_Str (Ocarina.AADL_Values.Image (Value (Node)));
end Print_Literal;
---------------------------
-- Print_Boolean_Literal --
---------------------------
procedure Print_Boolean_Literal (Node : Node_Id) is
pragma Assert (Kind (Node) = K_Boolean_Literal);
begin
if Is_True (Node) then
Print_Token (T_True);
Write_Space;
else
Print_Token (T_False);
Write_Space;
end if;
end Print_Boolean_Literal;
end Ocarina.BE_AADL_BA.Expressions;
......@@ -6,7 +6,7 @@
-- --
-- S p e c --
-- --
-- Copyright (C) 2009 Telecom ParisTech, 2010-2015 ESA & ISAE. --
-- Copyright (C) 2009 Telecom ParisTech, 2010-2016 ESA & ISAE. --
-- --
-- Ocarina is free software; you can redistribute it and/or modify under --
-- terms of the GNU General Public License as published by the Free Soft- --
......@@ -31,12 +31,18 @@
package Ocarina.BE_AADL_BA.Expressions is
procedure Print_Value_Holder (Node : Node_Id);
procedure Print_Value_Expression (Node : Node_Id);
procedure Print_Property_Constant (Node : Node_Id);
procedure Print_Integer_Range (Node : Node_Id);
procedure Print_Integer_Value (Node : Node_Id);
procedure Print_Behavior_Time (Node : Node_Id);
procedure Print_Literal (Node : Node_Id);
procedure Print_Value_Variable (Node : Node_Id);
procedure Print_Value_Expression (Node : Node_Id);
procedure Print_Property_Constant (Node : Node_Id);
procedure Print_Property_Reference (Node : Node_Id);
procedure Print_Property_Name (Node : Node_Id);
procedure Print_Property_Field (Node : Node_Id);
procedure Print_Component_Element_Ref (Node : Node_Id);
procedure Print_Integer_Range (Node : Node_Id);
procedure Print_Integer_Value (Node : Node_Id);
procedure Print_Behavior_Time (Node : Node_Id);
procedure Print_Literal (Node : Node_Id);
procedure Print_Boolean_Literal (Node : Node_Id);
procedure Print_Operator (Node : Node_Id);
end Ocarina.BE_AADL_BA.Expressions;
......@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
-- Copyright (C) 2009 Telecom ParisTech, 2010-2015 ESA & ISAE. --
-- Copyright (C) 2009 Telecom ParisTech, 2010-2016 ESA & ISAE. --
-- --
-- Ocarina is free software; you can redistribute it and/or modify under --
-- terms of the GNU General Public License as published by the Free Soft- --
......@@ -59,9 +59,8 @@ package body Ocarina.BE_AADL_BA.Identifiers is
---------------------------------
procedure Print_Identifier_With_Value (Node : Node_Id) is
pragma Assert
(Kind (Node) = K_Identifier
or else Kind (Node) = K_Identifier_With_Value);
pragma Assert (Kind (Node) = K_Identifier
or else Kind (Node) = K_Identifier_With_Value);
begin
Write_Name (Display_Name (Node));
......@@ -70,14 +69,13 @@ package body Ocarina.BE_AADL_BA.Identifiers is
if Present (Value_Constant (Node)) then
case Kind (Value_Constant (Node)) is
when K_Literal =>
Print_Literal (Value_Constant (Node));
when K_Property_Constant =>
Print_Property_Constant (Value_Constant (Node));
when K_Identifier =>
Print_Identifier (Value_Constant (Node));
when others =>
Write_Line (Bug_Str);
when K_Literal => Print_Literal
(Value_Constant (Node));
when K_Property_Constant => Print_Property_Constant
(Value_Constant (Node));
when K_Identifier => Print_Identifier
(Value_Constant (Node));
when others => Write_Line (Bug_Str);
end case;
elsif Is_Others (Node) then
......
......@@ -6,7 +6,7 @@
-- --
-- S p e c --
-- --
-- Copyright (C) 2009 Telecom ParisTech, 2010-2015 ESA & ISAE. --
-- Copyright (C) 2009 Telecom ParisTech, 2010-2016 ESA & ISAE. --
-- --
-- Ocarina is free software; you can redistribute it and/or modify under --
-- terms of the GNU General Public License as published by the Free Soft- --
......
......@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
-- Copyright (C) 2009 Telecom ParisTech, 2010-2015 ESA & ISAE. --
-- Copyright (C) 2009 Telecom ParisTech, 2010-2016 ESA & ISAE. --
-- --
-- Ocarina is free software; you can redistribute it and/or modify under --
-- terms of the GNU General Public License as published by the Free Soft- --
......@@ -53,13 +53,18 @@ package body Ocarina.BE_AADL_BA.Specifications is
package BAN renames Ocarina.ME_AADL_BA.BA_Tree.Nodes;
procedure Print_Behavior_Variable (Node : Node_Id);
procedure Print_Behavior_State (Node : Node_Id);
procedure Print_Behavior_State_Kind (State_Kind : Byte);
procedure Print_Behavior_Transition (Node : Node_Id);
procedure Print_Behavior_Variable (Node : Node_Id);
procedure Print_Behavior_State (Node : Node_Id);
procedure Print_Behavior_State_Kind (State_Kind : Byte);
procedure Print_Behavior_Transition (Node : Node_Id);
procedure Print_Execution_Behavior_Transition (Node : Node_Id);
procedure Print_Mode_Transition (Node : Node_Id);
procedure Print_Behavior_Condition (Node : Node_Id);
procedure Print_Mode_Transition (Node : Node_Id);
procedure Print_Behavior_Condition (Node : Node_Id);
procedure Print_Execute_Condition (Node : Node_Id);