1 /****************************************************************************
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the QtDeclarative module of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** No Commercial Usage
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
16 ** GNU Lesser General Public License Usage
17 ** Alternatively, this file may be used under the terms of the GNU Lesser
18 ** General Public License version 2.1 as published by the Free Software
19 ** Foundation and appearing in the file LICENSE.LGPL included in the
20 ** packaging of this file. Please review the following information to
21 ** ensure the GNU Lesser General Public License version 2.1 requirements
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 ** In addition, as a special exception, Nokia gives you certain additional
25 ** rights. These rights are described in the Nokia Qt LGPL Exception
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
40 ****************************************************************************/
47 // This file is not part of the Qt API. It exists purely as an
48 // implementation detail. This header file may change from version to
49 // version without notice, or even be removed.
55 // This file is automatically generated from qmljs.g.
56 // Changes will be lost.
59 #ifndef QDECLARATIVEJSPARSER_P_H
60 #define QDECLARATIVEJSPARSER_P_H
62 #include "private/qdeclarativejsglobal_p.h"
63 #include "private/qdeclarativejsgrammar_p.h"
64 #include "private/qdeclarativejsast_p.h"
65 #include "private/qdeclarativejsengine_p.h"
67 #include <QtCore/QList>
68 #include <QtCore/QString>
70 QT_QML_BEGIN_NAMESPACE
72 namespace QDeclarativeJS {
77 class QML_PARSER_EXPORT Parser: protected QDeclarativeJSGrammar
84 AST::ArgumentList *ArgumentList;
85 AST::CaseBlock *CaseBlock;
86 AST::CaseClause *CaseClause;
87 AST::CaseClauses *CaseClauses;
89 AST::DefaultClause *DefaultClause;
90 AST::ElementList *ElementList;
91 AST::Elision *Elision;
92 AST::ExpressionNode *Expression;
93 AST::Finally *Finally;
94 AST::FormalParameterList *FormalParameterList;
95 AST::FunctionBody *FunctionBody;
96 AST::FunctionDeclaration *FunctionDeclaration;
98 AST::PropertyName *PropertyName;
99 AST::PropertyNameAndValueList *PropertyNameAndValueList;
100 AST::SourceElement *SourceElement;
101 AST::SourceElements *SourceElements;
102 AST::Statement *Statement;
103 AST::StatementList *StatementList;
105 AST::VariableDeclaration *VariableDeclaration;
106 AST::VariableDeclarationList *VariableDeclarationList;
108 AST::UiProgram *UiProgram;
109 AST::UiImportList *UiImportList;
110 AST::UiImport *UiImport;
111 AST::UiParameterList *UiParameterList;
112 AST::UiPublicMember *UiPublicMember;
113 AST::UiObjectDefinition *UiObjectDefinition;
114 AST::UiObjectInitializer *UiObjectInitializer;
115 AST::UiObjectBinding *UiObjectBinding;
116 AST::UiScriptBinding *UiScriptBinding;
117 AST::UiArrayBinding *UiArrayBinding;
118 AST::UiObjectMember *UiObjectMember;
119 AST::UiObjectMemberList *UiObjectMemberList;
120 AST::UiArrayMemberList *UiArrayMemberList;
121 AST::UiQualifiedId *UiQualifiedId;
122 AST::UiSignature *UiSignature;
123 AST::UiFormalList *UiFormalList;
124 AST::UiFormal *UiFormal;
128 Parser(Engine *engine);
131 // parse a UI program
132 bool parse() { return parse(T_FEED_UI_PROGRAM); }
133 bool parseStatement() { return parse(T_FEED_JS_STATEMENT); }
134 bool parseExpression() { return parse(T_FEED_JS_EXPRESSION); }
135 bool parseSourceElement() { return parse(T_FEED_JS_SOURCE_ELEMENT); }
136 bool parseUiObjectMember() { return parse(T_FEED_UI_OBJECT_MEMBER); }
137 bool parseProgram() { return parse(T_FEED_JS_PROGRAM); }
139 AST::UiProgram *ast() const
140 { return AST::cast<AST::UiProgram *>(program); }
142 AST::Statement *statement() const
147 return program->statementCast();
150 AST::ExpressionNode *expression() const
155 return program->expressionCast();
158 AST::UiObjectMember *uiObjectMember() const
163 return program->uiObjectMemberCast();
166 AST::Node *rootNode() const
169 QList<DiagnosticMessage> diagnosticMessages() const
170 { return diagnostic_messages; }
172 inline DiagnosticMessage diagnosticMessage() const
174 foreach (const DiagnosticMessage &d, diagnostic_messages) {
175 if (! d.kind == DiagnosticMessage::Warning)
179 return DiagnosticMessage();
182 inline QString errorMessage() const
183 { return diagnosticMessage().message; }
185 inline int errorLineNumber() const
186 { return diagnosticMessage().loc.startLine; }
188 inline int errorColumnNumber() const
189 { return diagnosticMessage().loc.startColumn; }
192 bool parse(int startToken);
194 void reallocateStack();
196 inline Value &sym(int index)
197 { return sym_stack [tos + index - 1]; }
199 inline AST::SourceLocation &loc(int index)
200 { return location_stack [tos + index - 1]; }
202 AST::UiQualifiedId *reparseAsQualifiedId(AST::ExpressionNode *expr);
210 AST::SourceLocation *location_stack;
215 enum { TOKEN_BUFFER_SIZE = 3 };
220 AST::SourceLocation loc;
224 AST::SourceLocation yylloc;
225 AST::SourceLocation yyprevlloc;
227 SavedToken token_buffer[TOKEN_BUFFER_SIZE];
228 SavedToken *first_token;
229 SavedToken *last_token;
231 QList<DiagnosticMessage> diagnostic_messages;
234 } // end of namespace QDeclarativeJS
238 #define J_SCRIPT_REGEXPLITERAL_RULE1 78
240 #define J_SCRIPT_REGEXPLITERAL_RULE2 79
246 #endif // QDECLARATIVEJSPARSER_P_H