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: c_rcode.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 "c_rcode.hxx"
35 // NOT FULLY DECLARED SERVICES
36 #include <ary/cpp/c_gate.hxx>
37 #include <ary/cpp/c_namesp.hxx>
38 // #include <ary/cpp/c_groups.hxx>
39 #include <ary/loc/locp_le.hxx>
42 #include <x_parse.hxx>
43 #include "pe_file.hxx"
46 // see i19418 incomplete type for cpp::PE_Namespace
47 #include "pe_namsp.hxx"
48 #include "pe_ignor.hxx"
49 #include "pe_defs.hxx"
50 #include "pe_vafu.hxx"
51 #include "pe_tydef.hxx"
52 #include "pe_tpltp.hxx"
53 #include "pe_type.hxx"
54 #include "pe_vari.hxx"
55 #include "pe_funct.hxx"
56 #include "pe_enum.hxx"
57 #include "pe_param.hxx"
58 #include "pe_class.hxx"
59 #include "pe_expression.hxx"
60 #include "pe_base.hxx"
61 #include "pe_enum.hxx"
62 #include "pe_enval.hxx"
66 const uintt C_nNO_TRY
= uintt(-1);
72 CodeExplorer::CodeExplorer( ary::cpp::Gate
& io_rAryGate
)
73 : aGlobalParseContext(io_rAryGate
),
79 pPE_File
= new PE_File( aGlobalParseContext
);
82 CodeExplorer::~CodeExplorer()
87 CodeExplorer::StartNewFile()
89 csv::erase_container(aEnvironments
);
91 aEnvironments
.push_back( pPE_File
.MutablePtr() );
92 pPE_File
->Enter(push
);
96 CodeExplorer::Process_Token( DYN
cpp::Token
& let_drToken
)
98 if (DEBUG_ShowTokens())
100 Cout() << let_drToken
.Text() << Endl();
102 dpCurToken
= &let_drToken
;
103 aGlobalParseContext
.ResetResult();
106 CurToken().Trigger( CurEnv() );
108 } while ( dpCurToken
);
112 CodeExplorer::AcknowledgeResult()
114 if (CurResult().eDone
== done
)
117 switch ( CurResult().eStackAction
)
122 CurEnv().Leave(push
);
123 aEnvironments
.push_back( &PushEnv() );
124 PushEnv().Enter(push
);
127 CurEnv().Leave(pop_success
);
128 aEnvironments
.pop_back();
129 CurEnv().Enter(pop_success
);
133 Cpp_PE
* pRecover
= 0;
135 CurEnv().Leave(pop_failure
);
136 aEnvironments
.pop_back();
137 if ( aEnvironments
.empty() )
139 pRecover
= CurEnv().Handle_ChildFailure();
140 } while ( pRecover
== 0 );
143 aEnvironments
.push_back(pRecover
);
144 pRecover
->Enter(push
);
148 throw X_Parser( X_Parser::x_UnexpectedToken
, CurToken().Text(), aGlobalParseContext
.CurFileName(), aGlobalParseContext
.LineCount() );
153 } // end switch(CurResult().eStackAction)
157 CodeExplorer::CurToken() const
159 csv_assert(dpCurToken
);
165 CodeExplorer::CurEnv() const
167 csv_assert(aEnvironments
.size() > 0);
168 csv_assert(aEnvironments
.back() != 0);
170 return *aEnvironments
.back();
174 CodeExplorer::PushEnv() const
176 TokenProcessing_Result
& rCurResult
= const_cast< TokenProcessing_Result
& >(aGlobalParseContext
.CurResult());
177 Cpp_PE
* ret
= dynamic_cast< Cpp_PE
* >(rCurResult
.pEnv2Push
);
178 csv_assert( ret
!= 0 );