178bc99aaSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
378bc99aaSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
478bc99aaSAndrew Rist * or more contributor license agreements. See the NOTICE file
578bc99aaSAndrew Rist * distributed with this work for additional information
678bc99aaSAndrew Rist * regarding copyright ownership. The ASF licenses this file
778bc99aaSAndrew Rist * to you under the Apache License, Version 2.0 (the
878bc99aaSAndrew Rist * "License"); you may not use this file except in compliance
978bc99aaSAndrew Rist * with the License. You may obtain a copy of the License at
1078bc99aaSAndrew Rist *
1178bc99aaSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
1278bc99aaSAndrew Rist *
1378bc99aaSAndrew Rist * Unless required by applicable law or agreed to in writing,
1478bc99aaSAndrew Rist * software distributed under the License is distributed on an
1578bc99aaSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1678bc99aaSAndrew Rist * KIND, either express or implied. See the License for the
1778bc99aaSAndrew Rist * specific language governing permissions and limitations
1878bc99aaSAndrew Rist * under the License.
1978bc99aaSAndrew Rist *
2078bc99aaSAndrew Rist *************************************************************/
21cdf0e10cSrcweir
22cdf0e10cSrcweir #include <precomp.h>
23cdf0e10cSrcweir #include <s2_luidl/pe_excp.hxx>
24cdf0e10cSrcweir
25cdf0e10cSrcweir
26cdf0e10cSrcweir // NOT FULLY DECLARED SERVICES
27cdf0e10cSrcweir #include <ary/idl/i_exception.hxx>
28cdf0e10cSrcweir #include <ary/idl/i_gate.hxx>
29cdf0e10cSrcweir #include <ary/idl/i_structelem.hxx>
30cdf0e10cSrcweir #include <ary/idl/ip_ce.hxx>
31cdf0e10cSrcweir #include <ary/doc/d_oldidldocu.hxx>
32cdf0e10cSrcweir #include <s2_luidl/tk_ident.hxx>
33cdf0e10cSrcweir #include <s2_luidl/tk_punct.hxx>
34cdf0e10cSrcweir #include <s2_luidl/tk_keyw.hxx>
35cdf0e10cSrcweir #include <s2_luidl/pe_type2.hxx>
36cdf0e10cSrcweir #include <s2_luidl/pe_selem.hxx>
37cdf0e10cSrcweir
38cdf0e10cSrcweir
39cdf0e10cSrcweir
40cdf0e10cSrcweir namespace csi
41cdf0e10cSrcweir {
42cdf0e10cSrcweir namespace uidl
43cdf0e10cSrcweir {
44cdf0e10cSrcweir
45cdf0e10cSrcweir
PE_Exception()46cdf0e10cSrcweir PE_Exception::PE_Exception()
47cdf0e10cSrcweir // : aWork,
48cdf0e10cSrcweir // pStati
49cdf0e10cSrcweir {
50cdf0e10cSrcweir pStati = new S_Stati(*this);
51cdf0e10cSrcweir }
52cdf0e10cSrcweir
53cdf0e10cSrcweir void
EstablishContacts(UnoIDL_PE * io_pParentPE,ary::Repository & io_rRepository,TokenProcessing_Result & o_rResult)54cdf0e10cSrcweir PE_Exception::EstablishContacts( UnoIDL_PE * io_pParentPE,
55cdf0e10cSrcweir ary::Repository & io_rRepository,
56cdf0e10cSrcweir TokenProcessing_Result & o_rResult )
57cdf0e10cSrcweir {
58cdf0e10cSrcweir UnoIDL_PE::EstablishContacts(io_pParentPE,io_rRepository,o_rResult);
59cdf0e10cSrcweir Work().pPE_Element->EstablishContacts(this,io_rRepository,o_rResult);
60cdf0e10cSrcweir Work().pPE_Type->EstablishContacts(this,io_rRepository,o_rResult);
61cdf0e10cSrcweir }
62cdf0e10cSrcweir
~PE_Exception()63cdf0e10cSrcweir PE_Exception::~PE_Exception()
64cdf0e10cSrcweir {
65cdf0e10cSrcweir }
66cdf0e10cSrcweir
67cdf0e10cSrcweir void
ProcessToken(const Token & i_rToken)68cdf0e10cSrcweir PE_Exception::ProcessToken( const Token & i_rToken )
69cdf0e10cSrcweir {
70cdf0e10cSrcweir i_rToken.Trigger(*Stati().pCurStatus);
71cdf0e10cSrcweir }
72cdf0e10cSrcweir
73cdf0e10cSrcweir
74cdf0e10cSrcweir void
InitData()75cdf0e10cSrcweir PE_Exception::InitData()
76cdf0e10cSrcweir {
77cdf0e10cSrcweir Work().InitData();
78cdf0e10cSrcweir Stati().pCurStatus = &Stati().aWaitForName;
79cdf0e10cSrcweir }
80cdf0e10cSrcweir
81cdf0e10cSrcweir void
TransferData()82cdf0e10cSrcweir PE_Exception::TransferData()
83cdf0e10cSrcweir {
84cdf0e10cSrcweir if (NOT Work().bIsPreDeclaration)
85cdf0e10cSrcweir {
86*a0d53b35SJürgen Schmidt csv_assert(! Work().sData_Name.empty());
87cdf0e10cSrcweir csv_assert(Work().nCurStruct.IsValid());
88cdf0e10cSrcweir }
89cdf0e10cSrcweir Stati().pCurStatus = &Stati().aNone;
90cdf0e10cSrcweir }
91cdf0e10cSrcweir
92cdf0e10cSrcweir void
ReceiveData()93cdf0e10cSrcweir PE_Exception::ReceiveData()
94cdf0e10cSrcweir {
95cdf0e10cSrcweir Stati().pCurStatus->On_SubPE_Left();
96cdf0e10cSrcweir }
97cdf0e10cSrcweir
S_Work()98cdf0e10cSrcweir PE_Exception::S_Work::S_Work()
99cdf0e10cSrcweir : sData_Name(),
100cdf0e10cSrcweir bIsPreDeclaration(false),
101cdf0e10cSrcweir nCurStruct(0),
102cdf0e10cSrcweir pPE_Element(0),
103cdf0e10cSrcweir nCurParsed_ElementRef(0),
104cdf0e10cSrcweir pPE_Type(0),
105cdf0e10cSrcweir nCurParsed_Base(0)
106cdf0e10cSrcweir
107cdf0e10cSrcweir {
108cdf0e10cSrcweir pPE_Element = new PE_StructElement(nCurParsed_ElementRef,nCurStruct);
109cdf0e10cSrcweir pPE_Type = new PE_Type(nCurParsed_Base);
110cdf0e10cSrcweir }
111cdf0e10cSrcweir
112cdf0e10cSrcweir void
InitData()113cdf0e10cSrcweir PE_Exception::S_Work::InitData()
114cdf0e10cSrcweir {
115cdf0e10cSrcweir sData_Name.clear();
116cdf0e10cSrcweir bIsPreDeclaration = false;
117cdf0e10cSrcweir nCurStruct = 0;
118cdf0e10cSrcweir
119cdf0e10cSrcweir nCurParsed_ElementRef = 0;
120cdf0e10cSrcweir nCurParsed_Base = 0;
121cdf0e10cSrcweir }
122cdf0e10cSrcweir
123cdf0e10cSrcweir void
Prepare_PE_QualifiedName()124cdf0e10cSrcweir PE_Exception::S_Work::Prepare_PE_QualifiedName()
125cdf0e10cSrcweir {
126cdf0e10cSrcweir nCurParsed_ElementRef = 0;
127cdf0e10cSrcweir }
128cdf0e10cSrcweir
129cdf0e10cSrcweir void
Prepare_PE_Element()130cdf0e10cSrcweir PE_Exception::S_Work::Prepare_PE_Element()
131cdf0e10cSrcweir {
132cdf0e10cSrcweir nCurParsed_Base = 0;
133cdf0e10cSrcweir }
134cdf0e10cSrcweir
135cdf0e10cSrcweir void
Data_Set_Name(const char * i_sName)136cdf0e10cSrcweir PE_Exception::S_Work::Data_Set_Name( const char * i_sName )
137cdf0e10cSrcweir {
138cdf0e10cSrcweir sData_Name = i_sName;
139cdf0e10cSrcweir }
140cdf0e10cSrcweir
S_Stati(PE_Exception & io_rStruct)141cdf0e10cSrcweir PE_Exception::S_Stati::S_Stati(PE_Exception & io_rStruct)
142cdf0e10cSrcweir : aNone(io_rStruct),
143cdf0e10cSrcweir aWaitForName(io_rStruct),
144cdf0e10cSrcweir aGotName(io_rStruct),
145cdf0e10cSrcweir aWaitForBase(io_rStruct),
146cdf0e10cSrcweir aGotBase(io_rStruct),
147cdf0e10cSrcweir aWaitForElement(io_rStruct),
148cdf0e10cSrcweir aWaitForFinish(io_rStruct),
149cdf0e10cSrcweir pCurStatus(0)
150cdf0e10cSrcweir {
151cdf0e10cSrcweir pCurStatus = &aNone;
152cdf0e10cSrcweir }
153cdf0e10cSrcweir
154cdf0e10cSrcweir
155cdf0e10cSrcweir //*********************** Stati ***************************//
156cdf0e10cSrcweir
157cdf0e10cSrcweir
158cdf0e10cSrcweir UnoIDL_PE &
MyPE()159cdf0e10cSrcweir PE_Exception::PE_StructState::MyPE()
160cdf0e10cSrcweir {
161cdf0e10cSrcweir return rStruct;
162cdf0e10cSrcweir }
163cdf0e10cSrcweir
164cdf0e10cSrcweir
165cdf0e10cSrcweir void
Process_Identifier(const TokIdentifier & i_rToken)166cdf0e10cSrcweir PE_Exception::State_WaitForName::Process_Identifier( const TokIdentifier & i_rToken )
167cdf0e10cSrcweir {
168cdf0e10cSrcweir Work().Data_Set_Name(i_rToken.Text());
169cdf0e10cSrcweir MoveState( Stati().aGotName );
170cdf0e10cSrcweir SetResult(done,stay);
171cdf0e10cSrcweir }
172cdf0e10cSrcweir
173cdf0e10cSrcweir void
Process_Punctuation(const TokPunctuation & i_rToken)174cdf0e10cSrcweir PE_Exception::State_GotName::Process_Punctuation( const TokPunctuation & i_rToken )
175cdf0e10cSrcweir {
176cdf0e10cSrcweir if ( i_rToken.Id() != TokPunctuation::Semicolon )
177cdf0e10cSrcweir {
178cdf0e10cSrcweir switch (i_rToken.Id())
179cdf0e10cSrcweir {
180cdf0e10cSrcweir case TokPunctuation::Colon:
181cdf0e10cSrcweir MoveState( Stati().aWaitForBase );
182cdf0e10cSrcweir SetResult(done,push_sure,Work().pPE_Type.Ptr());
183cdf0e10cSrcweir Work().Prepare_PE_QualifiedName();
184cdf0e10cSrcweir break;
185cdf0e10cSrcweir case TokPunctuation::CurledBracketOpen:
186cdf0e10cSrcweir PE().store_Exception();
187cdf0e10cSrcweir MoveState( Stati().aWaitForElement );
188cdf0e10cSrcweir SetResult(done,stay);
189cdf0e10cSrcweir break;
190cdf0e10cSrcweir default:
191cdf0e10cSrcweir SetResult(not_done,pop_failure);
192cdf0e10cSrcweir } // end switch
193cdf0e10cSrcweir }
194cdf0e10cSrcweir else
195cdf0e10cSrcweir {
196cdf0e10cSrcweir Work().sData_Name.clear();
197cdf0e10cSrcweir SetResult(done,pop_success);
198cdf0e10cSrcweir }
199cdf0e10cSrcweir }
200cdf0e10cSrcweir
201cdf0e10cSrcweir void
On_SubPE_Left()202cdf0e10cSrcweir PE_Exception::State_WaitForBase::On_SubPE_Left()
203cdf0e10cSrcweir {
204cdf0e10cSrcweir MoveState(Stati().aGotBase);
205cdf0e10cSrcweir }
206cdf0e10cSrcweir
207cdf0e10cSrcweir void
Process_Punctuation(const TokPunctuation & i_rToken)208cdf0e10cSrcweir PE_Exception::State_GotBase::Process_Punctuation( const TokPunctuation & i_rToken )
209cdf0e10cSrcweir {
210cdf0e10cSrcweir if ( i_rToken.Id() == TokPunctuation::CurledBracketOpen )
211cdf0e10cSrcweir {
212cdf0e10cSrcweir PE().store_Exception();
213cdf0e10cSrcweir MoveState( Stati().aWaitForElement );
214cdf0e10cSrcweir SetResult(done,stay);
215cdf0e10cSrcweir }
216cdf0e10cSrcweir else
217cdf0e10cSrcweir {
218cdf0e10cSrcweir SetResult(not_done,pop_failure);
219cdf0e10cSrcweir }
220cdf0e10cSrcweir }
221cdf0e10cSrcweir
222cdf0e10cSrcweir void
Process_Identifier(const TokIdentifier &)223cdf0e10cSrcweir PE_Exception::State_WaitForElement::Process_Identifier( const TokIdentifier & )
224cdf0e10cSrcweir {
225cdf0e10cSrcweir SetResult( not_done, push_sure, Work().pPE_Element.Ptr() );
226cdf0e10cSrcweir Work().Prepare_PE_Element();
227cdf0e10cSrcweir }
228cdf0e10cSrcweir
229cdf0e10cSrcweir void
Process_NameSeparator()230cdf0e10cSrcweir PE_Exception::State_WaitForElement::Process_NameSeparator()
231cdf0e10cSrcweir {
232cdf0e10cSrcweir SetResult( not_done, push_sure, Work().pPE_Element.Ptr());
233cdf0e10cSrcweir Work().Prepare_PE_Element();
234cdf0e10cSrcweir }
235cdf0e10cSrcweir
236cdf0e10cSrcweir void
Process_BuiltInType(const TokBuiltInType &)237cdf0e10cSrcweir PE_Exception::State_WaitForElement::Process_BuiltInType( const TokBuiltInType & )
238cdf0e10cSrcweir {
239cdf0e10cSrcweir SetResult( not_done, push_sure, Work().pPE_Element.Ptr());
240cdf0e10cSrcweir Work().Prepare_PE_Element();
241cdf0e10cSrcweir }
242cdf0e10cSrcweir
243cdf0e10cSrcweir void
Process_TypeModifier(const TokTypeModifier &)244cdf0e10cSrcweir PE_Exception::State_WaitForElement::Process_TypeModifier(const TokTypeModifier & )
245cdf0e10cSrcweir {
246cdf0e10cSrcweir SetResult( not_done, push_sure, Work().pPE_Element.Ptr());
247cdf0e10cSrcweir Work().Prepare_PE_Element();
248cdf0e10cSrcweir }
249cdf0e10cSrcweir
250cdf0e10cSrcweir void
Process_Punctuation(const TokPunctuation & i_rToken)251cdf0e10cSrcweir PE_Exception::State_WaitForElement::Process_Punctuation( const TokPunctuation & i_rToken )
252cdf0e10cSrcweir {
253cdf0e10cSrcweir if ( i_rToken.Id() == TokPunctuation::CurledBracketClose )
254cdf0e10cSrcweir {
255cdf0e10cSrcweir MoveState( Stati().aWaitForFinish );
256cdf0e10cSrcweir SetResult( done, stay );
257cdf0e10cSrcweir }
258cdf0e10cSrcweir else
259cdf0e10cSrcweir {
260cdf0e10cSrcweir SetResult( not_done, pop_failure );
261cdf0e10cSrcweir }
262cdf0e10cSrcweir }
263cdf0e10cSrcweir
264cdf0e10cSrcweir void
Process_Punctuation(const TokPunctuation & i_rToken)265cdf0e10cSrcweir PE_Exception::State_WaitForFinish::Process_Punctuation( const TokPunctuation & i_rToken )
266cdf0e10cSrcweir {
267cdf0e10cSrcweir if (i_rToken.Id() == TokPunctuation::Semicolon)
268cdf0e10cSrcweir {
269cdf0e10cSrcweir MoveState( Stati().aNone );
270cdf0e10cSrcweir SetResult( done, pop_success );
271cdf0e10cSrcweir }
272cdf0e10cSrcweir else
273cdf0e10cSrcweir {
274cdf0e10cSrcweir SetResult( not_done, pop_failure );
275cdf0e10cSrcweir }
276cdf0e10cSrcweir }
277cdf0e10cSrcweir
278cdf0e10cSrcweir void
store_Exception()279cdf0e10cSrcweir PE_Exception::store_Exception()
280cdf0e10cSrcweir {
281cdf0e10cSrcweir ary::idl::Exception &
282cdf0e10cSrcweir rCe = Gate().Ces().Store_Exception(
283cdf0e10cSrcweir CurNamespace().CeId(),
284cdf0e10cSrcweir Work().sData_Name,
285cdf0e10cSrcweir Work().nCurParsed_Base );
286cdf0e10cSrcweir PassDocuAt(rCe);
287cdf0e10cSrcweir Work().nCurStruct = rCe.Id();
288cdf0e10cSrcweir }
289cdf0e10cSrcweir
290cdf0e10cSrcweir
291cdf0e10cSrcweir } // namespace uidl
292cdf0e10cSrcweir } // namespace csi
293