Commit 0158a248 authored by jhugues's avatar jhugues
Browse files

* Extend support for property types with "list of"



git-svn-id: https://tecsw.estec.esa.int/svn/taste/trunk/ocarina@5762 129961e7-ef38-4bb5-a8f7-c9a525a55882
parent 39a85f98
...@@ -7,16 +7,15 @@ property set Communication_Properties is ...@@ -7,16 +7,15 @@ property set Communication_Properties is
Fan_Out_Policy: enumeration (Broadcast, RoundRobin, Selective, OnDemand) Fan_Out_Policy: enumeration (Broadcast, RoundRobin, Selective, OnDemand)
applies to (port); applies to (port);
-- XXX not supported by Ocarina Connection_Pattern: list of list of Supported_Connection_Patterns
-- Connection_Pattern: list of list of Supported_Connection_Patterns applies to (connection);
-- applies to (connection);
-- Connection_Set: list of Connection_Pair Connection_Set: list of Connection_Pair
-- applies to (connection); applies to (connection);
-- Connection_Pair: type record ( Connection_Pair: type record (
-- src: list of aadlinteger; src: list of aadlinteger;
-- dst: list of aadlinteger;); dst: list of aadlinteger;);
Overflow_Handling_Protocol: enumeration (DropOldest, DropNewest, Error) => DropOldest Overflow_Handling_Protocol: enumeration (DropOldest, DropNewest, Error) => DropOldest
applies to (event port, event data port, subprogram access); applies to (event port, event data port, subprogram access);
......
...@@ -59,16 +59,15 @@ property set Deployment_Properties is ...@@ -59,16 +59,15 @@ property set Deployment_Properties is
Required_Connection_Quality_Of_Service: inherit list of Supported_Connection_QoS Required_Connection_Quality_Of_Service: inherit list of Supported_Connection_QoS
applies to (port, connection, virtual bus, thread, thread group, process, system, device); applies to (port, connection, virtual bus, thread, thread group, process, system, device);
-- XXX not supported by Ocarina Not_Collocated: record (
-- Not_Collocated: record ( Targets: list of reference (data, Targets: list of reference (data, thread, process, system, connection);
-- thread, process, system, connection); Location: Location: classifier (processor, memory, bus, system);) applies
-- classifier (processor, memory, bus, system);) applies to (process, system);
-- to (process, system);
Collocated: record ( Targets: list of reference (data, thread,
-- Collocated: record ( Targets: list of reference (data, thread, process, system, connection); Location: classifier
-- process, system, connection); Location: classifier (processor, memory, bus, system);) applies to
-- (processor, memory, bus, system);) applies to (process, system);
-- (process, system);
Allowed_Connection_Type: list of enumeration Allowed_Connection_Type: list of enumeration
(Sampled_Data_Connection, Immediate_Data_Connection, (Sampled_Data_Connection, Immediate_Data_Connection,
......
...@@ -36,6 +36,7 @@ with Ocarina.ME_AADL.AADL_Tree.Nodes; ...@@ -36,6 +36,7 @@ with Ocarina.ME_AADL.AADL_Tree.Nodes;
with Ocarina.BE_AADL.Properties; with Ocarina.BE_AADL.Properties;
with Ocarina.BE_AADL.Identifiers; with Ocarina.BE_AADL.Identifiers;
with Ocarina.BE_AADL.Components; with Ocarina.BE_AADL.Components;
with Ocarina.BE_AADL.Components.Arrays;
package body Ocarina.BE_AADL.Components.Features is package body Ocarina.BE_AADL.Components.Features is
...@@ -44,6 +45,7 @@ package body Ocarina.BE_AADL.Components.Features is ...@@ -44,6 +45,7 @@ package body Ocarina.BE_AADL.Components.Features is
use Ocarina.BE_AADL.Properties; use Ocarina.BE_AADL.Properties;
use Ocarina.BE_AADL.Identifiers; use Ocarina.BE_AADL.Identifiers;
use Ocarina.BE_AADL.Components; use Ocarina.BE_AADL.Components;
use Ocarina.BE_AADL.Components.Arrays;
------------------- -------------------
-- Print_Feature -- -- Print_Feature --
...@@ -174,6 +176,11 @@ package body Ocarina.BE_AADL.Components.Features is ...@@ -174,6 +176,11 @@ package body Ocarina.BE_AADL.Components.Features is
else else
Print_Token (T_Port); Print_Token (T_Port);
end if; end if;
if Present (Array_Dimensions (Node)) then
Write_Space;
Print_Array_Dimensions (Array_Dimensions (Node));
end if;
end Print_Port_Spec; end Print_Port_Spec;
------------------------------- -------------------------------
......
...@@ -393,6 +393,12 @@ package body Ocarina.BE_AADL.Properties.Values is ...@@ -393,6 +393,12 @@ package body Ocarina.BE_AADL.Properties.Values is
Print_Identifier (Identifier (Node)); Print_Identifier (Identifier (Node));
Write_Space; Write_Space;
Print_Token (T_Colon); Print_Token (T_Colon);
if Is_List (Node) then
Write_Space;
Print_Token (T_List);
Write_Space;
Print_Token (T_Of);
end if;
Write_Space; Write_Space;
Print_Property_Type_Designator (Property_Type_Designator (Node)); Print_Property_Type_Designator (Property_Type_Designator (Node));
Print_Token (T_Semicolon); Print_Token (T_Semicolon);
......
...@@ -253,8 +253,10 @@ package body Ocarina.BE_AADL.Properties is ...@@ -253,8 +253,10 @@ package body Ocarina.BE_AADL.Properties is
end if; end if;
if Is_List (Property_Name_Type (Node)) then if Is_List (Property_Name_Type (Node)) then
for J in 1 .. Multiplicity (Property_Name_Type (Node)) loop
Print_Tokens ((T_List, T_Of)); Print_Tokens ((T_List, T_Of));
Write_Space; Write_Space;
end loop;
end if; end if;
Print_Property_Type_Designator Print_Property_Type_Designator
......
...@@ -431,6 +431,7 @@ module Ocarina::ME_AADL::AADL_Tree::Nodes { ...@@ -431,6 +431,7 @@ module Ocarina::ME_AADL::AADL_Tree::Nodes {
boolean Is_Feature; boolean Is_Feature;
boolean Is_Event; // FIXME: Rename to Is_Event_Port boolean Is_Event; // FIXME: Rename to Is_Event_Port
boolean Is_Data; // FIXME: Rename to Is_Data_Port boolean Is_Data; // FIXME: Rename to Is_Data_Port
Node_Id Array_Dimensions; // AADL_V2
}; };
// AADL_V1 // AADL_V1
...@@ -1095,6 +1096,7 @@ module Ocarina::ME_AADL::AADL_Tree::Nodes { ...@@ -1095,6 +1096,7 @@ module Ocarina::ME_AADL::AADL_Tree::Nodes {
interface Property_Type : Node_Id { interface Property_Type : Node_Id {
boolean Is_List; boolean Is_List;
long Multiplicity; // number of "list of" in property type
Node_Id Property_Type_Designator; Node_Id Property_Type_Designator;
Node_Id Expanded_Type_Designator; Node_Id Expanded_Type_Designator;
}; };
...@@ -1124,7 +1126,7 @@ module Ocarina::ME_AADL::AADL_Tree::Nodes { ...@@ -1124,7 +1126,7 @@ module Ocarina::ME_AADL::AADL_Tree::Nodes {
}; };
// multi_valued_property ::= // multi_valued_property ::=
// list of property_type_designator // (list of)+ property_type_designator
// [ => ( [ default_property_expression // [ => ( [ default_property_expression
// { , default_property_expression }* ] ) ] // { , default_property_expression }* ] ) ]
...@@ -1246,7 +1248,11 @@ module Ocarina::ME_AADL::AADL_Tree::Nodes { ...@@ -1246,7 +1248,11 @@ module Ocarina::ME_AADL::AADL_Tree::Nodes {
// | bus_classsifer_reference // | bus_classsifer_reference
interface Property_List_Value : List_Id { }; interface Property_List_Value : List_Id { };
// interface Property_List_Value : Node_Id {
// List_Id Property_Values;
//};
// XXX Change to inherit from Node_Id, list being an internal field
/* /*
in_binding ::= in binding ( platform_classifier_reference in_binding ::= in binding ( platform_classifier_reference
{ , platform_classifier_reference }* ) { , platform_classifier_reference }* )
...@@ -1392,10 +1398,11 @@ module Ocarina::ME_AADL::AADL_Tree::Nodes { ...@@ -1392,10 +1398,11 @@ module Ocarina::ME_AADL::AADL_Tree::Nodes {
}; };
// record_term ::= // record_term ::=
// ( property_expression ( , property_expression )* ) // ( record_field_identifier => property_expression ;
// ( record_field_identifier => property_expression ; )* )
interface Record_Term : Node_Id { interface Record_Term : Node_Id {
List_Id List_Items; List_Id List_Items; // list of Record_Term_Element
}; };
interface Record_Term_Element : Node_Id { interface Record_Term_Element : Node_Id {
...@@ -1538,6 +1545,7 @@ module Ocarina::ME_AADL::AADL_Tree::Nodes { ...@@ -1538,6 +1545,7 @@ module Ocarina::ME_AADL::AADL_Tree::Nodes {
}; };
interface Record_Type_Element : Node_Id { interface Record_Type_Element : Node_Id {
boolean Is_List;
Node_Id Identifier; Node_Id Identifier;
Node_Id Property_Type_Designator; Node_Id Property_Type_Designator;
}; };
...@@ -1546,7 +1554,7 @@ module Ocarina::ME_AADL::AADL_Tree::Nodes { ...@@ -1546,7 +1554,7 @@ module Ocarina::ME_AADL::AADL_Tree::Nodes {
// defining_property_type_identifier : type property_type_designator ; // defining_property_type_identifier : type property_type_designator ;
// property_type_designator ::= property_type // property_type_designator ::= property_type
// | unique_property_type_identifie // | unique_property_type_identifier
// property_type ::= aadlboolean | aadlstring | enumeration_type // property_type ::= aadlboolean | aadlstring | enumeration_type
// | units_type | number_type | range_type // | units_type | number_type | range_type
......
...@@ -63,7 +63,8 @@ package body Ocarina.FE_AADL.Parser.Components.Arrays is ...@@ -63,7 +63,8 @@ package body Ocarina.FE_AADL.Parser.Components.Arrays is
use Ocarina.ME_AADL.AADL_Tree.Nutils; use Ocarina.ME_AADL.AADL_Tree.Nutils;
pragma Assert (Container /= No_Node pragma Assert (Container /= No_Node
and then (Kind (Container) = K_Subcomponent)); and then (Kind (Container) = K_Subcomponent
or else Kind (Container) = K_Port_Spec));
Loc : Location; Loc : Location;
List_Array_Dim : List_Id := No_List; List_Array_Dim : List_Id := No_List;
......
...@@ -35,6 +35,7 @@ with Locations; ...@@ -35,6 +35,7 @@ with Locations;
with Ocarina.ME_AADL.AADL_Tree.Nodes; with Ocarina.ME_AADL.AADL_Tree.Nodes;
with Ocarina.FE_AADL.Lexer; with Ocarina.FE_AADL.Lexer;
with Ocarina.ME_AADL.Tokens; with Ocarina.ME_AADL.Tokens;
with Ocarina.FE_AADL.Parser.Components.Arrays;
with Ocarina.FE_AADL.Parser.Identifiers; with Ocarina.FE_AADL.Parser.Identifiers;
with Ocarina.FE_AADL.Parser.Properties; with Ocarina.FE_AADL.Parser.Properties;
with Ocarina.Builder.AADL.Components.Features; with Ocarina.Builder.AADL.Components.Features;
...@@ -246,6 +247,7 @@ package body Ocarina.FE_AADL.Parser.Components.Features is ...@@ -246,6 +247,7 @@ package body Ocarina.FE_AADL.Parser.Components.Features is
-- port_spec ::= -- port_spec ::=
-- defining_port_identifier : ( in | out | in out ) port_type -- defining_port_identifier : ( in | out | in out ) port_type
-- XXX dimensions ???
-- [ { { port_property_association }+ } ] ; -- [ { { port_property_association }+ } ] ;
-- port_refinement ::= -- port_refinement ::=
...@@ -268,6 +270,7 @@ package body Ocarina.FE_AADL.Parser.Components.Features is ...@@ -268,6 +270,7 @@ package body Ocarina.FE_AADL.Parser.Components.Features is
use Parser.Properties; use Parser.Properties;
use Parser.Identifiers; use Parser.Identifiers;
use Ocarina.Builder.AADL.Components.Features; use Ocarina.Builder.AADL.Components.Features;
use Parser.Components.Arrays;
Class_Ref : Node_Id := No_Node; Class_Ref : Node_Id := No_Node;
Port_Spec : Node_Id := No_Node; Port_Spec : Node_Id := No_Node;
...@@ -277,6 +280,7 @@ package body Ocarina.FE_AADL.Parser.Components.Features is ...@@ -277,6 +280,7 @@ package body Ocarina.FE_AADL.Parser.Components.Features is
Code : Parsing_Code; Code : Parsing_Code;
OK : Boolean; OK : Boolean;
Loc : Location; Loc : Location;
Array_Dimensions : Node_Id;
begin begin
if Is_Refinement then if Is_Refinement then
...@@ -343,6 +347,29 @@ package body Ocarina.FE_AADL.Parser.Components.Features is ...@@ -343,6 +347,29 @@ package body Ocarina.FE_AADL.Parser.Components.Features is
Is_Refinement => Is_Refinement, Is_Refinement => Is_Refinement,
Associated_Entity => Class_Ref); Associated_Entity => Class_Ref);
Save_Lexer (Loc);
Scan_Token;
if Token = T_Left_Square_Bracket then
case AADL_Version is
when AADL_V2 =>
Array_Dimensions := P_Array_Dimensions (Port_Spec);
if No (Array_Dimensions) then
DPE (Code);
Skip_Tokens (T_Semicolon);
return No_Node;
end if;
Set_Array_Dimensions (Port_Spec, Array_Dimensions);
when AADL_V1 =>
DPE (CODE, EMC_Not_Allowed_In_AADL_V1);
Skip_Tokens (T_Semicolon);
return No_Node;
end case;
else
Restore_Lexer (Loc);
end if;
OK := P_Property_Associations (Port_Spec, True, PAT_Simple, Code); OK := P_Property_Associations (Port_Spec, True, PAT_Simple, Code);
if not OK then if not OK then
......
...@@ -82,7 +82,6 @@ package body Ocarina.FE_AADL.Parser.Components.Prototypes is ...@@ -82,7 +82,6 @@ package body Ocarina.FE_AADL.Parser.Components.Prototypes is
Is_Refinement : Boolean; Is_Refinement : Boolean;
OK : Boolean; OK : Boolean;
begin begin
P_Identifier_Refined_To P_Identifier_Refined_To
(Refinable_To_RT (Refinable), (Refinable_To_RT (Refinable),
False, False,
...@@ -146,7 +145,6 @@ package body Ocarina.FE_AADL.Parser.Components.Prototypes is ...@@ -146,7 +145,6 @@ package body Ocarina.FE_AADL.Parser.Components.Prototypes is
end if; end if;
return Prototype; return Prototype;
end P_Prototype_Or_Prototype_Refinement; end P_Prototype_Or_Prototype_Refinement;
-------------------------- --------------------------
...@@ -269,7 +267,6 @@ package body Ocarina.FE_AADL.Parser.Components.Prototypes is ...@@ -269,7 +267,6 @@ package body Ocarina.FE_AADL.Parser.Components.Prototypes is
end if; end if;
return Prototype_Binding; return Prototype_Binding;
end P_Prototype_Binding; end P_Prototype_Binding;
end Ocarina.FE_AADL.Parser.Components.Prototypes; end Ocarina.FE_AADL.Parser.Components.Prototypes;
...@@ -633,7 +633,7 @@ package body Ocarina.FE_AADL.Parser.Properties.Values is ...@@ -633,7 +633,7 @@ package body Ocarina.FE_AADL.Parser.Properties.Values is
-- P_Multi_Valued_Property -- -- P_Multi_Valued_Property --
----------------------------- -----------------------------
-- multi_valued_property ::= list of property_type_designator -- multi_valued_property ::= (list of)+ property_type_designator
-- [ => ( [ default_property_expression -- [ => ( [ default_property_expression
-- { , default_property_expression }* ] ) ] -- { , default_property_expression }* ] ) ]
...@@ -648,7 +648,6 @@ package body Ocarina.FE_AADL.Parser.Properties.Values is ...@@ -648,7 +648,6 @@ package body Ocarina.FE_AADL.Parser.Properties.Values is
Property_Type_Designator : Node_Id; Property_Type_Designator : Node_Id;
Property_Expressions : List_Id; Property_Expressions : List_Id;
Loc : Location; Loc : Location;
begin begin
Valued_Property := New_Node (K_Multi_Valued_Property, Token_Location); Valued_Property := New_Node (K_Multi_Valued_Property, Token_Location);
...@@ -659,7 +658,6 @@ package body Ocarina.FE_AADL.Parser.Properties.Values is ...@@ -659,7 +658,6 @@ package body Ocarina.FE_AADL.Parser.Properties.Values is
end if; end if;
Property_Type_Designator := P_Property_Type_Designator; Property_Type_Designator := P_Property_Type_Designator;
if No (Property_Type_Designator) then if No (Property_Type_Designator) then
-- error when parsing Property_Type_Designator, quit -- error when parsing Property_Type_Designator, quit
return No_Node; return No_Node;
...@@ -694,7 +692,6 @@ package body Ocarina.FE_AADL.Parser.Properties.Values is ...@@ -694,7 +692,6 @@ package body Ocarina.FE_AADL.Parser.Properties.Values is
Set_Property_Type_Designator (Valued_Property, Property_Type_Designator); Set_Property_Type_Designator (Valued_Property, Property_Type_Designator);
Set_Property_Expressions (Valued_Property, Property_Expressions); Set_Property_Expressions (Valued_Property, Property_Expressions);
return Valued_Property; return Valued_Property;
end P_Multi_Valued_Property; end P_Multi_Valued_Property;
...@@ -1766,9 +1763,11 @@ package body Ocarina.FE_AADL.Parser.Properties.Values is ...@@ -1766,9 +1763,11 @@ package body Ocarina.FE_AADL.Parser.Properties.Values is
-- P_Record_Type_Element -- -- P_Record_Type_Element --
---------------------------- ----------------------------
-- XXX To be renamed in P_Record_Field someday ..
-- AADL_V2 -- AADL_V2
-- --
-- defining_field_identifier : property_type_designator -- defining_field_identifier : [list of ] property_type_designator
function P_Record_Type_Element function P_Record_Type_Element
(Container : Node_Id) (Container : Node_Id)
...@@ -1785,6 +1784,7 @@ package body Ocarina.FE_AADL.Parser.Properties.Values is ...@@ -1785,6 +1784,7 @@ package body Ocarina.FE_AADL.Parser.Properties.Values is
Identifier : Node_Id; Identifier : Node_Id;
Record_Element : Node_Id; Record_Element : Node_Id;
Property_Type_Designator : Node_Id; Property_Type_Designator : Node_Id;
Is_List : Boolean := False;
begin begin
Save_Lexer (Loc); Save_Lexer (Loc);
...@@ -1803,6 +1803,21 @@ package body Ocarina.FE_AADL.Parser.Properties.Values is ...@@ -1803,6 +1803,21 @@ package body Ocarina.FE_AADL.Parser.Properties.Values is
Scan_Token; Scan_Token;
if Token = T_Colon then if Token = T_Colon then
Save_Lexer (Loc);
Scan_Token;
if Token = T_List then
Scan_Token;
if Token /= T_Of then
DPE (PC_Record_Type_Element, T_Of);
Skip_Tokens (T_Semicolon);
return No_Node;
end if;
Is_List := True;
else
Restore_Lexer (Loc);
end if;
Property_Type_Designator := P_Property_Type_Designator; Property_Type_Designator := P_Property_Type_Designator;
if No (Property_Type_Designator) then if No (Property_Type_Designator) then
DPE (PC_Record_Type_Element); DPE (PC_Record_Type_Element);
...@@ -1817,6 +1832,7 @@ package body Ocarina.FE_AADL.Parser.Properties.Values is ...@@ -1817,6 +1832,7 @@ package body Ocarina.FE_AADL.Parser.Properties.Values is
Set_Property_Type_Designator (Record_Element, Set_Property_Type_Designator (Record_Element,
Property_Type_Designator); Property_Type_Designator);
Set_Is_List (Record_Element, Is_List);
return Record_Element; return Record_Element;
end P_Record_Type_Element; end P_Record_Type_Element;
......
...@@ -67,12 +67,110 @@ package body Ocarina.FE_AADL.Parser.Properties is ...@@ -67,12 +67,110 @@ package body Ocarina.FE_AADL.Parser.Properties is
function P_Property_Owner_Category return Node_Id; function P_Property_Owner_Category return Node_Id;
function P_Property_Value (Container : Node_Id) return Node_Id;
----------------------
-- P_Property_Value --
----------------------
-- property_value ::= single_property_value | property_list_value
function P_Property_Value (Container : Node_Id) return Node_Id is
pragma Unreferenced (Container);
use Lexer;
use Ocarina.ME_AADL.Tokens;
use Ocarina.ME_AADL.AADL_Tree.Nodes;
use Ocarina.ME_AADL.AADL_Tree.Nutils;
use Ocarina.Builder.AADL.Properties;
use Ocarina.FE_AADL.Parser.Components.Modes;
use Ocarina.FE_AADL.Parser.Identifiers;
use Ocarina.FE_AADL.Parser.Properties.Values;
Loc : Location;
Prop_Value : Node_Id;
Parse_List_Of_Properties : Boolean := True;
begin
-- Parse Property_Value
Save_Lexer (Loc);
Scan_Token;
-- The AADLv2 BNF is ambiguous, a string starting with a '('
-- can either be a list of property expressions e.g. "(foo,
-- bar);" _or_ a single_expression containing a record term,
-- e.g. "(foo => 1; bar =>2;)". This look ahead loop scans
-- token to see which case we are currently processing.
declare
Loc2 : Location;
begin
Save_Lexer (Loc2);
if Token = T_Left_Parenthesis then
while Token /= T_Right_Parenthesis loop
Scan_Token;
if Token = T_Semicolon
or else Token = T_Applies
then
Parse_List_Of_Properties := False;
end if;
end loop;
else
Parse_List_Of_Properties := False;
end if;
Restore_Lexer (Loc2);
end;
if Parse_List_Of_Properties then
Save_Lexer (Loc);
Scan_Token;
if Token = T_Right_Parenthesis then
-- Property_List_Value is empty
Prop_Value := Node_Id (New_List (K_List_Id, Loc));
Set_Kind (Prop_Value, K_Property_List_Value);
Set_First_Node (List_Id (Prop_Value), No_Node);
Set_Last_Node (List_Id (Prop_Value), No_Node);
else
Restore_Lexer (Loc);
-- Prop_Value :=
-- Node_Id (P_Items_List (P_Property_Value'Access,
Prop_Value := Node_Id (P_Items_List (P_Property_Expression'Access,
No_Node,
T_Comma, T_Right_Parenthesis,
PC_Property_List_Value));
if No (Prop_Value) then
-- error when parsing Property_Expression list, quit
Skip_Tokens (T_Semicolon);
return No_Node;
end if;
Set_Kind (Prop_Value, K_Property_List_Value);
end if;
else
Restore_Lexer (Loc);
Prop_Value := P_Property_Expression (No_Node);