0
|
1 |
/****************************************************************************
|
|
2 |
**
|
|
3 |
** Copyright (C) 2001-2004 Roberto Raggi
|
|
4 |
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
5 |
** All rights reserved.
|
|
6 |
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
7 |
**
|
|
8 |
** This file is part of the qt3to4 porting application of the Qt Toolkit.
|
|
9 |
**
|
|
10 |
** $QT_BEGIN_LICENSE:LGPL$
|
|
11 |
** No Commercial Usage
|
|
12 |
** This file contains pre-release code and may not be distributed.
|
|
13 |
** You may use this file in accordance with the terms and conditions
|
|
14 |
** contained in the Technology Preview License Agreement accompanying
|
|
15 |
** this package.
|
|
16 |
**
|
|
17 |
** GNU Lesser General Public License Usage
|
|
18 |
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
19 |
** General Public License version 2.1 as published by the Free Software
|
|
20 |
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
21 |
** packaging of this file. Please review the following information to
|
|
22 |
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
23 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
24 |
**
|
|
25 |
** In addition, as a special exception, Nokia gives you certain additional
|
|
26 |
** rights. These rights are described in the Nokia Qt LGPL Exception
|
|
27 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
28 |
**
|
|
29 |
** If you have questions regarding the use of this file, please contact
|
|
30 |
** Nokia at qt-info@nokia.com.
|
|
31 |
**
|
|
32 |
**
|
|
33 |
**
|
|
34 |
**
|
|
35 |
**
|
|
36 |
**
|
|
37 |
**
|
|
38 |
**
|
|
39 |
** $QT_END_LICENSE$
|
|
40 |
**
|
|
41 |
****************************************************************************/
|
|
42 |
|
|
43 |
#ifndef TREEWALKER_H
|
|
44 |
#define TREEWALKER_H
|
|
45 |
|
|
46 |
#include "ast.h"
|
|
47 |
|
|
48 |
QT_BEGIN_NAMESPACE
|
|
49 |
|
|
50 |
class TreeWalker
|
|
51 |
{
|
|
52 |
public:
|
|
53 |
TreeWalker() {}
|
|
54 |
virtual ~TreeWalker() {}
|
|
55 |
|
|
56 |
virtual void parseNode(AST *node);
|
|
57 |
virtual void parseTemplateArgumentList(TemplateArgumentListAST *node);
|
|
58 |
virtual void parseClassOrNamespaceName(ClassOrNamespaceNameAST *node);
|
|
59 |
virtual void parseName(NameAST *node);
|
|
60 |
virtual void parseTypeParameter(TypeParameterAST *node);
|
|
61 |
virtual void parseDeclaration(DeclarationAST *node);
|
|
62 |
virtual void parseAccessDeclaration(AccessDeclarationAST *node);
|
|
63 |
virtual void parseTypeSpecifier(TypeSpecifierAST *node);
|
|
64 |
virtual void parseBaseSpecifier(BaseSpecifierAST *node);
|
|
65 |
virtual void parseBaseClause(BaseClauseAST *node);
|
|
66 |
virtual void parseClassSpecifier(ClassSpecifierAST *node);
|
|
67 |
virtual void parseEnumerator(EnumeratorAST *node);
|
|
68 |
virtual void parseEnumSpecifier(EnumSpecifierAST *node);
|
|
69 |
virtual void parseElaboratedTypeSpecifier(ElaboratedTypeSpecifierAST *node);
|
|
70 |
virtual void parseLinkageBody(LinkageBodyAST *node);
|
|
71 |
virtual void parseLinkageSpecification(LinkageSpecificationAST *node);
|
|
72 |
virtual void parseNamespace(NamespaceAST *node);
|
|
73 |
virtual void parseNamespaceAlias(NamespaceAliasAST *node);
|
|
74 |
virtual void parseUsing(UsingAST *node);
|
|
75 |
virtual void parseUsingDirective(UsingDirectiveAST *node);
|
|
76 |
virtual void parseDeclarator(DeclaratorAST *node);
|
|
77 |
virtual void parseParameterDeclaration(ParameterDeclarationAST *node);
|
|
78 |
virtual void parseParameterDeclarationList(ParameterDeclarationListAST *node);
|
|
79 |
virtual void parseParameterDeclarationClause(ParameterDeclarationClauseAST *node);
|
|
80 |
virtual void parseInitDeclarator(InitDeclaratorAST *node);
|
|
81 |
virtual void parseInitDeclaratorList(InitDeclaratorListAST *node);
|
|
82 |
virtual void parseTypedef(TypedefAST *node);
|
|
83 |
virtual void parseTemplateParameter(TemplateParameterAST *node);
|
|
84 |
virtual void parseTemplateParameterList(TemplateParameterListAST *node);
|
|
85 |
virtual void parseTemplateDeclaration(TemplateDeclarationAST *node);
|
|
86 |
virtual void parseSimpleDeclaration(SimpleDeclarationAST *node);
|
|
87 |
virtual void parseStatement(StatementAST *node);
|
|
88 |
virtual void parseExpressionStatement(ExpressionStatementAST *node);
|
|
89 |
virtual void parseCondition(ConditionAST *node);
|
|
90 |
virtual void parseIfStatement(IfStatementAST *node);
|
|
91 |
virtual void parseWhileStatement(WhileStatementAST *node);
|
|
92 |
virtual void parseDoStatement(DoStatementAST *node);
|
|
93 |
virtual void parseForStatement(ForStatementAST *node);
|
|
94 |
virtual void parseSwitchStatement(SwitchStatementAST *node);
|
|
95 |
virtual void parseLabeledStatement(LabeledStatementAST *node);
|
|
96 |
virtual void parseReturnStatement(ReturnStatementAST *node);
|
|
97 |
virtual void parseStatementList(StatementListAST *node);
|
|
98 |
virtual void parseDeclarationStatement(DeclarationStatementAST *node);
|
|
99 |
virtual void parseFunctionDefinition(FunctionDefinitionAST *node);
|
|
100 |
virtual void parseTranslationUnit(TranslationUnitAST *node);
|
|
101 |
virtual void parseExpression(AbstractExpressionAST *node);
|
|
102 |
virtual void parseBinaryExpression(BinaryExpressionAST *node);
|
|
103 |
};
|
|
104 |
|
|
105 |
inline void TreeWalker::parseNode(AST *node)
|
|
106 |
{
|
|
107 |
if (!node)
|
|
108 |
return;
|
|
109 |
|
|
110 |
switch(node->nodeType()) {
|
|
111 |
|
|
112 |
case NodeType_Declaration:
|
|
113 |
case NodeType_AccessDeclaration:
|
|
114 |
case NodeType_LinkageSpecification:
|
|
115 |
case NodeType_Namespace:
|
|
116 |
case NodeType_NamespaceAlias:
|
|
117 |
case NodeType_Using:
|
|
118 |
case NodeType_UsingDirective:
|
|
119 |
case NodeType_Typedef:
|
|
120 |
case NodeType_TemplateDeclaration:
|
|
121 |
case NodeType_SimpleDeclaration:
|
|
122 |
case NodeType_FunctionDefinition:
|
|
123 |
parseDeclaration(static_cast<DeclarationAST*>(node));
|
|
124 |
break;
|
|
125 |
|
|
126 |
case NodeType_Statement:
|
|
127 |
case NodeType_ExpressionStatement:
|
|
128 |
case NodeType_IfStatement:
|
|
129 |
case NodeType_WhileStatement:
|
|
130 |
case NodeType_DoStatement:
|
|
131 |
case NodeType_ForStatement:
|
|
132 |
case NodeType_SwitchStatement:
|
|
133 |
case NodeType_LabeledStatement:
|
|
134 |
case NodeType_StatementList:
|
|
135 |
case NodeType_DeclarationStatement:
|
|
136 |
case NodeType_ReturnStatement:
|
|
137 |
parseStatement(static_cast<StatementAST*>(node));
|
|
138 |
break;
|
|
139 |
|
|
140 |
case NodeType_TypeSpecifier:
|
|
141 |
case NodeType_ClassSpecifier:
|
|
142 |
case NodeType_EnumSpecifier:
|
|
143 |
case NodeType_ElaboratedTypeSpecifier:
|
|
144 |
parseTypeSpecifier(static_cast<TypeSpecifierAST*>(node));
|
|
145 |
break;
|
|
146 |
|
|
147 |
case NodeType_TemplateArgumentList:
|
|
148 |
parseTemplateArgumentList(static_cast<TemplateArgumentListAST*>(node));
|
|
149 |
break;
|
|
150 |
case NodeType_ClassOrNamespaceName:
|
|
151 |
parseClassOrNamespaceName(static_cast<ClassOrNamespaceNameAST*>(node));
|
|
152 |
break;
|
|
153 |
case NodeType_Name:
|
|
154 |
parseName(static_cast<NameAST*>(node));
|
|
155 |
break;
|
|
156 |
case NodeType_TypeParameter:
|
|
157 |
parseTypeParameter(static_cast<TypeParameterAST*>(node));
|
|
158 |
break;
|
|
159 |
case NodeType_BaseSpecifier:
|
|
160 |
parseBaseSpecifier(static_cast<BaseSpecifierAST*>(node));
|
|
161 |
break;
|
|
162 |
case NodeType_BaseClause:
|
|
163 |
parseBaseClause(static_cast<BaseClauseAST*>(node));
|
|
164 |
break;
|
|
165 |
case NodeType_Enumerator:
|
|
166 |
parseEnumerator(static_cast<EnumeratorAST*>(node));
|
|
167 |
break;
|
|
168 |
case NodeType_LinkageBody:
|
|
169 |
parseLinkageBody(static_cast<LinkageBodyAST*>(node));
|
|
170 |
break;
|
|
171 |
case NodeType_Declarator:
|
|
172 |
parseDeclarator(static_cast<DeclaratorAST*>(node));
|
|
173 |
break;
|
|
174 |
case NodeType_ParameterDeclaration:
|
|
175 |
parseParameterDeclaration(static_cast<ParameterDeclarationAST*>(node));
|
|
176 |
break;
|
|
177 |
case NodeType_ParameterDeclarationList:
|
|
178 |
parseParameterDeclarationList(static_cast<ParameterDeclarationListAST*>(node));
|
|
179 |
break;
|
|
180 |
case NodeType_ParameterDeclarationClause:
|
|
181 |
parseParameterDeclarationClause(static_cast<ParameterDeclarationClauseAST*>(node));
|
|
182 |
break;
|
|
183 |
case NodeType_InitDeclarator:
|
|
184 |
parseInitDeclarator(static_cast<InitDeclaratorAST*>(node));
|
|
185 |
break;
|
|
186 |
case NodeType_InitDeclaratorList:
|
|
187 |
parseInitDeclaratorList(static_cast<InitDeclaratorListAST*>(node));
|
|
188 |
break;
|
|
189 |
case NodeType_TemplateParameter:
|
|
190 |
parseTemplateParameter(static_cast<TemplateParameterAST*>(node));
|
|
191 |
break;
|
|
192 |
case NodeType_TemplateParameterList:
|
|
193 |
parseTemplateParameterList(static_cast<TemplateParameterListAST*>(node));
|
|
194 |
break;
|
|
195 |
case NodeType_Condition:
|
|
196 |
parseCondition(static_cast<ConditionAST*>(node));
|
|
197 |
break;
|
|
198 |
case NodeType_TranslationUnit:
|
|
199 |
parseTranslationUnit(static_cast<TranslationUnitAST*>(node));
|
|
200 |
break;
|
|
201 |
|
|
202 |
case NodeType_BinaryExpression:
|
|
203 |
parseBinaryExpression(static_cast<BinaryExpressionAST*>(node));
|
|
204 |
break;
|
|
205 |
|
|
206 |
case NodeType_Expression:
|
|
207 |
case NodeType_PrimaryExpression:
|
|
208 |
|
|
209 |
case NodeType_PostfixExpression:
|
|
210 |
case NodeType_Subscripting:
|
|
211 |
case NodeType_FunctionCall:
|
|
212 |
case NodeType_ExplicitTypeConversion:
|
|
213 |
case NodeType_PseudoConstructorCall:
|
|
214 |
case NodeType_ClassMemberAccess:
|
|
215 |
case NodeType_IncrDecr:
|
|
216 |
case NodeType_CppCastExpression:
|
|
217 |
case NodeType_TypeIdentification:
|
|
218 |
|
|
219 |
case NodeType_UnaryExpression:
|
|
220 |
case NodeType_NewExpression:
|
|
221 |
case NodeType_NewTypeId:
|
|
222 |
case NodeType_NewDeclarator:
|
|
223 |
case NodeType_NewInitializer:
|
|
224 |
case NodeType_DeleteExpression:
|
|
225 |
case NodeType_CastExpression:
|
|
226 |
case NodeType_ConditionalExpression:
|
|
227 |
case NodeType_ThrowExpression:
|
|
228 |
parseExpression(static_cast<AbstractExpressionAST*>(node));
|
|
229 |
break;
|
|
230 |
}
|
|
231 |
}
|
|
232 |
|
|
233 |
QT_END_NAMESPACE
|
|
234 |
|
|
235 |
#endif // TREEWALKER_H
|