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