1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
30 #include <s2_luidl/pe_file2.hxx>
33 // NOT FULLY DECLARED SERVICES
34 #include <ary/idl/i_gate.hxx>
35 #include <ary/idl/i_module.hxx>
36 #include <ary/idl/ip_ce.hxx>
37 #include <ary/doc/d_oldidldocu.hxx>
38 #include <s2_luidl/distrib.hxx>
39 #include <s2_luidl/pe_servi.hxx>
40 #include <s2_luidl/pe_iface.hxx>
41 #include <s2_luidl/pe_singl.hxx>
42 #include <s2_luidl/pe_struc.hxx>
43 #include <s2_luidl/pe_excp.hxx>
44 #include <s2_luidl/pe_const.hxx>
45 #include <s2_luidl/pe_enum2.hxx>
46 #include <s2_luidl/pe_tydf2.hxx>
47 #include <s2_luidl/tk_keyw.hxx>
48 #include <s2_luidl/tk_ident.hxx>
49 #include <s2_luidl/tk_punct.hxx>
60 PE_File::PE_File( TokenDistributor
& i_rTokenAdmin
,
61 const ParserInfo
& i_parseInfo
)
62 : pTokenAdmin(&i_rTokenAdmin
),
63 pPE_Service(new PE_Service
),
64 pPE_Singleton(new PE_Singleton
),
65 pPE_Interface(new PE_Interface
),
66 pPE_Struct(new PE_Struct
),
67 pPE_Exception(new PE_Exception
),
68 pPE_Constant(new PE_Constant
),
69 pPE_Enum(new PE_Enum
),
70 pPE_Typedef(new PE_Typedef
),
72 pParseInfo(&i_parseInfo
),
74 nBracketCount_inDefMode(0)
79 PE_File::EstablishContacts( UnoIDL_PE
* io_pParentPE
,
80 ary::Repository
& io_rRepository
,
81 TokenProcessing_Result
& o_rResult
)
83 UnoIDL_PE::EstablishContacts(io_pParentPE
,io_rRepository
,o_rResult
);
84 pPE_Service
->EstablishContacts(this,io_rRepository
,o_rResult
);
85 pPE_Singleton
->EstablishContacts(this,io_rRepository
,o_rResult
);
86 pPE_Interface
->EstablishContacts(this,io_rRepository
,o_rResult
);
87 pPE_Struct
->EstablishContacts(this,io_rRepository
,o_rResult
);
88 pPE_Exception
->EstablishContacts(this,io_rRepository
,o_rResult
);
89 pPE_Constant
->EstablishContacts(this,io_rRepository
,o_rResult
);
90 pPE_Enum
->EstablishContacts(this,io_rRepository
,o_rResult
);
91 pPE_Typedef
->EstablishContacts(this,io_rRepository
,o_rResult
);
93 pCurNamespace
= &Gate().Ces().GlobalNamespace();
101 PE_File::ProcessToken( const Token
& i_rToken
)
103 i_rToken
.Trigger(*this);
107 PE_File::Process_Identifier( const TokIdentifier
& i_rToken
)
111 case wait_for_module
:
113 csv_assert(pCurNamespace
!= 0);
115 ary::idl::Module
& rCe
= Gate().Ces().CheckIn_Module(pCurNamespace
->CeId(), i_rToken
.Text());
116 pCurNamespace
= &rCe
;
118 // Get docu out of normal:
119 SetDocu(pTokenAdmin
->ReleaseLastParsedDocu());
122 csv_assert(pCurNamespace
!= 0);
124 SetResult(done
, stay
);
125 eState
= wait_for_module_bracket
;
128 SetResult(done
, stay
);
136 PE_File::Process_Punctuation( const TokPunctuation
& i_rToken
)
141 if (i_rToken
.Id() == TokPunctuation::CurledBracketClose
)
143 csv_assert(pCurNamespace
!= 0);
145 pCurNamespace
= &Gate().Ces().Find_Module(pCurNamespace
->Owner());
147 SetResult(done
, stay
);
148 eState
= wait_for_module_semicolon
;
155 case wait_for_module_bracket
:
156 if (i_rToken
.Id() == TokPunctuation::CurledBracketOpen
)
158 SetResult(done
, stay
);
166 case wait_for_module_semicolon
:
167 if (i_rToken
.Id() == TokPunctuation::Semicolon
)
169 SetResult(done
, stay
);
178 if (i_rToken
.Id() == TokPunctuation::CurledBracketClose
)
180 nBracketCount_inDefMode
--;
182 else if (i_rToken
.Id() == TokPunctuation::CurledBracketOpen
)
184 nBracketCount_inDefMode
++;
186 else if (i_rToken
.Id() == TokPunctuation::Semicolon
)
188 if (nBracketCount_inDefMode
<= 0)
193 SetResult(done
, stay
);
201 PE_File::Process_MetaType( const TokMetaType
& i_rToken
)
203 switch (i_rToken
.Id())
205 case TokMetaType::mt_service
:
207 SetResult( not_done
, push_sure
, pPE_Service
.Ptr());
209 case TokMetaType::mt_singleton
:
211 SetResult( not_done
, push_sure
, pPE_Singleton
.Ptr());
213 case TokMetaType::mt_uik
:
214 Cerr() << "Syntax error: [uik ....] is obsolete now." << Endl();
215 SetResult( not_done
, pop_failure
);
217 case TokMetaType::mt_interface
:
219 SetResult( not_done
, push_sure
, pPE_Interface
.Ptr());
221 case TokMetaType::mt_module
:
222 eState
= wait_for_module
;
223 SetResult( done
, stay
);
225 case TokMetaType::mt_struct
:
227 SetResult( done
, push_sure
, pPE_Struct
.Ptr());
229 case TokMetaType::mt_exception
:
231 SetResult( done
, push_sure
, pPE_Exception
.Ptr());
233 case TokMetaType::mt_constants
:
235 SetResult( done
, push_sure
, pPE_Constant
.Ptr());
237 case TokMetaType::mt_enum
:
239 SetResult( done
, push_sure
, pPE_Enum
.Ptr());
241 case TokMetaType::mt_typedef
:
243 SetResult( done
, push_sure
, pPE_Typedef
.Ptr());
252 PE_File::Process_Stereotype( const TokStereotype
& i_rToken
)
254 if (i_rToken
.Id() == TokStereotype::ste_published
)
256 pTokenAdmin
->Set_PublishedOn();
258 SetResult(done
, stay
);
267 PE_File::Process_Default()
269 if (eState
!= on_default
)
272 nBracketCount_inDefMode
= 0;
274 SetResult(done
, stay
);
277 const ary::idl::Module
&
278 PE_File::CurNamespace() const
280 csv_assert(pCurNamespace
);
281 return *pCurNamespace
;
285 PE_File::ParseInfo() const
287 csv_assert(pParseInfo
);
298 PE_File::TransferData()
304 PE_File::ReceiveData()
320 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */