------------------------------------------ -------------------------------------- -- -- -- OCARINA COMPONENTS -- -- -- -- OCARINA.AADL.PARSER.COMPONENTS.SUBCOMPONENTS -- -- -- -- B o d y -- -- -- -- Copyright (C) 2004-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) -- -- -- ------------------------------------------------------------------------------ with Locations; with Ocarina.Nodes; with Ocarina.AADL.Lexer; with Ocarina.AADL.Tokens; with Ocarina.AADL.Parser.Components.Modes; with Ocarina.AADL.Parser.Properties; with Ocarina.AADL.Parser.Identifiers; with Ocarina.Builder.Components.Subcomponents; package body Ocarina.AADL.Parser.Components.Subcomponents is -------------------- -- P_Subcomponent -- -------------------- -- subcomponent ::= -- defining_subcomponent_identifier : -- component_category [ component classifier_reference ] -- [ { { subcomponent_property_association -- | contained_property_association }+ } ] -- [ in_modes ] ; -- subcomponent_refinement ::= -- defining_subcomponent_identifier : refined to -- component_category [ component classifier_reference ] -- [ { { subcomponent_property_association -- | contained_property_association }+ } ] -- [ in_modes ] ; function P_Subcomponent (Container : Types.node_id; Refinable : Boolean) return node_id is use Locations; use Ocarina.Nodes; use Tokens; use Lexer; use Parser.Components.Modes; use Parser.Properties; use Parser.Identifiers; use Ocarina.Builder.Components.Subcomponents; Subcomponent : node_id; -- output Identifier : node_id; Is_Refinement : Boolean; Category : component_category; Component_Ref : node_id; -- Component_Prop : List_Id; Component_Modes : node_id; Code : parsing_code; Loc : location; OK : Boolean; begin P_Identifier_Refined_To (Refinable_To_RT (Refinable), False, pc_subcomponent, pc_subcomponent_refinement, t_semicolon, Identifier, Is_Refinement, OK); if not OK then return No_Node; end if; if Is_Refinement then Code := pc_subcomponent_refinement; else Code := pc_subcomponent; end if; Scan_Token; Category := P_Component_Category; if Category = cc_unknown then Skip_Tokens (t_semicolon); return No_Node; end if; Save_Lexer (Loc); Scan_Token; if Token = t_identifier then Restore_Lexer (Loc); Component_Ref := P_Entity_Reference (Code); if No (Component_Ref) then Skip_Tokens (t_semicolon); return No_Node; end if; else Component_Ref := No_Node; Restore_Lexer (Loc); end if; Subcomponent := Add_New_Subcomponent (Loc => Ocarina.Nodes.Loc (Identifier), Name => Identifier, Comp_Impl => Container, Is_Refinement => Is_Refinement, Category => Category, In_Modes => No_Node); -- P_Property_Associations (Subcomponent, True, --PAT_Simple_Or_Contained, -- T_Semicolon, Code, Component_Prop, OK); OK := P_Property_Associations (Subcomponent, True, pat_simple_or_contained, Code); if not OK then return No_Node; end if; Save_Lexer (Loc); Scan_Token; if Token = t_in then Component_Modes := P_In_Modes (pc_in_modes); if No (Component_Modes) then Skip_Tokens (t_semicolon); return No_Node; end if; Set_In_Modes (Subcomponent, Component_Modes); else Restore_Lexer (Loc); end if; Save_Lexer (Loc); Scan_Token; if Token /= t_semicolon then DPE (Code, t_semicolon); Restore_Lexer (Loc); return No_Node; end if; if Subcomponent /= No_Node then Set_Entity_Ref (Subcomponent, Component_Ref); end if; return Subcomponent; end P_Subcomponent; end Ocarina.AADL.Parser.Components.Subcomponents;