1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef ADC_CPP_PEV_HXX 25 #define ADC_CPP_PEV_HXX 26 27 28 29 // USED SERVICES 30 // BASE CLASSES 31 #include <tokens/tokproct.hxx> 32 // COMPONENTS 33 // PARAMETERS 34 #include <ary/cpp/c_types4cpp.hxx> 35 36 namespace ary 37 { 38 namespace cpp 39 { 40 class Gate; 41 class InputContext; 42 43 class Namespace; 44 class Class; 45 class Enum; 46 class Typedef; 47 class Function; 48 class Variable; 49 class EnumValue; 50 51 class DefineEntity; 52 } 53 54 class Documentation; 55 } 56 57 58 namespace cpp 59 { 60 61 62 class PeEnvironment : protected TokenProcessing_Types 63 { 64 public: 65 // INQUIRY 66 virtual ~PeEnvironment() {} 67 68 // OPERATIONS 69 // Token results 70 void SetTokenResult( 71 E_TokenDone i_eDone, 72 E_EnvStackAction i_eWhat2DoWithEnvStack, 73 ParseEnvironment * i_pParseEnv2Push = 0 ); 74 75 // Owner stack 76 void OpenNamespace( 77 ary::cpp::Namespace & 78 io_rOpenedNamespace ); 79 void OpenExternC( 80 bool i_bOnlyForOneDeclaration = false ); 81 void OpenClass( 82 ary::cpp::Class & io_rOpenedClass ); 83 void OpenEnum( 84 ary::cpp::Enum & io_rOpenedEnum ); 85 void CloseBlock(); /// Handles a '}' on file scope. 86 void CloseClass(); 87 void CloseEnum(); 88 void SetCurProtection( /// Handles 'public:', 'protected:' and 'private:' on class scope. 89 ary::cpp::E_Protection 90 i_eProtection ); 91 void OpenTemplate( 92 const StringVector & 93 i_rParameters ); 94 /// Removes parameters from this object. 95 DYN StringVector * Get_CurTemplateParameters(); 96 /// Checks, if a template is still open, and if yes, closes it. 97 void Close_OpenTemplate(); 98 99 // Special events 100 void Event_Class_FinishedBase( 101 const String & i_sParameterName ); 102 103 void Event_Store_Typedef( 104 ary::cpp::Typedef & io_rTypedef ); 105 void Event_Store_EnumValue( 106 ary::cpp::EnumValue & 107 io_rEnumValue ); 108 void Event_Store_CppDefinition( 109 ary::cpp::DefineEntity & 110 io_rDefinition ); 111 112 void Event_EnterFunction_ParameterList(); 113 void Event_Function_FinishedParameter( 114 const String & i_sParameterName ); 115 void Event_LeaveFunction_ParameterList(); 116 void Event_EnterFunction_Implementation(); 117 void Event_LeaveFunction_Implementation(); 118 119 void Event_Store_Function( 120 ary::cpp::Function & 121 io_rFunction ); 122 void Event_Store_Variable( 123 ary::cpp::Variable & 124 io_rVariable ); 125 // Error recovery 126 void StartWaitingFor_Recovery(); 127 128 // INQUIRY 129 ary::cpp::Gate & AryGate() const; 130 const ary::cpp::InputContext & 131 Context() const; 132 String CurFileName() const; 133 uintt LineCount() const; 134 bool IsWaitingFor_Recovery() const; 135 bool IsExternC() const; 136 137 private: 138 virtual void do_SetTokenResult( 139 E_TokenDone i_eDone, 140 E_EnvStackAction i_eWhat2DoWithEnvStack, 141 ParseEnvironment * i_pParseEnv2Push ) = 0; 142 virtual void do_OpenNamespace( 143 ary::cpp::Namespace & 144 io_rOpenedNamespace ) = 0; 145 virtual void do_OpenExternC( 146 bool i_bOnlyForOneDeclaration ) = 0; 147 virtual void do_OpenClass( 148 ary::cpp::Class & io_rOpenedClass ) = 0; 149 virtual void do_OpenEnum( 150 ary::cpp::Enum & io_rOpenedEnum ) = 0; 151 virtual void do_CloseBlock() = 0; 152 virtual void do_CloseClass() = 0; 153 virtual void do_CloseEnum() = 0; 154 virtual void do_SetCurProtection( 155 ary::cpp::E_Protection 156 i_eProtection ) = 0; 157 virtual void do_OpenTemplate( 158 const StringVector & 159 i_rParameters ) = 0; 160 virtual DYN StringVector * 161 do_Get_CurTemplateParameters() = 0; 162 virtual void do_Close_OpenTemplate() = 0; 163 virtual void do_Event_Class_FinishedBase( 164 const String & i_sBaseName ) = 0; 165 166 virtual void do_Event_Store_Typedef( 167 ary::cpp::Typedef & io_rTypedef ) = 0; 168 virtual void do_Event_Store_EnumValue( 169 ary::cpp::EnumValue & 170 io_rEnumValue ) = 0; 171 virtual void do_Event_Store_CppDefinition( 172 ary::cpp::DefineEntity & 173 io_rDefinition ) = 0; 174 virtual void do_Event_EnterFunction_ParameterList() = 0; 175 virtual void do_Event_Function_FinishedParameter( 176 const String & i_sParameterName ) = 0; 177 virtual void do_Event_LeaveFunction_ParameterList() = 0; 178 virtual void do_Event_EnterFunction_Implementation() = 0; 179 virtual void do_Event_LeaveFunction_Implementation() = 0; 180 virtual void do_Event_Store_Function( 181 ary::cpp::Function & 182 io_rFunction ) = 0; 183 virtual void do_Event_Store_Variable( 184 ary::cpp::Variable & 185 io_rVariable ) = 0; 186 virtual void do_StartWaitingFor_Recovery() = 0; 187 virtual ary::cpp::Gate & 188 inq_AryGate() const = 0; 189 virtual const ary::cpp::InputContext & 190 inq_Context() const = 0; 191 virtual String inq_CurFileName() const = 0; 192 virtual uintt inq_LineCount() const = 0; 193 virtual bool inq_IsWaitingFor_Recovery() const = 0; 194 virtual bool inq_IsExternC() const = 0; 195 }; 196 197 198 199 // IMPLEMENTATION 200 201 inline void 202 PeEnvironment::SetTokenResult( E_TokenDone i_eDone, 203 E_EnvStackAction i_eWhat2DoWithEnvStack, 204 ParseEnvironment * i_pParseEnv2Push ) 205 { do_SetTokenResult(i_eDone, i_eWhat2DoWithEnvStack, i_pParseEnv2Push); } 206 inline void 207 PeEnvironment::OpenNamespace( ary::cpp::Namespace & io_rOpenedNamespace ) 208 { do_OpenNamespace(io_rOpenedNamespace); } 209 inline void 210 PeEnvironment::OpenExternC( bool i_bOnlyForOneDeclaration ) 211 { do_OpenExternC(i_bOnlyForOneDeclaration); } 212 inline void 213 PeEnvironment::OpenClass( ary::cpp::Class & io_rOpenedClass ) 214 { do_OpenClass(io_rOpenedClass); } 215 inline void 216 PeEnvironment::OpenEnum( ary::cpp::Enum & io_rOpenedEnum ) 217 { do_OpenEnum(io_rOpenedEnum); } 218 inline void 219 PeEnvironment::CloseBlock() 220 { do_CloseBlock(); } 221 inline void 222 PeEnvironment::CloseClass() 223 { do_CloseClass(); } 224 inline void 225 PeEnvironment::CloseEnum() 226 { do_CloseEnum(); } 227 inline void 228 PeEnvironment::SetCurProtection( ary::cpp::E_Protection i_eProtection ) 229 { do_SetCurProtection(i_eProtection); } 230 inline void 231 PeEnvironment::OpenTemplate( const StringVector & i_rParameters ) 232 { do_OpenTemplate(i_rParameters); } 233 inline DYN StringVector * 234 PeEnvironment::Get_CurTemplateParameters() 235 { return do_Get_CurTemplateParameters(); } 236 inline void 237 PeEnvironment::Close_OpenTemplate() 238 { do_Close_OpenTemplate(); } 239 inline void 240 PeEnvironment::Event_Class_FinishedBase( const String & i_sBaseName ) 241 { do_Event_Class_FinishedBase(i_sBaseName); } 242 inline void 243 PeEnvironment::Event_Store_Typedef( ary::cpp::Typedef & io_rTypedef ) 244 { do_Event_Store_Typedef(io_rTypedef); } 245 inline void 246 PeEnvironment::Event_Store_EnumValue( ary::cpp::EnumValue & io_rEnumValue ) 247 { do_Event_Store_EnumValue(io_rEnumValue); } 248 inline void 249 PeEnvironment::Event_Store_CppDefinition( ary::cpp::DefineEntity & io_rDefinition ) 250 { do_Event_Store_CppDefinition(io_rDefinition); } 251 inline void 252 PeEnvironment::Event_EnterFunction_ParameterList() 253 { do_Event_EnterFunction_ParameterList(); } 254 inline void 255 PeEnvironment::Event_Function_FinishedParameter( const String & i_sParameterName ) 256 { do_Event_Function_FinishedParameter(i_sParameterName); } 257 inline void 258 PeEnvironment::Event_LeaveFunction_ParameterList() 259 { do_Event_LeaveFunction_ParameterList(); } 260 inline void 261 PeEnvironment::Event_EnterFunction_Implementation() 262 { do_Event_EnterFunction_Implementation(); } 263 inline void 264 PeEnvironment::Event_LeaveFunction_Implementation() 265 { do_Event_LeaveFunction_Implementation(); } 266 inline void 267 PeEnvironment::Event_Store_Function( ary::cpp::Function & io_rFunction ) 268 { do_Event_Store_Function(io_rFunction); } 269 inline void 270 PeEnvironment::Event_Store_Variable( ary::cpp::Variable & io_rVariable ) 271 { do_Event_Store_Variable(io_rVariable); } 272 inline void 273 PeEnvironment::StartWaitingFor_Recovery() 274 { do_StartWaitingFor_Recovery(); } 275 inline ary::cpp::Gate & 276 PeEnvironment::AryGate() const 277 { return inq_AryGate(); } 278 inline const ary::cpp::InputContext & 279 PeEnvironment::Context() const 280 { return inq_Context(); } 281 inline String 282 PeEnvironment::CurFileName() const 283 { return inq_CurFileName(); } 284 inline uintt 285 PeEnvironment::LineCount() const 286 { return inq_LineCount(); } 287 inline bool 288 PeEnvironment::IsWaitingFor_Recovery() const 289 { return inq_IsWaitingFor_Recovery(); } 290 inline bool 291 PeEnvironment::IsExternC() const 292 { return inq_IsExternC(); } 293 294 295 296 } // namespace cpp 297 298 299 #endif 300 301