Updated core
[LibreOffice.git] / autodoc / source / parser_i / idl / pe_excp.cxx
blobd0ba60a6112ddb91b636abb87e1cc07136426593
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <precomp.h>
21 #include <s2_luidl/pe_excp.hxx>
24 // NOT FULLY DECLARED SERVICES
25 #include <ary/idl/i_exception.hxx>
26 #include <ary/idl/i_gate.hxx>
27 #include <ary/idl/i_structelem.hxx>
28 #include <ary/idl/ip_ce.hxx>
29 #include <ary/doc/d_oldidldocu.hxx>
30 #include <s2_luidl/tk_ident.hxx>
31 #include <s2_luidl/tk_punct.hxx>
32 #include <s2_luidl/tk_keyw.hxx>
33 #include <s2_luidl/pe_type2.hxx>
34 #include <s2_luidl/pe_selem.hxx>
38 namespace csi
40 namespace uidl
44 PE_Exception::PE_Exception()
45 // : aWork,
46 // pStati
48 pStati = new S_Stati(*this);
51 void
52 PE_Exception::EstablishContacts( UnoIDL_PE * io_pParentPE,
53 ary::Repository & io_rRepository,
54 TokenProcessing_Result & o_rResult )
56 UnoIDL_PE::EstablishContacts(io_pParentPE,io_rRepository,o_rResult);
57 Work().pPE_Element->EstablishContacts(this,io_rRepository,o_rResult);
58 Work().pPE_Type->EstablishContacts(this,io_rRepository,o_rResult);
61 PE_Exception::~PE_Exception()
65 void
66 PE_Exception::ProcessToken( const Token & i_rToken )
68 i_rToken.Trigger(*Stati().pCurStatus);
72 void
73 PE_Exception::InitData()
75 Work().InitData();
76 Stati().pCurStatus = &Stati().aWaitForName;
79 void
80 PE_Exception::TransferData()
82 if (NOT Work().bIsPreDeclaration)
84 csv_assert(Work().sData_Name.size() > 0);
85 csv_assert(Work().nCurStruct.IsValid());
87 Stati().pCurStatus = &Stati().aNone;
90 void
91 PE_Exception::ReceiveData()
93 Stati().pCurStatus->On_SubPE_Left();
96 PE_Exception::S_Work::S_Work()
97 : sData_Name(),
98 bIsPreDeclaration(false),
99 nCurStruct(0),
100 pPE_Element(0),
101 nCurParsed_ElementRef(0),
102 pPE_Type(0),
103 nCurParsed_Base(0)
106 pPE_Element = new PE_StructElement(nCurParsed_ElementRef,nCurStruct);
107 pPE_Type = new PE_Type(nCurParsed_Base);
110 void
111 PE_Exception::S_Work::InitData()
113 sData_Name.clear();
114 bIsPreDeclaration = false;
115 nCurStruct = 0;
117 nCurParsed_ElementRef = 0;
118 nCurParsed_Base = 0;
121 void
122 PE_Exception::S_Work::Prepare_PE_QualifiedName()
124 nCurParsed_ElementRef = 0;
127 void
128 PE_Exception::S_Work::Prepare_PE_Element()
130 nCurParsed_Base = 0;
133 void
134 PE_Exception::S_Work::Data_Set_Name( const char * i_sName )
136 sData_Name = i_sName;
139 PE_Exception::S_Stati::S_Stati(PE_Exception & io_rStruct)
140 : aNone(io_rStruct),
141 aWaitForName(io_rStruct),
142 aGotName(io_rStruct),
143 aWaitForBase(io_rStruct),
144 aGotBase(io_rStruct),
145 aWaitForElement(io_rStruct),
146 aWaitForFinish(io_rStruct),
147 pCurStatus(0)
149 pCurStatus = &aNone;
153 //*********************** Stati ***************************//
156 UnoIDL_PE &
157 PE_Exception::PE_StructState::MyPE()
159 return rStruct;
163 void
164 PE_Exception::State_WaitForName::Process_Identifier( const TokIdentifier & i_rToken )
166 Work().Data_Set_Name(i_rToken.Text());
167 MoveState( Stati().aGotName );
168 SetResult(done,stay);
171 void
172 PE_Exception::State_GotName::Process_Punctuation( const TokPunctuation & i_rToken )
174 if ( i_rToken.Id() != TokPunctuation::Semicolon )
176 switch (i_rToken.Id())
178 case TokPunctuation::Colon:
179 MoveState( Stati().aWaitForBase );
180 SetResult(done,push_sure,Work().pPE_Type.Ptr());
181 Work().Prepare_PE_QualifiedName();
182 break;
183 case TokPunctuation::CurledBracketOpen:
184 PE().store_Exception();
185 MoveState( Stati().aWaitForElement );
186 SetResult(done,stay);
187 break;
188 default:
189 SetResult(not_done,pop_failure);
190 } // end switch
192 else
194 Work().sData_Name.clear();
195 SetResult(done,pop_success);
199 void
200 PE_Exception::State_WaitForBase::On_SubPE_Left()
202 MoveState(Stati().aGotBase);
205 void
206 PE_Exception::State_GotBase::Process_Punctuation( const TokPunctuation & i_rToken )
208 if ( i_rToken.Id() == TokPunctuation::CurledBracketOpen )
210 PE().store_Exception();
211 MoveState( Stati().aWaitForElement );
212 SetResult(done,stay);
214 else
216 SetResult(not_done,pop_failure);
220 void
221 PE_Exception::State_WaitForElement::Process_Identifier( const TokIdentifier & )
223 SetResult( not_done, push_sure, Work().pPE_Element.Ptr() );
224 Work().Prepare_PE_Element();
227 void
228 PE_Exception::State_WaitForElement::Process_NameSeparator()
230 SetResult( not_done, push_sure, Work().pPE_Element.Ptr());
231 Work().Prepare_PE_Element();
234 void
235 PE_Exception::State_WaitForElement::Process_BuiltInType( const TokBuiltInType & )
237 SetResult( not_done, push_sure, Work().pPE_Element.Ptr());
238 Work().Prepare_PE_Element();
241 void
242 PE_Exception::State_WaitForElement::Process_TypeModifier(const TokTypeModifier & )
244 SetResult( not_done, push_sure, Work().pPE_Element.Ptr());
245 Work().Prepare_PE_Element();
248 void
249 PE_Exception::State_WaitForElement::Process_Punctuation( const TokPunctuation & i_rToken )
251 if ( i_rToken.Id() == TokPunctuation::CurledBracketClose )
253 MoveState( Stati().aWaitForFinish );
254 SetResult( done, stay );
256 else
258 SetResult( not_done, pop_failure );
262 void
263 PE_Exception::State_WaitForFinish::Process_Punctuation( const TokPunctuation & i_rToken )
265 if (i_rToken.Id() == TokPunctuation::Semicolon)
267 MoveState( Stati().aNone );
268 SetResult( done, pop_success );
270 else
272 SetResult( not_done, pop_failure );
276 void
277 PE_Exception::store_Exception()
279 ary::idl::Exception &
280 rCe = Gate().Ces().Store_Exception(
281 CurNamespace().CeId(),
282 Work().sData_Name,
283 Work().nCurParsed_Base );
284 PassDocuAt(rCe);
285 Work().nCurStruct = rCe.Id();
289 } // namespace uidl
290 } // namespace csi
292 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */