summaryrefslogtreecommitdiffstats
path: root/src/tools/qlalr
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/qlalr')
-rw-r--r--src/tools/qlalr/CMakeLists.txt18
-rw-r--r--src/tools/qlalr/compress.cpp39
-rw-r--r--src/tools/qlalr/compress.h29
-rw-r--r--src/tools/qlalr/cppgenerator.cpp146
-rw-r--r--src/tools/qlalr/cppgenerator.h35
-rw-r--r--src/tools/qlalr/dotgraph.cpp29
-rw-r--r--src/tools/qlalr/dotgraph.h29
-rw-r--r--src/tools/qlalr/examples/dummy-xml/ll/dummy-xml-ll.cpp29
-rw-r--r--src/tools/qlalr/examples/dummy-xml/xml.g27
-rw-r--r--src/tools/qlalr/examples/glsl/build.sh29
-rw-r--r--src/tools/qlalr/examples/glsl/glsl-lex.l31
-rw-r--r--src/tools/qlalr/examples/glsl/glsl.g27
-rw-r--r--src/tools/qlalr/examples/lambda/lambda.g27
-rw-r--r--src/tools/qlalr/examples/lambda/main.cpp29
-rw-r--r--src/tools/qlalr/examples/qparser/calc.g27
-rw-r--r--src/tools/qlalr/examples/qparser/calc.l33
-rw-r--r--src/tools/qlalr/examples/qparser/qparser.cpp29
-rw-r--r--src/tools/qlalr/examples/qparser/qparser.h29
-rw-r--r--src/tools/qlalr/grammar.cpp29
-rw-r--r--src/tools/qlalr/grammar_p.h29
-rw-r--r--src/tools/qlalr/lalr.cpp65
-rw-r--r--src/tools/qlalr/lalr.g159
-rw-r--r--src/tools/qlalr/lalr.h44
-rw-r--r--src/tools/qlalr/main.cpp65
-rw-r--r--src/tools/qlalr/parsetable.cpp29
-rw-r--r--src/tools/qlalr/parsetable.h29
-rw-r--r--src/tools/qlalr/recognizer.cpp101
-rw-r--r--src/tools/qlalr/recognizer.h36
28 files changed, 268 insertions, 960 deletions
diff --git a/src/tools/qlalr/CMakeLists.txt b/src/tools/qlalr/CMakeLists.txt
index 1b28154695..da8b351889 100644
--- a/src/tools/qlalr/CMakeLists.txt
+++ b/src/tools/qlalr/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qlalr.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## qlalr Tool:
@@ -8,7 +9,7 @@ qt_get_tool_target_name(target_name qlalr)
qt_internal_add_tool(${target_name}
TARGET_DESCRIPTION "Qt Look Ahead LR Parser Generator"
INSTALL_DIR "${INSTALL_LIBEXECDIR}"
- TOOLS_TARGET Core # special case
+ TOOLS_TARGET Core
SOURCES
compress.cpp compress.h
cppgenerator.cpp cppgenerator.h
@@ -20,11 +21,10 @@ qt_internal_add_tool(${target_name}
recognizer.cpp recognizer.h
DEFINES
QT_NO_FOREACH
- PUBLIC_LIBRARIES
- Qt::Core # special case
+ QT_NO_QPAIR
+ QT_USE_NODISCARD_FILE_OPEN
+ LIBRARIES
+ Qt::Core
+ Qt::CorePrivate
)
-
-#### Keys ignored in scope 1:.:.:qlalr.pro:<TRUE>:
-# OTHER_FILES = "lalr.g"
-# QMAKE_TARGET_DESCRIPTION = "Qt Look Ahead LR Parser Generator"
-# _OPTION = "host_build"
+qt_internal_return_unless_building_tools()
diff --git a/src/tools/qlalr/compress.cpp b/src/tools/qlalr/compress.cpp
index 18f9fb4b58..6ee083f7e9 100644
--- a/src/tools/qlalr/compress.cpp
+++ b/src/tools/qlalr/compress.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** 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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "compress.h"
@@ -164,7 +139,7 @@ void Compress::operator () (int *table, int row_count, int column_count)
#ifndef QLALR_NO_CHECK_SORTED_TABLE
int previous_zeros = INT_MAX;
- for (const UncompressedRow &row : qAsConst(sortedTable))
+ for (const UncompressedRow &row : std::as_const(sortedTable))
{
int zeros = row.count (0);
@@ -176,7 +151,7 @@ void Compress::operator () (int *table, int row_count, int column_count)
index.fill (-999999, row_count);
- for (const UncompressedRow &row : qAsConst(sortedTable))
+ for (const UncompressedRow &row : std::as_const(sortedTable))
{
int first_token = std::distance (row.begin (), row.beginNonZeros ());
QList<int>::iterator pos = info.begin();
@@ -186,7 +161,7 @@ void Compress::operator () (int *table, int row_count, int column_count)
if (pos == info.begin ())
{
// try to find a perfect match
- QList<int>::iterator pm = std::search(&*pos, &*info.end(), row.beginNonZeros(),
+ QList<int>::iterator pm = std::search(pos, info.end(), row.beginNonZeros(),
row.endNonZeros(), _PerfectMatch());
if (pm != info.end ())
@@ -196,7 +171,7 @@ void Compress::operator () (int *table, int row_count, int column_count)
}
}
- pos = std::search (&*pos, &*info.end (), row.beginNonZeros (), row.endNonZeros (), _Fit ());
+ pos = std::search (pos, info.end (), row.beginNonZeros (), row.endNonZeros (), _Fit ());
if (pos == info.end ())
break;
@@ -251,7 +226,7 @@ void Compress::operator () (int *table, int row_count, int column_count)
}
#if 0
- for (const UncompressedRow &row : qAsConst(sortedTable))
+ for (const UncompressedRow &row : std::as_const(sortedTable))
{
int i = row.index ();
Q_ASSERT (i < sortedTable.size ());
diff --git a/src/tools/qlalr/compress.h b/src/tools/qlalr/compress.h
index 84b804e234..99f790348a 100644
--- a/src/tools/qlalr/compress.h
+++ b/src/tools/qlalr/compress.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the utils of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** 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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#ifndef COMPRESS_H
#define COMPRESS_H
diff --git a/src/tools/qlalr/cppgenerator.cpp b/src/tools/qlalr/cppgenerator.cpp
index 7efe94a5c2..f12917f0eb 100644
--- a/src/tools/qlalr/cppgenerator.cpp
+++ b/src/tools/qlalr/cppgenerator.cpp
@@ -1,30 +1,7 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QLALR module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** 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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// REUSE-IgnoreStart
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// REUSE-IgnoreEnd
#include "cppgenerator.h"
@@ -35,9 +12,12 @@
#include <QtCore/qtextstream.h>
#include <QtCore/qfile.h>
#include <QtCore/qmap.h>
+#include <QtCore/private/qconfig_p.h>
#include <iterator>
+using namespace Qt::StringLiterals;
+
namespace {
void generateSeparator(int i, QTextStream &out)
@@ -61,43 +41,19 @@ void generateList(const QList<int> &list, QTextStream &out)
}
}
-
+// REUSE-IgnoreStart
QString CppGenerator::copyrightHeader() const
{
- return QLatin1String(
- "/****************************************************************************\n"
- "**\n"
- "** Copyright (C) 2016 The Qt Company Ltd.\n"
- "** Contact: https://www.qt.io/licensing/\n"
- "**\n"
- "** This file is part of the Qt Toolkit.\n"
- "**\n"
- "** $QT_BEGIN_LICENSE:GPL-EXCEPT$\n"
- "** Commercial License Usage\n"
- "** Licensees holding valid commercial Qt licenses may use this file in\n"
- "** accordance with the commercial license agreement provided with the\n"
- "** Software or, alternatively, in accordance with the terms contained in\n"
- "** a written agreement between you and The Qt Company. For licensing terms\n"
- "** and conditions see https://www.qt.io/terms-conditions. For further\n"
- "** information use the contact form at https://www.qt.io/contact-us.\n"
- "**\n"
- "** GNU General Public License Usage\n"
- "** Alternatively, this file may be used under the terms of the GNU\n"
- "** General Public License version 3 as published by the Free Software\n"
- "** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT\n"
- "** included in the packaging of this file. Please review the following\n"
- "** information to ensure the GNU General Public License requirements will\n"
- "** be met: https://www.gnu.org/licenses/gpl-3.0.html.\n"
- "**\n"
- "** $QT_END_LICENSE$\n"
- "**\n"
- "****************************************************************************/\n"
- "\n");
+ return
+ "// " QT_COPYRIGHT "\n"
+ "// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0\n"
+ "\n"_L1;
}
+// REUSE-IgnoreEnd
QString CppGenerator::privateCopyrightHeader() const
{
- return QLatin1String(
+ return
"//\n"
"// W A R N I N G\n"
"// -------------\n"
@@ -107,12 +63,12 @@ QString CppGenerator::privateCopyrightHeader() const
"// version without notice, or even be removed.\n"
"//\n"
"// We mean it.\n"
- "//\n");
+ "//\n"_L1;
}
QString CppGenerator::startIncludeGuard(const QString &fileName)
{
- const QString normalized(QString(fileName).replace(QLatin1Char('.'), QLatin1Char('_')).toUpper());
+ const QString normalized(QString(fileName).replace(u'.', u'_').toUpper());
return QString::fromLatin1("#ifndef %1\n"
"#define %2\n").arg(normalized, normalized);
@@ -120,7 +76,7 @@ QString CppGenerator::startIncludeGuard(const QString &fileName)
QString CppGenerator::endIncludeGuard(const QString &fileName)
{
- const QString normalized(QString(fileName).replace(QLatin1Char('.'), QLatin1Char('_')).toUpper());
+ const QString normalized(QString(fileName).replace(u'.', u'_').toUpper());
return QString::fromLatin1("#endif // %1\n").arg(normalized);
}
@@ -240,7 +196,15 @@ void CppGenerator::operator () ()
{
if (shift_reduce_conflict_count != grammar.expected_shift_reduce
|| reduce_reduce_conflict_count != grammar.expected_reduce_reduce)
- qerr() << "*** Conflicts: " << shift_reduce_conflict_count << " shift/reduce, " << reduce_reduce_conflict_count << " reduce/reduce" << Qt::endl;
+ {
+ qerr() << "*** Conflicts: " << shift_reduce_conflict_count << " shift/reduce, " << reduce_reduce_conflict_count << " reduce/reduce" << Qt::endl;
+ if (warnings_are_errors)
+ {
+ qerr() << "qlalr: error: warning occurred, treating as error due to "
+ "--exit-on-warn." << Qt::endl;
+ exit(2);
+ }
+ }
if (verbose)
qout() << Qt::endl << "*** Conflicts: " << shift_reduce_conflict_count << " shift/reduce, " << reduce_reduce_conflict_count << " reduce/reduce" << Qt::endl
@@ -262,12 +226,20 @@ void CppGenerator::operator () ()
}
auto rule = grammar.rules.begin();
- for (int i = 0; i < used_rules.count (); ++i, ++rule)
+ for (int i = 0; i < used_rules.size(); ++i, ++rule)
{
if (! used_rules.testBit (i))
{
if (rule != grammar.goal)
- qerr() << "*** Warning: Rule ``" << *rule << "'' is useless!" << Qt::endl;
+ {
+ qerr() << "*** Warning: Rule ``" << *rule << "'' is useless!" << Qt::endl;
+ if (warnings_are_errors)
+ {
+ qerr() << "qlalr: error: warning occurred, treating as error due to "
+ "--exit-on-warn." << Qt::endl;
+ exit(2);
+ }
+ }
}
}
@@ -374,12 +346,17 @@ void CppGenerator::operator () ()
}
// default behaviour
- QString declFileName = grammar.table_name.toLower () + QLatin1String("_p.h");
- QString bitsFileName = grammar.table_name.toLower () + QLatin1String(".cpp");
+ QString declFileName = grammar.table_name.toLower () + "_p.h"_L1;
+ QString bitsFileName = grammar.table_name.toLower () + ".cpp"_L1;
{ // decls...
QFile f (declFileName);
- f.open (QFile::WriteOnly);
+ if (! f.open (QFile::WriteOnly))
+ {
+ fprintf (stderr, "*** cannot create %s: %s\n",
+ qPrintable(declFileName), qPrintable(f.errorString()));
+ return;
+ }
QTextStream out (&f);
QString prot = declFileName.toUpper ().replace (QLatin1Char ('.'), QLatin1Char ('_'));
@@ -411,7 +388,12 @@ void CppGenerator::operator () ()
{ // bits...
QFile f (bitsFileName);
- f.open (QFile::WriteOnly);
+ if (! f.open (QFile::WriteOnly))
+ {
+ fprintf (stderr, "*** cannot create %s: %s\n",
+ qPrintable(bitsFileName), qPrintable(f.errorString()));
+ return;
+ }
QTextStream out (&f);
// copyright headers must come first, otherwise the headers tests will fail
@@ -432,7 +414,12 @@ void CppGenerator::operator () ()
if (! grammar.decl_file_name.isEmpty ())
{
QFile f (grammar.decl_file_name);
- f.open (QFile::WriteOnly);
+ if (! f.open (QFile::WriteOnly))
+ {
+ fprintf (stderr, "*** cannot create %s: %s\n",
+ qPrintable(grammar.decl_file_name), qPrintable(f.errorString()));
+ return;
+ }
QTextStream out (&f);
out << p.decls();
}
@@ -440,7 +427,12 @@ void CppGenerator::operator () ()
if (! grammar.impl_file_name.isEmpty ())
{
QFile f (grammar.impl_file_name);
- f.open (QFile::WriteOnly);
+ if (! f.open (QFile::WriteOnly))
+ {
+ fprintf (stderr, "*** cannot create %s: %s\n",
+ qPrintable(grammar.impl_file_name), qPrintable(f.errorString()));
+ return;
+ }
QTextStream out (&f);
out << p.impls();
}
@@ -448,9 +440,9 @@ void CppGenerator::operator () ()
QString CppGenerator::debugInfoProt() const
{
- QString prot = QLatin1String("QLALR_NO_");
+ QString prot = "QLALR_NO_"_L1;
prot += grammar.table_name.toUpper();
- prot += QLatin1String("_DEBUG_INFO");
+ prot += "_DEBUG_INFO"_L1;
return prot;
}
@@ -461,16 +453,16 @@ void CppGenerator::generateDecl (QTextStream &out)
<< "public:" << Qt::endl
<< " enum VariousConstants {" << Qt::endl;
- for (const Name &t : qAsConst(grammar.terminals))
+ for (const Name &t : std::as_const(grammar.terminals))
{
QString name = *t;
int value = std::distance (grammar.names.begin (), t);
- if (name == QLatin1String ("$end"))
- name = QLatin1String ("EOF_SYMBOL");
+ if (name == "$end"_L1)
+ name = "EOF_SYMBOL"_L1;
- else if (name == QLatin1String ("$accept"))
- name = QLatin1String ("ACCEPT_SYMBOL");
+ else if (name == "$accept"_L1)
+ name = "ACCEPT_SYMBOL"_L1;
else
name.prepend (grammar.token_prefix);
diff --git a/src/tools/qlalr/cppgenerator.h b/src/tools/qlalr/cppgenerator.h
index a83ec101fd..66ae781be4 100644
--- a/src/tools/qlalr/cppgenerator.h
+++ b/src/tools/qlalr/cppgenerator.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QLALR module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** 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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#ifndef CPPGENERATOR_H
#define CPPGENERATOR_H
@@ -45,7 +20,8 @@ public:
aut (aut),
verbose (verbose),
debug_info (false),
- copyright (false) {}
+ copyright (false),
+ warnings_are_errors(false) {}
void operator () ();
@@ -54,6 +30,8 @@ public:
void setCopyright (bool t) { copyright = t; }
+ void setWarningsAreErrors (bool e) { warnings_are_errors = e; }
+
private:
void generateDecl (QTextStream &out);
void generateImpl (QTextStream &out);
@@ -76,6 +54,7 @@ private:
int non_terminal_count;
bool debug_info;
bool copyright;
+ bool warnings_are_errors;
Compress compressed_action;
Compress compressed_goto;
QList<int> count;
diff --git a/src/tools/qlalr/dotgraph.cpp b/src/tools/qlalr/dotgraph.cpp
index 1d479af2b2..75bd304367 100644
--- a/src/tools/qlalr/dotgraph.cpp
+++ b/src/tools/qlalr/dotgraph.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the utils of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** 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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "dotgraph.h"
diff --git a/src/tools/qlalr/dotgraph.h b/src/tools/qlalr/dotgraph.h
index 2d4f1cd2fc..42d4527c46 100644
--- a/src/tools/qlalr/dotgraph.h
+++ b/src/tools/qlalr/dotgraph.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the utils of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** 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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#ifndef DOTGRAPH_H
#define DOTGRAPH_H
diff --git a/src/tools/qlalr/examples/dummy-xml/ll/dummy-xml-ll.cpp b/src/tools/qlalr/examples/dummy-xml/ll/dummy-xml-ll.cpp
index 7bf1506b4a..24399d3786 100644
--- a/src/tools/qlalr/examples/dummy-xml/ll/dummy-xml-ll.cpp
+++ b/src/tools/qlalr/examples/dummy-xml/ll/dummy-xml-ll.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QLALR module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** 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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <cstdlib>
#include <cstdio>
diff --git a/src/tools/qlalr/examples/dummy-xml/xml.g b/src/tools/qlalr/examples/dummy-xml/xml.g
index 43c1fb169f..59472dc219 100644
--- a/src/tools/qlalr/examples/dummy-xml/xml.g
+++ b/src/tools/qlalr/examples/dummy-xml/xml.g
@@ -1,30 +1,5 @@
-----------------------------------------------------------------------------
---
-- Copyright (C) 2016 The Qt Company Ltd.
--- Contact: https://www.qt.io/licensing/
---
--- This file is part of the QtCore module of the Qt Toolkit.
---
--- $QT_BEGIN_LICENSE:GPL-EXCEPT$
--- 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 General Public License Usage
--- Alternatively, this file may be used under the terms of the GNU
--- General Public License version 3 as published by the Free Software
--- Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
--- 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-3.0.html.
---
--- $QT_END_LICENSE$
---
-----------------------------------------------------------------------------
+-- SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
%parser XMLTable
diff --git a/src/tools/qlalr/examples/glsl/build.sh b/src/tools/qlalr/examples/glsl/build.sh
index 5bd0faab07..d43889bf72 100644
--- a/src/tools/qlalr/examples/glsl/build.sh
+++ b/src/tools/qlalr/examples/glsl/build.sh
@@ -1,31 +1,6 @@
#!/bin/sh
-#############################################################################
-##
-## Copyright (C) 2016 The Qt Company Ltd.
-## Contact: https://www.qt.io/licensing/
-##
-## This file is the build configuration utility of the Qt Toolkit.
-##
-## $QT_BEGIN_LICENSE:GPL-EXCEPT$
-## 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 General Public License Usage
-## Alternatively, this file may be used under the terms of the GNU
-## General Public License version 3 as published by the Free Software
-## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-## 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-3.0.html.
-##
-## $QT_END_LICENSE$
-##
-#############################################################################
+# Copyright (C) 2016 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
${FLEX-flex} -oglsl-lex.incl glsl-lex.l
${QLALR-qlalr} glsl.g
diff --git a/src/tools/qlalr/examples/glsl/glsl-lex.l b/src/tools/qlalr/examples/glsl/glsl-lex.l
index c92aad296b..f3f9bb4f50 100644
--- a/src/tools/qlalr/examples/glsl/glsl-lex.l
+++ b/src/tools/qlalr/examples/glsl/glsl-lex.l
@@ -1,32 +1,5 @@
-
-%{
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QLALR tool of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** 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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <cassert>
#define YY_DECL int GLSLParser::nextToken()
diff --git a/src/tools/qlalr/examples/glsl/glsl.g b/src/tools/qlalr/examples/glsl/glsl.g
index 66a2c73656..223e90284d 100644
--- a/src/tools/qlalr/examples/glsl/glsl.g
+++ b/src/tools/qlalr/examples/glsl/glsl.g
@@ -1,30 +1,5 @@
-----------------------------------------------------------------------------
---
-- Copyright (C) 2016 The Qt Company Ltd.
--- Contact: https://www.qt.io/licensing/
---
--- This file is part of the QtCore module of the Qt Toolkit.
---
--- $QT_BEGIN_LICENSE:GPL-EXCEPT$
--- 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 General Public License Usage
--- Alternatively, this file may be used under the terms of the GNU
--- General Public License version 3 as published by the Free Software
--- Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
--- 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-3.0.html.
---
--- $QT_END_LICENSE$
---
-----------------------------------------------------------------------------
+-- SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
%parser GLSLParserTable
%merged_output glsl.cpp
diff --git a/src/tools/qlalr/examples/lambda/lambda.g b/src/tools/qlalr/examples/lambda/lambda.g
index 2aa3c128e9..d4fd01ed4c 100644
--- a/src/tools/qlalr/examples/lambda/lambda.g
+++ b/src/tools/qlalr/examples/lambda/lambda.g
@@ -1,30 +1,5 @@
-----------------------------------------------------------------------------
---
-- Copyright (C) 2016 The Qt Company Ltd.
--- Contact: https://www.qt.io/licensing/
---
--- This file is part of the QtCore module of the Qt Toolkit.
---
--- $QT_BEGIN_LICENSE:GPL-EXCEPT$
--- 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 General Public License Usage
--- Alternatively, this file may be used under the terms of the GNU
--- General Public License version 3 as published by the Free Software
--- Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
--- 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-3.0.html.
---
--- $QT_END_LICENSE$
---
-----------------------------------------------------------------------------
+-- SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-- lambda calculus
diff --git a/src/tools/qlalr/examples/lambda/main.cpp b/src/tools/qlalr/examples/lambda/main.cpp
index 6198cc8538..c6a2695493 100644
--- a/src/tools/qlalr/examples/lambda/main.cpp
+++ b/src/tools/qlalr/examples/lambda/main.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QLALR module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** 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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "lambda.h"
diff --git a/src/tools/qlalr/examples/qparser/calc.g b/src/tools/qlalr/examples/qparser/calc.g
index 8524c1ca2c..2be9fd55c0 100644
--- a/src/tools/qlalr/examples/qparser/calc.g
+++ b/src/tools/qlalr/examples/qparser/calc.g
@@ -1,30 +1,5 @@
-----------------------------------------------------------------------------
---
-- Copyright (C) 2016 The Qt Company Ltd.
--- Contact: https://www.qt.io/licensing/
---
--- This file is part of the QtCore module of the Qt Toolkit.
---
--- $QT_BEGIN_LICENSE:GPL-EXCEPT$
--- 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 General Public License Usage
--- Alternatively, this file may be used under the terms of the GNU
--- General Public License version 3 as published by the Free Software
--- Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
--- 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-3.0.html.
---
--- $QT_END_LICENSE$
---
-----------------------------------------------------------------------------
+-- SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
%parser calc_grammar
%decl calc_parser.h
diff --git a/src/tools/qlalr/examples/qparser/calc.l b/src/tools/qlalr/examples/qparser/calc.l
index fe542680a8..0f42987758 100644
--- a/src/tools/qlalr/examples/qparser/calc.l
+++ b/src/tools/qlalr/examples/qparser/calc.l
@@ -1,34 +1,5 @@
-
-%option noyywrap
-
-%{
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QLALR tool of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** 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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "calc_parser.h"
#include <cstdlib>
diff --git a/src/tools/qlalr/examples/qparser/qparser.cpp b/src/tools/qlalr/examples/qparser/qparser.cpp
index c173436a9c..354a778458 100644
--- a/src/tools/qlalr/examples/qparser/qparser.cpp
+++ b/src/tools/qlalr/examples/qparser/qparser.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QLALR module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** 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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "qparser.h"
diff --git a/src/tools/qlalr/examples/qparser/qparser.h b/src/tools/qlalr/examples/qparser/qparser.h
index 7700562d55..80643616c4 100644
--- a/src/tools/qlalr/examples/qparser/qparser.h
+++ b/src/tools/qlalr/examples/qparser/qparser.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QLALR module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** 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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef QPARSER_H
#define QPARSER_H
diff --git a/src/tools/qlalr/grammar.cpp b/src/tools/qlalr/grammar.cpp
index 2ab6504bf8..d4d8916c6d 100644
--- a/src/tools/qlalr/grammar.cpp
+++ b/src/tools/qlalr/grammar.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** 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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
// This file was generated by qlalr - DO NOT EDIT!
#include "grammar_p.h"
diff --git a/src/tools/qlalr/grammar_p.h b/src/tools/qlalr/grammar_p.h
index 8482f9bfe1..b6fa6b6353 100644
--- a/src/tools/qlalr/grammar_p.h
+++ b/src/tools/qlalr/grammar_p.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** 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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
//
// W A R N I N G
diff --git a/src/tools/qlalr/lalr.cpp b/src/tools/qlalr/lalr.cpp
index 853465c272..51f1d94a40 100644
--- a/src/tools/qlalr/lalr.cpp
+++ b/src/tools/qlalr/lalr.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the utils of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** 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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "lalr.h"
@@ -39,6 +14,8 @@
#define QLALR_NO_DEBUG_INCLUDES
#define QLALR_NO_DEBUG_LOOKAHEADS
+using namespace Qt::StringLiterals;
+
QT_BEGIN_NAMESPACE
QTextStream &qerr()
{
@@ -162,24 +139,24 @@ State::State (Grammar *g):
{
}
-QPair<ItemPointer, bool> State::insert (const Item &item)
+std::pair<ItemPointer, bool> State::insert(const Item &item)
{
ItemPointer it = std::find (kernel.begin (), kernel.end (), item);
if (it != kernel.end ())
- return qMakePair (it, false);
+ return {it, false};
- return qMakePair (kernel.insert (it, item), true);
+ return {kernel.insert(it, item), true};
}
-QPair<ItemPointer, bool> State::insertClosure (const Item &item)
+std::pair<ItemPointer, bool> State::insertClosure(const Item &item)
{
ItemPointer it = std::find (closure.begin (), closure.end (), item);
if (it != closure.end ())
- return qMakePair (it, false);
+ return {it, false};
- return qMakePair (closure.insert (it, item), true);
+ return {closure.insert (it, item), true};
}
@@ -194,11 +171,11 @@ Grammar::Grammar ():
current_prec = 0;
current_assoc = NonAssoc;
- table_name = QLatin1String ("parser_table");
+ table_name = "parser_table"_L1;
tk_end = intern ("$end");
terminals.insert (tk_end);
- spells.insert (tk_end, QLatin1String("end of file"));
+ spells.insert (tk_end, "end of file"_L1);
/*tk_error= terminals.insert (intern ("error"))*/;
}
@@ -319,14 +296,14 @@ void Automaton::buildNullables ()
#endif
}
-QPair<StatePointer, bool> Automaton::internState (const State &state)
+std::pair<StatePointer, bool> Automaton::internState(const State &state)
{
StatePointer it = std::find (states.begin (), states.end (), state);
if (it != states.end ())
- return qMakePair (it, false);
+ return {it, false};
- return qMakePair (states.insert (it, state), true);
+ return {states.insert (it, state), true};
}
struct _Bucket
@@ -374,7 +351,7 @@ void Automaton::closure (StatePointer state)
if (_M_grammar->isNonTerminal (*item->dot))
{
- const auto range = qAsConst(_M_grammar->rule_map).equal_range(*item->dot);
+ const auto range = std::as_const(_M_grammar->rule_map).equal_range(*item->dot);
for (auto it = range.first; it != range.second; ++it)
{
const RulePointer &rule = *it;
@@ -382,7 +359,7 @@ void Automaton::closure (StatePointer state)
ii.rule = rule;
ii.dot = rule->rhs.begin ();
- QPair<ItemPointer, bool> r = state->insertClosure (ii);
+ std::pair<ItemPointer, bool> r = state->insertClosure(ii);
if (r.second)
working_list.push (r.first);
@@ -394,7 +371,7 @@ void Automaton::closure (StatePointer state)
for (bucket_map_type::iterator bucket = buckets.begin (); bucket != buckets.end (); ++bucket)
{
- QPair<StatePointer, bool> r = internState (bucket->toState (this));
+ std::pair<StatePointer, bool> r = internState(bucket->toState(this));
StatePointer target = r.first;
@@ -422,7 +399,7 @@ void Automaton::buildLookbackSets ()
if (! _M_grammar->isNonTerminal (A))
continue;
- const auto range = qAsConst(_M_grammar->rule_map).equal_range(A);
+ const auto range = std::as_const(_M_grammar->rule_map).equal_range(A);
for (auto it = range.first; it != range.second; ++it)
{
const RulePointer &rule = *it;
@@ -617,7 +594,7 @@ void Automaton::buildIncludesDigraph ()
if (! _M_grammar->isNonTerminal (name))
continue;
- const auto range = qAsConst(_M_grammar->rule_map).equal_range(name);
+ const auto range = std::as_const(_M_grammar->rule_map).equal_range(name);
for (auto it = range.first; it != range.second; ++it)
{
const RulePointer &rule = *it;
@@ -719,7 +696,7 @@ void Automaton::buildLookaheads ()
{
for (ItemPointer item = p->closure.begin (); item != p->closure.end (); ++item)
{
- const auto range = qAsConst(lookbacks).equal_range(item);
+ const auto range = std::as_const(lookbacks).equal_range(item);
for (auto it = range.first; it != range.second; ++it)
{
const Lookback &lookback = *it;
diff --git a/src/tools/qlalr/lalr.g b/src/tools/qlalr/lalr.g
index 3c1d1d3ebd..71d0054feb 100644
--- a/src/tools/qlalr/lalr.g
+++ b/src/tools/qlalr/lalr.g
@@ -1,30 +1,5 @@
------------------------------------------------------------------------------
---
-- Copyright (C) 2016 The Qt Company Ltd.
--- Contact: https://www.qt.io/licensing/
---
--- This file is part of the QLALR project on Qt Labs.
---
--- $QT_BEGIN_LICENSE:GPL-EXCEPT$
--- 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 General Public License Usage
--- Alternatively, this file may be used under the terms of the GNU
--- General Public License version 3 as published by the Free Software
--- Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
--- 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-3.0.html.
---
--- $QT_END_LICENSE$
---
------------------------------------------------------------------------------
+-- SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
%parser grammar
@@ -61,33 +36,8 @@
%start Specification
-/:/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QLALR project on Qt Labs.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** 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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+/:// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "$header"
@@ -126,7 +76,7 @@ protected: // scanner
{
ch = *_M_currentChar++;
- if (ch == QLatin1Char('\n'))
+ if (ch == u'\n')
++_M_line;
}
else
@@ -162,33 +112,8 @@ protected:
};
:/
-/./****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QLALR project on Qt Labs.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** 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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+/.// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "recognizer.h"
@@ -198,6 +123,8 @@ protected:
#include <cstring>
#include <cctype>
+using namespace Qt::StringLiterals;
+
Recognizer::Recognizer (Grammar *grammar, bool no_lines):
tos(0),
stack_size(0),
@@ -247,9 +174,9 @@ int Recognizer::nextToken()
{
inp(); // skip "
text.clear ();
- while (! ch.isNull () && ch != QLatin1Char ('"'))
+ while (! ch.isNull () && ch != u'"')
{
- if (ch == QLatin1Char ('\\'))
+ if (ch == u'\\')
{
text += ch;
inp();
@@ -258,7 +185,7 @@ int Recognizer::nextToken()
inp ();
}
- if (ch == QLatin1Char ('"'))
+ if (ch == u'"')
inp ();
else
qerr() << _M_input_file << ":" << _M_line << ": Warning. Expected `\"'" << Qt::endl;
@@ -267,11 +194,11 @@ int Recognizer::nextToken()
return (token = STRING_LITERAL);
}
- else if (ch.isLetterOrNumber () || ch == QLatin1Char ('_'))
+ else if (ch.isLetterOrNumber () || ch == u'_')
{
text.clear ();
do { text += ch; inp (); }
- while (ch.isLetterOrNumber () || ch == QLatin1Char ('_') || ch == QLatin1Char ('.'));
+ while (ch.isLetterOrNumber () || ch == u'_' || ch == u'.');
_M_current_value = text;
return (token = ID);
}
@@ -284,33 +211,33 @@ int Recognizer::nextToken()
while (ch.isSpace ());
do { text += ch; inp (); }
- while (ch.isLetterOrNumber () || ch == QLatin1Char ('_') || ch == QLatin1Char ('-'));
+ while (ch.isLetterOrNumber () || ch == u'_' || ch == u'-');
- if (text == QLatin1String("token_prefix"))
+ if (text == "token_prefix"_L1)
return (token = TOKEN_PREFIX);
- else if (text == QLatin1String("merged_output"))
+ else if (text == "merged_output"_L1)
return (token = MERGED_OUTPUT);
- else if (text == QLatin1String("token"))
+ else if (text == "token"_L1)
return (token = TOKEN);
- else if (text == QLatin1String("start"))
+ else if (text == "start"_L1)
return (token = START);
- else if (text == QLatin1String("parser"))
+ else if (text == "parser"_L1)
return (token = PARSER);
- else if (text == QLatin1String("decl"))
+ else if (text == "decl"_L1)
return (token = DECL_FILE);
- else if (text == QLatin1String("impl"))
+ else if (text == "impl"_L1)
return (token = IMPL_FILE);
- else if (text == QLatin1String("expect"))
+ else if (text == "expect"_L1)
return (token = EXPECT);
- else if (text == QLatin1String("expect-rr"))
+ else if (text == "expect-rr"_L1)
return (token = EXPECT_RR);
- else if (text == QLatin1String("left"))
+ else if (text == "left"_L1)
return (token = LEFT);
- else if (text == QLatin1String("right"))
+ else if (text == "right"_L1)
return (token = RIGHT);
- else if (text == QLatin1String("nonassoc"))
+ else if (text == "nonassoc"_L1)
return (token = NONASSOC);
- else if (text == QLatin1String("prec"))
+ else if (text == "prec"_L1)
return (token = PREC);
else
{
@@ -322,30 +249,30 @@ int Recognizer::nextToken()
inp ();
- if (token == '-' && ch == QLatin1Char ('-'))
+ if (token == '-' && ch == u'-')
{
do { inp (); }
- while (! ch.isNull () && ch != QLatin1Char ('\n'));
+ while (! ch.isNull () && ch != u'\n');
goto Lagain;
}
- else if (token == ':' && ch == QLatin1Char (':'))
+ else if (token == ':' && ch == u':')
{
inp ();
- if (ch != QLatin1Char ('='))
+ if (ch != u'=')
return (token = ERROR);
inp ();
return (token = COLON);
}
- else if (token == '/' && ch == QLatin1Char (':'))
+ else if (token == '/' && ch == u':')
{
_M_action_line = _M_line;
text.clear ();
if (! _M_no_lines)
- text += QLatin1String("\n#line ") + QString::number(_M_action_line) +
- QLatin1String(" \"") + QDir::fromNativeSeparators(_M_input_file) + QLatin1String("\"\n");
+ text += "\n#line "_L1 + QString::number(_M_action_line) +
+ " \""_L1 + QDir::fromNativeSeparators(_M_input_file) + "\"\n"_L1;
inp (); // skip ':'
forever
@@ -355,13 +282,13 @@ int Recognizer::nextToken()
token = ch.unicode ();
inp ();
- if (token == ':' && ch == QLatin1Char ('/'))
+ if (token == ':' && ch == u'/')
break;
text += QLatin1Char (token);
}
- if (ch != QLatin1Char ('/'))
+ if (ch != u'/')
return (token = ERROR);
inp ();
@@ -372,18 +299,18 @@ int Recognizer::nextToken()
return (token = DECL);
}
else
- text += QLatin1String (":/");
+ text += ":/"_L1;
}
}
- else if (token == '/' && ch == QLatin1Char ('.'))
+ else if (token == '/' && ch == u'.')
{
_M_action_line = _M_line;
text.clear ();
if (! _M_no_lines)
- text += QLatin1String("\n#line ") + QString::number(_M_action_line) +
- QLatin1String(" \"") + QDir::fromNativeSeparators(_M_input_file) + QLatin1String("\"\n");
+ text += "\n#line "_L1 + QString::number(_M_action_line) +
+ " \""_L1 + QDir::fromNativeSeparators(_M_input_file) + "\"\n"_L1;
inp (); // skip ':'
@@ -394,13 +321,13 @@ int Recognizer::nextToken()
token = ch.unicode ();
inp ();
- if (token == '.' && ch == QLatin1Char ('/'))
+ if (token == '.' && ch == u'/')
break;
text += QLatin1Char (token);
}
- if (ch != QLatin1Char ('/'))
+ if (ch != u'/')
return (token = ERROR);
inp ();
@@ -411,7 +338,7 @@ int Recognizer::nextToken()
return (token = IMPL);
}
else
- text += QLatin1String ("./");
+ text += "./"_L1;
}
}
diff --git a/src/tools/qlalr/lalr.h b/src/tools/qlalr/lalr.h
index 5be44fea67..efa0a91a39 100644
--- a/src/tools/qlalr/lalr.h
+++ b/src/tools/qlalr/lalr.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the utils of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** 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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#ifndef LALR_H
#define LALR_H
@@ -34,7 +9,6 @@
#include <QtCore/qmap.h>
#include <QtCore/qstring.h>
#include <QtCore/qtextstream.h>
-#include <QtCore/qpair.h>
#include <algorithm>
#include <functional>
@@ -142,8 +116,8 @@ public:
inline bool operator != (const State &other) const
{ return kernel != other.kernel; }
- QPair<ItemPointer, bool> insert (const Item &item);
- QPair<ItemPointer, bool> insertClosure (const Item &item);
+ std::pair<ItemPointer, bool> insert(const Item &item);
+ std::pair<ItemPointer, bool> insertClosure(const Item &item);
public: // attributes
ItemList kernel;
@@ -168,7 +142,7 @@ public:
public:
static iterator get (_Tp data);
- QPair<edge_iterator, bool> insertEdge (iterator other) const;
+ std::pair<edge_iterator, bool> insertEdge(iterator other) const;
inline edge_iterator begin () const
{ return outs.begin (); }
@@ -223,15 +197,15 @@ typename Node<_Tp>::iterator Node<_Tp>::get (_Tp data)
}
template <typename _Tp>
-QPair<typename std::list<typename Node<_Tp>::iterator>::iterator, bool> Node<_Tp>::insertEdge(typename Node<_Tp>::iterator other) const
+std::pair<typename std::list<typename Node<_Tp>::iterator>::iterator, bool> Node<_Tp>::insertEdge(typename Node<_Tp>::iterator other) const
{
edge_iterator it = std::find (outs.begin (), outs.end (), other);
if (it != outs.end ())
- return qMakePair (it, false);
+ return {it, false};
other->root = false;
- return qMakePair (outs.insert (outs.end (), other), true);
+ return {outs.insert (outs.end (), other), true};
}
/////////////////////////////////////////////////////////////
@@ -337,7 +311,7 @@ class Automaton
public:
Automaton (Grammar *g);
- QPair<StatePointer, bool> internState (const State &state);
+ std::pair<StatePointer, bool> internState (const State &state);
typedef Node<Read> ReadsGraph;
typedef ReadsGraph::iterator ReadNode;
diff --git a/src/tools/qlalr/main.cpp b/src/tools/qlalr/main.cpp
index 6a57c7aa7a..04ae54d986 100644
--- a/src/tools/qlalr/main.cpp
+++ b/src/tools/qlalr/main.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the utils of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** 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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "lalr.h"
#include "dotgraph.h"
@@ -42,6 +17,8 @@
#define QLALR_NO_DEBUG_TABLE
#define QLALR_NO_DEBUG_DOT
+using namespace Qt::StringLiterals;
+
static void help_me ()
{
qerr() << "Usage: qlalr [options] [input file name]" << Qt::endl
@@ -51,7 +28,8 @@ static void help_me ()
<< " --no-debug\t\tno debug information" << Qt::endl
<< " --no-lines\t\tno #line directives" << Qt::endl
<< " --dot\t\t\tgenerate a graph" << Qt::endl
- << " --qt\t\tadd the Qt copyright header and Qt-specific types and macros" << Qt::endl
+ << " --qt\t\t\tadd the Qt copyright header and Qt-specific types and macros" << Qt::endl
+ << " --exit-on-warn\texit with status code 2 on warning" << Qt::endl
<< Qt::endl;
exit (0);
}
@@ -65,28 +43,32 @@ int main (int argc, char *argv[])
bool no_lines = false;
bool debug_info = true;
bool qt_copyright = false;
+ bool warnings_are_errors = false;
QString file_name;
const QStringList args = app.arguments().mid(1);
for (const QString &arg : args) {
- if (arg == QLatin1String ("-h") || arg == QLatin1String ("--help"))
+ if (arg == "-h"_L1 || arg == "--help"_L1)
help_me ();
- else if (arg == QLatin1String ("-v") || arg == QLatin1String ("--verbose"))
+ else if (arg == "-v"_L1 || arg == "--verbose"_L1)
generate_report = true;
- else if (arg == QLatin1String ("--dot"))
+ else if (arg == "--dot"_L1)
generate_dot = true;
- else if (arg == QLatin1String ("--no-lines"))
+ else if (arg == "--no-lines"_L1)
no_lines = true;
- else if (arg == QLatin1String ("--no-debug"))
+ else if (arg == "--no-debug"_L1)
debug_info = false;
- else if (arg == QLatin1String ("--qt"))
+ else if (arg == "--qt"_L1)
qt_copyright = true;
+ else if (arg == "--exit-on-warn"_L1)
+ warnings_are_errors = true;
+
else if (file_name.isEmpty ())
file_name = arg;
@@ -127,6 +109,7 @@ int main (int argc, char *argv[])
CppGenerator gen (p, grammar, aut, generate_report);
gen.setDebugInfo (debug_info);
gen.setCopyright (qt_copyright);
+ gen.setWarningsAreErrors (warnings_are_errors);
gen ();
if (generate_dot)
@@ -150,19 +133,19 @@ QString Recognizer::expand (const QString &text) const
if (_M_grammar->start != _M_grammar->names.end ())
{
- code = code.replace (QLatin1String("$start_id"), QString::number (std::distance (_M_grammar->names.begin (), _M_grammar->start)));
- code = code.replace (QLatin1String("$start"), *_M_grammar->start);
+ code = code.replace ("$start_id"_L1, QString::number (std::distance (_M_grammar->names.begin (), _M_grammar->start)));
+ code = code.replace ("$start"_L1, *_M_grammar->start);
}
- code = code.replace (QLatin1String("$header"), _M_grammar->table_name.toLower () + QLatin1String("_p.h"));
+ code = code.replace ("$header"_L1, _M_grammar->table_name.toLower () + "_p.h"_L1);
- code = code.replace (QLatin1String("$table"), _M_grammar->table_name);
- code = code.replace (QLatin1String("$parser"), _M_grammar->table_name);
+ code = code.replace ("$table"_L1, _M_grammar->table_name);
+ code = code.replace ("$parser"_L1, _M_grammar->table_name);
if (_M_current_rule != _M_grammar->rules.end ())
{
- code = code.replace (QLatin1String("$rule_number"), QString::number (std::distance (_M_grammar->rules.begin (), _M_current_rule)));
- code = code.replace (QLatin1String("$rule"), *_M_current_rule->lhs);
+ code = code.replace ("$rule_number"_L1, QString::number (std::distance (_M_grammar->rules.begin (), _M_current_rule)));
+ code = code.replace ("$rule"_L1, *_M_current_rule->lhs);
}
return code;
diff --git a/src/tools/qlalr/parsetable.cpp b/src/tools/qlalr/parsetable.cpp
index 9e71acebb4..c144b6f7a6 100644
--- a/src/tools/qlalr/parsetable.cpp
+++ b/src/tools/qlalr/parsetable.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the utils of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** 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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "parsetable.h"
diff --git a/src/tools/qlalr/parsetable.h b/src/tools/qlalr/parsetable.h
index 2bf477011b..9d3a97026b 100644
--- a/src/tools/qlalr/parsetable.h
+++ b/src/tools/qlalr/parsetable.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the utils of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** 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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#ifndef PARSETABLE_H
#define PARSETABLE_H
diff --git a/src/tools/qlalr/recognizer.cpp b/src/tools/qlalr/recognizer.cpp
index 760a094460..65862f7b02 100644
--- a/src/tools/qlalr/recognizer.cpp
+++ b/src/tools/qlalr/recognizer.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QLALR project on Qt Labs.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** 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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "recognizer.h"
@@ -34,6 +9,8 @@
#include <cstring>
#include <cctype>
+using namespace Qt::StringLiterals;
+
Recognizer::Recognizer (Grammar *grammar, bool no_lines):
tos(0),
stack_size(0),
@@ -83,9 +60,9 @@ int Recognizer::nextToken()
{
inp(); // skip "
text.clear ();
- while (! ch.isNull () && ch != QLatin1Char ('"'))
+ while (!ch.isNull () && ch != u'"')
{
- if (ch == QLatin1Char ('\\'))
+ if (ch == u'\\')
{
text += ch;
inp();
@@ -94,7 +71,7 @@ int Recognizer::nextToken()
inp ();
}
- if (ch == QLatin1Char ('"'))
+ if (ch == u'"')
inp ();
else
qerr() << _M_input_file << ":" << _M_line << ": Warning. Expected `\"'" << Qt::endl;
@@ -103,11 +80,11 @@ int Recognizer::nextToken()
return (token = STRING_LITERAL);
}
- else if (ch.isLetterOrNumber () || ch == QLatin1Char ('_'))
+ else if (ch.isLetterOrNumber () || ch == u'_')
{
text.clear ();
do { text += ch; inp (); }
- while (ch.isLetterOrNumber () || ch == QLatin1Char ('_') || ch == QLatin1Char ('.'));
+ while (ch.isLetterOrNumber () || ch == u'_' || ch == u'.');
_M_current_value = text;
return (token = ID);
}
@@ -120,33 +97,33 @@ int Recognizer::nextToken()
while (ch.isSpace ());
do { text += ch; inp (); }
- while (ch.isLetterOrNumber () || ch == QLatin1Char ('_') || ch == QLatin1Char ('-'));
+ while (ch.isLetterOrNumber () || ch == u'_' || ch == u'-');
- if (text == QLatin1String("token_prefix"))
+ if (text == "token_prefix"_L1)
return (token = TOKEN_PREFIX);
- else if (text == QLatin1String("merged_output"))
+ else if (text == "merged_output"_L1)
return (token = MERGED_OUTPUT);
- else if (text == QLatin1String("token"))
+ else if (text == "token"_L1)
return (token = TOKEN);
- else if (text == QLatin1String("start"))
+ else if (text == "start"_L1)
return (token = START);
- else if (text == QLatin1String("parser"))
+ else if (text == "parser"_L1)
return (token = PARSER);
- else if (text == QLatin1String("decl"))
+ else if (text == "decl"_L1)
return (token = DECL_FILE);
- else if (text == QLatin1String("impl"))
+ else if (text == "impl"_L1)
return (token = IMPL_FILE);
- else if (text == QLatin1String("expect"))
+ else if (text == "expect"_L1)
return (token = EXPECT);
- else if (text == QLatin1String("expect-rr"))
+ else if (text == "expect-rr"_L1)
return (token = EXPECT_RR);
- else if (text == QLatin1String("left"))
+ else if (text == "left"_L1)
return (token = LEFT);
- else if (text == QLatin1String("right"))
+ else if (text == "right"_L1)
return (token = RIGHT);
- else if (text == QLatin1String("nonassoc"))
+ else if (text == "nonassoc"_L1)
return (token = NONASSOC);
- else if (text == QLatin1String("prec"))
+ else if (text == "prec"_L1)
return (token = PREC);
else
{
@@ -158,30 +135,30 @@ int Recognizer::nextToken()
inp ();
- if (token == '-' && ch == QLatin1Char ('-'))
+ if (token == '-' && ch == u'-')
{
do { inp (); }
- while (! ch.isNull () && ch != QLatin1Char ('\n'));
+ while (!ch.isNull () && ch != u'\n');
goto Lagain;
}
- else if (token == ':' && ch == QLatin1Char (':'))
+ else if (token == ':' && ch == u':')
{
inp ();
- if (ch != QLatin1Char ('='))
+ if (ch != u'=')
return (token = ERROR);
inp ();
return (token = COLON);
}
- else if (token == '/' && ch == QLatin1Char (':'))
+ else if (token == '/' && ch == u':')
{
_M_action_line = _M_line;
text.clear ();
if (! _M_no_lines)
- text += QLatin1String("\n#line ") + QString::number(_M_action_line) +
- QLatin1String(" \"") + QDir::fromNativeSeparators(_M_input_file) + QLatin1String("\"\n");
+ text += "\n#line "_L1 + QString::number(_M_action_line) +
+ " \""_L1 + QDir::fromNativeSeparators(_M_input_file) + "\"\n"_L1;
inp (); // skip ':'
forever
@@ -191,13 +168,13 @@ int Recognizer::nextToken()
token = ch.unicode ();
inp ();
- if (token == ':' && ch == QLatin1Char ('/'))
+ if (token == ':' && ch == u'/')
break;
text += QLatin1Char (token);
}
- if (ch != QLatin1Char ('/'))
+ if (ch != u'/')
return (token = ERROR);
inp ();
@@ -208,18 +185,18 @@ int Recognizer::nextToken()
return (token = DECL);
}
else
- text += QLatin1String (":/");
+ text += ":/"_L1;
}
}
- else if (token == '/' && ch == QLatin1Char ('.'))
+ else if (token == '/' && ch == u'.')
{
_M_action_line = _M_line;
text.clear ();
if (! _M_no_lines)
- text += QLatin1String("\n#line ") + QString::number(_M_action_line) +
- QLatin1String(" \"") + QDir::fromNativeSeparators(_M_input_file) + QLatin1String("\"\n");
+ text += "\n#line "_L1 + QString::number(_M_action_line) +
+ " \""_L1 + QDir::fromNativeSeparators(_M_input_file) + "\"\n"_L1;
inp (); // skip ':'
@@ -230,13 +207,13 @@ int Recognizer::nextToken()
token = ch.unicode ();
inp ();
- if (token == '.' && ch == QLatin1Char ('/'))
+ if (token == '.' && ch == u'/')
break;
text += QLatin1Char (token);
}
- if (ch != QLatin1Char ('/'))
+ if (ch != u'/')
return (token = ERROR);
inp ();
@@ -247,7 +224,7 @@ int Recognizer::nextToken()
return (token = IMPL);
}
else
- text += QLatin1String ("");
+ text += ""_L1;
}
}
diff --git a/src/tools/qlalr/recognizer.h b/src/tools/qlalr/recognizer.h
index 001de3bcf1..31d606e657 100644
--- a/src/tools/qlalr/recognizer.h
+++ b/src/tools/qlalr/recognizer.h
@@ -1,30 +1,8 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QLALR project on Qt Labs.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** 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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#ifndef RECOGNIZER_H
+#define RECOGNIZER_H
#include "grammar_p.h"
@@ -63,7 +41,7 @@ protected: // scanner
{
ch = *_M_currentChar++;
- if (ch == QLatin1Char('\n'))
+ if (ch == u'\n')
++_M_line;
}
else
@@ -97,3 +75,5 @@ protected:
QString _M_current_value;
bool _M_no_lines;
};
+
+#endif // RECOGNIZER_H