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_CLASS_HXX
25cdf0e10cSrcweir #define ADC_CPP_PE_CLASS_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir 
28cdf0e10cSrcweir 
29cdf0e10cSrcweir // USED SERVICES
30cdf0e10cSrcweir 	// BASE CLASSES
31cdf0e10cSrcweir #include "cpp_pe.hxx"
32cdf0e10cSrcweir 	// OTHER
33cdf0e10cSrcweir #include <semantic/callf.hxx>
34cdf0e10cSrcweir #include <semantic/sub_peu.hxx>
35cdf0e10cSrcweir #include <ary/cpp/c_types4cpp.hxx>
36cdf0e10cSrcweir #include <ary/cpp/c_slntry.hxx>
37cdf0e10cSrcweir #include "all_toks.hxx"
38cdf0e10cSrcweir 
39cdf0e10cSrcweir namespace ary
40cdf0e10cSrcweir {
41cdf0e10cSrcweir namespace cpp
42cdf0e10cSrcweir {
43cdf0e10cSrcweir     class Class;
44cdf0e10cSrcweir }
45cdf0e10cSrcweir }
46cdf0e10cSrcweir 
47cdf0e10cSrcweir 
48cdf0e10cSrcweir namespace cpp
49cdf0e10cSrcweir {
50cdf0e10cSrcweir 
51cdf0e10cSrcweir 
52cdf0e10cSrcweir using ary::cpp::E_Protection;
53cdf0e10cSrcweir using ary::cpp::E_Virtuality;
54cdf0e10cSrcweir 
55cdf0e10cSrcweir 
56cdf0e10cSrcweir class PE_Base;
57cdf0e10cSrcweir class PE_Enum;
58cdf0e10cSrcweir class PE_Typedef;
59cdf0e10cSrcweir class PE_VarFunc;
60cdf0e10cSrcweir class PE_Ignore;
61cdf0e10cSrcweir class PE_Defines;
62cdf0e10cSrcweir 
63cdf0e10cSrcweir 
64cdf0e10cSrcweir class PE_Class : public cpp::Cpp_PE
65cdf0e10cSrcweir {
66cdf0e10cSrcweir   public:
67cdf0e10cSrcweir 	enum E_State
68cdf0e10cSrcweir 	{
69cdf0e10cSrcweir 		start,      		///	before class, struct or union
70cdf0e10cSrcweir 		expectName,    		/// after class, struct or union
71cdf0e10cSrcweir 		gotName,       		/// after name, before : or {
72cdf0e10cSrcweir 		bodyStd,			/// after {
73cdf0e10cSrcweir 		inProtection,       /// after public, protected or private and before ":"
74cdf0e10cSrcweir 		afterDecl,          /// after ending }
75cdf0e10cSrcweir 		size_of_states
76cdf0e10cSrcweir 	};
77cdf0e10cSrcweir 
78cdf0e10cSrcweir 	enum E_KindOfResult
79cdf0e10cSrcweir 	{
80cdf0e10cSrcweir 		is_declaration,         	// normal
81cdf0e10cSrcweir 		is_implicit_declaration,    // like in: class Abc { public int n; } aAbc;
82cdf0e10cSrcweir 		is_predeclaration,      	// like: 	class Abc;
83cdf0e10cSrcweir 		is_qualified_typename   	// like in: class Abc * fx();
84cdf0e10cSrcweir 
85cdf0e10cSrcweir 	};
86cdf0e10cSrcweir 
87cdf0e10cSrcweir 						PE_Class(
88cdf0e10cSrcweir 							Cpp_PE *			i_pParent );
89cdf0e10cSrcweir 						~PE_Class();
90cdf0e10cSrcweir 
91cdf0e10cSrcweir 	virtual void		Call_Handler(
92cdf0e10cSrcweir 							const cpp::Token &	i_rTok );
93cdf0e10cSrcweir     virtual Cpp_PE *    Handle_ChildFailure();
94cdf0e10cSrcweir 
95cdf0e10cSrcweir 	E_KindOfResult		Result_KindOf() const;
96cdf0e10cSrcweir 	const String  &		Result_LocalName() const;
97cdf0e10cSrcweir 	const String  &		Result_FirstNameSegment() const;
98cdf0e10cSrcweir 
99cdf0e10cSrcweir   private:
100cdf0e10cSrcweir 	typedef SubPe< PE_Class, PE_Base >		 	SP_Base;
101cdf0e10cSrcweir //	typedef SubPe< PE_Class, PE_Enum>		    SP_Enum;
102cdf0e10cSrcweir 	typedef SubPe< PE_Class, PE_Typedef>		SP_Typedef;
103cdf0e10cSrcweir 	typedef SubPe< PE_Class, PE_VarFunc>	    SP_VarFunc;
104cdf0e10cSrcweir 	typedef SubPe< PE_Class, PE_Ignore >		SP_Ignore;
105cdf0e10cSrcweir 	typedef SubPe< PE_Class, PE_Defines>	    SP_Defines;
106cdf0e10cSrcweir 
107cdf0e10cSrcweir 	typedef SubPeUse< PE_Class, PE_Base> 		SPU_Base;
108cdf0e10cSrcweir //	typedef SubPeUse< PE_Class, PE_Enum>			SPU_Enum;
109cdf0e10cSrcweir 	typedef SubPeUse< PE_Class, PE_Typedef>		SPU_Typedef;
110cdf0e10cSrcweir 	typedef SubPeUse< PE_Class, PE_VarFunc> 	SPU_VarFunc;
111cdf0e10cSrcweir 	typedef SubPeUse< PE_Class, PE_Ignore> 		SPU_Ignore;
112cdf0e10cSrcweir 	typedef SubPeUse< PE_Class, PE_Defines>	    SPU_Defines;
113cdf0e10cSrcweir 
114cdf0e10cSrcweir 	typedef ary::cpp::List_Bases                BaseList;
115cdf0e10cSrcweir 	typedef ary::cpp::S_Classes_Base            Base;
116cdf0e10cSrcweir 	typedef ary::cpp::E_Protection              E_Protection;
117cdf0e10cSrcweir 
118cdf0e10cSrcweir 	void				Setup_StatusFunctions();
119cdf0e10cSrcweir 	virtual void		InitData();
120cdf0e10cSrcweir 	virtual void		TransferData();
121cdf0e10cSrcweir 	void  				Hdl_SyntaxError( const char *);
122cdf0e10cSrcweir 	void				Init_CurObject();
123cdf0e10cSrcweir 
124cdf0e10cSrcweir 	void				SpReturn_Base();
125cdf0e10cSrcweir 
126cdf0e10cSrcweir 	void				On_start_class( const char * );
127cdf0e10cSrcweir 	void				On_start_struct( const char * );
128cdf0e10cSrcweir 	void				On_start_union( const char * );
129cdf0e10cSrcweir 
130cdf0e10cSrcweir 	void				On_expectName_Identifier( const char * );
131cdf0e10cSrcweir 	void				On_expectName_SwBracket_Left( const char * );
132cdf0e10cSrcweir 	void				On_expectName_Colon( const char * );
133cdf0e10cSrcweir 
134cdf0e10cSrcweir 	void				On_gotName_SwBracket_Left( const char * );
135cdf0e10cSrcweir 	void				On_gotName_Semicolon( const char * );
136cdf0e10cSrcweir 	void				On_gotName_Colon( const char * );
137cdf0e10cSrcweir 	void                On_gotName_Return2Type( const char * );
138cdf0e10cSrcweir 
139cdf0e10cSrcweir 	void				On_bodyStd_VarFunc( const char * );
140cdf0e10cSrcweir 	void				On_bodyStd_ClassKey( const char * );
141cdf0e10cSrcweir 	void				On_bodyStd_enum( const char * );
142cdf0e10cSrcweir 	void				On_bodyStd_typedef( const char * );
143cdf0e10cSrcweir 	void				On_bodyStd_public( const char * );
144cdf0e10cSrcweir 	void				On_bodyStd_protected( const char * );
145cdf0e10cSrcweir 	void				On_bodyStd_private( const char * );
146cdf0e10cSrcweir 	void				On_bodyStd_template( const char * );
147cdf0e10cSrcweir 	void				On_bodyStd_friend( const char * );
148cdf0e10cSrcweir 	void				On_bodyStd_using( const char * );
149cdf0e10cSrcweir 	void				On_bodyStd_SwBracket_Right( const char * );
150cdf0e10cSrcweir 	void  				On_bodyStd_DefineName(const char * );
151cdf0e10cSrcweir 	void  				On_bodyStd_MacroName(const char * );
152cdf0e10cSrcweir 
153cdf0e10cSrcweir 	void				On_inProtection_Colon( const char * );
154cdf0e10cSrcweir 
155cdf0e10cSrcweir 	void				On_afterDecl_Semicolon( const char * );
156cdf0e10cSrcweir 	void                On_afterDecl_Return2Type( const char * );
157cdf0e10cSrcweir 
158cdf0e10cSrcweir 	// DATA
159cdf0e10cSrcweir 	Dyn< PeStatusArray<PE_Class> >
160cdf0e10cSrcweir 						pStati;
161cdf0e10cSrcweir 
162cdf0e10cSrcweir 	Dyn<SP_Base>	    pSpBase;
163cdf0e10cSrcweir //	Dyn<SP_Enum>   		pSpEnum;
164cdf0e10cSrcweir 	Dyn<SP_Typedef>		pSpTypedef;
165cdf0e10cSrcweir 	Dyn<SP_VarFunc>	    pSpVarFunc;
166cdf0e10cSrcweir 	Dyn<SP_Ignore>		pSpIgnore;
167cdf0e10cSrcweir 	Dyn<SP_Defines>	    pSpDefs;
168cdf0e10cSrcweir 
169cdf0e10cSrcweir 	Dyn<SPU_Base>	 	pSpuBase;
170cdf0e10cSrcweir //	Dyn<SPU_Enum>		pSpuEnum;
171cdf0e10cSrcweir 	Dyn<SPU_Typedef> 	pSpuTypedef;
172cdf0e10cSrcweir 	Dyn<SPU_VarFunc>	pSpuVarFunc;
173cdf0e10cSrcweir 
174cdf0e10cSrcweir 	Dyn<SPU_Ignore>		pSpuTemplate;
175cdf0e10cSrcweir 	Dyn<SPU_Ignore>		pSpuUsing;
176cdf0e10cSrcweir 	Dyn<SPU_Ignore>		pSpuIgnoreFailure;
177cdf0e10cSrcweir 	Dyn<SPU_Defines>	pSpuDefs;
178cdf0e10cSrcweir 
179cdf0e10cSrcweir 
180cdf0e10cSrcweir 
181cdf0e10cSrcweir 	String              sLocalName;
182cdf0e10cSrcweir 	ary::cpp::E_ClassKey
183cdf0e10cSrcweir 						eClassKey;
184cdf0e10cSrcweir 	ary::cpp::Class *	pCurObject;
185cdf0e10cSrcweir 	BaseList            aBases;
186cdf0e10cSrcweir 
187cdf0e10cSrcweir 	E_KindOfResult		eResult_KindOf;
188cdf0e10cSrcweir };
189cdf0e10cSrcweir 
190cdf0e10cSrcweir 
191cdf0e10cSrcweir 
192cdf0e10cSrcweir // IMPLEMENTATION
193cdf0e10cSrcweir 
194cdf0e10cSrcweir inline PE_Class::E_KindOfResult
Result_KindOf() const195cdf0e10cSrcweir PE_Class::Result_KindOf() const
196cdf0e10cSrcweir {
197cdf0e10cSrcweir 	return eResult_KindOf;
198cdf0e10cSrcweir }
199cdf0e10cSrcweir 
200cdf0e10cSrcweir inline const String  &
Result_LocalName() const201cdf0e10cSrcweir PE_Class::Result_LocalName() const
202cdf0e10cSrcweir {
203cdf0e10cSrcweir 	return sLocalName;
204cdf0e10cSrcweir }
205cdf0e10cSrcweir 
206cdf0e10cSrcweir inline const String  &
Result_FirstNameSegment() const207cdf0e10cSrcweir PE_Class::Result_FirstNameSegment() const
208cdf0e10cSrcweir {
209cdf0e10cSrcweir 	return sLocalName;
210cdf0e10cSrcweir }
211cdf0e10cSrcweir 
212cdf0e10cSrcweir 
213cdf0e10cSrcweir 
214cdf0e10cSrcweir 
215cdf0e10cSrcweir }   // namespace cpp
216cdf0e10cSrcweir 
217cdf0e10cSrcweir 
218cdf0e10cSrcweir #if 0	// Branches
219cdf0e10cSrcweir 
220cdf0e10cSrcweir class struct union
221cdf0e10cSrcweir 	-> Class
222cdf0e10cSrcweir 	-> Predeclaration
223cdf0e10cSrcweir 
224cdf0e10cSrcweir typedef
225cdf0e10cSrcweir 	-> Typedef
226cdf0e10cSrcweir 
227cdf0e10cSrcweir enum
228cdf0e10cSrcweir 	-> Enum
229cdf0e10cSrcweir 
230cdf0e10cSrcweir TypeDeclaration
231cdf0e10cSrcweir 	-> Function In Class
232cdf0e10cSrcweir 	-> Variable
233cdf0e10cSrcweir 
234cdf0e10cSrcweir public, protected, private
235cdf0e10cSrcweir 	-> Protection declaration
236cdf0e10cSrcweir 
237cdf0e10cSrcweir friend
238cdf0e10cSrcweir 	->	Friend Class
239cdf0e10cSrcweir 	->  Friend Function
240cdf0e10cSrcweir 
241cdf0e10cSrcweir virtual
242cdf0e10cSrcweir 	-> Function In Class
243cdf0e10cSrcweir 
244cdf0e10cSrcweir using
245cdf0e10cSrcweir 	-> Using Declaration
246cdf0e10cSrcweir 
247cdf0e10cSrcweir 
248cdf0e10cSrcweir #endif // 0
249cdf0e10cSrcweir 
250cdf0e10cSrcweir 
251cdf0e10cSrcweir #endif
252cdf0e10cSrcweir 
253