--------------------------------------------------------------------- ----------- -- -- -- OCARINA COMPONENTS -- -- -- -- O C A R I N A . A A D L . P A R S E R . A N N E X E S -- -- -- -- 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.AADL.Tokens; with Ocarina.AADL.Lexer; with Ocarina.AADL.Parser.Identifiers; with Ocarina.Builder.Annexes; package body Ocarina.AADL.Parser.Annexes is function P_Annex (Namespace : Types.Node_Id; Code : Parsing_Code; Private_Declaration : Boolean) return Node_Id; -- Parse Annex_Library or Annex_Subclause, current token must be 'annex' ------------- -- P_Annex -- ------------- function P_Annex (Namespace : Types.Node_Id; Code : Parsing_Code; Private_Declaration : Boolean) return Node_Id is use Tokens; use Lexer; use Locations; use Ocarina.AADL.Parser.Identifiers; use Ocarina.Builder.Annexes; Annex : Node_Id; -- output Identifier : Node_Id; Loc : Location; Annex_Content : Name_Id; Annex_Location : constant Location := Token_Location; begin Identifier := P_Identifier (No_Node); if Identifier = No_Node then DPE (Code, T_Identifier); Skip_Tokens ((T_End_Annex, T_Semicolon)); return No_Node; end if; Scan_Token; if Token /= T_Begin_Annex then DPE (Code, T_Begin_Annex); Skip_Tokens ((T_End_Annex, T_Semicolon)); return No_Node; end if; Save_Lexer (Loc); Scan_Raw_Text (T_End_Annex); Annex_Content := Raw_Text_Value; Scan_Token; if Token /= T_End_Annex then DPE (Code, T_End_Annex); Skip_Tokens (T_Semicolon); return No_Node; 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 Code = PC_Annex_Library then Annex := Add_New_Annex_Library (Annex_Location, Identifier, Namespace, Is_Private => Private_Declaration); else Annex := Add_New_Annex_Subclause (Annex_Location, Identifier, Namespace); end if; if Annex /= No_Node and then Set_Annex_Content (Annex, Annex_Content) then return Annex; else return No_Node; end if; end P_Annex; --------------------- -- P_Annex_Library -- --------------------- -- annex_library ::= -- annex annex_identifier {** -- annex_specific_reusable_constructs -- **} ; function P_Annex_Library (Namespace : Types.Node_Id; Private_Declaration : Boolean := False) return Node_Id is begin return P_Annex (Namespace, PC_Annex_Library, Private_Declaration); end P_Annex_Library; ----------------------- -- P_Annex_Subclause -- ----------------------- -- annex_subclause ::= -- annex annex_identifier {** -- annex_specific_language_constructs -- **} ; function P_Annex_Subclause (Namespace : Types.Node_Id) return Node_Id is begin return P_Annex (Namespace, PC_Annex_Subclause, False); end P_Annex_Subclause; end Ocarina.AADL.Parser.Annexes;