---------------------------------- ---------------------------------------------- -- -- -- OCARINA COMPONENTS -- -- -- -- OCARINA.AADL.PARSER.COMPONENTS.SUBPROGRAM_CALLS -- -- -- -- 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.Identifiers; with Ocarina.AADL.Parser.Components.Modes; with Ocarina.AADL.Parser.Properties; with Ocarina.Builder.Components.Subprogram_Calls; package body Ocarina.AADL.Parser.Components.Subprogram_Calls is function P_Subprogram_Call (Container : Types.node_id) return node_id; ----------------------- -- P_Subprogram_Call -- ----------------------- -- subprogram_call ::= -- defining_call_identifier : subprogram called_subprogram -- [ { { subcomponent_call_property_association }+ } ] ; -- called_subprogram ::= -- subprogram_classifier_reference -- | data_unique_type_reference . data_subprogram_identifier function P_Subprogram_Call (Container : Types.node_id) return node_id is use Locations; use Ocarina.Nodes; use Parser.Properties; use Lexer; use Tokens; use Ocarina.AADL.Parser.Identifiers; use Ocarina.Builder.Components.Subprogram_Calls; pragma assert (Container /= No_Node and then Kind (Container) = k_subprogram_call_sequence); Subprog_Call : node_id; Identifier : node_id; -- Call_Prop : List_Id; Call_Ref : node_id; OK : Boolean; Loc : location; begin Save_Lexer (Loc); Scan_Token; if Token /= t_identifier then DPE (pc_subprogram_call, t_identifier); Skip_Tokens (t_semicolon); return No_Node; end if; Identifier := Make_Current_Identifier (No_Node); -- Subprog_Call := New_Node (K_Subprogram_Call, Token_Location); -- Set_Identifier (Subprog_Call, Identifier); Scan_Token; -- parse ':' if Token /= t_colon then DPE (pc_subprogram_call, t_colon); Skip_Tokens (t_semicolon); return No_Node; end if; Scan_Token; -- parse 'subprogram' if Token /= t_subprogram then DPE (pc_subprogram_call, t_subprogram); Skip_Tokens (t_semicolon); return No_Node; end if; -- Call_Ref := P_Classifier_Reference (No_Node); Call_Ref := P_Entity_Reference (pc_subprogram_call); if No (Call_Ref) then Skip_Tokens (t_semicolon); return No_Node; end if; Subprog_Call := Add_New_Subprogram_Call (Loc => Loc, Name => Identifier, Call_Sequence => Container); OK := P_Property_Associations (Subprog_Call, True, pat_simple, pc_subprogram_call); if not OK then return No_Node; end if; Save_Lexer (Loc); Scan_Token; if Token /= t_semicolon then DPE (pc_subprogram_call, t_semicolon); Restore_Lexer (Loc); return No_Node; end if; Set_Entity_Ref (Subprog_Call, Call_Ref); return Subprog_Call; end P_Subprogram_Call; -------------------------------- -- P_Subprogram_Call_Sequence -- -------------------------------- -- subprogram_call_sequence ::= -- [ defining_call_sequence_identifier : ] -- { { subprogram_call }+ } [ in_modes ] ; function P_Subprogram_Call_Sequence (Container : Types.node_id) return node_id is use Locations; use Ocarina.Nodes; use Parser.Components.Modes; use Lexer; use Tokens; use Ocarina.AADL.Parser.Identifiers; use Ocarina.Builder.Components.Subprogram_Calls; Call_Sequence : node_id; Identifier : node_id := No_Node; Subprogram_Calls : list_id; In_Modes : node_id; Loc : location; Start_Loc : location; begin Save_Lexer (Loc); Start_Loc := Loc; Scan_Token; if Token /= t_identifier and then Token /= t_left_curly_bracket then -- return No_Node, try to parse other element, so no error message Restore_Lexer (Loc); return No_Node; end if; if Token = t_identifier then Identifier := Make_Current_Identifier (No_Node); Scan_Token; -- parse next token, ':' is expected if Token /= t_colon then DPE (pc_subprogram_call_sequence, t_colon); Skip_Tokens (t_semicolon); return No_Node; end if; Scan_Token; -- parse next token, '{' is expected end if; if Token /= t_left_curly_bracket then DPE (pc_subprogram_call_sequence, t_left_curly_bracket); Skip_Tokens (t_semicolon); return No_Node; end if; Call_Sequence := Add_New_Subprogram_Call_Sequence (Loc => Start_Loc, Comp_Impl => Container, Name => Identifier, In_Modes => No_Node); Subprogram_Calls := P_Items_List (P_Subprogram_Call'access, Call_Sequence, t_right_curly_bracket, True); -- XXX The container should not be 'no_node'. Yet, at this -- point, the sequence has not been created yet if No (Subprogram_Calls) then Skip_Tokens (t_semicolon); return No_Node; end if; Save_Lexer (Loc); Scan_Token; if Token = t_in then In_Modes := P_In_Modes (pc_in_modes); if No (In_Modes) then Skip_Tokens (t_semicolon); return No_Node; end if; Set_In_Modes (Call_Sequence, In_Modes); else In_Modes := No_Node; Restore_Lexer (Loc); end if; Save_Lexer (Loc); Scan_Token; if Token /= t_semicolon then DPE (pc_subprogram_call_sequence, t_semicolon); Restore_Lexer (Loc); return No_Node; end if; -- Set_Subprogram_Calls (Call_Sequence, Subprogram_Calls); return Call_Sequence; end P_Subprogram_Call_Sequence; end Ocarina.AADL.Parser.Components.Subprogram_Calls;