diff options
Diffstat (limited to 'src/qml/parser')
-rw-r--r-- | src/qml/parser/parser.pri | 4 | ||||
-rw-r--r-- | src/qml/parser/qqmljs.g | 37 | ||||
-rw-r--r-- | src/qml/parser/qqmljsast_p.h | 2 | ||||
-rw-r--r-- | src/qml/parser/qqmljsastfwd_p.h | 2 | ||||
-rw-r--r-- | src/qml/parser/qqmljsengine_p.cpp | 4 | ||||
-rw-r--r-- | src/qml/parser/qqmljsengine_p.h | 6 | ||||
-rw-r--r-- | src/qml/parser/qqmljslexer.cpp | 8 | ||||
-rw-r--r-- | src/qml/parser/qqmljssourcelocation_p.h | 87 |
8 files changed, 30 insertions, 120 deletions
diff --git a/src/qml/parser/parser.pri b/src/qml/parser/parser.pri index e15730f5d1..57855a82f9 100644 --- a/src/qml/parser/parser.pri +++ b/src/qml/parser/parser.pri @@ -5,9 +5,7 @@ HEADERS += \ $$PWD/qqmljsengine_p.h \ $$PWD/qqmljslexer_p.h \ $$PWD/qqmljsglobal_p.h \ - $$PWD/qqmljskeywords_p.h \ - $$PWD/qqmljsengine_p.h \ - $$PWD/qqmljssourcelocation_p.h + $$PWD/qqmljskeywords_p.h SOURCES += \ $$PWD/qqmljsast.cpp \ diff --git a/src/qml/parser/qqmljs.g b/src/qml/parser/qqmljs.g index a246dfba7a..ef814a57b0 100644 --- a/src/qml/parser/qqmljs.g +++ b/src/qml/parser/qqmljs.g @@ -390,10 +390,10 @@ public: { return diagnosticMessage().message; } inline int errorLineNumber() const - { return diagnosticMessage().line; } + { return diagnosticMessage().loc.startLine; } inline int errorColumnNumber() const - { return diagnosticMessage().column; } + { return diagnosticMessage().loc.startColumn; } protected: bool parse(int startToken); @@ -409,7 +409,7 @@ protected: inline QStringRef &rawStringRef(int index) { return rawString_stack [tos + index - 1]; } - inline AST::SourceLocation &loc(int index) + inline SourceLocation &loc(int index) { return location_stack [tos + index - 1]; } AST::UiQualifiedId *reparseAsQualifiedId(AST::ExpressionNode *expr); @@ -417,21 +417,20 @@ protected: void pushToken(int token); int lookaheadToken(Lexer *lexer); - static DiagnosticMessage compileError(const AST::SourceLocation &location, + static DiagnosticMessage compileError(const SourceLocation &location, const QString &message, QtMsgType kind = QtCriticalMsg) { DiagnosticMessage error; - error.line = location.startLine; - error.column = location.startColumn; + error.loc = location; error.message = message; error.type = kind; return error; } - void syntaxError(const AST::SourceLocation &location, const char *message) { + void syntaxError(const SourceLocation &location, const char *message) { diagnostic_messages.append(compileError(location, QLatin1String(message))); } - void syntaxError(const AST::SourceLocation &location, const QString &message) { + void syntaxError(const SourceLocation &location, const QString &message) { diagnostic_messages.append(compileError(location, message)); } @@ -444,7 +443,7 @@ protected: int stack_size = 0; Value *sym_stack = nullptr; int *state_stack = nullptr; - AST::SourceLocation *location_stack = nullptr; + SourceLocation *location_stack = nullptr; QVector<QStringRef> string_stack; QVector<QStringRef> rawString_stack; @@ -456,7 +455,7 @@ protected: struct SavedToken { int token; double dval; - AST::SourceLocation loc; + SourceLocation loc; QStringRef spell; QStringRef raw; }; @@ -465,8 +464,8 @@ protected: double yylval = 0.; QStringRef yytokenspell; QStringRef yytokenraw; - AST::SourceLocation yylloc; - AST::SourceLocation yyprevlloc; + SourceLocation yylloc; + SourceLocation yyprevlloc; SavedToken token_buffer[TOKEN_BUFFER_SIZE]; SavedToken *first_token = nullptr; @@ -479,7 +478,7 @@ protected: CE_ParenthesizedExpression, CE_FormalParameterList }; - AST::SourceLocation coverExpressionErrorLocation; + SourceLocation coverExpressionErrorLocation; CoverExpressionType coverExpressionType = CE_Invalid; QList<DiagnosticMessage> diagnostic_messages; @@ -524,7 +523,7 @@ void Parser::reallocateStack() sym_stack = reinterpret_cast<Value*> (realloc(sym_stack, stack_size * sizeof(Value))); state_stack = reinterpret_cast<int*> (realloc(state_stack, stack_size * sizeof(int))); - location_stack = reinterpret_cast<AST::SourceLocation*> (realloc(location_stack, stack_size * sizeof(AST::SourceLocation))); + location_stack = reinterpret_cast<SourceLocation*> (realloc(location_stack, stack_size * sizeof(SourceLocation))); string_stack.resize(stack_size); rawString_stack.resize(stack_size); } @@ -544,9 +543,9 @@ Parser::~Parser() } } -static inline AST::SourceLocation location(Lexer *lexer) +static inline SourceLocation location(Lexer *lexer) { - AST::SourceLocation loc; + SourceLocation loc; loc.offset = lexer->tokenOffset(); loc.length = lexer->tokenLength(); loc.startLine = lexer->tokenStartLine(); @@ -557,7 +556,7 @@ static inline AST::SourceLocation location(Lexer *lexer) AST::UiQualifiedId *Parser::reparseAsQualifiedId(AST::ExpressionNode *expr) { QVarLengthArray<QStringRef, 4> nameIds; - QVarLengthArray<AST::SourceLocation, 4> locations; + QVarLengthArray<SourceLocation, 4> locations; AST::ExpressionNode *it = expr; while (AST::FieldMemberExpression *m = AST::cast<AST::FieldMemberExpression *>(it)) { @@ -2857,7 +2856,7 @@ AssignmentExpression_In: LeftHandSideExpression T_EQ AssignmentExpression_In; case $rule_number: { // need to convert the LHS to an AssignmentPattern if it was an Array/ObjectLiteral if (AST::Pattern *p = sym(1).Expression->patternCast()) { - AST::SourceLocation errorLoc; + SourceLocation errorLoc; QString errorMsg; if (!p->convertLiteralToAssignmentPattern(pool, &errorLoc, &errorMsg)) { syntaxError(errorLoc, errorMsg); @@ -3523,7 +3522,7 @@ IterationStatement: T_FOR T_LPAREN LeftHandSideExpression InOrOf Expression_In T case $rule_number: { // need to convert the LHS to an AssignmentPattern if it was an Array/ObjectLiteral if (AST::Pattern *p = sym(3).Expression->patternCast()) { - AST::SourceLocation errorLoc; + SourceLocation errorLoc; QString errorMsg; if (!p->convertLiteralToAssignmentPattern(pool, &errorLoc, &errorMsg)) { syntaxError(errorLoc, errorMsg); diff --git a/src/qml/parser/qqmljsast_p.h b/src/qml/parser/qqmljsast_p.h index b92a635228..de554a53af 100644 --- a/src/qml/parser/qqmljsast_p.h +++ b/src/qml/parser/qqmljsast_p.h @@ -1071,7 +1071,7 @@ public: PatternPropertyList *next; }; -class QML_PARSER_EXPORT IdentifierPropertyName : public PropertyName +class QML_PARSER_EXPORT IdentifierPropertyName: public PropertyName { public: QQMLJS_DECLARE_AST_NODE(IdentifierPropertyName) diff --git a/src/qml/parser/qqmljsastfwd_p.h b/src/qml/parser/qqmljsastfwd_p.h index 8df0be7590..ef37e8072f 100644 --- a/src/qml/parser/qqmljsastfwd_p.h +++ b/src/qml/parser/qqmljsastfwd_p.h @@ -41,7 +41,7 @@ #define QQMLJSAST_FWD_P_H #include "qqmljsglobal_p.h" -#include "qqmljssourcelocation_p.h" +#include <private/qqmljssourcelocation_p.h> #include <QtCore/qglobal.h> diff --git a/src/qml/parser/qqmljsengine_p.cpp b/src/qml/parser/qqmljsengine_p.cpp index bb27f3992e..cb6b0375e6 100644 --- a/src/qml/parser/qqmljsengine_p.cpp +++ b/src/qml/parser/qqmljsengine_p.cpp @@ -123,9 +123,9 @@ void Engine::setCode(const QString &code) { _code = code; } void Engine::addComment(int pos, int len, int line, int col) -{ if (len > 0) _comments.append(QQmlJS::AST::SourceLocation(pos, len, line, col)); } +{ if (len > 0) _comments.append(QQmlJS::SourceLocation(pos, len, line, col)); } -QList<QQmlJS::AST::SourceLocation> Engine::comments() const +QList<QQmlJS::SourceLocation> Engine::comments() const { return _comments; } Lexer *Engine::lexer() const diff --git a/src/qml/parser/qqmljsengine_p.h b/src/qml/parser/qqmljsengine_p.h index 8a3e2db6a1..a34922fa1e 100644 --- a/src/qml/parser/qqmljsengine_p.h +++ b/src/qml/parser/qqmljsengine_p.h @@ -52,7 +52,7 @@ // #include "qqmljsglobal_p.h" -#include "qqmljssourcelocation_p.h" +#include <private/qqmljssourcelocation_p.h> #include <private/qqmljsmemorypool_p.h> @@ -97,7 +97,7 @@ class QML_PARSER_EXPORT Engine Lexer *_lexer; Directives *_directives; MemoryPool _pool; - QList<AST::SourceLocation> _comments; + QList<SourceLocation> _comments; QString _extraCode; QString _code; @@ -109,7 +109,7 @@ public: const QString &code() const { return _code; } void addComment(int pos, int len, int line, int col); - QList<AST::SourceLocation> comments() const; + QList<SourceLocation> comments() const; Lexer *lexer() const; void setLexer(Lexer *lexer); diff --git a/src/qml/parser/qqmljslexer.cpp b/src/qml/parser/qqmljslexer.cpp index 0c61679f0b..243fc5bd30 100644 --- a/src/qml/parser/qqmljslexer.cpp +++ b/src/qml/parser/qqmljslexer.cpp @@ -1480,8 +1480,8 @@ bool Lexer::scanDirectives(Directives *directives, DiagnosticMessage *error) { auto setError = [error, this](QString message) { error->message = std::move(message); - error->line = tokenStartLine(); - error->column = tokenStartColumn(); + error->loc.startLine = tokenStartLine(); + error->loc.startColumn = tokenStartColumn(); }; QScopedValueRollback<bool> directivesGuard(_handlingDirectives, true); @@ -1596,8 +1596,8 @@ bool Lexer::scanDirectives(Directives *directives, DiagnosticMessage *error) else setError(QCoreApplication::translate("QQmlParser", "Module import requires a qualifier")); if (tokenStartLine() != lineNumber) { - error->line = lineNumber; - error->line = column; + error->loc.startLine = lineNumber; + error->loc.startColumn = column; } return false; // expected `as' } diff --git a/src/qml/parser/qqmljssourcelocation_p.h b/src/qml/parser/qqmljssourcelocation_p.h deleted file mode 100644 index d76e701d49..0000000000 --- a/src/qml/parser/qqmljssourcelocation_p.h +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QQMLJSSOURCELOCATION_P_H -#define QQMLJSSOURCELOCATION_P_H - -#include "qqmljsglobal_p.h" - -#include <QtCore/qglobal.h> - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -QT_BEGIN_NAMESPACE - -namespace QQmlJS { namespace AST { - -class SourceLocation -{ -public: - explicit SourceLocation(quint32 offset = 0, quint32 length = 0, quint32 line = 0, quint32 column = 0) - : offset(offset), length(length), - startLine(line), startColumn(column) - { } - - bool isValid() const { return length != 0; } - - quint32 begin() const { return offset; } - quint32 end() const { return offset + length; } - -// attributes - // ### encode - quint32 offset; - quint32 length; - quint32 startLine; - quint32 startColumn; -}; - -} } // namespace AST - -QT_END_NAMESPACE - -#endif |