Bump for 3.6-28
[LibreOffice.git] / autodoc / source / parser_i / idl / pe_file2.cxx
blob144470f8945eced424b9a7c26f309757acef9d5a
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 ************************************************************************/
29 #include <precomp.h>
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>
54 namespace csi
56 namespace uidl
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),
71 pCurNamespace(0),
72 pParseInfo(&i_parseInfo),
73 eState(e_none),
74 nBracketCount_inDefMode(0)
78 void
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();
96 PE_File::~PE_File()
100 void
101 PE_File::ProcessToken( const Token & i_rToken )
103 i_rToken.Trigger(*this);
106 void
107 PE_File::Process_Identifier( const TokIdentifier & i_rToken )
109 switch (eState)
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());
120 PassDocuAt(rCe);
122 csv_assert(pCurNamespace != 0);
124 SetResult(done, stay);
125 eState = wait_for_module_bracket;
126 } break;
127 case on_default:
128 SetResult(done, stay);
129 break;
130 default:
131 csv_assert(false);
135 void
136 PE_File::Process_Punctuation( const TokPunctuation & i_rToken )
138 switch (eState)
140 case e_std:
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;
150 else
152 csv_assert(false);
154 break;
155 case wait_for_module_bracket:
156 if (i_rToken.Id() == TokPunctuation::CurledBracketOpen)
158 SetResult(done, stay);
159 eState = e_std;
161 else
163 csv_assert(false);
165 break;
166 case wait_for_module_semicolon:
167 if (i_rToken.Id() == TokPunctuation::Semicolon)
169 SetResult(done, stay);
170 eState = e_std;
172 else
174 csv_assert(false);
176 break;
177 case on_default:
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)
190 eState = e_std;
193 SetResult(done, stay);
194 break;
195 default:
196 csv_assert(false);
200 void
201 PE_File::Process_MetaType( const TokMetaType & i_rToken )
203 switch (i_rToken.Id())
205 case TokMetaType::mt_service:
206 eState = in_sub_pe;
207 SetResult( not_done, push_sure, pPE_Service.Ptr());
208 break;
209 case TokMetaType::mt_singleton:
210 eState = in_sub_pe;
211 SetResult( not_done, push_sure, pPE_Singleton.Ptr());
212 break;
213 case TokMetaType::mt_uik:
214 Cerr() << "Syntax error: [uik ....] is obsolete now." << Endl();
215 SetResult( not_done, pop_failure);
216 break;
217 case TokMetaType::mt_interface:
218 eState = in_sub_pe;
219 SetResult( not_done, push_sure, pPE_Interface.Ptr());
220 break;
221 case TokMetaType::mt_module:
222 eState = wait_for_module;
223 SetResult( done, stay );
224 break;
225 case TokMetaType::mt_struct:
226 eState = in_sub_pe;
227 SetResult( done, push_sure, pPE_Struct.Ptr());
228 break;
229 case TokMetaType::mt_exception:
230 eState = in_sub_pe;
231 SetResult( done, push_sure, pPE_Exception.Ptr());
232 break;
233 case TokMetaType::mt_constants:
234 eState = in_sub_pe;
235 SetResult( done, push_sure, pPE_Constant.Ptr());
236 break;
237 case TokMetaType::mt_enum:
238 eState = in_sub_pe;
239 SetResult( done, push_sure, pPE_Enum.Ptr());
240 break;
241 case TokMetaType::mt_typedef:
242 eState = in_sub_pe;
243 SetResult( done, push_sure, pPE_Typedef.Ptr());
244 break;
246 default:
247 Process_Default();
248 } // end switch
251 void
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);
260 else
262 Process_Default();
266 void
267 PE_File::Process_Default()
269 if (eState != on_default)
271 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;
284 const ParserInfo &
285 PE_File::ParseInfo() const
287 csv_assert(pParseInfo);
288 return *pParseInfo;
291 void
292 PE_File::InitData()
294 eState = e_std;
297 void
298 PE_File::TransferData()
300 eState = e_none;
303 void
304 PE_File::ReceiveData()
306 eState = e_std;
310 UnoIDL_PE &
311 PE_File::MyPE()
313 return *this;
316 } // namespace uidl
317 } // namespace csi
320 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */