1*1c78a5d6SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*1c78a5d6SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*1c78a5d6SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*1c78a5d6SAndrew Rist * distributed with this work for additional information 6*1c78a5d6SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*1c78a5d6SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*1c78a5d6SAndrew Rist * "License"); you may not use this file except in compliance 9*1c78a5d6SAndrew Rist * with the License. You may obtain a copy of the License at 10*1c78a5d6SAndrew Rist * 11*1c78a5d6SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*1c78a5d6SAndrew Rist * 13*1c78a5d6SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*1c78a5d6SAndrew Rist * software distributed under the License is distributed on an 15*1c78a5d6SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*1c78a5d6SAndrew Rist * KIND, either express or implied. See the License for the 17*1c78a5d6SAndrew Rist * specific language governing permissions and limitations 18*1c78a5d6SAndrew Rist * under the License. 19*1c78a5d6SAndrew Rist * 20*1c78a5d6SAndrew Rist *************************************************************/ 21*1c78a5d6SAndrew Rist 22*1c78a5d6SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef ADC_CPP_PE_FILE_HXX 25cdf0e10cSrcweir #define ADC_CPP_PE_FILE_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir 28cdf0e10cSrcweir 29cdf0e10cSrcweir // USED SERVICES 30cdf0e10cSrcweir // BASE CLASSES 31cdf0e10cSrcweir #include "cpp_pe.hxx" 32cdf0e10cSrcweir // COMPONENTS 33cdf0e10cSrcweir #include <semantic/callf.hxx> 34cdf0e10cSrcweir #include <semantic/sub_peu.hxx> 35cdf0e10cSrcweir // PARAMETERS 36cdf0e10cSrcweir 37cdf0e10cSrcweir 38cdf0e10cSrcweir namespace cpp { 39cdf0e10cSrcweir 40cdf0e10cSrcweir class PeEnvironment; 41cdf0e10cSrcweir 42cdf0e10cSrcweir class PE_Namespace; 43cdf0e10cSrcweir class PE_Enum; 44cdf0e10cSrcweir class PE_Typedef; 45cdf0e10cSrcweir class PE_VarFunc; 46cdf0e10cSrcweir class PE_TemplateTop; 47cdf0e10cSrcweir class PE_Defines; 48cdf0e10cSrcweir class PE_Ignore; 49cdf0e10cSrcweir 50cdf0e10cSrcweir #if 0 51cdf0e10cSrcweir class PE_Template; 52cdf0e10cSrcweir class PE_Extern; 53cdf0e10cSrcweir #endif 54cdf0e10cSrcweir 55cdf0e10cSrcweir 56cdf0e10cSrcweir class PE_File : public Cpp_PE 57cdf0e10cSrcweir { 58cdf0e10cSrcweir public: 59cdf0e10cSrcweir enum E_State 60cdf0e10cSrcweir { 61cdf0e10cSrcweir std, /// before class, struct or union 62cdf0e10cSrcweir in_extern, 63cdf0e10cSrcweir in_externC, 64cdf0e10cSrcweir size_of_states 65cdf0e10cSrcweir }; 66cdf0e10cSrcweir 67cdf0e10cSrcweir PE_File( 68cdf0e10cSrcweir PeEnvironment & io_rEnv ); 69cdf0e10cSrcweir ~PE_File(); 70cdf0e10cSrcweir 71cdf0e10cSrcweir virtual void Call_Handler( 72cdf0e10cSrcweir const cpp::Token & i_rTok ); 73cdf0e10cSrcweir virtual Cpp_PE * Handle_ChildFailure(); 74cdf0e10cSrcweir 75cdf0e10cSrcweir private: 76cdf0e10cSrcweir typedef SubPe< PE_File, PE_Namespace> SP_Namespace; 77cdf0e10cSrcweir typedef SubPe< PE_File, PE_Typedef> SP_Typedef; 78cdf0e10cSrcweir typedef SubPe< PE_File, PE_VarFunc> SP_VarFunc; 79cdf0e10cSrcweir typedef SubPe< PE_File, PE_TemplateTop> SP_Template; 80cdf0e10cSrcweir typedef SubPe< PE_File, PE_Defines> SP_Defines; 81cdf0e10cSrcweir typedef SubPe< PE_File, PE_Ignore > SP_Ignore; 82cdf0e10cSrcweir #if 0 83cdf0e10cSrcweir typedef SubPe< PE_File, PE_Using> SP_Using; 84cdf0e10cSrcweir #endif // 0 85cdf0e10cSrcweir 86cdf0e10cSrcweir typedef SubPeUse< PE_File, PE_Namespace> SPU_Namespace; 87cdf0e10cSrcweir typedef SubPeUse< PE_File, PE_Typedef> SPU_Typedef; 88cdf0e10cSrcweir typedef SubPeUse< PE_File, PE_VarFunc> SPU_VarFunc; 89cdf0e10cSrcweir typedef SubPeUse< PE_File, PE_TemplateTop> SPU_Template; 90cdf0e10cSrcweir typedef SubPeUse< PE_File, PE_Defines> SPU_Defines; 91cdf0e10cSrcweir typedef SubPeUse< PE_File, PE_Ignore> SPU_Ignore; 92cdf0e10cSrcweir 93cdf0e10cSrcweir void Setup_StatusFunctions(); 94cdf0e10cSrcweir virtual void InitData(); 95cdf0e10cSrcweir virtual void TransferData(); 96cdf0e10cSrcweir void Hdl_SyntaxError( const char *); 97cdf0e10cSrcweir 98cdf0e10cSrcweir void SpReturn_VarFunc(); 99cdf0e10cSrcweir void SpReturn_Template(); 100cdf0e10cSrcweir 101cdf0e10cSrcweir void On_std_namespace(const char * i_sText); 102cdf0e10cSrcweir void On_std_ClassKey(const char * i_sText); 103cdf0e10cSrcweir void On_std_typedef(const char * i_sText); 104cdf0e10cSrcweir void On_std_enum(const char * i_sText); 105cdf0e10cSrcweir void On_std_VarFunc(const char * i_sText); 106cdf0e10cSrcweir void On_std_template(const char * i_sText); 107cdf0e10cSrcweir void On_std_extern(const char * i_sText); 108cdf0e10cSrcweir void On_std_using(const char * i_sText); 109cdf0e10cSrcweir void On_std_SwBracketRight(const char * i_sText); 110cdf0e10cSrcweir 111cdf0e10cSrcweir void On_std_DefineName(const char * i_sText); 112cdf0e10cSrcweir void On_std_MacroName(const char * i_sText); 113cdf0e10cSrcweir 114cdf0e10cSrcweir void On_in_extern_Constant(const char * i_sText); 115cdf0e10cSrcweir void On_in_extern_Ignore(const char * i_sText); 116cdf0e10cSrcweir void On_in_externC_SwBracket_Left(const char * i_sText); 117cdf0e10cSrcweir void On_in_externC_NoBlock(const char * i_sText); 118cdf0e10cSrcweir access_Env()119cdf0e10cSrcweir PeEnvironment & access_Env() { return *pEnv; } 120cdf0e10cSrcweir 121cdf0e10cSrcweir 122cdf0e10cSrcweir // DATA 123cdf0e10cSrcweir PeEnvironment * pEnv; 124cdf0e10cSrcweir 125cdf0e10cSrcweir Dyn< PeStatusArray<PE_File> > 126cdf0e10cSrcweir pStati; 127cdf0e10cSrcweir 128cdf0e10cSrcweir Dyn<SP_Namespace> pSpNamespace; 129cdf0e10cSrcweir Dyn<SP_Typedef> pSpTypedef; 130cdf0e10cSrcweir Dyn<SP_VarFunc> pSpVarFunc; 131cdf0e10cSrcweir Dyn<SP_Template> pSpTemplate; 132cdf0e10cSrcweir Dyn<SP_Defines> pSpDefs; 133cdf0e10cSrcweir 134cdf0e10cSrcweir Dyn<SP_Ignore> pSpIgnore; 135cdf0e10cSrcweir #if 0 136cdf0e10cSrcweir SP_Using aSpUsing; 137cdf0e10cSrcweir #endif // 0 138cdf0e10cSrcweir 139cdf0e10cSrcweir Dyn<SPU_Namespace> pSpuNamespace; 140cdf0e10cSrcweir Dyn<SPU_Typedef> pSpuTypedef; 141cdf0e10cSrcweir Dyn<SPU_VarFunc> pSpuVarFunc; 142cdf0e10cSrcweir Dyn<SPU_Template> pSpuTemplate; 143cdf0e10cSrcweir Dyn<SPU_Defines> pSpuDefs; 144cdf0e10cSrcweir 145cdf0e10cSrcweir Dyn<SPU_Ignore> pSpuUsing; 146cdf0e10cSrcweir Dyn<SPU_Ignore> pSpuIgnoreFailure; 147cdf0e10cSrcweir 148cdf0e10cSrcweir bool bWithinSingleExternC; /** After 'extern "C"' without following '{', 149cdf0e10cSrcweir waiting for the next function or variable to 150cdf0e10cSrcweir set back to false. 151cdf0e10cSrcweir */ 152cdf0e10cSrcweir }; 153cdf0e10cSrcweir 154cdf0e10cSrcweir } // namespace cpp 155cdf0e10cSrcweir 156cdf0e10cSrcweir 157cdf0e10cSrcweir 158cdf0e10cSrcweir #if 0 // Branches 159cdf0e10cSrcweir 160cdf0e10cSrcweir namespace 161cdf0e10cSrcweir -> Named Namespace declaration 162cdf0e10cSrcweir -> Unnamed Namespace declaration 163cdf0e10cSrcweir -> Namespace alias definition 164cdf0e10cSrcweir 165cdf0e10cSrcweir class struct union 166cdf0e10cSrcweir -> Class 167cdf0e10cSrcweir -> Predeclaration 168cdf0e10cSrcweir 169cdf0e10cSrcweir typedef 170cdf0e10cSrcweir -> Typedef 171cdf0e10cSrcweir 172cdf0e10cSrcweir enum 173cdf0e10cSrcweir -> Enum 174cdf0e10cSrcweir 175cdf0e10cSrcweir extern 176cdf0e10cSrcweir -> Extern-"C" 177cdf0e10cSrcweir -> TypeDeclaration 178cdf0e10cSrcweir 179cdf0e10cSrcweir TypeDeclaration 180cdf0e10cSrcweir -> FunctionDecl 181cdf0e10cSrcweir -> FunctionDef 182cdf0e10cSrcweir -> Variable 183cdf0e10cSrcweir 184cdf0e10cSrcweir template 185cdf0e10cSrcweir -> TemplateClass 186cdf0e10cSrcweir -> TemplateFunction 187cdf0e10cSrcweir -> TemplateFunction/Method-Implementation 188cdf0e10cSrcweir -> TemplatePredeclaration 189cdf0e10cSrcweir 190cdf0e10cSrcweir } 191cdf0e10cSrcweir -> End of Namespace 192cdf0e10cSrcweir -> End of Extern-"C" 193cdf0e10cSrcweir 194cdf0e10cSrcweir asm 195cdf0e10cSrcweir -> AssemblerDeclaration 196cdf0e10cSrcweir 197cdf0e10cSrcweir using 198cdf0e10cSrcweir -> Using-Declaration 199cdf0e10cSrcweir -> Using-Directive 200cdf0e10cSrcweir 201cdf0e10cSrcweir #endif // 0 202cdf0e10cSrcweir 203cdf0e10cSrcweir 204cdf0e10cSrcweir #endif 205cdf0e10cSrcweir 206