Mercurial > projects > qtd
annotate generator/parser/parser.h @ 392:6bd75093d3bb
Allow specifying the location the resulting D modules are installed to.
author | David Nadlinger <code@klickverbot.at> |
---|---|
date | Sat, 28 Aug 2010 02:17:15 +0200 |
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 PARSER_H | |
46 #define PARSER_H | |
47 | |
48 #include "ast.h" | |
49 #include "lexer.h" | |
50 | |
51 #include <QtCore/QString> | |
52 | |
53 class FileSymbol; | |
54 class Control; | |
55 | |
56 class Parser | |
57 { | |
58 public: | |
59 Parser(Control *control); | |
60 ~Parser(); | |
61 | |
62 LocationManager &location() { return _M_location; } | |
63 | |
64 TranslationUnitAST *parse(const char *contents, std::size_t size, pool *p); | |
65 | |
66 private: | |
67 void reportError(const QString& msg); | |
68 void syntaxError(); | |
69 void tokenRequiredError(int expected); | |
70 | |
71 public: | |
72 bool skipFunctionBody(StatementAST *&node); | |
73 | |
74 public: | |
75 bool parse_Attribute__(); | |
76 bool parseAbstractDeclarator(DeclaratorAST *&node); | |
77 bool parseAccessSpecifier(DeclarationAST *&node); | |
78 bool parseAdditiveExpression(ExpressionAST *&node); | |
79 bool parseAndExpression(ExpressionAST *&node, bool templArgs = false); | |
80 bool parseAsmDefinition(DeclarationAST *&node); | |
81 bool parseAssignmentExpression(ExpressionAST *&node); | |
82 bool parseBaseClause(BaseClauseAST *&node); | |
83 bool parseBaseSpecifier(BaseSpecifierAST *&node); | |
84 bool parseBlockDeclaration(DeclarationAST *&node); | |
85 bool parseCastExpression(ExpressionAST *&node); | |
86 bool parseClassSpecifier(TypeSpecifierAST *&node); | |
87 bool parseForwardDeclarationSpecifier(TypeSpecifierAST *&node); | |
88 bool parseCommaExpression(ExpressionAST *&node); | |
89 bool parseCompoundStatement(StatementAST *&node); | |
90 bool parseCondition(ConditionAST *&node, bool initRequired = true); | |
91 bool parseConditionalExpression(ExpressionAST *&node); | |
92 bool parseConstantExpression(ExpressionAST *&node); | |
93 bool parseCtorInitializer(CtorInitializerAST *&node); | |
94 bool parseCvQualify(const ListNode<std::size_t> *&node); | |
95 bool parseDeclaration(DeclarationAST *&node); | |
96 bool parseDeclarationInternal(DeclarationAST *&node); | |
97 bool parseDeclarationStatement(StatementAST *&node); | |
98 bool parseDeclarator(DeclaratorAST *&node); | |
99 bool parseDeleteExpression(ExpressionAST *&node); | |
100 bool parseDoStatement(StatementAST *&node); | |
101 bool parseElaboratedTypeSpecifier(TypeSpecifierAST *&node); | |
102 bool parseEnumSpecifier(TypeSpecifierAST *&node); | |
103 bool parseEnumerator(EnumeratorAST *&node); | |
104 bool parseEqualityExpression(ExpressionAST *&node, | |
105 bool templArgs = false); | |
106 bool parseExceptionSpecification(ExceptionSpecificationAST *&node); | |
107 bool parseExclusiveOrExpression(ExpressionAST *&node, | |
108 bool templArgs = false); | |
109 bool parseExpression(ExpressionAST *&node); | |
110 bool parseExpressionOrDeclarationStatement(StatementAST *&node); | |
111 bool parseExpressionStatement(StatementAST *&node); | |
112 bool parseForInitStatement(StatementAST *&node); | |
113 bool parseForStatement(StatementAST *&node); | |
114 bool parseFunctionBody(StatementAST *&node); | |
115 bool parseFunctionSpecifier(const ListNode<std::size_t> *&node); | |
116 bool parseIfStatement(StatementAST *&node); | |
117 bool parseInclusiveOrExpression(ExpressionAST *&node, | |
118 bool templArgs = false); | |
119 bool parseInitDeclarator(InitDeclaratorAST *&node); | |
120 bool parseInitDeclaratorList(const ListNode<InitDeclaratorAST*> *&node); | |
121 bool parseInitializer(InitializerAST *&node); | |
122 bool parseInitializerClause(InitializerClauseAST *&node); | |
123 bool parseLabeledStatement(StatementAST *&node); | |
124 bool parseLinkageBody(LinkageBodyAST *&node); | |
125 bool parseLinkageSpecification(DeclarationAST *&node); | |
126 bool parseLogicalAndExpression(ExpressionAST *&node, | |
127 bool templArgs = false); | |
128 bool parseLogicalOrExpression(ExpressionAST *&node, | |
129 bool templArgs = false); | |
130 bool parseMemInitializer(MemInitializerAST *&node); | |
131 bool parseMemInitializerList(const ListNode<MemInitializerAST*> *&node); | |
132 bool parseMemberSpecification(DeclarationAST *&node); | |
133 bool parseMultiplicativeExpression(ExpressionAST *&node); | |
134 bool parseName(NameAST *&node, bool acceptTemplateId = false); | |
135 bool parseNamespace(DeclarationAST *&node); | |
136 bool parseNamespaceAliasDefinition(DeclarationAST *&node); | |
137 bool parseNewDeclarator(NewDeclaratorAST *&node); | |
138 bool parseNewExpression(ExpressionAST *&node); | |
139 bool parseNewInitializer(NewInitializerAST *&node); | |
140 bool parseNewTypeId(NewTypeIdAST *&node); | |
141 bool parseOperator(OperatorAST *&node); | |
142 bool parseOperatorFunctionId(OperatorFunctionIdAST *&node); | |
143 bool parseParameterDeclaration(ParameterDeclarationAST *&node); | |
144 bool parseParameterDeclarationClause(ParameterDeclarationClauseAST *&node); | |
145 bool parseParameterDeclarationList(const ListNode<ParameterDeclarationAST*> *&node); | |
146 bool parsePmExpression(ExpressionAST *&node); | |
147 bool parsePostfixExpression(ExpressionAST *&node); | |
148 bool parsePostfixExpressionInternal(ExpressionAST *&node); | |
149 bool parsePrimaryExpression(ExpressionAST *&node); | |
150 bool parsePtrOperator(PtrOperatorAST *&node); | |
151 bool parsePtrToMember(PtrToMemberAST *&node); | |
152 bool parseRelationalExpression(ExpressionAST *&node, | |
153 bool templArgs = false); | |
154 bool parseShiftExpression(ExpressionAST *&node); | |
155 bool parseSimpleTypeSpecifier(TypeSpecifierAST *&node, | |
156 bool onlyIntegral = false); | |
157 bool parseStatement(StatementAST *&node); | |
158 bool parseStorageClassSpecifier(const ListNode<std::size_t> *&node); | |
159 bool parseStringLiteral(StringLiteralAST *&node); | |
160 bool parseSwitchStatement(StatementAST *&node); | |
161 bool parseTemplateArgument(TemplateArgumentAST *&node); | |
162 bool parseTemplateArgumentList(const ListNode<TemplateArgumentAST*> *&node, | |
163 bool reportError = true); | |
164 bool parseTemplateDeclaration(DeclarationAST *&node); | |
165 bool parseTemplateParameter(TemplateParameterAST *&node); | |
166 bool parseTemplateParameterList(const ListNode<TemplateParameterAST*> *&node); | |
167 bool parseThrowExpression(ExpressionAST *&node); | |
168 bool parseTranslationUnit(TranslationUnitAST *&node); | |
169 bool parseTryBlockStatement(StatementAST *&node); | |
170 bool parseTypeId(TypeIdAST *&node); | |
171 bool parseTypeIdList(const ListNode<TypeIdAST*> *&node); | |
172 bool parseTypeParameter(TypeParameterAST *&node); | |
173 bool parseTypeSpecifier(TypeSpecifierAST *&node); | |
174 bool parseTypeSpecifierOrClassSpec(TypeSpecifierAST *&node); | |
175 bool parseTypedef(DeclarationAST *&node); | |
176 bool parseUnaryExpression(ExpressionAST *&node); | |
177 bool parseUnqualifiedName(UnqualifiedNameAST *&node, | |
178 bool parseTemplateId = true); | |
179 bool parseUsing(DeclarationAST *&node); | |
180 bool parseUsingDirective(DeclarationAST *&node); | |
181 bool parseWhileStatement(StatementAST *&node); | |
182 bool parseWinDeclSpec(WinDeclSpecAST *&node); | |
183 | |
184 bool parseQ_PROPERTY(DeclarationAST *&node); | |
185 bool parseQ_ENUMS(DeclarationAST *&node); | |
186 | |
187 bool skipUntil(int token); | |
188 bool skipUntilDeclaration(); | |
189 bool skipUntilStatement(); | |
190 bool skip(int l, int r); | |
191 | |
192 void advance(); | |
193 | |
194 // private: | |
195 TokenStream token_stream; | |
196 LocationTable location_table; | |
197 LocationTable line_table; | |
198 | |
199 bool block_errors(bool block); | |
200 | |
201 private: | |
202 QString tokenText(AST *) const; | |
203 | |
204 LocationManager _M_location; | |
205 Control *control; | |
206 Lexer lexer; | |
207 pool *_M_pool; | |
208 bool _M_block_errors; | |
209 | |
210 private: | |
211 Parser(const Parser& source); | |
212 void operator = (const Parser& source); | |
213 }; | |
214 | |
215 #endif | |
216 | |
217 // kate: space-indent on; indent-width 2; replace-tabs on; |