Commit 0158a248 authored by jhugues's avatar jhugues

* 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
Fan_Out_Policy: enumeration (Broadcast, RoundRobin, Selective, OnDemand)
applies to (port);
-- XXX not supported by Ocarina
-- Connection_Pattern: list of list of Supported_Connection_Patterns
-- applies to (connection);
Connection_Pattern: list of list of Supported_Connection_Patterns
applies to (connection);
-- Connection_Set: list of Connection_Pair
-- applies to (connection);
Connection_Set: list of Connection_Pair
applies to (connection);
-- Connection_Pair: type record (
-- src: list of aadlinteger;
-- dst: list of aadlinteger;);
Connection_Pair: type record (
src: list of aadlinteger;
dst: list of aadlinteger;);
Overflow_Handling_Protocol: enumeration (DropOldest, DropNewest, Error) => DropOldest
applies to (event port, event data port, subprogram access);
......
......@@ -59,16 +59,15 @@ property set Deployment_Properties is
Required_Connection_Quality_Of_Service: inherit list of Supported_Connection_QoS
applies to (port, connection, virtual bus, thread, thread group, process, system, device);
-- XXX not supported by Ocarina
-- Not_Collocated: record ( Targets: list of reference (data,
-- thread, process, system, connection); Location:
-- classifier (processor, memory, bus, system);) applies
-- to (process, system);
-- Collocated: record ( Targets: list of reference (data, thread,
-- process, system, connection); Location: classifier
-- (processor, memory, bus, system);) applies to
-- (process, system);
Not_Collocated: record (
Targets: list of reference (data, thread, process, system, connection);
Location: classifier (processor, memory, bus, system);) applies
to (process, system);
Collocated: record ( Targets: list of reference (data, thread,
process, system, connection); Location: classifier
(processor, memory, bus, system);) applies to
(process, system);
Allowed_Connection_Type: list of enumeration
(Sampled_Data_Connection, Immediate_Data_Connection,
......
......@@ -36,6 +36,7 @@ with Ocarina.ME_AADL.AADL_Tree.Nodes;
with Ocarina.BE_AADL.Properties;
with Ocarina.BE_AADL.Identifiers;
with Ocarina.BE_AADL.Components;
with Ocarina.BE_AADL.Components.Arrays;
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.Identifiers;
use Ocarina.BE_AADL.Components;
use Ocarina.BE_AADL.Components.Arrays;
-------------------
-- Print_Feature --
......@@ -174,6 +176,11 @@ package body Ocarina.BE_AADL.Components.Features is
else
Print_Token (T_Port);
end if;
if Present (Array_Dimensions (Node)) then
Write_Space;
Print_Array_Dimensions (Array_Dimensions (Node));
end if;
end Print_Port_Spec;
-------------------------------
......
......@@ -393,6 +393,12 @@ package body Ocarina.BE_AADL.Properties.Values is
Print_Identifier (Identifier (Node));
Write_Space;
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;
Print_Property_Type_Designator (Property_Type_Designator (Node));
Print_Token (T_Semicolon);
......
......@@ -253,8 +253,10 @@ package body Ocarina.BE_AADL.Properties is
end if;
if Is_List (Property_Name_Type (Node)) then
for J in 1 .. Multiplicity (Property_Name_Type (Node)) loop
Print_Tokens ((T_List, T_Of));
Write_Space;
end loop;
end if;
Print_Property_Type_Designator
......
......@@ -431,6 +431,7 @@ module Ocarina::ME_AADL::AADL_Tree::Nodes {
boolean Is_Feature;
boolean Is_Event; // FIXME: Rename to Is_Event_Port
boolean Is_Data; // FIXME: Rename to Is_Data_Port
Node_Id Array_Dimensions; // AADL_V2
};
// AADL_V1
......@@ -1095,6 +1096,7 @@ module Ocarina::ME_AADL::AADL_Tree::Nodes {
interface Property_Type : Node_Id {
boolean Is_List;
long Multiplicity; // number of "list of" in property type
Node_Id Property_Type_Designator;
Node_Id Expanded_Type_Designator;
};
......@@ -1124,7 +1126,7 @@ module Ocarina::ME_AADL::AADL_Tree::Nodes {
};
// multi_valued_property ::=
// list of property_type_designator
// (list of)+ property_type_designator
// [ => ( [ default_property_expression
// { , default_property_expression }* ] ) ]
......@@ -1246,7 +1248,11 @@ module Ocarina::ME_AADL::AADL_Tree::Nodes {
// | bus_classsifer_reference
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
{ , platform_classifier_reference }* )
......@@ -1392,10 +1398,11 @@ module Ocarina::ME_AADL::AADL_Tree::Nodes {
};
// record_term ::=
// ( property_expression ( , property_expression )* )
// ( record_field_identifier => property_expression ;
// ( record_field_identifier => property_expression ; )* )
interface Record_Term : Node_Id {
List_Id List_Items;
List_Id List_Items; // list of Record_Term_Element
};
interface Record_Term_Element : Node_Id {
......@@ -1538,6 +1545,7 @@ module Ocarina::ME_AADL::AADL_Tree::Nodes {
};
interface Record_Type_Element : Node_Id {
boolean Is_List;
Node_Id Identifier;
Node_Id Property_Type_Designator;
};
......@@ -1546,7 +1554,7 @@ module Ocarina::ME_AADL::AADL_Tree::Nodes {
// defining_property_type_identifier : type property_type_designator ;
// property_type_designator ::= property_type
// | unique_property_type_identifie
// | unique_property_type_identifier
// property_type ::= aadlboolean | aadlstring | enumeration_type
// | units_type | number_type | range_type
......
......@@ -63,7 +63,8 @@ package body Ocarina.FE_AADL.Parser.Components.Arrays is
use Ocarina.ME_AADL.AADL_Tree.Nutils;
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;
List_Array_Dim : List_Id := No_List;
......
......@@ -35,6 +35,7 @@ with Locations;
with Ocarina.ME_AADL.AADL_Tree.Nodes;
with Ocarina.FE_AADL.Lexer;
with Ocarina.ME_AADL.Tokens;
with Ocarina.FE_AADL.Parser.Components.Arrays;
with Ocarina.FE_AADL.Parser.Identifiers;
with Ocarina.FE_AADL.Parser.Properties;
with Ocarina.Builder.AADL.Components.Features;
......@@ -246,6 +247,7 @@ package body Ocarina.FE_AADL.Parser.Components.Features is
-- port_spec ::=
-- defining_port_identifier : ( in | out | in out ) port_type
-- XXX dimensions ???
-- [ { { port_property_association }+ } ] ;
-- port_refinement ::=
......@@ -268,6 +270,7 @@ package body Ocarina.FE_AADL.Parser.Components.Features is
use Parser.Properties;
use Parser.Identifiers;
use Ocarina.Builder.AADL.Components.Features;
use Parser.Components.Arrays;
Class_Ref : Node_Id := No_Node;
Port_Spec : Node_Id := No_Node;
......@@ -277,6 +280,7 @@ package body Ocarina.FE_AADL.Parser.Components.Features is
Code : Parsing_Code;
OK : Boolean;
Loc : Location;
Array_Dimensions : Node_Id;
begin
if Is_Refinement then
......@@ -343,6 +347,29 @@ package body Ocarina.FE_AADL.Parser.Components.Features is
Is_Refinement => Is_Refinement,
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);
if not OK then
......
......@@ -82,7 +82,6 @@ package body Ocarina.FE_AADL.Parser.Components.Prototypes is
Is_Refinement : Boolean;
OK : Boolean;
begin
P_Identifier_Refined_To
(Refinable_To_RT (Refinable),
False,
......@@ -146,7 +145,6 @@ package body Ocarina.FE_AADL.Parser.Components.Prototypes is
end if;
return Prototype;
end P_Prototype_Or_Prototype_Refinement;
--------------------------
......@@ -269,7 +267,6 @@ package body Ocarina.FE_AADL.Parser.Components.Prototypes is
end if;
return Prototype_Binding;
end P_Prototype_Binding;
end Ocarina.FE_AADL.Parser.Components.Prototypes;
......@@ -633,7 +633,7 @@ package body Ocarina.FE_AADL.Parser.Properties.Values is
-- 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 }* ] ) ]
......@@ -648,7 +648,6 @@ package body Ocarina.FE_AADL.Parser.Properties.Values is
Property_Type_Designator : Node_Id;
Property_Expressions : List_Id;
Loc : Location;
begin
Valued_Property := New_Node (K_Multi_Valued_Property, Token_Location);
......@@ -659,7 +658,6 @@ package body Ocarina.FE_AADL.Parser.Properties.Values is
end if;
Property_Type_Designator := P_Property_Type_Designator;
if No (Property_Type_Designator) then
-- error when parsing Property_Type_Designator, quit
return No_Node;
......@@ -694,7 +692,6 @@ package body Ocarina.FE_AADL.Parser.Properties.Values is
Set_Property_Type_Designator (Valued_Property, Property_Type_Designator);
Set_Property_Expressions (Valued_Property, Property_Expressions);
return Valued_Property;
end P_Multi_Valued_Property;
......@@ -1766,9 +1763,11 @@ package body Ocarina.FE_AADL.Parser.Properties.Values is
-- P_Record_Type_Element --
----------------------------
-- XXX To be renamed in P_Record_Field someday ..
-- AADL_V2
--
-- defining_field_identifier : property_type_designator
-- defining_field_identifier : [list of ] property_type_designator
function P_Record_Type_Element
(Container : Node_Id)
......@@ -1785,6 +1784,7 @@ package body Ocarina.FE_AADL.Parser.Properties.Values is
Identifier : Node_Id;
Record_Element : Node_Id;
Property_Type_Designator : Node_Id;
Is_List : Boolean := False;
begin
Save_Lexer (Loc);
......@@ -1803,6 +1803,21 @@ package body Ocarina.FE_AADL.Parser.Properties.Values is
Scan_Token;
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;
if No (Property_Type_Designator) then
DPE (PC_Record_Type_Element);
......@@ -1817,6 +1832,7 @@ package body Ocarina.FE_AADL.Parser.Properties.Values is
Set_Property_Type_Designator (Record_Element,
Property_Type_Designator);
Set_Is_List (Record_Element, Is_List);
return Record_Element;
end P_Record_Type_Element;
......
......@@ -67,12 +67,110 @@ package body Ocarina.FE_AADL.Parser.Properties is
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);
if No (Prop_Value) then
-- error when parsing Property_Expression, quit
Skip_Tokens (T_Semicolon);
return No_Node;
end if;
end if;
return Prop_Value;
end P_Property_Value;
----------------------------
-- P_Property_Association --
----------------------------
function P_Property_Association (Container : Node_Id) return Node_Id is
use Ocarina.ME_AADL.Tokens;
begin
......@@ -157,8 +255,6 @@ package body Ocarina.FE_AADL.Parser.Properties is
-- annex_path ::=
-- [ { annex_identifier } ] { ** model_element_identifier }+
-- property_value ::= single_property_value | property_list_value
-- single_property_value ::= property_expression
-- property_list_value ::=
......@@ -209,7 +305,6 @@ package body Ocarina.FE_AADL.Parser.Properties is
Property_Loc : Location;
Item : Node_Id;
Parse_List_Of_Properties : Boolean := True;
begin
Save_Lexer (Loc);
Scan_Token;
......@@ -301,67 +396,7 @@ package body Ocarina.FE_AADL.Parser.Properties is
-- 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,
-- bard);"_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 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_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);
if No (Prop_Value) then
-- error when parsing Property_Expression, quit
Skip_Tokens (T_Semicolon);
return No_Node;
end if;
end if;
Prop_Value := P_Property_Value (Container);
-- Parse 'applies to ...'
......@@ -694,6 +729,7 @@ package body Ocarina.FE_AADL.Parser.Properties is
Multiple_Default_Value : List_Id;
Owner_Categories : List_Id;
Loc : Location;
Multiplicity : Int := 0;
begin
Save_Lexer (Loc);
Scan_Token;
......@@ -726,6 +762,22 @@ package body Ocarina.FE_AADL.Parser.Properties is
if Token = T_List then
Is_A_List := True;
Multiplicity := 1;
Save_Lexer (Loc);
Scan_Token;
if Token = T_Of then
Scan_Token;
if Token /= T_List then
Restore_Lexer (Loc);
else
Multiplicity := 2; -- XXX shall we iterate? BNF says yes
end if;
else
Restore_Lexer (Loc);
end if;
Property_Definition_Value := P_Multi_Valued_Property;
Single_Default_Value := No_Node;
......@@ -831,6 +883,7 @@ package body Ocarina.FE_AADL.Parser.Properties is
Property_Type_Is_A_List => Is_A_List,
Applies_To_All => Is_All,
Applies_To => Owner_Categories);
Set_Multiplicity (Property_Name_Type (Property), Multiplicity);
return Property;
end P_Property_Definition_Declaration;
......
example_005.aadl:29:21: parsing Port_Spec, token ';' is expected, found token '['
example_005.aadl:27:01: parsing Features, list is empty
Cannot parse AADL specifications
example_005.aadl:16:03: Connection_Pattern (property association) does not point to anything
example_005.aadl:16:22: (property term) does not point to anything or to something unreachable
example_005.aadl:18:03: Connection_Pattern (property association) does not point to anything
example_005.aadl:18:22: (property term) does not point to anything or to something unreachable
Cannot analyze AADL specifications
example_014.aadl:14:32: parsing Property_Expression, not allowed in aadl v2
example_014.aadl:15:01: parsing Property_Association or Contained_Property_Association, token ';' is expected, found keyword 'end'
example_014.aadl:13:01: parsing Properties, list is empty
example_014.aadl:16:01: parsing AADL_Declaration, not allowed in aadl v2
example_014.aadl:18:01: parsing AADL_Declaration, not allowed in aadl v2
example_014.aadl:21:01: parsing AADL_Declaration, unexpected keyword 'end'
example_014.aadl:22:01: parsing AADL_Declaration, unexpected keyword 'end'
Cannot parse AADL specifications
example_018.aadl:11:21: parsing Port_Spec, token ';' is expected, found token '['
example_018.aadl:10:01: parsing Features, list is empty
Cannot parse AADL specifications
example_018.aadl:29:41: Connection_Pattern (property association) does not point to anything
example_018.aadl:29:60: (property term) does not point to anything or to something unreachable
Cannot analyze AADL specifications
example_023.aadl:22:27: parsing Record_Term_Element, token '=>' is expected, found token ','
example_023.aadl:22:46: parsing Property_Association, token ';' is expected, found token '}'
example_023.aadl:20:01: parsing Connections, list is empty
Cannot parse AADL specifications
......@@ -5,6 +5,7 @@
property set ARINC653 is
Partition_Slots : list of Time
applies to (processor);
......
This diff is collapsed.
This diff is collapsed.
Markdown is supported
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