1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: pe_enum.cxx,v $
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 ************************************************************************/
32 #include "pe_enum.hxx"
35 // NOT FULLY DECLARED SERVICES
36 #include <ary/cpp/c_gate.hxx>
37 #include <ary/cpp/c_enum.hxx>
38 #include <ary/cpp/cp_ce.hxx>
39 #include <all_toks.hxx>
40 #include "pe_enval.hxx"
46 PE_Enum::PE_Enum(Cpp_PE
* i_pParent
)
48 pStati( new PeStatusArray
<PE_Enum
> ),
53 eResult_KindOf(is_declaration
)
55 Setup_StatusFunctions();
57 pSpValue
= new SP_EnumValue(*this);
58 pSpuValue
= new SPU_EnumValue(*pSpValue
, 0, 0);
67 PE_Enum::Call_Handler( const cpp::Token
& i_rTok
)
69 pStati
->Cur().Call_Handler(i_rTok
.TypeId(), i_rTok
.Text());
73 PE_Enum::Setup_StatusFunctions()
75 typedef CallFunction
<PE_Enum
>::F_Tok F_Tok
;
76 static F_Tok stateF_expectName
[] = { &PE_Enum::On_expectName_Identifier
,
77 &PE_Enum::On_expectName_SwBracket_Left
79 static INT16 stateT_expectName
[] = { Tid_Identifier
,
83 static F_Tok stateF_gotName
[] = { &PE_Enum::On_gotName_SwBracket_Left
};
84 static INT16 stateT_gotName
[] = { Tid_SwBracket_Left
};
86 static F_Tok stateF_bodyStd
[] = { &PE_Enum::On_bodyStd_Identifier
,
87 &PE_Enum::On_bodyStd_SwBracket_Right
};
88 static INT16 stateT_bodyStd
[] = { Tid_Identifier
,
89 Tid_SwBracket_Right
};
91 static F_Tok stateF_afterBlock
[] = { &PE_Enum::On_afterBlock_Semicolon
};
92 static INT16 stateT_afterBlock
[] = { Tid_Semicolon
};
94 SEMPARSE_CREATE_STATUS(PE_Enum
, expectName
, Hdl_SyntaxError
);
95 SEMPARSE_CREATE_STATUS(PE_Enum
, gotName
, On_gotName_Return2Type
);
96 SEMPARSE_CREATE_STATUS(PE_Enum
, bodyStd
, Hdl_SyntaxError
);
97 SEMPARSE_CREATE_STATUS(PE_Enum
, afterBlock
, On_afterBlock_Return2Type
);
103 pStati
->SetCur(expectName
);
106 eResult_KindOf
= is_declaration
;
110 PE_Enum::TransferData()
112 pStati
->SetCur(size_of_states
);
116 PE_Enum::Hdl_SyntaxError( const char * i_sText
)
118 StdHandlingOfSyntaxError(i_sText
);
122 PE_Enum::On_expectName_Identifier( const char * i_sText
)
124 SetTokenResult(done
, stay
);
125 pStati
->SetCur(gotName
);
127 sLocalName
= i_sText
;
128 pCurObject
= & Env().AryGate().Ces().Store_Enum( Env().Context(), sLocalName
);
132 PE_Enum::On_expectName_SwBracket_Left( const char * )
134 SetTokenResult(done
, stay
);
135 pStati
->SetCur(bodyStd
);
138 pCurObject
= & Env().AryGate().Ces().Store_Enum( Env().Context(), sLocalName
);
139 sLocalName
= pCurObject
->LocalName();
141 Env().OpenEnum(*pCurObject
);
145 PE_Enum::On_gotName_SwBracket_Left( const char * )
147 SetTokenResult(done
, stay
);
148 pStati
->SetCur(bodyStd
);
149 Env().OpenEnum(*pCurObject
);
153 PE_Enum::On_gotName_Return2Type( const char * )
155 SetTokenResult(not_done
, pop_success
);
157 eResult_KindOf
= is_qualified_typename
;
161 PE_Enum::On_bodyStd_Identifier( const char * )
163 pSpuValue
->Push(not_done
);
167 PE_Enum::On_bodyStd_SwBracket_Right( const char * )
169 SetTokenResult(done
, stay
);
170 pStati
->SetCur(afterBlock
);
176 PE_Enum::On_afterBlock_Semicolon( const char * )
178 SetTokenResult(not_done
, pop_success
);
179 eResult_KindOf
= is_declaration
;
183 PE_Enum::On_afterBlock_Return2Type( const char * )
185 SetTokenResult(not_done
, pop_success
);
186 eResult_KindOf
= is_implicit_declaration
;