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 "cx_c_std.hxx"
24 
25 
26 // NOT FULLY DECLARED SERVICES
27 #include "all_toks.hxx"
28 #include "cx_c_pp.hxx"
29 #include "cx_c_sub.hxx"
30 #include <tools/tkpchars.hxx>
31 #include <tokens/tkpstama.hxx>
32 #include <x_parse.hxx>
33 #include "c_dealer.hxx"
34 
35 
36 namespace cpp {
37 
38 
39 const intt C_nCppInitialNrOfStati = 600;
40 const intt C_nStatusSize = 128;
41 
42 
43 
44 const uintt nF_fin_Error = 1;
45 const uintt nF_fin_CreateWithoutText = 2;
46 const uintt nF_fin_CreateWithText = 3;
47 const uintt nF_fin_Ignore = 4;
48 const uintt nF_fin_EOL = 5;
49 const uintt nF_fin_EOF = 6;
50 const uintt nF_fin_Bezeichner = 7;
51 
52 const uintt nF_goto_Preprocessor = 10;
53 const uintt nF_goto_Comment = 11;
54 const uintt nF_goto_Docu = 12;
55 const uintt nF_goto_Const = 13;
56 const uintt nF_goto_UnblockMacro = 14;
57 
58 // Token create functions for the state machine:
TCF_Identifier(const char * text)59 DYN TextToken * TCF_Identifier(const char * text) { return new Tok_Identifier(text); }
60 
TCF_operator(const char *)61 DYN TextToken * TCF_operator(const char *) { return new Tok_operator; }
TCF_class(const char *)62 DYN TextToken * TCF_class(const char *) { return new Tok_class; }
TCF_struct(const char *)63 DYN TextToken * TCF_struct(const char *) { return new Tok_struct; }
TCF_union(const char *)64 DYN TextToken * TCF_union(const char *) { return new Tok_union; }
TCF_enum(const char *)65 DYN TextToken * TCF_enum(const char *) { return new Tok_enum; }
TCF_typedef(const char *)66 DYN TextToken * TCF_typedef(const char *) { return new Tok_typedef; }
TCF_public(const char *)67 DYN TextToken * TCF_public(const char *) { return new Tok_public; }
TCF_protected(const char *)68 DYN TextToken * TCF_protected(const char *) { return new Tok_protected; }
TCF_private(const char *)69 DYN TextToken * TCF_private(const char *) { return new Tok_private; }
TCF_template(const char *)70 DYN TextToken * TCF_template(const char *) { return new Tok_template; }
TCF_virtual(const char *)71 DYN TextToken * TCF_virtual(const char *) { return new Tok_virtual; }
TCF_friend(const char *)72 DYN TextToken * TCF_friend(const char *) { return new Tok_friend; }
TCF_Tilde(const char *)73 DYN TextToken * TCF_Tilde(const char *) { return new Tok_Tilde; }
TCF_const(const char *)74 DYN TextToken * TCF_const(const char *) { return new Tok_const; }
TCF_volatile(const char *)75 DYN TextToken * TCF_volatile(const char *) { return new Tok_volatile; }
TCF_extern(const char *)76 DYN TextToken * TCF_extern(const char *) { return new Tok_extern; }
TCF_static(const char *)77 DYN TextToken * TCF_static(const char *) { return new Tok_static; }
TCF_mutable(const char *)78 DYN TextToken * TCF_mutable(const char *) { return new Tok_mutable; }
TCF_register(const char *)79 DYN TextToken * TCF_register(const char *) { return new Tok_register; }
TCF_inline(const char *)80 DYN TextToken * TCF_inline(const char *) { return new Tok_inline; }
TCF_explicit(const char *)81 DYN TextToken * TCF_explicit(const char *) { return new Tok_explicit; }
TCF_namespace(const char *)82 DYN TextToken * TCF_namespace(const char *) { return new Tok_namespace; }
TCF_using(const char *)83 DYN TextToken * TCF_using(const char *) { return new Tok_using; }
TCF_throw(const char *)84 DYN TextToken * TCF_throw(const char *) { return new Tok_throw; }
TCF_SwBracketOpen(const char *)85 DYN TextToken * TCF_SwBracketOpen(const char *) { return new Tok_SwBracket_Left; }
TCF_SwBracketClose(const char *)86 DYN TextToken * TCF_SwBracketClose(const char *) { return new Tok_SwBracket_Right; }
TCF_ArBracketOpen(const char *)87 DYN TextToken * TCF_ArBracketOpen(const char *) { return new Tok_ArrayBracket_Left; }
TCF_ArBracketClose(const char *)88 DYN TextToken * TCF_ArBracketClose(const char *) { return new Tok_ArrayBracket_Right; }
TCF_BracketOpen(const char *)89 DYN TextToken * TCF_BracketOpen(const char *) { return new Tok_Bracket_Left; }
TCF_BracketClose(const char *)90 DYN TextToken * TCF_BracketClose(const char *) { return new Tok_Bracket_Right; }
TCF_DblColon(const char *)91 DYN TextToken * TCF_DblColon(const char *) { return new Tok_DoubleColon; }
TCF_Semikolon(const char *)92 DYN TextToken * TCF_Semikolon(const char *) { return new Tok_Semicolon; }
TCF_Komma(const char *)93 DYN TextToken * TCF_Komma(const char *) { return new Tok_Comma; }
TCF_Colon(const char *)94 DYN TextToken * TCF_Colon(const char *) { return new Tok_Colon; }
TCF_Zuweisung(const char *)95 DYN TextToken * TCF_Zuweisung(const char *) { return new Tok_Assign; }
TCF_Smaller(const char *)96 DYN TextToken * TCF_Smaller(const char *) { return new Tok_Less; }
TCF_Bigger(const char *)97 DYN TextToken * TCF_Bigger(const char *) { return new Tok_Greater; }
TCF_Stern(const char *)98 DYN TextToken * TCF_Stern(const char *) { return new Tok_Asterix; }
TCF_Ampersand(const char *)99 DYN TextToken * TCF_Ampersand(const char *) { return new Tok_AmpersAnd; }
TCF_Ellipse(const char *)100 DYN TextToken * TCF_Ellipse(const char *) { return new Tok_Ellipse; }
TCF_typename(const char *)101 DYN TextToken * TCF_typename(const char *) { return new Tok_typename; }
102 
103 	// Operators
TCF_Operator(const char * text)104 DYN TextToken * TCF_Operator(const char * text) { return new Tok_Operator(text); }
105 
TCF_BuiltInType(const char * text)106 DYN TextToken * TCF_BuiltInType(const char * text) { return new Tok_BuiltInType(text); }
TCF_TypeModifier(const char * text)107 DYN TextToken * TCF_TypeModifier(const char * text) { return new Tok_TypeSpecializer(text); }
108 
TCF_Eof(const char *)109 DYN TextToken * TCF_Eof(const char *) { return new Tok_Eof; }
110 
111 
112 
Context_CppStd(DYN autodoc::TkpDocuContext & let_drContext_Docu)113 Context_CppStd::Context_CppStd( DYN autodoc::TkpDocuContext & let_drContext_Docu )
114 	:   Cx_Base(0),
115         aStateMachine(C_nStatusSize,C_nCppInitialNrOfStati),
116 		pDocuContext(&let_drContext_Docu),
117 		pContext_Comment(0),
118 		pContext_Preprocessor(0),
119 		pContext_ConstString(0),
120 		pContext_ConstChar(0),
121 		pContext_ConstNumeric(0),
122 		pContext_UnblockMacro(0)
123 {
124 	pDocuContext->SetParentContext(*this,"*/");
125 
126     pContext_Comment = new Context_Comment(*this);
127 	pContext_Preprocessor = new Context_Preprocessor(*this);
128 	pContext_ConstString = new Context_ConstString(*this);
129 	pContext_ConstChar = new Context_ConstChar(*this);
130 	pContext_ConstNumeric = new Context_ConstNumeric(*this);
131 	pContext_UnblockMacro = new Context_UnblockMacro(*this);
132 
133 	SetupStateMachine();
134 }
135 
~Context_CppStd()136 Context_CppStd::~Context_CppStd()
137 {
138 }
139 
140 void
ReadCharChain(CharacterSource & io_rText)141 Context_CppStd::ReadCharChain( CharacterSource & io_rText )
142 {
143 	SetNewToken(0);
144 
145 	TextToken::F_CRTOK fTokenCreateFunction = 0;
146 	StmBoundsStatus & rBound = aStateMachine.GetCharChain(fTokenCreateFunction, io_rText);
147 
148 	// !!!
149 	// 	 The order of the next two lines is essential, because
150 	//   pFollowUpContext may be changed by PerformStatusFunction() also,
151 	//   which then MUST override the previous assignment.
152 	SetFollowUpContext(rBound.FollowUpContext());
153 	PerformStatusFunction(rBound.StatusFunctionNr(), fTokenCreateFunction, io_rText);
154 }
155 
156 void
AssignDealer(Distributor & o_rDealer)157 Context_CppStd::AssignDealer( Distributor & o_rDealer )
158 {
159     Cx_Base::AssignDealer(o_rDealer);
160 
161     pDocuContext->AssignDealer(o_rDealer);
162     pContext_Comment->AssignDealer(o_rDealer);
163     pContext_Preprocessor->AssignDealer(o_rDealer);
164     pContext_ConstString->AssignDealer(o_rDealer);
165     pContext_ConstChar->AssignDealer(o_rDealer);
166     pContext_ConstNumeric->AssignDealer(o_rDealer);
167     pContext_UnblockMacro->AssignDealer(o_rDealer);
168 }
169 
170 void
PerformStatusFunction(uintt i_nStatusSignal,F_CRTOK i_fTokenCreateFunction,CharacterSource & io_rText)171 Context_CppStd::PerformStatusFunction( uintt					i_nStatusSignal,
172 									   F_CRTOK 	                i_fTokenCreateFunction,
173 									   CharacterSource &	    io_rText )
174 {
175 	switch (i_nStatusSignal)
176 	{
177 		case nF_fin_CreateWithoutText:
178 			io_rText.CutToken();
179 			csv_assert(i_fTokenCreateFunction != 0);
180 			SetNewToken( (*i_fTokenCreateFunction)(0) );
181 			break;
182 		case nF_fin_CreateWithText:
183 			csv_assert(i_fTokenCreateFunction != 0);
184 			SetNewToken( (*i_fTokenCreateFunction)(io_rText.CutToken()) );
185 			break;
186 		case nF_fin_Ignore:
187 			io_rText.CutToken();
188 			SetNewToken(0);
189 			break;
190 		case nF_fin_EOL:
191 			io_rText.CutToken();
192 			SetNewToken(0);
193 			Dealer().Deal_Eol();
194 			break;
195 		case nF_fin_EOF:
196 			io_rText.CutToken();
197 			SetNewToken( TCF_Eof(0) );
198 			break;
199 		case nF_fin_Bezeichner:
200 			SetNewToken( TCF_Identifier(io_rText.CutToken()) );
201 			break;
202 
203 		case nF_goto_Preprocessor:
204 			io_rText.CutToken();
205 			SetNewToken(0);
206 			break;
207 		case nF_goto_Comment:
208 			SetNewToken(0);
209 			pContext_Comment->SetMode_IsMultiLine( io_rText.CutToken()[1] == '*' );
210 			break;
211 		case nF_goto_Docu:
212 			SetNewToken(0);
213 			pDocuContext->SetMode_IsMultiLine( io_rText.CutToken()[1] == '*' );
214 			break;
215 		case nF_goto_Const:
216 			SetNewToken(0);
217 			break;
218         case nF_goto_UnblockMacro:
219 			SetNewToken(0);
220 			break;
221 
222 		case nF_fin_Error:
223 		default:
224         {
225             char cCC = io_rText.CurChar();
226             String  sCurChar( &cCC, 1 );
227 			throw X_Parser( X_Parser::x_InvalidChar, sCurChar, String::Null_(), 0 );
228         }
229 	}	// end switch (i_nStatusSignal)
230 }
231 
232 void
SetupStateMachine()233 Context_CppStd::SetupStateMachine()
234 {
235 	// Besondere Array-Stati (kein Tokenabschluss oder Kontextwechsel):
236 //	const INT16	top = 0;		// Top-Status
237 	const INT16	wht = 1;		// Whitespace-�berlese-Status
238 	const INT16	bez = 2;        // Bezeichner-lese-Status
239 
240 	// Tokenfinish-Stati:
241 	const INT16	finError = 3;
242 	const INT16 finIgnore = 4;
243 	const INT16 finBezeichner = 5;
244 	const INT16 finKeyword = 6;
245 	const INT16 finPunctuation = 7;
246 	const INT16 finBiType = 8;
247 	const INT16 finTypeModifier = 9;
248 	const INT16 finEOL = 10;
249 	const INT16 finEOF = 11;
250 
251 	// Kontextwechsel-Stati:
252 	const INT16	gotoComment = 12;
253 	const INT16	gotoDocu = 13;
254 	const INT16 gotoPreprocessor = 14;
255 	const INT16	gotoConstString = 15;
256 	const INT16	gotoConstChar = 16;
257 	const INT16	gotoConstNumeric = 17;
258 	const INT16 gotoUnblockMacro = 18;
259 
260 	// Abbreviations to be used in status tables:
261 	const INT16 err = finError;
262 	const INT16 fig = finIgnore;
263 	const INT16 fbz = finBezeichner;
264 	const INT16 fof = finEOF;
265 	const INT16 cst = gotoConstString;
266 	const INT16 cch = gotoConstChar;
267 	const INT16 cnr = gotoConstNumeric;
268 
269 
270 	/// Zeros - '0' - will be replaced by AddToken().
271 
272 	const INT16 A_nTopStatus[C_nStatusSize] =
273 	//  0	1	2	3	4	5	6	7	8	9  10  11  12  13  14  15
274 	{fof,err,err,err,err,err,err,err,err,wht,  0,wht,wht,  0,err,err,
275 	 err,err,err,err,err,err,err,err,err,err,fof,err,err,err,err,err, // 16 ...
276 	 wht,  0,cst,  0,err,  0,  0,cch,  0,  0,  0,  0,  0,  0,  0,  0,
277 	 cnr,cnr,cnr,cnr,cnr,cnr,cnr,cnr,cnr,cnr,  0,  0,  0,  0,  0,  0, // 48 ...
278 	   0,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,
279 	 bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,  0,  0,  0,  0,bez, // 80 ...
280 	   0,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,
281 	 bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,  0,  0,  0,  0,err, // 80 ...
282 	};
283 
284 	const INT16 A_nWhitespaceStatus[C_nStatusSize] =
285 	// 	0	1	2	3	4	5	6	7	8	9  10  11  12  13  14  15
286 	{fof,err,err,err,err,err,err,err,err,wht,fig,wht,wht,fig,err,err,
287 	 err,err,err,err,err,err,err,err,err,err,fof,err,err,err,err,err, // 16 ...
288 	 wht,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,
289 	 fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig, // 48 ...
290 	 fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,
291 	 fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig, // 80 ...
292 	 fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,
293 	 fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,fig,err
294 	};
295 
296 	const INT16 A_nBezeichnerStatus[C_nStatusSize] =
297 	// 	0	1	2	3	4	5	6	7	8	9  10  11  12  13  14  15
298 	{fbz,err,err,err,err,err,err,err,err,fbz,fbz,fbz,fbz,fbz,err,err,
299 	 err,err,err,err,err,err,err,err,err,err,fbz,err,err,err,err,err, // 16 ...
300 	 fbz,fbz,fbz,fbz,fbz,fbz,fbz,fbz,fbz,fbz,fbz,fbz,fbz,fbz,fbz,fbz,
301 	 bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,fbz,fbz,fbz,fbz,fbz,fbz, // 48 ...
302 	 fbz,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,
303 	 bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,fbz,fbz,fbz,fbz,bez, // 80 ...
304 	 fbz,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,
305 	 bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,fbz,fbz,fbz,fbz,err
306 	};
307 
308 
309 	const INT16 A_nOperatorDefStatus[C_nStatusSize] =
310 	// 	0	1	2	3	4	5	6	7	8	9  10  11  12  13  14  15
311 	{err,err,err,err,err,err,err,err,err,err,err,err,err,err,err,err,
312 	 err,err,err,err,err,err,err,err,err,err,err,err,err,err,err,err, // 16 ...
313 	 err,err,err,err,err,err,err,err,err,err,err,err,err,err,err,err,
314 	 err,err,err,err,err,err,err,err,err,err,err,err,err,err,err,err, // 48 ...
315 	 err,err,err,err,err,err,err,err,err,err,err,err,err,err,err,err,
316 	 err,err,err,err,err,err,err,err,err,err,err,err,err,err,err,err, // 80 ...
317 	 err,err,err,err,err,err,err,err,err,err,err,err,err,err,err,err,
318 	 err,err,err,err,err,err,err,err,err,err,err,err,err,err,err,err
319 	};
320 
321 	const INT16 A_nBezDefStatus[C_nStatusSize] =
322 	// 	0	1	2	3	4	5	6	7	8	9  10  11  12  13  14  15
323 	{fbz,err,err,err,err,err,err,err,err,fbz,fbz,fbz,fbz,fbz,err,err,
324 	 err,err,err,err,err,err,err,err,err,err,fbz,err,err,err,err,err, // 16 ...
325 	 fbz,fbz,fbz,fbz,fbz,fbz,fbz,fbz,fbz,fbz,fbz,fbz,fbz,fbz,fbz,fbz,
326 	 bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,fbz,fbz,fbz,fbz,fbz,fbz, // 48 ...
327 	 fbz,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,
328 	 bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,fbz,fbz,fbz,fbz,bez, // 80 ...
329 	 fbz,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,
330 	 bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,bez,fbz,fbz,fbz,fbz,err
331 	};
332 
333 	DYN StmArrayStatus * dpStatusTop
334 			= new StmArrayStatus( C_nStatusSize, A_nTopStatus, 0, true);
335 	DYN StmArrayStatus * dpStatusWhite
336 			= new StmArrayStatus( C_nStatusSize, A_nWhitespaceStatus, 0, true);
337 	DYN StmArrayStatus * dpStatusBez
338 			= new StmArrayStatus( C_nStatusSize, A_nBezeichnerStatus, TCF_Identifier, true);
339 
340 	DYN StmBoundsStatus *  	dpBst_finError
341 			= new StmBoundsStatus( *this, TkpContext::Null_(), nF_fin_Error, true );
342 	DYN StmBoundsStatus *  	dpBst_finIgnore
343 			= new StmBoundsStatus( *this, *this, nF_fin_Ignore, true );
344 	DYN StmBoundsStatus *  	dpBst_finBezeichner
345 			= new StmBoundsStatus( *this, *this, nF_fin_Bezeichner, true );
346 	DYN StmBoundsStatus *  	dpBst_finKeyword
347 			= new StmBoundsStatus( *this, *this, nF_fin_CreateWithoutText, false );
348 	DYN StmBoundsStatus *  	dpBst_finPunctuation
349 			= new StmBoundsStatus( *this, *this, nF_fin_CreateWithText, false );
350 	DYN StmBoundsStatus *  	dpBst_finBiType
351 			= new StmBoundsStatus( *this, *this, nF_fin_CreateWithText, false );
352 	DYN StmBoundsStatus *  	dpBst_finTypeModifier
353 			= new StmBoundsStatus( *this, *this, nF_fin_CreateWithText, false );
354 	DYN StmBoundsStatus *  	dpBst_finEOL
355 			= new StmBoundsStatus( *this, *this, nF_fin_EOL, false );
356 	DYN StmBoundsStatus *  	dpBst_finEOF
357 			= new StmBoundsStatus( *this, TkpContext::Null_(), nF_fin_EOF, false );
358 
359 	DYN StmBoundsStatus *  	dpBst_gotoComment
360 			= new StmBoundsStatus( *this, *pContext_Comment, nF_goto_Comment, false );
361 	DYN StmBoundsStatus *  	dpBst_gotoDocu
362 			= new StmBoundsStatus( *this, *pDocuContext, nF_goto_Docu, false );
363 	DYN StmBoundsStatus *  	dpBst_gotoPreprocessor
364 			= new StmBoundsStatus( *this, *pContext_Preprocessor, nF_goto_Preprocessor, false );
365 	DYN StmBoundsStatus *  	dpBst_gotoConstString
366 			= new StmBoundsStatus( *this, *pContext_ConstString, nF_goto_Const, false );
367 	DYN StmBoundsStatus *  	dpBst_gotoConstChar
368 			= new StmBoundsStatus( *this, *pContext_ConstChar, nF_goto_Const, false );
369 	DYN StmBoundsStatus *  	dpBst_gotoConstNumeric
370 			= new StmBoundsStatus( *this, *pContext_ConstNumeric, nF_goto_Const, false );
371 	DYN StmBoundsStatus *  	dpBst_gotoUnblockMacro
372 			= new StmBoundsStatus( *this, *pContext_UnblockMacro, nF_goto_UnblockMacro, false );
373 
374 	// dpMain aufbauen:
375 	aStateMachine.AddStatus(dpStatusTop);
376 
377 	aStateMachine.AddStatus(dpStatusWhite);
378 	aStateMachine.AddStatus(dpStatusBez);
379 
380 	aStateMachine.AddStatus(dpBst_finError);
381 	aStateMachine.AddStatus(dpBst_finIgnore);
382 	aStateMachine.AddStatus(dpBst_finBezeichner);
383 	aStateMachine.AddStatus(dpBst_finKeyword);
384 	aStateMachine.AddStatus(dpBst_finPunctuation);
385 	aStateMachine.AddStatus(dpBst_finBiType);
386 	aStateMachine.AddStatus(dpBst_finTypeModifier);
387 	aStateMachine.AddStatus(dpBst_finEOL);
388 	aStateMachine.AddStatus(dpBst_finEOF);
389 
390 	aStateMachine.AddStatus(dpBst_gotoComment);
391 	aStateMachine.AddStatus(dpBst_gotoDocu);
392 	aStateMachine.AddStatus(dpBst_gotoPreprocessor);
393 	aStateMachine.AddStatus(dpBst_gotoConstString);
394 	aStateMachine.AddStatus(dpBst_gotoConstChar);
395 	aStateMachine.AddStatus(dpBst_gotoConstNumeric);
396     aStateMachine.AddStatus(dpBst_gotoUnblockMacro);
397 
398 	// Identifier
399 
400 	// Keywords and other unique Tokens
401 	aStateMachine.AddToken("operator",TCF_operator,A_nBezDefStatus,finKeyword);
402 	aStateMachine.AddToken("class",TCF_class,A_nBezDefStatus,finKeyword);
403 	aStateMachine.AddToken("struct",TCF_struct,A_nBezDefStatus,finKeyword);
404 	aStateMachine.AddToken("union",TCF_union,A_nBezDefStatus,finKeyword);
405 	aStateMachine.AddToken("enum",TCF_enum,A_nBezDefStatus,finKeyword);
406 	aStateMachine.AddToken("typedef",TCF_typedef,A_nBezDefStatus,finKeyword);
407 	aStateMachine.AddToken("public",TCF_public,A_nBezDefStatus,finKeyword);
408 	aStateMachine.AddToken("protected",TCF_protected,A_nBezDefStatus,finKeyword);
409 	aStateMachine.AddToken("private",TCF_private,A_nBezDefStatus,finKeyword);
410 	aStateMachine.AddToken("template",TCF_template,A_nBezDefStatus,finKeyword);
411 	aStateMachine.AddToken("virtual",TCF_virtual,A_nBezDefStatus,finKeyword);
412 	aStateMachine.AddToken("friend",TCF_friend,A_nBezDefStatus,finKeyword);
413 	aStateMachine.AddToken("~",TCF_Tilde,A_nOperatorDefStatus,finKeyword);
414 	aStateMachine.AddToken("const",TCF_const,A_nBezDefStatus,finKeyword);
415 	aStateMachine.AddToken("volatile",TCF_volatile,A_nBezDefStatus,finKeyword);
416 	aStateMachine.AddToken("extern",TCF_extern,A_nBezDefStatus,finKeyword);
417 	aStateMachine.AddToken("static",TCF_static,A_nBezDefStatus,finKeyword);
418 	aStateMachine.AddToken("mutable",TCF_mutable,A_nBezDefStatus,finKeyword);
419 	aStateMachine.AddToken("register",TCF_register,A_nBezDefStatus,finKeyword);
420 	aStateMachine.AddToken("inline",TCF_inline,A_nBezDefStatus,finKeyword);
421 	aStateMachine.AddToken("explicit",TCF_explicit,A_nBezDefStatus,finKeyword);
422 	aStateMachine.AddToken("namespace",TCF_namespace,A_nBezDefStatus,finKeyword);
423 	aStateMachine.AddToken("using",TCF_using,A_nBezDefStatus,finKeyword);
424 	aStateMachine.AddToken("throw",TCF_throw,A_nBezDefStatus,finKeyword);
425 	aStateMachine.AddToken("{",TCF_SwBracketOpen,A_nOperatorDefStatus,finKeyword);
426 	aStateMachine.AddToken("}",TCF_SwBracketClose,A_nOperatorDefStatus,finKeyword);
427 	aStateMachine.AddToken("[",TCF_ArBracketOpen,A_nOperatorDefStatus,finKeyword);
428 	aStateMachine.AddToken("]",TCF_ArBracketClose,A_nOperatorDefStatus,finKeyword);
429 	aStateMachine.AddToken("(",TCF_BracketOpen,A_nOperatorDefStatus,finKeyword);
430 	aStateMachine.AddToken(")",TCF_BracketClose,A_nOperatorDefStatus,finKeyword);
431 	aStateMachine.AddToken("::",TCF_DblColon,A_nOperatorDefStatus,finKeyword);
432 	aStateMachine.AddToken(";",TCF_Semikolon,A_nOperatorDefStatus,finKeyword);
433 	aStateMachine.AddToken(",",TCF_Komma,A_nOperatorDefStatus,finKeyword);
434 	aStateMachine.AddToken(":",TCF_Colon,A_nOperatorDefStatus,finKeyword);
435 	aStateMachine.AddToken("=",TCF_Zuweisung,A_nOperatorDefStatus,finKeyword);
436 	aStateMachine.AddToken("<",TCF_Smaller,A_nOperatorDefStatus,finKeyword);
437 	aStateMachine.AddToken(">",TCF_Bigger,A_nOperatorDefStatus,finKeyword);
438 	aStateMachine.AddToken("*",TCF_Stern,A_nOperatorDefStatus,finKeyword);
439 	aStateMachine.AddToken("&",TCF_Ampersand,A_nOperatorDefStatus,finKeyword);
440 	aStateMachine.AddToken("...",TCF_Ellipse,A_nOperatorDefStatus,finKeyword);
441 	aStateMachine.AddToken("typename",TCF_typename,A_nOperatorDefStatus,finKeyword);
442 
443 	// Operators
444 	aStateMachine.AddToken("==",TCF_Operator,A_nOperatorDefStatus,finPunctuation);
445 	aStateMachine.AddToken("!=",TCF_Operator,A_nOperatorDefStatus,finPunctuation);
446 	aStateMachine.AddToken("<=",TCF_Operator,A_nOperatorDefStatus,finPunctuation);
447 	aStateMachine.AddToken(">=",TCF_Operator,A_nOperatorDefStatus,finPunctuation);
448 	aStateMachine.AddToken("&&",TCF_Operator,A_nOperatorDefStatus,finPunctuation);
449 	aStateMachine.AddToken("||",TCF_Operator,A_nOperatorDefStatus,finPunctuation);
450 	aStateMachine.AddToken("!",TCF_Operator,A_nOperatorDefStatus,finPunctuation);
451 	aStateMachine.AddToken("new",TCF_Operator,A_nBezDefStatus,finPunctuation);
452 	aStateMachine.AddToken("delete",TCF_Operator,A_nBezDefStatus,finPunctuation);
453 	aStateMachine.AddToken("sizeof",TCF_Operator,A_nBezDefStatus,finPunctuation);
454 	aStateMachine.AddToken("typeid",TCF_Operator,A_nBezDefStatus,finPunctuation);
455 	aStateMachine.AddToken("+",TCF_Operator,A_nOperatorDefStatus,finPunctuation);
456 	aStateMachine.AddToken("-",TCF_Operator,A_nOperatorDefStatus,finPunctuation);
457 	aStateMachine.AddToken("/",TCF_Operator,A_nOperatorDefStatus,finPunctuation);
458 	aStateMachine.AddToken("%",TCF_Operator,A_nOperatorDefStatus,finPunctuation);
459 	aStateMachine.AddToken("^",TCF_Operator,A_nOperatorDefStatus,finPunctuation);
460 	aStateMachine.AddToken("|",TCF_Operator,A_nOperatorDefStatus,finPunctuation);
461 	aStateMachine.AddToken("<<",TCF_Operator,A_nOperatorDefStatus,finPunctuation);
462 	aStateMachine.AddToken(">>",TCF_Operator,A_nOperatorDefStatus,finPunctuation);
463 	aStateMachine.AddToken(".",TCF_Operator,A_nOperatorDefStatus,finPunctuation);
464 	aStateMachine.AddToken("->",TCF_Operator,A_nOperatorDefStatus,finPunctuation);
465 	aStateMachine.AddToken("?",TCF_Operator,A_nOperatorDefStatus,finPunctuation);
466 	aStateMachine.AddToken("+=",TCF_Operator,A_nOperatorDefStatus,finPunctuation);
467 	aStateMachine.AddToken("-=",TCF_Operator,A_nOperatorDefStatus,finPunctuation);
468 	aStateMachine.AddToken("*=",TCF_Operator,A_nOperatorDefStatus,finPunctuation);
469 	aStateMachine.AddToken("/=",TCF_Operator,A_nOperatorDefStatus,finPunctuation);
470 	aStateMachine.AddToken("%=",TCF_Operator,A_nOperatorDefStatus,finPunctuation);
471 	aStateMachine.AddToken("&=",TCF_Operator,A_nOperatorDefStatus,finPunctuation);
472 	aStateMachine.AddToken("|=",TCF_Operator,A_nOperatorDefStatus,finPunctuation);
473 	aStateMachine.AddToken("^=",TCF_Operator,A_nOperatorDefStatus,finPunctuation);
474 	aStateMachine.AddToken("<<=",TCF_Operator,A_nOperatorDefStatus,finPunctuation);
475 	aStateMachine.AddToken(">>=",TCF_Operator,A_nOperatorDefStatus,finPunctuation);
476 
477 	// Builtin types
478 	aStateMachine.AddToken("char",	TCF_BuiltInType,	A_nBezDefStatus,	finBiType);
479 	aStateMachine.AddToken("short",	TCF_BuiltInType,	A_nBezDefStatus,	finBiType);
480 	aStateMachine.AddToken("int",	TCF_BuiltInType,	A_nBezDefStatus,	finBiType);
481 	aStateMachine.AddToken("long",	TCF_BuiltInType,	A_nBezDefStatus,	finBiType);
482 	aStateMachine.AddToken("float",	TCF_BuiltInType,	A_nBezDefStatus,	finBiType);
483 	aStateMachine.AddToken("double",TCF_BuiltInType,	A_nBezDefStatus,	finBiType);
484 	aStateMachine.AddToken("wchar_t",TCF_BuiltInType,	A_nBezDefStatus,    finBiType);
485 	aStateMachine.AddToken("size_t",TCF_BuiltInType,	A_nBezDefStatus,    finBiType);
486 
487 	// Type modifiers
488 	aStateMachine.AddToken("signed",	TCF_TypeModifier,	A_nBezDefStatus,	finTypeModifier);
489 	aStateMachine.AddToken("unsigned",	TCF_TypeModifier,	A_nBezDefStatus,	finTypeModifier);
490 
491 	// To ignore
492 	aStateMachine.AddToken("auto",		0,	A_nBezDefStatus,  	finIgnore);
493 	aStateMachine.AddToken("_cdecl",	0,	A_nBezDefStatus,	finIgnore);
494 	aStateMachine.AddToken("__cdecl",	0,	A_nBezDefStatus,	finIgnore);
495 	aStateMachine.AddToken("__stdcall", 0,	A_nBezDefStatus,	finIgnore);
496 	aStateMachine.AddToken("__fastcall",0,	A_nBezDefStatus,	finIgnore);
497 	aStateMachine.AddToken("/**/",	    0,	A_nOperatorDefStatus,finIgnore);
498 
499 	// Context changers
500 	aStateMachine.AddToken("#",		0,	A_nOperatorDefStatus,   gotoPreprocessor);
501 	aStateMachine.AddToken("#undef",0,	A_nOperatorDefStatus,   gotoPreprocessor);
502 	aStateMachine.AddToken("#unblock-",
503                                     0,	A_nOperatorDefStatus,   gotoUnblockMacro);
504 	aStateMachine.AddToken("/*",	0,	A_nOperatorDefStatus,	gotoComment);
505 	aStateMachine.AddToken("//",	0,	A_nOperatorDefStatus,	gotoComment);
506 	aStateMachine.AddToken("/**",   0,	A_nOperatorDefStatus,	gotoDocu);
507 	aStateMachine.AddToken("///",   0,	A_nOperatorDefStatus,	gotoDocu);
508 
509 	// Line ends
510 		//	regular
511 	aStateMachine.AddToken("\r\n",	0,	A_nOperatorDefStatus,	finEOL);
512 	aStateMachine.AddToken("\n",	0,	A_nOperatorDefStatus,	finEOL);
513 	aStateMachine.AddToken("\r",    0,	A_nOperatorDefStatus,	finEOL);
514 		//	To ignore in some cases(may be only at preprocessor?), but
515 		//		linecount has to be incremented.
516 	aStateMachine.AddToken("\\\r\n",0,	A_nOperatorDefStatus,	finEOL);
517 	aStateMachine.AddToken("\\\n",	0,	A_nOperatorDefStatus,	finEOL);
518 	aStateMachine.AddToken("\\\r",	0,	A_nOperatorDefStatus,	finEOL);
519 };
520 
521 
522 }   // namespace cpp
523 
524