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_FILE_HXX
25 #define ADC_CPP_PE_FILE_HXX
26 
27 
28 
29 // USED SERVICES
30 	// BASE CLASSES
31 #include "cpp_pe.hxx"
32 	// COMPONENTS
33 #include <semantic/callf.hxx>
34 #include <semantic/sub_peu.hxx>
35 	// PARAMETERS
36 
37 
38 namespace cpp {
39 
40 	class PeEnvironment;
41 
42 	class PE_Namespace;
43 	class PE_Enum;
44 	class PE_Typedef;
45 	class PE_VarFunc;
46     class PE_TemplateTop;
47     class PE_Defines;
48 	class PE_Ignore;
49 
50 #if 0
51 class PE_Template;
52 class PE_Extern;
53 #endif
54 
55 
56 class PE_File : public Cpp_PE
57 {
58   public:
59 	enum E_State
60 	{
61 		std,      		///	before class, struct or union
62         in_extern,
63         in_externC,
64 		size_of_states
65 	};
66 
67 						PE_File(
68 							PeEnvironment &     io_rEnv );
69 						~PE_File();
70 
71 	virtual void		Call_Handler(
72 							const cpp::Token &	i_rTok );
73     virtual Cpp_PE *    Handle_ChildFailure();
74 
75   private:
76 	typedef SubPe< PE_File, PE_Namespace>	SP_Namespace;
77 	typedef SubPe< PE_File, PE_Typedef>		SP_Typedef;
78 	typedef SubPe< PE_File, PE_VarFunc>	    SP_VarFunc;
79 	typedef SubPe< PE_File, PE_TemplateTop>	SP_Template;
80 	typedef SubPe< PE_File, PE_Defines>	    SP_Defines;
81 	typedef SubPe< PE_File, PE_Ignore >		SP_Ignore;
82 #if 0
83 	typedef SubPe< PE_File, PE_Using>		SP_Using;
84 #endif // 0
85 
86 	typedef SubPeUse< PE_File, PE_Namespace>    SPU_Namespace;
87 	typedef SubPeUse< PE_File, PE_Typedef>		SPU_Typedef;
88 	typedef SubPeUse< PE_File, PE_VarFunc> 		SPU_VarFunc;
89 	typedef SubPeUse< PE_File, PE_TemplateTop>	SPU_Template;
90 	typedef SubPeUse< PE_File, PE_Defines>	    SPU_Defines;
91 	typedef SubPeUse< PE_File, PE_Ignore> 		SPU_Ignore;
92 
93 	void				Setup_StatusFunctions();
94 	virtual void		InitData();
95 	virtual void		TransferData();
96 	void  				Hdl_SyntaxError( const char *);
97 
98 	void				SpReturn_VarFunc();
99 	void				SpReturn_Template();
100 
101 	void  				On_std_namespace(const char * i_sText);
102 	void  				On_std_ClassKey(const char * i_sText);
103 	void  				On_std_typedef(const char * i_sText);
104 	void  				On_std_enum(const char * i_sText);
105 	void  				On_std_VarFunc(const char * i_sText);
106 	void  				On_std_template(const char * i_sText);
107 	void				On_std_extern(const char * i_sText);
108 	void  				On_std_using(const char * i_sText);
109 	void  				On_std_SwBracketRight(const char * i_sText);
110 
111 	void  				On_std_DefineName(const char * i_sText);
112 	void  				On_std_MacroName(const char * i_sText);
113 
114     void                On_in_extern_Constant(const char * i_sText);
115     void                On_in_extern_Ignore(const char * i_sText);
116     void                On_in_externC_SwBracket_Left(const char * i_sText);
117     void                On_in_externC_NoBlock(const char * i_sText);
118 
access_Env()119 	PeEnvironment &     access_Env()            { return *pEnv; }
120 
121 
122 	// DATA
123 	PeEnvironment *		pEnv;
124 
125 	Dyn< PeStatusArray<PE_File> >
126 						pStati;
127 
128 	Dyn<SP_Namespace>	pSpNamespace;
129 	Dyn<SP_Typedef>		pSpTypedef;
130 	Dyn<SP_VarFunc>	    pSpVarFunc;
131 	Dyn<SP_Template>	pSpTemplate;
132 	Dyn<SP_Defines>	    pSpDefs;
133 
134 	Dyn<SP_Ignore>		pSpIgnore;
135 #if 0
136 	SP_Using			aSpUsing;
137 #endif // 0
138 
139 	Dyn<SPU_Namespace>	pSpuNamespace;
140 	Dyn<SPU_Typedef> 	pSpuTypedef;
141 	Dyn<SPU_VarFunc>	pSpuVarFunc;
142 	Dyn<SPU_Template>	pSpuTemplate;
143 	Dyn<SPU_Defines>	pSpuDefs;
144 
145 	Dyn<SPU_Ignore>		pSpuUsing;
146 	Dyn<SPU_Ignore>		pSpuIgnoreFailure;
147 
148     bool                bWithinSingleExternC;   /** After 'extern "C"' without following '{',
149                                                     waiting for the next function or variable to
150                                                     set back to false.
151                                                 */
152 };
153 
154 }   // namespace cpp
155 
156 
157 
158 #if 0	// Branches
159 
160 namespace
161 	-> Named Namespace declaration
162 	-> Unnamed Namespace declaration
163 	-> Namespace alias definition
164 
165 class struct union
166 	-> Class
167 	-> Predeclaration
168 
169 typedef
170 	-> Typedef
171 
172 enum
173 	-> Enum
174 
175 extern
176 	-> Extern-"C"
177 	-> TypeDeclaration
178 
179 TypeDeclaration
180 	-> FunctionDecl
181 	-> FunctionDef
182 	-> Variable
183 
184 template
185 	-> TemplateClass
186 	-> TemplateFunction
187 	-> TemplateFunction/Method-Implementation
188 	-> TemplatePredeclaration
189 
190 }
191 	-> End of Namespace
192 	-> End of Extern-"C"
193 
194 asm
195 	-> AssemblerDeclaration
196 
197 using
198 	-> Using-Declaration
199     -> Using-Directive
200 
201 #endif // 0
202 
203 
204 #endif
205 
206