xref: /trunk/main/autodoc/source/parser/cpp/pe_enum.cxx (revision 78bc99aa)
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 #include <precomp.h>
23 #include "pe_enum.hxx"
24 
25 
26 // NOT FULLY DECLARED SERVICES
27 #include <ary/cpp/c_gate.hxx>
28 #include <ary/cpp/c_enum.hxx>
29 #include <ary/cpp/cp_ce.hxx>
30 #include <all_toks.hxx>
31 #include "pe_enval.hxx"
32 
33 
34 namespace cpp {
35 
36 
PE_Enum(Cpp_PE * i_pParent)37 PE_Enum::PE_Enum(Cpp_PE * i_pParent )
38 	:   Cpp_PE(i_pParent),
39 		pStati( new PeStatusArray<PE_Enum> ),
40 		// pSpValue,
41 		// pSpuValue,
42         // sLocalName,
43 		pCurObject(0),
44         eResult_KindOf(is_declaration)
45 {
46 	Setup_StatusFunctions();
47 
48 	pSpValue    = new SP_EnumValue(*this);
49 	pSpuValue	= new SPU_EnumValue(*pSpValue, 0, 0);
50 }
51 
52 
~PE_Enum()53 PE_Enum::~PE_Enum()
54 {
55 }
56 
57 void
Call_Handler(const cpp::Token & i_rTok)58 PE_Enum::Call_Handler( const cpp::Token & i_rTok )
59 {
60 	pStati->Cur().Call_Handler(i_rTok.TypeId(), i_rTok.Text());
61 }
62 
63 void
Setup_StatusFunctions()64 PE_Enum::Setup_StatusFunctions()
65 {
66 	typedef CallFunction<PE_Enum>::F_Tok	F_Tok;
67 	static F_Tok stateF_expectName[] = 		{ &PE_Enum::On_expectName_Identifier,
68                                               &PE_Enum::On_expectName_SwBracket_Left
69                                             };
70 	static INT16 stateT_expectName[] = 		{ Tid_Identifier,
71                                               Tid_SwBracket_Left
72                                             };
73 
74 	static F_Tok stateF_gotName[] =			{ &PE_Enum::On_gotName_SwBracket_Left };
75 	static INT16 stateT_gotName[] =       	{ Tid_SwBracket_Left };
76 
77 	static F_Tok stateF_bodyStd[] =			{ &PE_Enum::On_bodyStd_Identifier,
78                                               &PE_Enum::On_bodyStd_SwBracket_Right };
79 	static INT16 stateT_bodyStd[] =       	{ Tid_Identifier,
80                                               Tid_SwBracket_Right };
81 
82 	static F_Tok stateF_afterBlock[] = 	    { &PE_Enum::On_afterBlock_Semicolon };
83 	static INT16 stateT_afterBlock[] =   	{ Tid_Semicolon };
84 
85 	SEMPARSE_CREATE_STATUS(PE_Enum, expectName, Hdl_SyntaxError);
86 	SEMPARSE_CREATE_STATUS(PE_Enum, gotName, On_gotName_Return2Type);
87 	SEMPARSE_CREATE_STATUS(PE_Enum, bodyStd, Hdl_SyntaxError);
88 	SEMPARSE_CREATE_STATUS(PE_Enum, afterBlock, On_afterBlock_Return2Type);
89 }
90 
91 void
InitData()92 PE_Enum::InitData()
93 {
94 	pStati->SetCur(expectName);
95 	pCurObject = 0;
96     sLocalName.clear();
97     eResult_KindOf = is_declaration;
98 }
99 
100 void
TransferData()101 PE_Enum::TransferData()
102 {
103 	pStati->SetCur(size_of_states);
104 }
105 
106 void
Hdl_SyntaxError(const char * i_sText)107 PE_Enum::Hdl_SyntaxError( const char * i_sText)
108 {
109 	StdHandlingOfSyntaxError(i_sText);
110 }
111 
112 void
On_expectName_Identifier(const char * i_sText)113 PE_Enum::On_expectName_Identifier( const char * i_sText )
114 {
115 	SetTokenResult(done, stay);
116 	pStati->SetCur(gotName);
117 
118 	sLocalName = i_sText;
119 	pCurObject = & Env().AryGate().Ces().Store_Enum( Env().Context(), sLocalName );
120 }
121 
122 void
On_expectName_SwBracket_Left(const char *)123 PE_Enum::On_expectName_SwBracket_Left( const char * )
124 {
125 	SetTokenResult(done, stay);
126 	pStati->SetCur(bodyStd);
127 
128     sLocalName = "";
129 	pCurObject = & Env().AryGate().Ces().Store_Enum( Env().Context(), sLocalName );
130     sLocalName = pCurObject->LocalName();
131 
132 	Env().OpenEnum(*pCurObject);
133 }
134 
135 void
On_gotName_SwBracket_Left(const char *)136 PE_Enum::On_gotName_SwBracket_Left( const char * )
137 {
138 	SetTokenResult(done, stay);
139 	pStati->SetCur(bodyStd);
140 	Env().OpenEnum(*pCurObject);
141 }
142 
143 void
On_gotName_Return2Type(const char *)144 PE_Enum::On_gotName_Return2Type( const char * )
145 {
146 	SetTokenResult(not_done, pop_success);
147 
148 	eResult_KindOf = is_qualified_typename;
149 }
150 
151 void
On_bodyStd_Identifier(const char *)152 PE_Enum::On_bodyStd_Identifier( const char * )
153 {
154     pSpuValue->Push(not_done);
155 }
156 
157 void
On_bodyStd_SwBracket_Right(const char *)158 PE_Enum::On_bodyStd_SwBracket_Right( const char * )
159 {
160     SetTokenResult(done, stay);
161 	pStati->SetCur(afterBlock);
162 
163 	Env().CloseEnum();
164 }
165 
166 void
On_afterBlock_Semicolon(const char *)167 PE_Enum::On_afterBlock_Semicolon( const char * )
168 {
169 	SetTokenResult(not_done, pop_success);
170 	eResult_KindOf = is_declaration;
171 }
172 
173 void
On_afterBlock_Return2Type(const char *)174 PE_Enum::On_afterBlock_Return2Type( const char * )
175 {
176 	SetTokenResult(not_done, pop_success);
177 	eResult_KindOf = is_implicit_declaration;
178 }
179 
180 }   // namespace cpp
181 
182 
183 
184