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_excp.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_excp.hxx>
35 // NOT FULLY DECLARED SERVICES
36 #include <ary/idl/i_exception.hxx>
37 #include <ary/idl/i_gate.hxx>
38 #include <ary/idl/i_structelem.hxx>
39 #include <ary/idl/ip_ce.hxx>
40 #include <ary/doc/d_oldidldocu.hxx>
41 #include <s2_luidl/tk_ident.hxx>
42 #include <s2_luidl/tk_punct.hxx>
43 #include <s2_luidl/tk_keyw.hxx>
44 #include <s2_luidl/pe_type2.hxx>
45 #include <s2_luidl/pe_selem.hxx>
55 PE_Exception::PE_Exception()
59 pStati
= new S_Stati(*this);
63 PE_Exception::EstablishContacts( UnoIDL_PE
* io_pParentPE
,
64 ary::Repository
& io_rRepository
,
65 TokenProcessing_Result
& o_rResult
)
67 UnoIDL_PE::EstablishContacts(io_pParentPE
,io_rRepository
,o_rResult
);
68 Work().pPE_Element
->EstablishContacts(this,io_rRepository
,o_rResult
);
69 Work().pPE_Type
->EstablishContacts(this,io_rRepository
,o_rResult
);
72 PE_Exception::~PE_Exception()
77 PE_Exception::ProcessToken( const Token
& i_rToken
)
79 i_rToken
.Trigger(*Stati().pCurStatus
);
84 PE_Exception::InitData()
87 Stati().pCurStatus
= &Stati().aWaitForName
;
91 PE_Exception::TransferData()
93 if (NOT
Work().bIsPreDeclaration
)
95 csv_assert(Work().sData_Name
.size() > 0);
96 csv_assert(Work().nCurStruct
.IsValid());
98 Stati().pCurStatus
= &Stati().aNone
;
102 PE_Exception::ReceiveData()
104 Stati().pCurStatus
->On_SubPE_Left();
107 PE_Exception::S_Work::S_Work()
109 bIsPreDeclaration(false),
112 nCurParsed_ElementRef(0),
117 pPE_Element
= new PE_StructElement(nCurParsed_ElementRef
,nCurStruct
);
118 pPE_Type
= new PE_Type(nCurParsed_Base
);
122 PE_Exception::S_Work::InitData()
125 bIsPreDeclaration
= false;
128 nCurParsed_ElementRef
= 0;
133 PE_Exception::S_Work::Prepare_PE_QualifiedName()
135 nCurParsed_ElementRef
= 0;
139 PE_Exception::S_Work::Prepare_PE_Element()
145 PE_Exception::S_Work::Data_Set_Name( const char * i_sName
)
147 sData_Name
= i_sName
;
150 PE_Exception::S_Stati::S_Stati(PE_Exception
& io_rStruct
)
152 aWaitForName(io_rStruct
),
153 aGotName(io_rStruct
),
154 aWaitForBase(io_rStruct
),
155 aGotBase(io_rStruct
),
156 aWaitForElement(io_rStruct
),
157 aWaitForFinish(io_rStruct
),
164 //*********************** Stati ***************************//
168 PE_Exception::PE_StructState::MyPE()
175 PE_Exception::State_WaitForName::Process_Identifier( const TokIdentifier
& i_rToken
)
177 Work().Data_Set_Name(i_rToken
.Text());
178 MoveState( Stati().aGotName
);
179 SetResult(done
,stay
);
183 PE_Exception::State_GotName::Process_Punctuation( const TokPunctuation
& i_rToken
)
185 if ( i_rToken
.Id() != TokPunctuation::Semicolon
)
187 switch (i_rToken
.Id())
189 case TokPunctuation::Colon
:
190 MoveState( Stati().aWaitForBase
);
191 SetResult(done
,push_sure
,Work().pPE_Type
.Ptr());
192 Work().Prepare_PE_QualifiedName();
194 case TokPunctuation::CurledBracketOpen
:
195 PE().store_Exception();
196 MoveState( Stati().aWaitForElement
);
197 SetResult(done
,stay
);
200 SetResult(not_done
,pop_failure
);
205 Work().sData_Name
.clear();
206 SetResult(done
,pop_success
);
211 PE_Exception::State_WaitForBase::On_SubPE_Left()
213 MoveState(Stati().aGotBase
);
217 PE_Exception::State_GotBase::Process_Punctuation( const TokPunctuation
& i_rToken
)
219 if ( i_rToken
.Id() == TokPunctuation::CurledBracketOpen
)
221 PE().store_Exception();
222 MoveState( Stati().aWaitForElement
);
223 SetResult(done
,stay
);
227 SetResult(not_done
,pop_failure
);
232 PE_Exception::State_WaitForElement::Process_Identifier( const TokIdentifier
& )
234 SetResult( not_done
, push_sure
, Work().pPE_Element
.Ptr() );
235 Work().Prepare_PE_Element();
239 PE_Exception::State_WaitForElement::Process_NameSeparator()
241 SetResult( not_done
, push_sure
, Work().pPE_Element
.Ptr());
242 Work().Prepare_PE_Element();
246 PE_Exception::State_WaitForElement::Process_BuiltInType( const TokBuiltInType
& )
248 SetResult( not_done
, push_sure
, Work().pPE_Element
.Ptr());
249 Work().Prepare_PE_Element();
253 PE_Exception::State_WaitForElement::Process_TypeModifier(const TokTypeModifier
& )
255 SetResult( not_done
, push_sure
, Work().pPE_Element
.Ptr());
256 Work().Prepare_PE_Element();
260 PE_Exception::State_WaitForElement::Process_Punctuation( const TokPunctuation
& i_rToken
)
262 if ( i_rToken
.Id() == TokPunctuation::CurledBracketClose
)
264 MoveState( Stati().aWaitForFinish
);
265 SetResult( done
, stay
);
269 SetResult( not_done
, pop_failure
);
274 PE_Exception::State_WaitForFinish::Process_Punctuation( const TokPunctuation
& i_rToken
)
276 if (i_rToken
.Id() == TokPunctuation::Semicolon
)
278 MoveState( Stati().aNone
);
279 SetResult( done
, pop_success
);
283 SetResult( not_done
, pop_failure
);
288 PE_Exception::store_Exception()
290 ary::idl::Exception
&
291 rCe
= Gate().Ces().Store_Exception(
292 CurNamespace().CeId(),
294 Work().nCurParsed_Base
);
296 Work().nCurStruct
= rCe
.Id();