----------------------------------------------------------------- ------ ----------- -- -- -- 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;