diff options
Diffstat (limited to 'src/tools/qlalr')
-rw-r--r-- | src/tools/qlalr/CMakeLists.txt | 16 | ||||
-rw-r--r-- | src/tools/qlalr/compress.cpp | 6 | ||||
-rw-r--r-- | src/tools/qlalr/cppgenerator.cpp | 55 | ||||
-rw-r--r-- | src/tools/qlalr/cppgenerator.h | 6 | ||||
-rw-r--r-- | src/tools/qlalr/examples/dummy-xml/ll/dummy-xml-ll.cpp | 2 | ||||
-rw-r--r-- | src/tools/qlalr/examples/dummy-xml/xml.g | 2 | ||||
-rw-r--r-- | src/tools/qlalr/examples/glsl/build.sh | 2 | ||||
-rw-r--r-- | src/tools/qlalr/examples/glsl/glsl-lex.l | 2 | ||||
-rw-r--r-- | src/tools/qlalr/examples/glsl/glsl.g | 2 | ||||
-rw-r--r-- | src/tools/qlalr/examples/lambda/lambda.g | 2 | ||||
-rw-r--r-- | src/tools/qlalr/examples/lambda/main.cpp | 2 | ||||
-rw-r--r-- | src/tools/qlalr/examples/qparser/calc.g | 2 | ||||
-rw-r--r-- | src/tools/qlalr/examples/qparser/calc.l | 2 | ||||
-rw-r--r-- | src/tools/qlalr/examples/qparser/qparser.cpp | 2 | ||||
-rw-r--r-- | src/tools/qlalr/examples/qparser/qparser.h | 2 | ||||
-rw-r--r-- | src/tools/qlalr/lalr.cpp | 30 | ||||
-rw-r--r-- | src/tools/qlalr/lalr.h | 15 | ||||
-rw-r--r-- | src/tools/qlalr/main.cpp | 8 | ||||
-rw-r--r-- | src/tools/qlalr/recognizer.h | 5 |
19 files changed, 105 insertions, 58 deletions
diff --git a/src/tools/qlalr/CMakeLists.txt b/src/tools/qlalr/CMakeLists.txt index 5eaa7887fc..da8b351889 100644 --- a/src/tools/qlalr/CMakeLists.txt +++ b/src/tools/qlalr/CMakeLists.txt @@ -1,7 +1,5 @@ # Copyright (C) 2022 The Qt Company Ltd. -# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 - -# Generated from qlalr.pro. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## qlalr Tool: @@ -11,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 @@ -23,12 +21,10 @@ qt_internal_add_tool(${target_name} recognizer.cpp recognizer.h DEFINES QT_NO_FOREACH + QT_NO_QPAIR + QT_USE_NODISCARD_FILE_OPEN LIBRARIES - Qt::Core # special case + Qt::Core + Qt::CorePrivate ) qt_internal_return_unless_building_tools() - -#### Keys ignored in scope 1:.:.:qlalr.pro:<TRUE>: -# OTHER_FILES = "lalr.g" -# QMAKE_TARGET_DESCRIPTION = "Qt Look Ahead LR Parser Generator" -# _OPTION = "host_build" diff --git a/src/tools/qlalr/compress.cpp b/src/tools/qlalr/compress.cpp index c6d0ef14b7..6ee083f7e9 100644 --- a/src/tools/qlalr/compress.cpp +++ b/src/tools/qlalr/compress.cpp @@ -139,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); @@ -151,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(); @@ -226,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/cppgenerator.cpp b/src/tools/qlalr/cppgenerator.cpp index a41aa87835..fd56de106d 100644 --- a/src/tools/qlalr/cppgenerator.cpp +++ b/src/tools/qlalr/cppgenerator.cpp @@ -10,6 +10,7 @@ #include <QtCore/qtextstream.h> #include <QtCore/qfile.h> #include <QtCore/qmap.h> +#include <QtCore/private/qconfig_p.h> #include <iterator> @@ -42,7 +43,7 @@ void generateList(const QList<int> &list, QTextStream &out) QString CppGenerator::copyrightHeader() const { return - "// Copyright (C) 2016 The Qt Company Ltd.\n" + "// " QT_COPYRIGHT "\n" "// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0\n" "\n"_L1; } @@ -192,7 +193,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 @@ -214,12 +223,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); + } + } } } @@ -331,7 +348,12 @@ void CppGenerator::operator () () { // 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 ('_')); @@ -363,7 +385,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 @@ -384,7 +411,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(); } @@ -392,7 +424,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(); } @@ -413,7 +450,7 @@ 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); diff --git a/src/tools/qlalr/cppgenerator.h b/src/tools/qlalr/cppgenerator.h index b83dc1396c..66ae781be4 100644 --- a/src/tools/qlalr/cppgenerator.h +++ b/src/tools/qlalr/cppgenerator.h @@ -20,7 +20,8 @@ public: aut (aut), verbose (verbose), debug_info (false), - copyright (false) {} + copyright (false), + warnings_are_errors(false) {} void operator () (); @@ -29,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); @@ -51,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/examples/dummy-xml/ll/dummy-xml-ll.cpp b/src/tools/qlalr/examples/dummy-xml/ll/dummy-xml-ll.cpp index c3aac8662d..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,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// 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 1999ebc35d..59472dc219 100644 --- a/src/tools/qlalr/examples/dummy-xml/xml.g +++ b/src/tools/qlalr/examples/dummy-xml/xml.g @@ -1,5 +1,5 @@ -- Copyright (C) 2016 The Qt Company Ltd. --- SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +-- 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 5f6879737c..d43889bf72 100644 --- a/src/tools/qlalr/examples/glsl/build.sh +++ b/src/tools/qlalr/examples/glsl/build.sh @@ -1,6 +1,6 @@ #!/bin/sh # Copyright (C) 2016 The Qt Company Ltd. -# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +# 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 505e1c14e0..f3f9bb4f50 100644 --- a/src/tools/qlalr/examples/glsl/glsl-lex.l +++ b/src/tools/qlalr/examples/glsl/glsl-lex.l @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// 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 e6a397aa70..223e90284d 100644 --- a/src/tools/qlalr/examples/glsl/glsl.g +++ b/src/tools/qlalr/examples/glsl/glsl.g @@ -1,5 +1,5 @@ -- Copyright (C) 2016 The Qt Company Ltd. --- SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +-- 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 99fa215745..d4fd01ed4c 100644 --- a/src/tools/qlalr/examples/lambda/lambda.g +++ b/src/tools/qlalr/examples/lambda/lambda.g @@ -1,5 +1,5 @@ -- Copyright (C) 2016 The Qt Company Ltd. --- SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +-- 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 94b54e8d0b..c6a2695493 100644 --- a/src/tools/qlalr/examples/lambda/main.cpp +++ b/src/tools/qlalr/examples/lambda/main.cpp @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// 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 33b44a4f62..2be9fd55c0 100644 --- a/src/tools/qlalr/examples/qparser/calc.g +++ b/src/tools/qlalr/examples/qparser/calc.g @@ -1,5 +1,5 @@ -- Copyright (C) 2016 The Qt Company Ltd. --- SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +-- 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 34792d0319..0f42987758 100644 --- a/src/tools/qlalr/examples/qparser/calc.l +++ b/src/tools/qlalr/examples/qparser/calc.l @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// 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 9c497b3559..354a778458 100644 --- a/src/tools/qlalr/examples/qparser/qparser.cpp +++ b/src/tools/qlalr/examples/qparser/qparser.cpp @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// 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 bd135b7a26..80643616c4 100644 --- a/src/tools/qlalr/examples/qparser/qparser.h +++ b/src/tools/qlalr/examples/qparser/qparser.h @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #ifndef QPARSER_H #define QPARSER_H diff --git a/src/tools/qlalr/lalr.cpp b/src/tools/qlalr/lalr.cpp index 460be04272..51f1d94a40 100644 --- a/src/tools/qlalr/lalr.cpp +++ b/src/tools/qlalr/lalr.cpp @@ -139,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}; } @@ -296,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 @@ -351,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; @@ -359,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); @@ -371,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; @@ -399,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; @@ -594,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; @@ -696,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.h b/src/tools/qlalr/lalr.h index 19dcdb626e..efa0a91a39 100644 --- a/src/tools/qlalr/lalr.h +++ b/src/tools/qlalr/lalr.h @@ -9,7 +9,6 @@ #include <QtCore/qmap.h> #include <QtCore/qstring.h> #include <QtCore/qtextstream.h> -#include <QtCore/qpair.h> #include <algorithm> #include <functional> @@ -117,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; @@ -143,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 (); } @@ -198,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}; } ///////////////////////////////////////////////////////////// @@ -312,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 8d339173ec..04ae54d986 100644 --- a/src/tools/qlalr/main.cpp +++ b/src/tools/qlalr/main.cpp @@ -28,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); } @@ -42,6 +43,7 @@ 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); @@ -64,6 +66,9 @@ int main (int argc, char *argv[]) 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; @@ -104,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) diff --git a/src/tools/qlalr/recognizer.h b/src/tools/qlalr/recognizer.h index ce07ff361f..31d606e657 100644 --- a/src/tools/qlalr/recognizer.h +++ b/src/tools/qlalr/recognizer.h @@ -1,6 +1,9 @@ // 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" #include "lalr.h" @@ -72,3 +75,5 @@ protected: QString _M_current_value; bool _M_no_lines; }; + +#endif // RECOGNIZER_H |