---------------------------------------- ---------------------------------------- -- -- -- OCARINA COMPONENTS -- -- -- -- O C A R I N A . D I A . P A R S E R . C O R E -- -- -- -- S p e c -- -- -- -- Copyright (C) 2005-2006, GET-Telecom Paris. -- -- -- -- Ocarina is free software; you can redistribute it and/or modify -- -- it under terms of the GNU General Public License as published by the -- -- Free Software Foundation; either version 2, or (at your option) any -- -- later version. Ocarina is distributed in the hope that it will be -- -- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -- -- Public License for more details. You should have received a copy of the -- -- GNU General Public License distributed with Ocarina; see file COPYING. -- -- If not, write to the Free Software Foundation, 51 Franklin Street, Fifth -- -- Floor, Boston, MA 02111-1301, USA. -- -- -- -- As a special exception, if other files instantiate generics from this -- -- unit, or you link this unit with other files to produce an executable, -- -- this unit does not by itself cause the resulting executable to be -- -- covered by the GNU General Public License. This exception does not -- -- however invalidate any other reasons why the executable file might be -- -- covered by the GNU Public License. -- -- -- -- Ocarina is maintained by the Ocarina team -- -- (ocarina-users@listes.enst.fr) -- -- -- ------------------------------------------------------------------------------ -- This package implements the raw parsing of Dia files into a list -- of generic nodes containing all the information that is sound to -- Ocarina for generating the corresponding AADL tree. with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Unchecked_Deallocation; with DOM.Core; package Ocarina.Dia.Parser.Core is ----------------------------------------------------------- type Connection_Point is record Object_ID : Unbounded_String; Port : Natural; end record; type Connection is tagged record Start_Point : Connection_Point; End_Point : Connection_Point; end record; -- These two types are used to represent connections type Port_Type is ( Access_Provider, -- 9 Access_Requirer, -- 10 In_Data_Port, -- 11 In_Event_Port, -- 12 In_Event_Data_Port, -- 13 Out_Data_Port, -- 14 Out_Event_Port, -- 15 Out_Event_Data_Port, -- 16 In_Out_Data_Port, -- 17 In_Out_Event_Port, -- 18 In_Out_Event_Data_Port, -- 19 Port_Group, -- 20 Point); -- The different possible ports subtype Real_Port is Port_Type range Access_Provider .. Port_Group; -- A convenient subtype for actual ports ----------------------------------------------------------- type Port_Record (Port_Type_Arg : Port_Type) is record case Port_Type_Arg is when Real_Port => Declaration : Unbounded_String; when Point => Position : Unbounded_String; end case; end record; type Port is access all Port_Record; type Port_List_Record; type Port_List is access Port_List_Record; type Port_List_Record is record Hd : Port; Tl : Port_List; end record; -- A simple ordered list of ports ------------------------------------------------------------ ----------- -- Nodes -- ----------- -- This is the base type for all Ocarina.Dia.Parser types. It is -- declared in this package for visibility reason. type Node_Type is ( Process, Thread, Data, Processor, Memory, Bus, System, Subprogram, Thread_Group, Device, Link, Void); -- All different types of nodes subtype AADLObject_Type is Node_Type range Process .. Device; -- A convenient subtype for "real" objects ----------------------------------------------------------- type Node_Record (Node_Type_Arg : Node_Type) is record ID : Unbounded_String; Version : Integer; case Node_Type_Arg is when AADLObject_Type => Name : Unbounded_String; Declaration : Unbounded_String; Ports : Port_List; Parent : Unbounded_String := To_Unbounded_String (""); -- if this node is not a child node when Link => Conn : Connection; Style : Natural; -- 0 for plain, > 0 for any dashed style Start_Head_Style : Natural; End_Head_Style : Natural; when Void => null; end case; end record; -- The actual definition of the node tagged type type Node is access Node_Record; ------------------------------------------------------------ type Node_Array is array (Integer range <>) of Node; type Node_Array_Access is access Node_Array; type Node_List is record Items : Node_Array_Access := null; Last : Integer := -1; end record; Null_List : constant Node_List := (null, -1); procedure Free is new Unchecked_Deallocation ( Node_Array, Node_Array_Access); procedure Append (List : in out Node_List; N : Node); -- Insert N as the last element in List procedure Remove (List : in out Node_List; N : Node); -- Remove N from the list -- N must be an element of List, this is not checked. -- Implementation of lists of nodes function Count_Objects (NL : Node_List) return Integer; -- Returns the number of objects in a list Missing_Attribute : exception; -- Exception raised when a required attribute is not found function Get_Required_Attribute (Attrs : DOM.Core.Named_Node_Map; N : String) return String; -- Looks for a specific attribute and returns its value, or raises -- Missing_Attribute Missing_Child : exception; -- Raised when a required child element is not found procedure Get_Required_Child (Children : DOM.Core.Node_List; S : String; Index : in out Natural; E : out DOM.Core.Node); -- Looks for a specific child node and returns the first element -- with that name -- Generic Purpose functions, for retrieving a specific child or -- attribute in a Dia XML element end Ocarina.Dia.Parser.Core;