1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
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>
44 PE_Exception::PE_Exception()
48 pStati
= new S_Stati(*this);
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()
66 PE_Exception::ProcessToken( const Token
& i_rToken
)
68 i_rToken
.Trigger(*Stati().pCurStatus
);
73 PE_Exception::InitData()
76 Stati().pCurStatus
= &Stati().aWaitForName
;
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
;
91 PE_Exception::ReceiveData()
93 Stati().pCurStatus
->On_SubPE_Left();
96 PE_Exception::S_Work::S_Work()
98 bIsPreDeclaration(false),
101 nCurParsed_ElementRef(0),
106 pPE_Element
= new PE_StructElement(nCurParsed_ElementRef
,nCurStruct
);
107 pPE_Type
= new PE_Type(nCurParsed_Base
);
111 PE_Exception::S_Work::InitData()
114 bIsPreDeclaration
= false;
117 nCurParsed_ElementRef
= 0;
122 PE_Exception::S_Work::Prepare_PE_QualifiedName()
124 nCurParsed_ElementRef
= 0;
128 PE_Exception::S_Work::Prepare_PE_Element()
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
)
141 aWaitForName(io_rStruct
),
142 aGotName(io_rStruct
),
143 aWaitForBase(io_rStruct
),
144 aGotBase(io_rStruct
),
145 aWaitForElement(io_rStruct
),
146 aWaitForFinish(io_rStruct
),
153 //*********************** Stati ***************************//
157 PE_Exception::PE_StructState::MyPE()
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
);
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();
183 case TokPunctuation::CurledBracketOpen
:
184 PE().store_Exception();
185 MoveState( Stati().aWaitForElement
);
186 SetResult(done
,stay
);
189 SetResult(not_done
,pop_failure
);
194 Work().sData_Name
.clear();
195 SetResult(done
,pop_success
);
200 PE_Exception::State_WaitForBase::On_SubPE_Left()
202 MoveState(Stati().aGotBase
);
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
);
216 SetResult(not_done
,pop_failure
);
221 PE_Exception::State_WaitForElement::Process_Identifier( const TokIdentifier
& )
223 SetResult( not_done
, push_sure
, Work().pPE_Element
.Ptr() );
224 Work().Prepare_PE_Element();
228 PE_Exception::State_WaitForElement::Process_NameSeparator()
230 SetResult( not_done
, push_sure
, Work().pPE_Element
.Ptr());
231 Work().Prepare_PE_Element();
235 PE_Exception::State_WaitForElement::Process_BuiltInType( const TokBuiltInType
& )
237 SetResult( not_done
, push_sure
, Work().pPE_Element
.Ptr());
238 Work().Prepare_PE_Element();
242 PE_Exception::State_WaitForElement::Process_TypeModifier(const TokTypeModifier
& )
244 SetResult( not_done
, push_sure
, Work().pPE_Element
.Ptr());
245 Work().Prepare_PE_Element();
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
);
258 SetResult( not_done
, pop_failure
);
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
);
272 SetResult( not_done
, pop_failure
);
277 PE_Exception::store_Exception()
279 ary::idl::Exception
&
280 rCe
= Gate().Ces().Store_Exception(
281 CurNamespace().CeId(),
283 Work().nCurParsed_Base
);
285 Work().nCurStruct
= rCe
.Id();
292 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */