1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: pe_file2.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
32 #include <s2_luidl/pe_file2.hxx>
35 // NOT FULLY DECLARED SERVICES
36 #include <ary/idl/i_gate.hxx>
37 #include <ary/idl/i_module.hxx>
38 #include <ary/idl/ip_ce.hxx>
39 #include <ary/doc/d_oldidldocu.hxx>
40 #include <s2_luidl/distrib.hxx>
41 #include <s2_luidl/pe_servi.hxx>
42 #include <s2_luidl/pe_iface.hxx>
43 #include <s2_luidl/pe_singl.hxx>
44 #include <s2_luidl/pe_struc.hxx>
45 #include <s2_luidl/pe_excp.hxx>
46 #include <s2_luidl/pe_const.hxx>
47 #include <s2_luidl/pe_enum2.hxx>
48 #include <s2_luidl/pe_tydf2.hxx>
49 #include <s2_luidl/tk_keyw.hxx>
50 #include <s2_luidl/tk_ident.hxx>
51 #include <s2_luidl/tk_punct.hxx>
62 PE_File::PE_File( TokenDistributor
& i_rTokenAdmin
,
63 const ParserInfo
& i_parseInfo
)
64 : pTokenAdmin(&i_rTokenAdmin
),
65 pPE_Service(new PE_Service
),
66 pPE_Singleton(new PE_Singleton
),
67 pPE_Interface(new PE_Interface
),
68 pPE_Struct(new PE_Struct
),
69 pPE_Exception(new PE_Exception
),
70 pPE_Constant(new PE_Constant
),
71 pPE_Enum(new PE_Enum
),
72 pPE_Typedef(new PE_Typedef
),
74 pParseInfo(&i_parseInfo
),
76 nBracketCount_inDefMode(0)
81 PE_File::EstablishContacts( UnoIDL_PE
* io_pParentPE
,
82 ary::Repository
& io_rRepository
,
83 TokenProcessing_Result
& o_rResult
)
85 UnoIDL_PE::EstablishContacts(io_pParentPE
,io_rRepository
,o_rResult
);
86 pPE_Service
->EstablishContacts(this,io_rRepository
,o_rResult
);
87 pPE_Singleton
->EstablishContacts(this,io_rRepository
,o_rResult
);
88 pPE_Interface
->EstablishContacts(this,io_rRepository
,o_rResult
);
89 pPE_Struct
->EstablishContacts(this,io_rRepository
,o_rResult
);
90 pPE_Exception
->EstablishContacts(this,io_rRepository
,o_rResult
);
91 pPE_Constant
->EstablishContacts(this,io_rRepository
,o_rResult
);
92 pPE_Enum
->EstablishContacts(this,io_rRepository
,o_rResult
);
93 pPE_Typedef
->EstablishContacts(this,io_rRepository
,o_rResult
);
95 pCurNamespace
= &Gate().Ces().GlobalNamespace();
103 PE_File::ProcessToken( const Token
& i_rToken
)
105 i_rToken
.Trigger(*this);
109 PE_File::Process_Identifier( const TokIdentifier
& i_rToken
)
113 case wait_for_module
:
115 csv_assert(pCurNamespace
!= 0);
117 ary::idl::Module
& rCe
= Gate().Ces().CheckIn_Module(pCurNamespace
->CeId(), i_rToken
.Text());
118 pCurNamespace
= &rCe
;
120 // Get docu out of normal:
121 SetDocu(pTokenAdmin
->ReleaseLastParsedDocu());
124 csv_assert(pCurNamespace
!= 0);
126 SetResult(done
, stay
);
127 eState
= wait_for_module_bracket
;
130 SetResult(done
, stay
);
138 PE_File::Process_Punctuation( const TokPunctuation
& i_rToken
)
143 if (i_rToken
.Id() == TokPunctuation::CurledBracketClose
)
145 csv_assert(pCurNamespace
!= 0);
147 pCurNamespace
= &Gate().Ces().Find_Module(pCurNamespace
->Owner());
149 SetResult(done
, stay
);
150 eState
= wait_for_module_semicolon
;
157 case wait_for_module_bracket
:
158 if (i_rToken
.Id() == TokPunctuation::CurledBracketOpen
)
160 SetResult(done
, stay
);
168 case wait_for_module_semicolon
:
169 if (i_rToken
.Id() == TokPunctuation::Semicolon
)
171 SetResult(done
, stay
);
180 if (i_rToken
.Id() == TokPunctuation::CurledBracketClose
)
182 nBracketCount_inDefMode
--;
184 else if (i_rToken
.Id() == TokPunctuation::CurledBracketOpen
)
186 nBracketCount_inDefMode
++;
188 else if (i_rToken
.Id() == TokPunctuation::Semicolon
)
190 if (nBracketCount_inDefMode
<= 0)
195 SetResult(done
, stay
);
203 PE_File::Process_MetaType( const TokMetaType
& i_rToken
)
205 switch (i_rToken
.Id())
207 case TokMetaType::mt_service
:
209 SetResult( not_done
, push_sure
, pPE_Service
.Ptr());
211 case TokMetaType::mt_singleton
:
213 SetResult( not_done
, push_sure
, pPE_Singleton
.Ptr());
215 case TokMetaType::mt_uik
:
216 Cerr() << "Syntax error: [uik ....] is obsolete now." << Endl();
217 SetResult( not_done
, pop_failure
);
219 case TokMetaType::mt_interface
:
221 SetResult( not_done
, push_sure
, pPE_Interface
.Ptr());
223 case TokMetaType::mt_module
:
224 eState
= wait_for_module
;
225 SetResult( done
, stay
);
227 case TokMetaType::mt_struct
:
229 SetResult( done
, push_sure
, pPE_Struct
.Ptr());
231 case TokMetaType::mt_exception
:
233 SetResult( done
, push_sure
, pPE_Exception
.Ptr());
235 case TokMetaType::mt_constants
:
237 SetResult( done
, push_sure
, pPE_Constant
.Ptr());
239 case TokMetaType::mt_enum
:
241 SetResult( done
, push_sure
, pPE_Enum
.Ptr());
243 case TokMetaType::mt_typedef
:
245 SetResult( done
, push_sure
, pPE_Typedef
.Ptr());
254 PE_File::Process_Stereotype( const TokStereotype
& i_rToken
)
256 if (i_rToken
.Id() == TokStereotype::ste_published
)
258 pTokenAdmin
->Set_PublishedOn();
260 SetResult(done
, stay
);
269 PE_File::Process_Default()
271 if (eState
!= on_default
)
274 nBracketCount_inDefMode
= 0;
276 SetResult(done
, stay
);
279 const ary::idl::Module
&
280 PE_File::CurNamespace() const
282 csv_assert(pCurNamespace
);
283 return *pCurNamespace
;
287 PE_File::ParseInfo() const
289 csv_assert(pParseInfo
);
300 PE_File::TransferData()
306 PE_File::ReceiveData()