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_PE_VARI_HXX 25 #define ADC_CPP_PE_VARI_HXX 26 27 28 29 // USED SERVICES 30 // BASE CLASSES 31 #include "cpp_pe.hxx" 32 // COMPONENTS 33 #include <semantic/callf.hxx> 34 #include <semantic/sub_peu.hxx> 35 #include <ary/cpp/c_types4cpp.hxx> 36 #include <ary/cpp/c_vfflag.hxx> 37 // PARAMETERS 38 39 40 namespace cpp { 41 42 class PE_Expression; 43 44 45 class PE_Variable : public Cpp_PE 46 { 47 public: 48 enum E_State 49 { 50 afterName, // 51 afterSize, // after ] 52 expectFinish, // after InitExpression 53 size_of_states 54 }; 55 PE_Variable( 56 Cpp_PE * i_pParent ); 57 ~PE_Variable(); 58 59 /** @return 60 Bit 0x0001 != 0, if there is a size and 61 bit 0x0002 != 0, if there is an initialisation. 62 */ 63 UINT16 Result_Pattern() const; 64 const String & Result_SizeExpression() const; 65 const String & Result_InitExpression() const; 66 67 virtual void Call_Handler( 68 const cpp::Token & i_rTok ); 69 70 private: 71 typedef SubPe< PE_Variable, PE_Expression > SP_Expression; 72 typedef SubPeUse< PE_Variable, PE_Expression> SPU_Expression; 73 74 void Setup_StatusFunctions(); 75 virtual void InitData(); 76 virtual void TransferData(); 77 void Hdl_SyntaxError(const char *); 78 79 void SpReturn_ArraySizeExpression(); 80 void SpReturn_InitExpression(); 81 82 void On_afterName_ArrayBracket_Left(const char * i_sText); 83 void On_afterName_Semicolon(const char * i_sText); 84 void On_afterName_Comma(const char * i_sText); 85 void On_afterName_Assign(const char * i_sText); 86 87 void On_afterSize_ArrayBracket_Right(const char * i_sText); 88 89 void On_expectFinish_Semicolon(const char * i_sText); 90 void On_expectFinish_Comma(const char * i_sText); 91 void On_expectFinish_Bracket_Right(const char * i_sText); 92 93 // DATA 94 Dyn< PeStatusArray<PE_Variable> > 95 pStati; 96 97 Dyn<SP_Expression> pSpExpression; 98 Dyn<SPU_Expression> pSpuArraySizeExpression; 99 Dyn<SPU_Expression> pSpuInitExpression; 100 101 String sResultSizeExpression; 102 String sResultInitExpression; 103 }; 104 105 106 107 // IMPLEMENTATION 108 109 110 inline UINT16 111 PE_Variable::Result_Pattern() const 112 { return ( sResultSizeExpression.length() > 0 ? 1 : 0 ) 113 + ( sResultInitExpression.length() > 0 ? 2 : 0 ); } 114 inline const String & 115 PE_Variable::Result_SizeExpression() const 116 { return sResultSizeExpression; } 117 inline const String & 118 PE_Variable::Result_InitExpression() const 119 { return sResultInitExpression; } 120 121 122 } // namespace cpp 123 124 125 #endif 126 127