~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to tools/porting/src/treewalker.h

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
**
 
3
** Copyright (C) 2004-2005 Trolltech AS. All rights reserved.
 
4
** Copyright (C) 2001-2004 Roberto Raggi
 
5
**
 
6
** This file is part of the porting application of the Qt Toolkit.
 
7
**
 
8
** This file may be distributed under the terms of the Q Public License
 
9
** as defined by Trolltech AS of Norway and appearing in the file
 
10
** LICENSE.QPL included in the packaging of this file.
 
11
**
 
12
** This file may be distributed and/or modified under the terms of the
 
13
** GNU General Public License version 2 as published by the Free Software
 
14
** Foundation and appearing in the file LICENSE.GPL included in the
 
15
** packaging of this file.
 
16
**
 
17
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
 
18
**   information about Qt Commercial License Agreements.
 
19
** See http://www.trolltech.com/qpl/ for QPL licensing information.
 
20
** See http://www.trolltech.com/gpl/ for GPL licensing information.
 
21
**
 
22
** Contact info@trolltech.com if any conditions of this licensing are
 
23
** not clear to you.
 
24
**
 
25
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 
26
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 
27
**
 
28
****************************************************************************/
 
29
 
 
30
#ifndef __treewalker_h
 
31
#define __treewalker_h
 
32
 
 
33
#include "ast.h"
 
34
 
 
35
class TreeWalker
 
36
{
 
37
public:
 
38
    TreeWalker() {}
 
39
    virtual ~TreeWalker() {}
 
40
 
 
41
    virtual void parseNode(AST *node);
 
42
    virtual void parseTemplateArgumentList(TemplateArgumentListAST *node);
 
43
    virtual void parseClassOrNamespaceName(ClassOrNamespaceNameAST *node);
 
44
    virtual void parseName(NameAST *node);
 
45
    virtual void parseTypeParameter(TypeParameterAST *node);
 
46
    virtual void parseDeclaration(DeclarationAST *node);
 
47
    virtual void parseAccessDeclaration(AccessDeclarationAST *node);
 
48
    virtual void parseTypeSpecifier(TypeSpecifierAST *node);
 
49
    virtual void parseBaseSpecifier(BaseSpecifierAST *node);
 
50
    virtual void parseBaseClause(BaseClauseAST *node);
 
51
    virtual void parseClassSpecifier(ClassSpecifierAST *node);
 
52
    virtual void parseEnumerator(EnumeratorAST *node);
 
53
    virtual void parseEnumSpecifier(EnumSpecifierAST *node);
 
54
    virtual void parseElaboratedTypeSpecifier(ElaboratedTypeSpecifierAST *node);
 
55
    virtual void parseLinkageBody(LinkageBodyAST *node);
 
56
    virtual void parseLinkageSpecification(LinkageSpecificationAST *node);
 
57
    virtual void parseNamespace(NamespaceAST *node);
 
58
    virtual void parseNamespaceAlias(NamespaceAliasAST *node);
 
59
    virtual void parseUsing(UsingAST *node);
 
60
    virtual void parseUsingDirective(UsingDirectiveAST *node);
 
61
    virtual void parseDeclarator(DeclaratorAST *node);
 
62
    virtual void parseParameterDeclaration(ParameterDeclarationAST *node);
 
63
    virtual void parseParameterDeclarationList(ParameterDeclarationListAST *node);
 
64
    virtual void parseParameterDeclarationClause(ParameterDeclarationClauseAST *node);
 
65
    virtual void parseInitDeclarator(InitDeclaratorAST *node);
 
66
    virtual void parseInitDeclaratorList(InitDeclaratorListAST *node);
 
67
    virtual void parseTypedef(TypedefAST *node);
 
68
    virtual void parseTemplateParameter(TemplateParameterAST *node);
 
69
    virtual void parseTemplateParameterList(TemplateParameterListAST *node);
 
70
    virtual void parseTemplateDeclaration(TemplateDeclarationAST *node);
 
71
    virtual void parseSimpleDeclaration(SimpleDeclarationAST *node);
 
72
    virtual void parseStatement(StatementAST *node);
 
73
    virtual void parseExpressionStatement(ExpressionStatementAST *node);
 
74
    virtual void parseCondition(ConditionAST *node);
 
75
    virtual void parseIfStatement(IfStatementAST *node);
 
76
    virtual void parseWhileStatement(WhileStatementAST *node);
 
77
    virtual void parseDoStatement(DoStatementAST *node);
 
78
    virtual void parseForStatement(ForStatementAST *node);
 
79
    virtual void parseSwitchStatement(SwitchStatementAST *node);
 
80
    virtual void parseReturnStatement(ReturnStatementAST *node);
 
81
    virtual void parseStatementList(StatementListAST *node);
 
82
    virtual void parseDeclarationStatement(DeclarationStatementAST *node);
 
83
    virtual void parseFunctionDefinition(FunctionDefinitionAST *node);
 
84
    virtual void parseTranslationUnit(TranslationUnitAST *node);
 
85
    virtual void parseExpression(AbstractExpressionAST *node);
 
86
    virtual void parseBinaryExpression(BinaryExpressionAST *node);
 
87
};
 
88
 
 
89
inline void TreeWalker::parseNode(AST *node)
 
90
{
 
91
    if (!node)
 
92
        return;
 
93
 
 
94
    switch(node->nodeType()) {
 
95
 
 
96
    case NodeType_Declaration:
 
97
    case NodeType_AccessDeclaration:
 
98
    case NodeType_LinkageSpecification:
 
99
    case NodeType_Namespace:
 
100
    case NodeType_NamespaceAlias:
 
101
    case NodeType_Using:
 
102
    case NodeType_UsingDirective:
 
103
    case NodeType_Typedef:
 
104
    case NodeType_TemplateDeclaration:
 
105
    case NodeType_SimpleDeclaration:
 
106
    case NodeType_FunctionDefinition:
 
107
        parseDeclaration(static_cast<DeclarationAST*>(node));
 
108
        break;
 
109
 
 
110
    case NodeType_Statement:
 
111
    case NodeType_ExpressionStatement:
 
112
    case NodeType_IfStatement:
 
113
    case NodeType_WhileStatement:
 
114
    case NodeType_DoStatement:
 
115
    case NodeType_ForStatement:
 
116
    case NodeType_SwitchStatement:
 
117
    case NodeType_StatementList:
 
118
    case NodeType_DeclarationStatement:
 
119
    case NodeType_ReturnStatement:
 
120
        parseStatement(static_cast<StatementAST*>(node));
 
121
        break;
 
122
 
 
123
    case NodeType_TypeSpecifier:
 
124
    case NodeType_ClassSpecifier:
 
125
    case NodeType_EnumSpecifier:
 
126
    case NodeType_ElaboratedTypeSpecifier:
 
127
        parseTypeSpecifier(static_cast<TypeSpecifierAST*>(node));
 
128
        break;
 
129
 
 
130
    case NodeType_TemplateArgumentList:
 
131
        parseTemplateArgumentList(static_cast<TemplateArgumentListAST*>(node));
 
132
        break;
 
133
    case NodeType_ClassOrNamespaceName:
 
134
        parseClassOrNamespaceName(static_cast<ClassOrNamespaceNameAST*>(node));
 
135
        break;
 
136
    case NodeType_Name:
 
137
        parseName(static_cast<NameAST*>(node));
 
138
        break;
 
139
    case NodeType_TypeParameter:
 
140
        parseTypeParameter(static_cast<TypeParameterAST*>(node));
 
141
        break;
 
142
    case NodeType_BaseSpecifier:
 
143
        parseBaseSpecifier(static_cast<BaseSpecifierAST*>(node));
 
144
        break;
 
145
    case NodeType_BaseClause:
 
146
        parseBaseClause(static_cast<BaseClauseAST*>(node));
 
147
        break;
 
148
    case NodeType_Enumerator:
 
149
        parseEnumerator(static_cast<EnumeratorAST*>(node));
 
150
        break;
 
151
    case NodeType_LinkageBody:
 
152
        parseLinkageBody(static_cast<LinkageBodyAST*>(node));
 
153
        break;
 
154
    case NodeType_Declarator:
 
155
        parseDeclarator(static_cast<DeclaratorAST*>(node));
 
156
        break;
 
157
    case NodeType_ParameterDeclaration:
 
158
        parseParameterDeclaration(static_cast<ParameterDeclarationAST*>(node));
 
159
        break;
 
160
    case NodeType_ParameterDeclarationList:
 
161
        parseParameterDeclarationList(static_cast<ParameterDeclarationListAST*>(node));
 
162
        break;
 
163
    case NodeType_ParameterDeclarationClause:
 
164
        parseParameterDeclarationClause(static_cast<ParameterDeclarationClauseAST*>(node));
 
165
        break;
 
166
    case NodeType_InitDeclarator:
 
167
        parseInitDeclarator(static_cast<InitDeclaratorAST*>(node));
 
168
        break;
 
169
    case NodeType_InitDeclaratorList:
 
170
        parseInitDeclaratorList(static_cast<InitDeclaratorListAST*>(node));
 
171
        break;
 
172
    case NodeType_TemplateParameter:
 
173
        parseTemplateParameter(static_cast<TemplateParameterAST*>(node));
 
174
        break;
 
175
    case NodeType_TemplateParameterList:
 
176
        parseTemplateParameterList(static_cast<TemplateParameterListAST*>(node));
 
177
        break;
 
178
    case NodeType_Condition:
 
179
        parseCondition(static_cast<ConditionAST*>(node));
 
180
        break;
 
181
    case NodeType_TranslationUnit:
 
182
        parseTranslationUnit(static_cast<TranslationUnitAST*>(node));
 
183
        break;
 
184
 
 
185
    case NodeType_BinaryExpression:
 
186
        parseBinaryExpression(static_cast<BinaryExpressionAST*>(node));
 
187
        break;
 
188
 
 
189
    case NodeType_Expression:
 
190
    case NodeType_PrimaryExpression:
 
191
 
 
192
    case NodeType_PostfixExpression:
 
193
    case NodeType_Subscripting:
 
194
    case NodeType_FunctionCall:
 
195
    case NodeType_ExplicitTypeConversion:
 
196
    case NodeType_PseudoConstructorCall:
 
197
    case NodeType_ClassMemberAccess:
 
198
    case NodeType_IncrDecr:
 
199
    case NodeType_CppCastExpression:
 
200
    case NodeType_TypeIdentification:
 
201
 
 
202
    case NodeType_UnaryExpression:
 
203
    case NodeType_NewExpression:
 
204
    case NodeType_NewTypeId:
 
205
    case NodeType_NewDeclarator:
 
206
    case NodeType_NewInitializer:
 
207
    case NodeType_DeleteExpression:
 
208
    case NodeType_CastExpression:
 
209
    case NodeType_ConditionalExpression:
 
210
    case NodeType_ThrowExpression:
 
211
        parseExpression(static_cast<AbstractExpressionAST*>(node));
 
212
        break;
 
213
    }
 
214
}
 
215
 
 
216
#endif // __treewalker_h