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_excp.hxx>
33 // NOT FULLY DECLARED SERVICES
34 #include <ary/idl/i_exception.hxx>
35 #include <ary/idl/i_gate.hxx>
36 #include <ary/idl/i_structelem.hxx>
37 #include <ary/idl/ip_ce.hxx>
38 #include <ary/doc/d_oldidldocu.hxx>
39 #include <s2_luidl/tk_ident.hxx>
40 #include <s2_luidl/tk_punct.hxx>
41 #include <s2_luidl/tk_keyw.hxx>
42 #include <s2_luidl/pe_type2.hxx>
43 #include <s2_luidl/pe_selem.hxx>
53 PE_Exception::PE_Exception()
57 pStati
= new S_Stati(*this);
61 PE_Exception::EstablishContacts( UnoIDL_PE
* io_pParentPE
,
62 ary::Repository
& io_rRepository
,
63 TokenProcessing_Result
& o_rResult
)
65 UnoIDL_PE::EstablishContacts(io_pParentPE
,io_rRepository
,o_rResult
);
66 Work().pPE_Element
->EstablishContacts(this,io_rRepository
,o_rResult
);
67 Work().pPE_Type
->EstablishContacts(this,io_rRepository
,o_rResult
);
70 PE_Exception::~PE_Exception()
75 PE_Exception::ProcessToken( const Token
& i_rToken
)
77 i_rToken
.Trigger(*Stati().pCurStatus
);
82 PE_Exception::InitData()
85 Stati().pCurStatus
= &Stati().aWaitForName
;
89 PE_Exception::TransferData()
91 if (NOT
Work().bIsPreDeclaration
)
93 csv_assert(Work().sData_Name
.size() > 0);
94 csv_assert(Work().nCurStruct
.IsValid());
96 Stati().pCurStatus
= &Stati().aNone
;
100 PE_Exception::ReceiveData()
102 Stati().pCurStatus
->On_SubPE_Left();
105 PE_Exception::S_Work::S_Work()
107 bIsPreDeclaration(false),
110 nCurParsed_ElementRef(0),
115 pPE_Element
= new PE_StructElement(nCurParsed_ElementRef
,nCurStruct
);
116 pPE_Type
= new PE_Type(nCurParsed_Base
);
120 PE_Exception::S_Work::InitData()
123 bIsPreDeclaration
= false;
126 nCurParsed_ElementRef
= 0;
131 PE_Exception::S_Work::Prepare_PE_QualifiedName()
133 nCurParsed_ElementRef
= 0;
137 PE_Exception::S_Work::Prepare_PE_Element()
143 PE_Exception::S_Work::Data_Set_Name( const char * i_sName
)
145 sData_Name
= i_sName
;
148 PE_Exception::S_Stati::S_Stati(PE_Exception
& io_rStruct
)
150 aWaitForName(io_rStruct
),
151 aGotName(io_rStruct
),
152 aWaitForBase(io_rStruct
),
153 aGotBase(io_rStruct
),
154 aWaitForElement(io_rStruct
),
155 aWaitForFinish(io_rStruct
),
162 //*********************** Stati ***************************//
166 PE_Exception::PE_StructState::MyPE()
173 PE_Exception::State_WaitForName::Process_Identifier( const TokIdentifier
& i_rToken
)
175 Work().Data_Set_Name(i_rToken
.Text());
176 MoveState( Stati().aGotName
);
177 SetResult(done
,stay
);
181 PE_Exception::State_GotName::Process_Punctuation( const TokPunctuation
& i_rToken
)
183 if ( i_rToken
.Id() != TokPunctuation::Semicolon
)
185 switch (i_rToken
.Id())
187 case TokPunctuation::Colon
:
188 MoveState( Stati().aWaitForBase
);
189 SetResult(done
,push_sure
,Work().pPE_Type
.Ptr());
190 Work().Prepare_PE_QualifiedName();
192 case TokPunctuation::CurledBracketOpen
:
193 PE().store_Exception();
194 MoveState( Stati().aWaitForElement
);
195 SetResult(done
,stay
);
198 SetResult(not_done
,pop_failure
);
203 Work().sData_Name
.clear();
204 SetResult(done
,pop_success
);
209 PE_Exception::State_WaitForBase::On_SubPE_Left()
211 MoveState(Stati().aGotBase
);
215 PE_Exception::State_GotBase::Process_Punctuation( const TokPunctuation
& i_rToken
)
217 if ( i_rToken
.Id() == TokPunctuation::CurledBracketOpen
)
219 PE().store_Exception();
220 MoveState( Stati().aWaitForElement
);
221 SetResult(done
,stay
);
225 SetResult(not_done
,pop_failure
);
230 PE_Exception::State_WaitForElement::Process_Identifier( const TokIdentifier
& )
232 SetResult( not_done
, push_sure
, Work().pPE_Element
.Ptr() );
233 Work().Prepare_PE_Element();
237 PE_Exception::State_WaitForElement::Process_NameSeparator()
239 SetResult( not_done
, push_sure
, Work().pPE_Element
.Ptr());
240 Work().Prepare_PE_Element();
244 PE_Exception::State_WaitForElement::Process_BuiltInType( const TokBuiltInType
& )
246 SetResult( not_done
, push_sure
, Work().pPE_Element
.Ptr());
247 Work().Prepare_PE_Element();
251 PE_Exception::State_WaitForElement::Process_TypeModifier(const TokTypeModifier
& )
253 SetResult( not_done
, push_sure
, Work().pPE_Element
.Ptr());
254 Work().Prepare_PE_Element();
258 PE_Exception::State_WaitForElement::Process_Punctuation( const TokPunctuation
& i_rToken
)
260 if ( i_rToken
.Id() == TokPunctuation::CurledBracketClose
)
262 MoveState( Stati().aWaitForFinish
);
263 SetResult( done
, stay
);
267 SetResult( not_done
, pop_failure
);
272 PE_Exception::State_WaitForFinish::Process_Punctuation( const TokPunctuation
& i_rToken
)
274 if (i_rToken
.Id() == TokPunctuation::Semicolon
)
276 MoveState( Stati().aNone
);
277 SetResult( done
, pop_success
);
281 SetResult( not_done
, pop_failure
);
286 PE_Exception::store_Exception()
288 ary::idl::Exception
&
289 rCe
= Gate().Ces().Store_Exception(
290 CurNamespace().CeId(),
292 Work().nCurParsed_Base
);
294 Work().nCurStruct
= rCe
.Id();
301 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */