1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #include <precomp.h> 29 #include "pe_enum.hxx" 30 31 32 // NOT FULLY DECLARED SERVICES 33 #include <ary/cpp/c_gate.hxx> 34 #include <ary/cpp/c_enum.hxx> 35 #include <ary/cpp/cp_ce.hxx> 36 #include <all_toks.hxx> 37 #include "pe_enval.hxx" 38 39 40 namespace cpp { 41 42 43 PE_Enum::PE_Enum(Cpp_PE * i_pParent ) 44 : Cpp_PE(i_pParent), 45 pStati( new PeStatusArray<PE_Enum> ), 46 // pSpValue, 47 // pSpuValue, 48 // sLocalName, 49 pCurObject(0), 50 eResult_KindOf(is_declaration) 51 { 52 Setup_StatusFunctions(); 53 54 pSpValue = new SP_EnumValue(*this); 55 pSpuValue = new SPU_EnumValue(*pSpValue, 0, 0); 56 } 57 58 59 PE_Enum::~PE_Enum() 60 { 61 } 62 63 void 64 PE_Enum::Call_Handler( const cpp::Token & i_rTok ) 65 { 66 pStati->Cur().Call_Handler(i_rTok.TypeId(), i_rTok.Text()); 67 } 68 69 void 70 PE_Enum::Setup_StatusFunctions() 71 { 72 typedef CallFunction<PE_Enum>::F_Tok F_Tok; 73 static F_Tok stateF_expectName[] = { &PE_Enum::On_expectName_Identifier, 74 &PE_Enum::On_expectName_SwBracket_Left 75 }; 76 static INT16 stateT_expectName[] = { Tid_Identifier, 77 Tid_SwBracket_Left 78 }; 79 80 static F_Tok stateF_gotName[] = { &PE_Enum::On_gotName_SwBracket_Left }; 81 static INT16 stateT_gotName[] = { Tid_SwBracket_Left }; 82 83 static F_Tok stateF_bodyStd[] = { &PE_Enum::On_bodyStd_Identifier, 84 &PE_Enum::On_bodyStd_SwBracket_Right }; 85 static INT16 stateT_bodyStd[] = { Tid_Identifier, 86 Tid_SwBracket_Right }; 87 88 static F_Tok stateF_afterBlock[] = { &PE_Enum::On_afterBlock_Semicolon }; 89 static INT16 stateT_afterBlock[] = { Tid_Semicolon }; 90 91 SEMPARSE_CREATE_STATUS(PE_Enum, expectName, Hdl_SyntaxError); 92 SEMPARSE_CREATE_STATUS(PE_Enum, gotName, On_gotName_Return2Type); 93 SEMPARSE_CREATE_STATUS(PE_Enum, bodyStd, Hdl_SyntaxError); 94 SEMPARSE_CREATE_STATUS(PE_Enum, afterBlock, On_afterBlock_Return2Type); 95 } 96 97 void 98 PE_Enum::InitData() 99 { 100 pStati->SetCur(expectName); 101 pCurObject = 0; 102 sLocalName.clear(); 103 eResult_KindOf = is_declaration; 104 } 105 106 void 107 PE_Enum::TransferData() 108 { 109 pStati->SetCur(size_of_states); 110 } 111 112 void 113 PE_Enum::Hdl_SyntaxError( const char * i_sText) 114 { 115 StdHandlingOfSyntaxError(i_sText); 116 } 117 118 void 119 PE_Enum::On_expectName_Identifier( const char * i_sText ) 120 { 121 SetTokenResult(done, stay); 122 pStati->SetCur(gotName); 123 124 sLocalName = i_sText; 125 pCurObject = & Env().AryGate().Ces().Store_Enum( Env().Context(), sLocalName ); 126 } 127 128 void 129 PE_Enum::On_expectName_SwBracket_Left( const char * ) 130 { 131 SetTokenResult(done, stay); 132 pStati->SetCur(bodyStd); 133 134 sLocalName = ""; 135 pCurObject = & Env().AryGate().Ces().Store_Enum( Env().Context(), sLocalName ); 136 sLocalName = pCurObject->LocalName(); 137 138 Env().OpenEnum(*pCurObject); 139 } 140 141 void 142 PE_Enum::On_gotName_SwBracket_Left( const char * ) 143 { 144 SetTokenResult(done, stay); 145 pStati->SetCur(bodyStd); 146 Env().OpenEnum(*pCurObject); 147 } 148 149 void 150 PE_Enum::On_gotName_Return2Type( const char * ) 151 { 152 SetTokenResult(not_done, pop_success); 153 154 eResult_KindOf = is_qualified_typename; 155 } 156 157 void 158 PE_Enum::On_bodyStd_Identifier( const char * ) 159 { 160 pSpuValue->Push(not_done); 161 } 162 163 void 164 PE_Enum::On_bodyStd_SwBracket_Right( const char * ) 165 { 166 SetTokenResult(done, stay); 167 pStati->SetCur(afterBlock); 168 169 Env().CloseEnum(); 170 } 171 172 void 173 PE_Enum::On_afterBlock_Semicolon( const char * ) 174 { 175 SetTokenResult(not_done, pop_success); 176 eResult_KindOf = is_declaration; 177 } 178 179 void 180 PE_Enum::On_afterBlock_Return2Type( const char * ) 181 { 182 SetTokenResult(not_done, pop_success); 183 eResult_KindOf = is_implicit_declaration; 184 } 185 186 } // namespace cpp 187 188 189 190