From 62d5b16a5b315d2197f89c8356b86bd2543f810e Mon Sep 17 00:00:00 2001 From: Roberto Raggi <roberto.raggi@nokia.com> Date: Thu, 2 Apr 2009 19:53:39 +0200 Subject: [PATCH] Fixed QScriptParser::loc(n) --- .../qtscripteditor/parser/javascript.g | 7 ++-- .../parser/javascriptgrammar.cpp | 36 +++---------------- .../parser/javascriptgrammar_p.h | 36 +++---------------- .../parser/javascriptparser.cpp | 4 ++- .../parser/javascriptparser_p.h | 3 +- 5 files changed, 18 insertions(+), 68 deletions(-) diff --git a/src/plugins/qtscripteditor/parser/javascript.g b/src/plugins/qtscripteditor/parser/javascript.g index 80dfaddcad4..33657f8a1a9 100644 --- a/src/plugins/qtscripteditor/parser/javascript.g +++ b/src/plugins/qtscripteditor/parser/javascript.g @@ -316,7 +316,7 @@ protected: { return sym_stack [tos + index - 1]; } inline Location &loc(int index) - { return location_stack [tos + index - 2]; } + { return location_stack [tos + index - 1]; } protected: int tos; @@ -336,6 +336,7 @@ protected: double yylval; Location yylloc; + Location yyprevlloc; SavedToken token_buffer[TOKEN_BUFFER_SIZE]; SavedToken *first_token; @@ -427,6 +428,8 @@ bool JavaScriptParser::parse(JavaScriptEnginePrivate *driver) _Lcheck_token: if (yytoken == -1 && -TERMINAL_COUNT != action_index[action]) { + yyprevlloc = yylloc; + if (first_token == last_token) { yytoken = lexer->lex(); yylval = lexer->dval(); @@ -2092,7 +2095,7 @@ PropertyNameAndValueListOpt: PropertyNameAndValueList ; const QString msg = QString::fromUtf8("Missing `;'"); diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Warning, - yylloc.startLine, yylloc.startColumn, msg)); + yyprevlloc.startLine, yyprevlloc.startColumn, msg)); first_token = &token_buffer[0]; last_token = &token_buffer[1]; diff --git a/src/plugins/qtscripteditor/parser/javascriptgrammar.cpp b/src/plugins/qtscripteditor/parser/javascriptgrammar.cpp index d5b7765ebc5..abe49bf93ec 100644 --- a/src/plugins/qtscripteditor/parser/javascriptgrammar.cpp +++ b/src/plugins/qtscripteditor/parser/javascriptgrammar.cpp @@ -2,41 +2,13 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) ** -** This file is part of the QtCore module of the Qt Toolkit. +** This file is part of the $MODULE$ of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. +** $TROLLTECH_DUAL_LICENSE$ ** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ****************************************************************************/ diff --git a/src/plugins/qtscripteditor/parser/javascriptgrammar_p.h b/src/plugins/qtscripteditor/parser/javascriptgrammar_p.h index 3b51d8e4242..8e62d4abd06 100644 --- a/src/plugins/qtscripteditor/parser/javascriptgrammar_p.h +++ b/src/plugins/qtscripteditor/parser/javascriptgrammar_p.h @@ -2,41 +2,13 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) ** -** This file is part of the QtCore module of the Qt Toolkit. +** This file is part of the $MODULE$ of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. +** $TROLLTECH_DUAL_LICENSE$ ** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ****************************************************************************/ diff --git a/src/plugins/qtscripteditor/parser/javascriptparser.cpp b/src/plugins/qtscripteditor/parser/javascriptparser.cpp index ac8eabf0954..4026a970ce1 100644 --- a/src/plugins/qtscripteditor/parser/javascriptparser.cpp +++ b/src/plugins/qtscripteditor/parser/javascriptparser.cpp @@ -132,6 +132,8 @@ bool JavaScriptParser::parse(JavaScriptEnginePrivate *driver) _Lcheck_token: if (yytoken == -1 && -TERMINAL_COUNT != action_index[action]) { + yyprevlloc = yylloc; + if (first_token == last_token) { yytoken = lexer->lex(); yylval = lexer->dval(); @@ -1097,7 +1099,7 @@ case 266: { const QString msg = QString::fromUtf8("Missing `;'"); diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Warning, - yylloc.startLine, yylloc.startColumn, msg)); + yyprevlloc.startLine, yyprevlloc.startColumn, msg)); first_token = &token_buffer[0]; last_token = &token_buffer[1]; diff --git a/src/plugins/qtscripteditor/parser/javascriptparser_p.h b/src/plugins/qtscripteditor/parser/javascriptparser_p.h index d3b4e70208f..f3b16f54066 100644 --- a/src/plugins/qtscripteditor/parser/javascriptparser_p.h +++ b/src/plugins/qtscripteditor/parser/javascriptparser_p.h @@ -167,7 +167,7 @@ protected: { return sym_stack [tos + index - 1]; } inline Location &loc(int index) - { return location_stack [tos + index - 2]; } + { return location_stack [tos + index - 1]; } protected: int tos; @@ -187,6 +187,7 @@ protected: double yylval; Location yylloc; + Location yyprevlloc; SavedToken token_buffer[TOKEN_BUFFER_SIZE]; SavedToken *first_token; -- GitLab