Update ooo320-m1
[ooovba.git] / autodoc / source / parser / cpp / c_rcode.cxx
blob0a81644d2966ed0fcac347cf98055e62920de641
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: c_rcode.cxx,v $
10 * $Revision: 1.7 $
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 ************************************************************************/
31 #include <precomp.h>
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>
40 #include "cpp_pe.hxx"
41 #include <adc_cl.hxx>
42 #include <x_parse.hxx>
43 #include "pe_file.hxx"
45 #ifdef IRIX
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"
63 #endif
66 const uintt C_nNO_TRY = uintt(-1);
69 namespace cpp {
72 CodeExplorer::CodeExplorer( ary::cpp::Gate & io_rAryGate )
73 : aGlobalParseContext(io_rAryGate),
74 // aEnvironments,
75 pPE_File(0),
76 pGate(&io_rAryGate),
77 dpCurToken(0)
79 pPE_File = new PE_File( aGlobalParseContext );
82 CodeExplorer::~CodeExplorer()
86 void
87 CodeExplorer::StartNewFile()
89 csv::erase_container(aEnvironments);
91 aEnvironments.push_back( pPE_File.MutablePtr() );
92 pPE_File->Enter(push);
95 void
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();
105 do {
106 CurToken().Trigger( CurEnv() );
107 AcknowledgeResult();
108 } while ( dpCurToken );
111 void
112 CodeExplorer::AcknowledgeResult()
114 if (CurResult().eDone == done)
115 dpCurToken = 0;
117 switch ( CurResult().eStackAction )
119 case stay:
120 break;
121 case push:
122 CurEnv().Leave(push);
123 aEnvironments.push_back( &PushEnv() );
124 PushEnv().Enter(push);
125 break;
126 case pop_success:
127 CurEnv().Leave(pop_success);
128 aEnvironments.pop_back();
129 CurEnv().Enter(pop_success);
130 break;
131 case pop_failure:
133 Cpp_PE * pRecover = 0;
134 do {
135 CurEnv().Leave(pop_failure);
136 aEnvironments.pop_back();
137 if ( aEnvironments.empty() )
138 break;
139 pRecover = CurEnv().Handle_ChildFailure();
140 } while ( pRecover == 0 );
141 if ( pRecover != 0 )
143 aEnvironments.push_back(pRecover);
144 pRecover->Enter(push);
146 else
148 throw X_Parser( X_Parser::x_UnexpectedToken, CurToken().Text(), aGlobalParseContext.CurFileName(), aGlobalParseContext.LineCount() );
150 } break;
151 default:
152 csv_assert(false);
153 } // end switch(CurResult().eStackAction)
156 const Token &
157 CodeExplorer::CurToken() const
159 csv_assert(dpCurToken);
161 return *dpCurToken;
164 Cpp_PE &
165 CodeExplorer::CurEnv() const
167 csv_assert(aEnvironments.size() > 0);
168 csv_assert(aEnvironments.back() != 0);
170 return *aEnvironments.back();
173 Cpp_PE &
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 );
179 return *ret;
184 } // namespace cpp