Mercurial > projects > qtd
annotate generator/parser/ast.h @ 399:e40f33cc0bf5
Explicitly include qglobal.h before all the ?master includes?.
This makes sure that macros like Q_CORE_EXPORT are already defined for all parsed header files.
Starting with this commit, QtD should build successfully against the pre-built Cocoa packages on OS X 10.6.
author | David Nadlinger <code@klickverbot.at> |
---|---|
date | Sun, 16 Jan 2011 00:56:21 +0100 |
parents | 09a0f1d048f2 |
children |
rev | line source |
---|---|
1 | 1 /**************************************************************************** |
2 ** | |
52
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
3 ** Copyright (C) 1992-2009 Nokia. All rights reserved. |
1 | 4 ** Copyright (C) 2002-2005 Roberto Raggi <roberto@kdevelop.org> |
5 ** | |
6 ** This file is part of Qt Jambi. | |
7 ** | |
52
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
8 ** Commercial Usage |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
9 Licensees holding valid Qt Commercial licenses may use this file in |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
10 accordance with the Qt Commercial License Agreement provided with the |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
11 Software or, alternatively, in accordance with the terms contained in |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
12 a written agreement between you and Nokia. |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
13 |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
14 GNU Lesser General Public License Usage |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
15 Alternatively, this file may be used under the terms of the GNU Lesser |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
16 General Public License version 2.1 as published by the Free Software |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
17 Foundation and appearing in the file LICENSE.LGPL included in the |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
18 packaging of this file. Please review the following information to |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
19 ensure the GNU Lesser General Public License version 2.1 requirements |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
20 will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
21 |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
22 In addition, as a special exception, Nokia gives you certain |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
23 additional rights. These rights are described in the Nokia Qt LGPL |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
24 Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
25 package. |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
26 |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
27 GNU General Public License Usage |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
28 Alternatively, this file may be used under the terms of the GNU |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
29 General Public License version 3.0 as published by the Free Software |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
30 Foundation and appearing in the file LICENSE.GPL included in the |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
31 packaging of this file. Please review the following information to |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
32 ensure the GNU General Public License version 3.0 requirements will be |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
33 met: http://www.gnu.org/copyleft/gpl.html. |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
34 |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
35 If you are unsure which license is appropriate for your use, please |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
36 contact the sales department at qt-sales@nokia.com. |
1 | 37 |
38 ** | |
39 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | |
40 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | |
41 ** | |
42 ****************************************************************************/ | |
43 | |
44 | |
45 #ifndef AST_H | |
46 #define AST_H | |
47 | |
48 #include "smallobject.h" | |
49 #include "list.h" | |
50 | |
51 class QString; | |
52 | |
53 #define DECLARE_AST_NODE(k) \ | |
54 enum { __node_kind = Kind_##k }; | |
55 | |
56 class TokenStream; | |
57 | |
58 struct AccessSpecifierAST; | |
59 struct AsmDefinitionAST; | |
60 struct BaseClauseAST; | |
61 struct BaseSpecifierAST; | |
62 struct BinaryExpressionAST; | |
63 struct CastExpressionAST; | |
64 struct ClassMemberAccessAST; | |
65 struct ClassSpecifierAST; | |
66 struct CompoundStatementAST; | |
67 struct ConditionAST; | |
68 struct ConditionalExpressionAST; | |
69 struct CppCastExpressionAST; | |
70 struct CtorInitializerAST; | |
71 struct DeclarationAST; | |
72 struct DeclarationStatementAST; | |
73 struct DeclaratorAST; | |
74 struct DeleteExpressionAST; | |
75 struct DoStatementAST; | |
76 struct ElaboratedTypeSpecifierAST; | |
77 struct EnumSpecifierAST; | |
78 struct EnumeratorAST; | |
79 struct ExceptionSpecificationAST; | |
80 struct ExpressionAST; | |
81 struct ExpressionOrDeclarationStatementAST; | |
82 struct ExpressionStatementAST; | |
83 struct ForStatementAST; | |
84 struct FunctionCallAST; | |
85 struct FunctionDefinitionAST; | |
86 struct IfStatementAST; | |
87 struct IncrDecrExpressionAST; | |
88 struct InitDeclaratorAST; | |
89 struct InitializerAST; | |
90 struct InitializerClauseAST; | |
91 struct LabeledStatementAST; | |
92 struct LinkageBodyAST; | |
93 struct LinkageSpecificationAST; | |
94 struct MemInitializerAST; | |
95 struct NameAST; | |
96 struct NamespaceAST; | |
97 struct NamespaceAliasDefinitionAST; | |
98 struct NewDeclaratorAST; | |
99 struct NewExpressionAST; | |
100 struct NewInitializerAST; | |
101 struct NewTypeIdAST; | |
102 struct OperatorAST; | |
103 struct OperatorFunctionIdAST; | |
104 struct ParameterDeclarationAST; | |
105 struct ParameterDeclarationClauseAST; | |
106 struct PostfixExpressionAST; | |
107 struct PrimaryExpressionAST; | |
108 struct PtrOperatorAST; | |
109 struct PtrToMemberAST; | |
110 struct ReturnStatementAST; | |
111 struct SimpleDeclarationAST; | |
112 struct SimpleTypeSpecifierAST; | |
113 struct SizeofExpressionAST; | |
114 struct StatementAST; | |
115 struct StringLiteralAST; | |
116 struct SubscriptExpressionAST; | |
117 struct SwitchStatementAST; | |
118 struct TemplateArgumentAST; | |
119 struct TemplateDeclarationAST; | |
120 struct TemplateParameterAST; | |
121 struct ThrowExpressionAST; | |
122 struct TranslationUnitAST; | |
123 struct TryBlockStatementAST; | |
124 struct TypeIdAST; | |
125 struct TypeIdentificationAST; | |
126 struct TypeParameterAST; | |
127 struct TypeSpecifierAST; | |
128 struct TypedefAST; | |
129 struct UnaryExpressionAST; | |
130 struct UnqualifiedNameAST; | |
131 struct UsingAST; | |
132 struct UsingDirectiveAST; | |
133 struct WhileStatementAST; | |
134 struct WinDeclSpecAST; | |
135 struct QPropertyAST; | |
136 struct QEnumsAST; | |
137 | |
138 struct AST | |
139 { | |
140 enum NODE_KIND | |
141 { | |
142 Kind_UNKNOWN = 0, | |
143 | |
144 Kind_AccessSpecifier, | |
145 Kind_AsmDefinition, | |
146 Kind_BaseClause, | |
147 Kind_BaseSpecifier, | |
148 Kind_BinaryExpression, | |
149 Kind_CastExpression, | |
150 Kind_ClassMemberAccess, | |
151 Kind_ClassSpecifier, | |
152 Kind_CompoundStatement, | |
153 Kind_Condition, | |
154 Kind_ConditionalExpression, | |
155 Kind_CppCastExpression, | |
156 Kind_CtorInitializer, | |
157 Kind_DeclarationStatement, | |
158 Kind_Declarator, | |
159 Kind_DeleteExpression, | |
160 Kind_DoStatement, | |
161 Kind_ElaboratedTypeSpecifier, | |
162 Kind_EnumSpecifier, | |
163 Kind_Enumerator, | |
164 Kind_ExceptionSpecification, | |
165 Kind_ExpressionOrDeclarationStatement, | |
166 Kind_ExpressionStatement, | |
167 Kind_ForStatement, | |
168 Kind_FunctionCall, | |
169 Kind_FunctionDefinition, | |
170 Kind_IfStatement, | |
171 Kind_IncrDecrExpression, | |
172 Kind_InitDeclarator, | |
173 Kind_Initializer, | |
174 Kind_InitializerClause, | |
175 Kind_LabeledStatement, | |
176 Kind_LinkageBody, | |
177 Kind_LinkageSpecification, | |
178 Kind_MemInitializer, | |
179 Kind_Name, | |
180 Kind_Namespace, | |
181 Kind_NamespaceAliasDefinition, | |
182 Kind_NewDeclarator, | |
183 Kind_NewExpression, | |
184 Kind_NewInitializer, | |
185 Kind_NewTypeId, | |
186 Kind_Operator, | |
187 Kind_OperatorFunctionId, | |
188 Kind_ParameterDeclaration, | |
189 Kind_ParameterDeclarationClause, | |
190 Kind_PostfixExpression, | |
191 Kind_PrimaryExpression, | |
192 Kind_PtrOperator, | |
193 Kind_PtrToMember, | |
194 Kind_ReturnStatement, | |
195 Kind_SimpleDeclaration, | |
196 Kind_SimpleTypeSpecifier, | |
197 Kind_SizeofExpression, | |
198 Kind_StringLiteral, | |
199 Kind_SubscriptExpression, | |
200 Kind_SwitchStatement, | |
201 Kind_TemplateArgument, | |
202 Kind_TemplateDeclaration, | |
203 Kind_TemplateParameter, | |
204 Kind_ThrowExpression, | |
205 Kind_TranslationUnit, | |
206 Kind_TryBlockStatement, | |
207 Kind_TypeId, | |
208 Kind_TypeIdentification, | |
209 Kind_TypeParameter, | |
210 Kind_Typedef, | |
211 Kind_UnaryExpression, | |
212 Kind_UnqualifiedName, | |
213 Kind_Using, | |
214 Kind_UsingDirective, | |
215 Kind_WhileStatement, | |
216 Kind_WinDeclSpec, | |
217 Kind_QPropertyAST, | |
218 Kind_ForwardDeclarationSpecifier, | |
219 Kind_QEnumsAST, | |
220 | |
221 NODE_KIND_COUNT | |
222 }; | |
223 | |
224 QString toString(TokenStream *stream) const; | |
225 | |
226 int kind; | |
227 | |
228 std::size_t start_token; | |
229 std::size_t end_token; | |
230 }; | |
231 | |
232 struct TypeSpecifierAST: public AST | |
233 { | |
234 const ListNode<std::size_t> *cv; | |
235 }; | |
236 | |
237 struct StatementAST: public AST | |
238 { | |
239 }; | |
240 | |
241 struct ExpressionAST: public AST | |
242 { | |
243 }; | |
244 | |
245 struct DeclarationAST: public AST | |
246 { | |
247 }; | |
248 | |
249 struct AccessSpecifierAST: public DeclarationAST | |
250 { | |
251 DECLARE_AST_NODE(AccessSpecifier) | |
252 | |
253 const ListNode<std::size_t> *specs; | |
254 }; | |
255 | |
256 struct AsmDefinitionAST: public DeclarationAST | |
257 { | |
258 DECLARE_AST_NODE(AsmDefinition) | |
259 | |
260 const ListNode<std::size_t> *cv; | |
261 }; | |
262 | |
263 struct BaseClauseAST: public AST // ### kill me | |
264 { | |
265 DECLARE_AST_NODE(BaseClause) | |
266 | |
267 const ListNode<BaseSpecifierAST*> *base_specifiers; | |
268 }; | |
269 | |
270 struct BaseSpecifierAST: public AST | |
271 { | |
272 DECLARE_AST_NODE(BaseSpecifier) | |
273 | |
274 std::size_t virt; | |
275 std::size_t access_specifier; | |
276 NameAST *name; | |
277 }; | |
278 | |
279 struct BinaryExpressionAST: public ExpressionAST | |
280 { | |
281 DECLARE_AST_NODE(BinaryExpression) | |
282 | |
283 std::size_t op; | |
284 ExpressionAST *left_expression; | |
285 ExpressionAST *right_expression; | |
286 }; | |
287 | |
288 struct CastExpressionAST: public ExpressionAST | |
289 { | |
290 DECLARE_AST_NODE(CastExpression) | |
291 | |
292 TypeIdAST *type_id; | |
293 ExpressionAST *expression; | |
294 }; | |
295 | |
296 struct ClassMemberAccessAST: public ExpressionAST | |
297 { | |
298 DECLARE_AST_NODE(ClassMemberAccess) | |
299 | |
300 std::size_t op; | |
301 NameAST *name; | |
302 }; | |
303 | |
304 struct ClassSpecifierAST: public TypeSpecifierAST | |
305 { | |
306 DECLARE_AST_NODE(ClassSpecifier) | |
307 | |
308 WinDeclSpecAST *win_decl_specifiers; | |
309 std::size_t class_key; | |
310 NameAST *name; | |
311 BaseClauseAST *base_clause; | |
312 const ListNode<DeclarationAST*> *member_specs; | |
313 }; | |
314 | |
315 struct ForwardDeclarationSpecifierAST: public TypeSpecifierAST | |
316 { | |
317 DECLARE_AST_NODE(ForwardDeclarationSpecifier) | |
318 | |
319 std::size_t class_key; | |
320 NameAST *name; | |
321 BaseClauseAST *base_clause; | |
322 }; | |
323 | |
324 struct CompoundStatementAST: public StatementAST | |
325 { | |
326 DECLARE_AST_NODE(CompoundStatement) | |
327 | |
328 const ListNode<StatementAST*> *statements; | |
329 }; | |
330 | |
331 struct ConditionAST: public AST | |
332 { | |
333 DECLARE_AST_NODE(Condition) | |
334 | |
335 TypeSpecifierAST *type_specifier; | |
336 DeclaratorAST *declarator; | |
337 ExpressionAST *expression; | |
338 }; | |
339 | |
340 struct ConditionalExpressionAST: public ExpressionAST | |
341 { | |
342 DECLARE_AST_NODE(ConditionalExpression) | |
343 | |
344 ExpressionAST *condition; | |
345 ExpressionAST *left_expression; | |
346 ExpressionAST *right_expression; | |
347 }; | |
348 | |
349 struct CppCastExpressionAST: public ExpressionAST | |
350 { | |
351 DECLARE_AST_NODE(CppCastExpression) | |
352 | |
353 std::size_t op; | |
354 TypeIdAST *type_id; | |
355 ExpressionAST *expression; | |
356 const ListNode<ExpressionAST*> *sub_expressions; | |
357 }; | |
358 | |
359 struct CtorInitializerAST: public AST | |
360 { | |
361 DECLARE_AST_NODE(CtorInitializer) | |
362 | |
363 std::size_t colon; | |
364 const ListNode<MemInitializerAST*> *member_initializers; | |
365 }; | |
366 | |
367 struct DeclarationStatementAST: public StatementAST | |
368 { | |
369 DECLARE_AST_NODE(DeclarationStatement) | |
370 | |
371 DeclarationAST *declaration; | |
372 }; | |
373 | |
374 struct DeclaratorAST: public AST | |
375 { | |
376 DECLARE_AST_NODE(Declarator) | |
377 | |
378 const ListNode<PtrOperatorAST*> *ptr_ops; | |
379 DeclaratorAST *sub_declarator; | |
380 NameAST *id; | |
381 ExpressionAST *bit_expression; | |
382 const ListNode<ExpressionAST*> *array_dimensions; | |
383 ParameterDeclarationClauseAST *parameter_declaration_clause; | |
384 const ListNode<std::size_t> *fun_cv; | |
385 ExceptionSpecificationAST *exception_spec; | |
386 }; | |
387 | |
388 struct DeleteExpressionAST: public ExpressionAST | |
389 { | |
390 DECLARE_AST_NODE(DeleteExpression) | |
391 | |
392 std::size_t scope_token; | |
393 std::size_t delete_token; | |
394 std::size_t lbracket_token; | |
395 std::size_t rbracket_token; | |
396 ExpressionAST *expression; | |
397 }; | |
398 | |
399 struct DoStatementAST: public StatementAST | |
400 { | |
401 DECLARE_AST_NODE(DoStatement) | |
402 | |
403 StatementAST *statement; | |
404 ExpressionAST *expression; | |
405 }; | |
406 | |
407 struct ElaboratedTypeSpecifierAST: public TypeSpecifierAST | |
408 { | |
409 DECLARE_AST_NODE(ElaboratedTypeSpecifier) | |
410 | |
411 std::size_t type; | |
412 NameAST *name; | |
413 }; | |
414 | |
415 struct EnumSpecifierAST: public TypeSpecifierAST | |
416 { | |
417 DECLARE_AST_NODE(EnumSpecifier) | |
418 | |
419 NameAST *name; | |
420 const ListNode<EnumeratorAST*> *enumerators; | |
421 }; | |
422 | |
423 struct EnumeratorAST: public AST | |
424 { | |
425 DECLARE_AST_NODE(Enumerator) | |
426 | |
427 std::size_t id; | |
428 ExpressionAST *expression; | |
429 }; | |
430 | |
431 struct ExceptionSpecificationAST: public AST | |
432 { | |
433 DECLARE_AST_NODE(ExceptionSpecification) | |
434 | |
435 std::size_t ellipsis; | |
436 const ListNode<TypeIdAST*> *type_ids; | |
437 }; | |
438 | |
439 struct ExpressionOrDeclarationStatementAST: public StatementAST | |
440 { | |
441 DECLARE_AST_NODE(ExpressionOrDeclarationStatement) | |
442 | |
443 StatementAST *expression; | |
444 StatementAST *declaration; | |
445 }; | |
446 | |
447 struct ExpressionStatementAST: public StatementAST | |
448 { | |
449 DECLARE_AST_NODE(ExpressionStatement) | |
450 | |
451 ExpressionAST *expression; | |
452 }; | |
453 | |
454 struct FunctionCallAST: public ExpressionAST | |
455 { | |
456 DECLARE_AST_NODE(FunctionCall) | |
457 | |
458 ExpressionAST *arguments; | |
459 }; | |
460 | |
461 struct FunctionDefinitionAST: public DeclarationAST | |
462 { | |
463 DECLARE_AST_NODE(FunctionDefinition) | |
464 | |
465 const ListNode<std::size_t> *storage_specifiers; | |
466 const ListNode<std::size_t> *function_specifiers; | |
467 TypeSpecifierAST *type_specifier; | |
468 InitDeclaratorAST *init_declarator; | |
469 StatementAST *function_body; | |
470 WinDeclSpecAST *win_decl_specifiers; | |
471 }; | |
472 | |
473 struct ForStatementAST: public StatementAST | |
474 { | |
475 DECLARE_AST_NODE(ForStatement) | |
476 | |
477 StatementAST *init_statement; | |
478 ConditionAST *condition; | |
479 ExpressionAST *expression; | |
480 StatementAST *statement; | |
481 }; | |
482 | |
483 struct IfStatementAST: public StatementAST | |
484 { | |
485 DECLARE_AST_NODE(IfStatement) | |
486 | |
487 ConditionAST *condition; | |
488 StatementAST *statement; | |
489 StatementAST *else_statement; | |
490 }; | |
491 | |
492 struct IncrDecrExpressionAST: public ExpressionAST | |
493 { | |
494 DECLARE_AST_NODE(IncrDecrExpression) | |
495 | |
496 std::size_t op; | |
497 }; | |
498 | |
499 struct InitDeclaratorAST: public AST | |
500 { | |
501 DECLARE_AST_NODE(InitDeclarator) | |
502 | |
503 DeclaratorAST *declarator; | |
504 InitializerAST *initializer; | |
505 }; | |
506 | |
507 struct InitializerAST: public AST | |
508 { | |
509 DECLARE_AST_NODE(Initializer) | |
510 | |
511 InitializerClauseAST *initializer_clause; | |
512 ExpressionAST *expression; | |
513 }; | |
514 | |
515 struct InitializerClauseAST: public AST | |
516 { | |
517 DECLARE_AST_NODE(InitializerClause) | |
518 | |
519 ExpressionAST *expression; | |
520 }; | |
521 | |
522 struct LabeledStatementAST: public StatementAST | |
523 { | |
524 DECLARE_AST_NODE(LabeledStatement) | |
525 }; | |
526 | |
527 struct LinkageBodyAST: public AST | |
528 { | |
529 DECLARE_AST_NODE(LinkageBody) | |
530 | |
531 const ListNode<DeclarationAST*> *declarations; | |
532 }; | |
533 | |
534 struct LinkageSpecificationAST: public DeclarationAST | |
535 { | |
536 DECLARE_AST_NODE(LinkageSpecification) | |
537 | |
538 std::size_t extern_type; | |
539 LinkageBodyAST *linkage_body; | |
540 DeclarationAST *declaration; | |
541 }; | |
542 | |
543 struct MemInitializerAST: public AST | |
544 { | |
545 DECLARE_AST_NODE(MemInitializer) | |
546 | |
547 NameAST *initializer_id; | |
548 ExpressionAST *expression; | |
549 }; | |
550 | |
551 struct NameAST: public AST | |
552 { | |
553 DECLARE_AST_NODE(Name) | |
554 | |
555 bool global; | |
556 const ListNode<UnqualifiedNameAST*> *qualified_names; | |
557 UnqualifiedNameAST *unqualified_name; | |
558 }; | |
559 | |
560 struct NamespaceAST: public DeclarationAST | |
561 { | |
562 DECLARE_AST_NODE(Namespace) | |
563 | |
564 std::size_t namespace_name; | |
565 LinkageBodyAST *linkage_body; | |
566 }; | |
567 | |
568 struct NamespaceAliasDefinitionAST: public DeclarationAST | |
569 { | |
570 DECLARE_AST_NODE(NamespaceAliasDefinition) | |
571 | |
572 std::size_t namespace_name; | |
573 NameAST *alias_name; | |
574 }; | |
575 | |
576 struct NewDeclaratorAST: public AST | |
577 { | |
578 DECLARE_AST_NODE(NewDeclarator) | |
579 | |
580 PtrOperatorAST *ptr_op; | |
581 NewDeclaratorAST *sub_declarator; | |
582 const ListNode<ExpressionAST*> *expressions; | |
583 }; | |
584 | |
585 struct NewExpressionAST: public ExpressionAST | |
586 { | |
587 DECLARE_AST_NODE(NewExpression) | |
588 | |
589 std::size_t scope_token; | |
590 std::size_t new_token; | |
591 ExpressionAST *expression; | |
592 TypeIdAST *type_id; | |
593 NewTypeIdAST *new_type_id; | |
594 NewInitializerAST *new_initializer; | |
595 }; | |
596 | |
597 struct NewInitializerAST: public AST | |
598 { | |
599 DECLARE_AST_NODE(NewInitializer) | |
600 | |
601 ExpressionAST *expression; | |
602 }; | |
603 | |
604 struct NewTypeIdAST: public AST | |
605 { | |
606 DECLARE_AST_NODE(NewTypeId) | |
607 | |
608 TypeSpecifierAST *type_specifier; | |
609 NewInitializerAST *new_initializer; | |
610 NewDeclaratorAST *new_declarator; | |
611 }; | |
612 | |
613 struct OperatorAST: public AST | |
614 { | |
615 DECLARE_AST_NODE(Operator) | |
616 | |
617 std::size_t op; | |
618 std::size_t open; | |
619 std::size_t close; | |
620 }; | |
621 | |
622 struct OperatorFunctionIdAST: public AST | |
623 { | |
624 DECLARE_AST_NODE(OperatorFunctionId) | |
625 | |
626 OperatorAST *op; | |
627 TypeSpecifierAST *type_specifier; | |
628 const ListNode<PtrOperatorAST*> *ptr_ops; | |
629 }; | |
630 | |
631 struct ParameterDeclarationAST: public AST | |
632 { | |
633 DECLARE_AST_NODE(ParameterDeclaration) | |
634 | |
635 TypeSpecifierAST *type_specifier; | |
636 DeclaratorAST *declarator; | |
637 ExpressionAST *expression; | |
638 }; | |
639 | |
640 struct ParameterDeclarationClauseAST: public AST | |
641 { | |
642 DECLARE_AST_NODE(ParameterDeclarationClause) | |
643 | |
644 const ListNode<ParameterDeclarationAST*> *parameter_declarations; | |
645 std::size_t ellipsis; | |
646 }; | |
647 | |
648 struct PostfixExpressionAST: public ExpressionAST | |
649 { | |
650 DECLARE_AST_NODE(PostfixExpression) | |
651 | |
652 TypeSpecifierAST *type_specifier; | |
653 ExpressionAST *expression; | |
654 const ListNode<ExpressionAST*> *sub_expressions; | |
655 }; | |
656 | |
657 struct PrimaryExpressionAST: public ExpressionAST | |
658 { | |
659 DECLARE_AST_NODE(PrimaryExpression) | |
660 | |
661 StringLiteralAST *literal; | |
662 std::size_t token; | |
663 StatementAST *expression_statement; | |
664 ExpressionAST *sub_expression; | |
665 NameAST *name; | |
666 }; | |
667 | |
668 struct PtrOperatorAST: public AST | |
669 { | |
670 DECLARE_AST_NODE(PtrOperator) | |
671 | |
672 const ListNode<std::size_t> *cv; | |
673 std::size_t op; | |
674 PtrToMemberAST *mem_ptr; | |
675 }; | |
676 | |
677 struct PtrToMemberAST: public AST | |
678 { | |
679 DECLARE_AST_NODE(PtrToMember) | |
680 }; | |
681 | |
682 struct ReturnStatementAST: public StatementAST | |
683 { | |
684 DECLARE_AST_NODE(ReturnStatement) | |
685 | |
686 ExpressionAST *expression; | |
687 }; | |
688 | |
689 struct SimpleDeclarationAST: public DeclarationAST | |
690 { | |
691 DECLARE_AST_NODE(SimpleDeclaration) | |
692 | |
693 const ListNode<std::size_t> *storage_specifiers; | |
694 const ListNode<std::size_t> *function_specifiers; | |
695 TypeSpecifierAST *type_specifier; | |
696 const ListNode<InitDeclaratorAST*> *init_declarators; | |
697 WinDeclSpecAST *win_decl_specifiers; | |
698 }; | |
699 | |
700 struct SimpleTypeSpecifierAST: public TypeSpecifierAST | |
701 { | |
702 DECLARE_AST_NODE(SimpleTypeSpecifier) | |
703 | |
704 const ListNode<std::size_t> *integrals; | |
705 std::size_t type_of; | |
706 TypeIdAST *type_id; | |
707 ExpressionAST *expression; | |
708 NameAST *name; | |
709 }; | |
710 | |
711 struct SizeofExpressionAST: public ExpressionAST | |
712 { | |
713 DECLARE_AST_NODE(SizeofExpression) | |
714 | |
715 std::size_t sizeof_token; | |
716 TypeIdAST *type_id; | |
717 ExpressionAST *expression; | |
718 }; | |
719 | |
720 struct StringLiteralAST: public AST | |
721 { | |
722 DECLARE_AST_NODE(StringLiteral) | |
723 | |
724 const ListNode<std::size_t> *literals; | |
725 }; | |
726 | |
727 struct SubscriptExpressionAST: public ExpressionAST | |
728 { | |
729 DECLARE_AST_NODE(SubscriptExpression) | |
730 | |
731 ExpressionAST *subscript; | |
732 }; | |
733 | |
734 struct SwitchStatementAST: public StatementAST | |
735 { | |
736 DECLARE_AST_NODE(SwitchStatement) | |
737 | |
738 ConditionAST *condition; | |
739 StatementAST *statement; | |
740 }; | |
741 | |
742 struct TemplateArgumentAST: public AST | |
743 { | |
744 DECLARE_AST_NODE(TemplateArgument) | |
745 | |
746 TypeIdAST *type_id; | |
747 ExpressionAST *expression; | |
748 }; | |
749 | |
750 struct TemplateDeclarationAST: public DeclarationAST | |
751 { | |
752 DECLARE_AST_NODE(TemplateDeclaration) | |
753 | |
754 std::size_t exported; | |
755 const ListNode<TemplateParameterAST*> *template_parameters; | |
756 DeclarationAST* declaration; | |
757 }; | |
758 | |
759 struct TemplateParameterAST: public AST | |
760 { | |
761 DECLARE_AST_NODE(TemplateParameter) | |
762 | |
763 TypeParameterAST *type_parameter; | |
764 ParameterDeclarationAST *parameter_declaration; | |
765 }; | |
766 | |
767 struct ThrowExpressionAST: public ExpressionAST | |
768 { | |
769 DECLARE_AST_NODE(ThrowExpression) | |
770 | |
771 std::size_t throw_token; | |
772 ExpressionAST *expression; | |
773 }; | |
774 | |
775 struct TranslationUnitAST: public AST | |
776 { | |
777 DECLARE_AST_NODE(TranslationUnit) | |
778 | |
779 const ListNode<DeclarationAST*> *declarations; | |
780 }; | |
781 | |
782 struct TryBlockStatementAST: public StatementAST | |
783 { | |
784 DECLARE_AST_NODE(TryBlockStatement) | |
785 }; | |
786 | |
787 struct TypeIdAST: public AST | |
788 { | |
789 DECLARE_AST_NODE(TypeId) | |
790 | |
791 TypeSpecifierAST *type_specifier; | |
792 DeclaratorAST *declarator; | |
793 }; | |
794 | |
795 struct TypeIdentificationAST: public ExpressionAST | |
796 { | |
797 DECLARE_AST_NODE(TypeIdentification) | |
798 | |
799 std::size_t typename_token; | |
800 NameAST *name; | |
801 ExpressionAST *expression; | |
802 }; | |
803 | |
804 struct TypeParameterAST: public AST | |
805 { | |
806 DECLARE_AST_NODE(TypeParameter) | |
807 | |
808 std::size_t type; | |
809 NameAST *name; | |
810 TypeIdAST *type_id; | |
811 const ListNode<TemplateParameterAST*> *template_parameters; | |
812 NameAST *template_name; | |
813 }; | |
814 | |
815 struct TypedefAST: public DeclarationAST | |
816 { | |
817 DECLARE_AST_NODE(Typedef) | |
818 | |
819 TypeSpecifierAST *type_specifier; | |
820 const ListNode<InitDeclaratorAST*> *init_declarators; | |
821 }; | |
822 | |
823 struct UnaryExpressionAST: public ExpressionAST | |
824 { | |
825 DECLARE_AST_NODE(UnaryExpression) | |
826 | |
827 std::size_t op; | |
828 ExpressionAST *expression; | |
829 }; | |
830 | |
831 struct UnqualifiedNameAST: public AST | |
832 { | |
833 DECLARE_AST_NODE(UnqualifiedName) | |
834 | |
835 std::size_t tilde; | |
836 std::size_t id; | |
837 OperatorFunctionIdAST *operator_id; | |
838 const ListNode<TemplateArgumentAST*> *template_arguments; | |
839 }; | |
840 | |
841 struct UsingAST: public DeclarationAST | |
842 { | |
843 DECLARE_AST_NODE(Using) | |
844 | |
845 std::size_t type_name; | |
846 NameAST *name; | |
847 }; | |
848 | |
849 struct UsingDirectiveAST: public DeclarationAST | |
850 { | |
851 DECLARE_AST_NODE(UsingDirective) | |
852 | |
853 NameAST *name; | |
854 }; | |
855 | |
856 struct WhileStatementAST: public StatementAST | |
857 { | |
858 DECLARE_AST_NODE(WhileStatement) | |
859 | |
860 ConditionAST *condition; | |
861 StatementAST *statement; | |
862 }; | |
863 | |
864 struct WinDeclSpecAST: public AST | |
865 { | |
866 DECLARE_AST_NODE(WinDeclSpec) | |
867 | |
868 std::size_t specifier; | |
869 std::size_t modifier; | |
870 }; | |
871 | |
872 struct QPropertyAST : public DeclarationAST | |
873 { | |
874 DECLARE_AST_NODE(QPropertyAST) | |
875 }; | |
876 | |
877 struct QEnumsAST : public DeclarationAST | |
878 { | |
879 DECLARE_AST_NODE(QEnumsAST) | |
880 }; | |
881 | |
882 template <class _Tp> | |
883 _Tp *CreateNode(pool *memory_pool) | |
884 { | |
885 _Tp *node = reinterpret_cast<_Tp*>(memory_pool->allocate(sizeof(_Tp))); | |
886 node->kind = _Tp::__node_kind; | |
887 return node; | |
888 } | |
889 | |
890 template <class _Tp> | |
891 _Tp ast_cast(AST *item) | |
892 { | |
893 if (item && static_cast<_Tp>(0)->__node_kind == item->kind) | |
894 return static_cast<_Tp>(item); | |
895 | |
896 return 0; | |
897 } | |
898 | |
899 #endif // AST_H | |
900 | |
901 // kate: space-indent on; indent-width 2; replace-tabs on; |