author | Eckhart Koeppen <eckhart.koppen@nokia.com> |
Thu, 22 Apr 2010 16:15:11 +0300 | |
branch | RCL_3 |
changeset 14 | 8c4229025c0b |
parent 4 | 3b1da2848fc7 |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
3 |
** Copyright (C) 2001-2004 Roberto Raggi |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 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 PARSER_H |
|
44 |
#define PARSER_H |
|
45 |
||
46 |
#include "ast.h" |
|
47 |
#include "tokenstreamadapter.h" |
|
48 |
||
49 |
#include <QString> |
|
50 |
#include <QStringList> |
|
51 |
#include <QList> |
|
52 |
||
53 |
QT_BEGIN_NAMESPACE |
|
54 |
||
55 |
class FileSymbol; |
|
56 |
class TokenStream; |
|
57 |
class Error; |
|
58 |
||
59 |
class Parser |
|
60 |
{ |
|
61 |
public: |
|
62 |
Parser(); |
|
63 |
~Parser(); |
|
64 |
||
65 |
// TranslationUnitAST *parse(FileSymbol *file, pool *p); |
|
66 |
TranslationUnitAST *parse(TokenStreamAdapter::TokenStream *tokenStream, pool *p); |
|
67 |
TranslationUnitAST *parse(TokenStreamAdapter::TokenStream *tokenStream, pool *p, int targetMaxASTnodes, bool &done); |
|
68 |
private: |
|
69 |
bool reportError(const Error& err); |
|
70 |
/** @todo remove*/ bool reportError(const QString& msg); |
|
71 |
/** @todo remove*/ void syntaxError(); |
|
72 |
||
73 |
public /*rules*/ : |
|
74 |
||
75 |
bool parseTranslationUnit(TranslationUnitAST *&node); |
|
76 |
||
77 |
bool parseDeclaration(DeclarationAST *&node); |
|
78 |
bool parseBlockDeclaration(DeclarationAST *&node); |
|
79 |
bool parseLinkageSpecification(DeclarationAST *&node); |
|
80 |
bool parseLinkageBody(LinkageBodyAST *&node); |
|
81 |
bool parseNamespace(DeclarationAST *&node); |
|
82 |
bool parseNamespaceAliasDefinition(DeclarationAST *&node); |
|
83 |
bool parseUsing(DeclarationAST *&node); |
|
84 |
bool parseUsingDirective(DeclarationAST *&node); |
|
85 |
bool parseTypedef(DeclarationAST *&node); |
|
86 |
bool parseAsmDefinition(DeclarationAST *&node); |
|
87 |
bool parseTemplateDeclaration(DeclarationAST *&node); |
|
88 |
bool parseDeclarationInternal(DeclarationAST *&node); |
|
89 |
||
90 |
bool parseStringLiteral(AST *&node); |
|
91 |
bool parseUnqualifiedName(ClassOrNamespaceNameAST *&node, bool parseTemplateId = true); |
|
92 |
bool parseName(NameAST *&node, bool parseTemplateId = true); |
|
93 |
bool parseOperatorFunctionId(AST *&node); |
|
94 |
bool parseTemplateArgumentList(TemplateArgumentListAST *&node, bool reportError = true); |
|
95 |
bool parseOperator(AST *&node); |
|
96 |
bool parseCvQualify(AST *&node); |
|
97 |
bool parseSimpleTypeSpecifier(TypeSpecifierAST *&node, bool onlyIntegral = false); |
|
98 |
bool parsePtrOperator(AST *&node); |
|
99 |
bool parseTemplateArgument(AST *&node); |
|
100 |
bool parseTypeSpecifier(TypeSpecifierAST *&node); |
|
101 |
bool parseTypeSpecifierOrClassSpec(TypeSpecifierAST *&node); |
|
102 |
bool parseDeclarator(DeclaratorAST *&node); |
|
103 |
bool parseTemplateParameterList(TemplateParameterListAST *&node); |
|
104 |
bool parseTemplateParameter(TemplateParameterAST *&node); |
|
105 |
bool parseStorageClassSpecifier(AST *&node); |
|
106 |
bool parseFunctionSpecifier(AST *&node); |
|
107 |
bool parseInitDeclaratorList(InitDeclaratorListAST *&node); |
|
108 |
bool parseInitDeclarator(InitDeclaratorAST *&node); |
|
109 |
bool parseParameterDeclarationClause(ParameterDeclarationClauseAST *&node); |
|
110 |
bool parseCtorInitializer(AST *&node); |
|
111 |
bool parsePtrToMember(AST *&node); |
|
112 |
bool parseEnumSpecifier(TypeSpecifierAST *&node); |
|
113 |
bool parseClassSpecifier(TypeSpecifierAST *&node); |
|
114 |
bool parseWinDeclSpec(AST *&node); |
|
115 |
bool parseElaboratedTypeSpecifier(TypeSpecifierAST *&node); |
|
116 |
bool parseDeclaratorId(NameAST *&node); |
|
117 |
bool parseExceptionSpecification(AST *&node); |
|
118 |
bool parseEnumerator(EnumeratorAST *&node); |
|
119 |
bool parseTypeParameter(TypeParameterAST *&node); |
|
120 |
bool parseParameterDeclaration(ParameterDeclarationAST *&node); |
|
121 |
bool parseTypeId(TypeIdAST *&node); |
|
122 |
bool parseAbstractDeclarator(DeclaratorAST *&node); |
|
123 |
bool parseParameterDeclarationList(ParameterDeclarationListAST *&node); |
|
124 |
bool parseMemberSpecification(DeclarationAST *&node); |
|
125 |
bool parseAccessSpecifier(AST *&node); |
|
126 |
bool parseTypeIdList(AST *&node); |
|
127 |
bool parseMemInitializerList(AST *&node); |
|
128 |
bool parseMemInitializer(AST *&node); |
|
129 |
bool parseInitializer(AST *&node); |
|
130 |
bool parseBaseClause(BaseClauseAST *&node); |
|
131 |
bool parseBaseSpecifier(BaseSpecifierAST *&node); |
|
132 |
bool parseInitializerClause(AST *&node); |
|
133 |
bool parseMemInitializerId(NameAST *&node); |
|
134 |
bool parseFunctionBody(StatementListAST *&node); |
|
135 |
||
136 |
// expression |
|
137 |
bool skipExpression(AbstractExpressionAST *&node); |
|
138 |
bool skipCommaExpression(AbstractExpressionAST *&node); |
|
139 |
bool skipExpressionStatement(StatementAST *&node); |
|
140 |
||
141 |
bool parseExpression(AbstractExpressionAST *&node); |
|
142 |
bool parsePrimaryExpression(AbstractExpressionAST *&node); |
|
143 |
bool parsePostfixExpression(AbstractExpressionAST *&node); |
|
144 |
bool parsePostfixExpressionInternal(AbstractExpressionAST *expr, AbstractExpressionAST *&node); |
|
145 |
bool parseUnaryExpression(AbstractExpressionAST *&node); |
|
146 |
bool parseNewExpression(AbstractExpressionAST *&node); |
|
147 |
bool parseNewTypeId(AbstractExpressionAST *&node); |
|
148 |
bool parseNewDeclarator(AbstractExpressionAST *&node); |
|
149 |
bool parseNewInitializer(AbstractExpressionAST *&node); |
|
150 |
bool parseDeleteExpression(AbstractExpressionAST *&node); |
|
151 |
bool parseCastExpression(AbstractExpressionAST *&node); |
|
152 |
bool parsePmExpression(AbstractExpressionAST *&node); |
|
153 |
bool parseMultiplicativeExpression(AbstractExpressionAST *&node); |
|
154 |
bool parseAdditiveExpression(AbstractExpressionAST *&node); |
|
155 |
bool parseShiftExpression(AbstractExpressionAST *&node); |
|
156 |
bool parseRelationalExpression(AbstractExpressionAST *&node, bool templArgs = false); |
|
157 |
bool parseEqualityExpression(AbstractExpressionAST *&node, bool templArgs = false); |
|
158 |
bool parseAndExpression(AbstractExpressionAST *&node, bool templArgs = false); |
|
159 |
bool parseExclusiveOrExpression(AbstractExpressionAST *&node, bool templArgs = false); |
|
160 |
bool parseInclusiveOrExpression(AbstractExpressionAST *&node, bool templArgs = false); |
|
161 |
bool parseLogicalAndExpression(AbstractExpressionAST *&node, bool templArgs = false); |
|
162 |
bool parseLogicalOrExpression(AbstractExpressionAST *&node, bool templArgs = false); |
|
163 |
bool parseConditionalExpression(AbstractExpressionAST *&node); |
|
164 |
bool parseAssignmentExpression(AbstractExpressionAST *&node); |
|
165 |
bool parseConstantExpression(AbstractExpressionAST *&node); |
|
166 |
bool parseCommaExpression(AbstractExpressionAST *&node); |
|
167 |
bool parseThrowExpression(AbstractExpressionAST *&node); |
|
168 |
||
169 |
// statement |
|
170 |
bool parseCondition(ConditionAST *&node); |
|
171 |
bool parseStatement(StatementAST *&node); |
|
172 |
bool parseWhileStatement(StatementAST *&node); |
|
173 |
bool parseDoStatement(StatementAST *&node); |
|
174 |
bool parseForStatement(StatementAST *&node); |
|
175 |
bool parseCompoundStatement(StatementAST *&node); |
|
176 |
bool parseForInitStatement(StatementAST *&node); |
|
177 |
bool parseIfStatement(StatementAST *&node); |
|
178 |
bool parseSwitchStatement(StatementAST *&node); |
|
179 |
bool parseLabeledStatement(StatementAST *&node); |
|
180 |
bool parseDeclarationStatement(StatementAST *&node); |
|
181 |
bool parseTryBlockStatement(StatementAST *&node); |
|
182 |
||
183 |
// objective c |
|
184 |
bool parseObjcDef(DeclarationAST *&node); |
|
185 |
bool parseObjcClassDef(DeclarationAST *&node); |
|
186 |
bool parseObjcClassDecl(DeclarationAST *&node); |
|
187 |
bool parseObjcProtocolDecl(DeclarationAST *&node); |
|
188 |
bool parseObjcAliasDecl(DeclarationAST *&node); |
|
189 |
bool parseObjcProtocolDef(DeclarationAST *&node); |
|
190 |
bool parseObjcMethodDef(DeclarationAST *&node); |
|
191 |
||
192 |
bool parseIvarDeclList(AST *&node); |
|
193 |
bool parseIvarDecls(AST *&node); |
|
194 |
bool parseIvarDecl(AST *&node); |
|
195 |
bool parseIvars(AST *&node); |
|
196 |
bool parseIvarDeclarator(AST *&node); |
|
197 |
bool parseMethodDecl(AST *&node); |
|
198 |
bool parseUnarySelector(AST *&node); |
|
199 |
bool parseKeywordSelector(AST *&node); |
|
200 |
bool parseSelector(AST *&node); |
|
201 |
bool parseKeywordDecl(AST *&node); |
|
202 |
bool parseReceiver(AST *&node); |
|
203 |
bool parseObjcMessageExpr(AST *&node); |
|
204 |
bool parseMessageArgs(AST *&node); |
|
205 |
bool parseKeywordExpr(AST *&node); |
|
206 |
bool parseKeywordArgList(AST *&node); |
|
207 |
bool parseKeywordArg(AST *&node); |
|
208 |
bool parseReservedWord(AST *&node); |
|
209 |
bool parseMyParms(AST *&node); |
|
210 |
bool parseMyParm(AST *&node); |
|
211 |
bool parseOptParmList(AST *&node); |
|
212 |
bool parseObjcSelectorExpr(AST *&node); |
|
213 |
bool parseSelectorArg(AST *&node); |
|
214 |
bool parseKeywordNameList(AST *&node); |
|
215 |
bool parseKeywordName(AST *&node); |
|
216 |
bool parseObjcEncodeExpr(AST *&node); |
|
217 |
bool parseObjcString(AST *&node); |
|
218 |
bool parseProtocolRefs(AST *&node); |
|
219 |
bool parseIdentifierList(AST *&node); |
|
220 |
bool parseIdentifierColon(AST *&node); |
|
221 |
bool parseObjcProtocolExpr(AST *&node); |
|
222 |
bool parseObjcOpenBracketExpr(AST *&node); |
|
223 |
bool parseObjcCloseBracket(AST *&node); |
|
224 |
||
225 |
bool skipUntil(int token); |
|
226 |
bool skipUntilDeclaration(); |
|
227 |
bool skipUntilStatement(); |
|
228 |
bool skip(int l, int r); |
|
229 |
||
230 |
void advance(); |
|
231 |
||
232 |
private: |
|
233 |
int m_problems; |
|
234 |
int m_maxProblems; |
|
235 |
bool objcp; |
|
236 |
TokenStreamAdapter::TokenStream *tokenStream; |
|
237 |
pool *m_pool; |
|
238 |
FileSymbol *m_file; |
|
239 |
||
240 |
private: |
|
241 |
Parser(const Parser& source); |
|
242 |
void operator = (const Parser& source); |
|
243 |
}; |
|
244 |
||
245 |
QT_END_NAMESPACE |
|
246 |
||
247 |
#endif |