From 4383cd2b6bac4f935046cb35c2965cc662aa8487 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Del=20Pino?= <stephane.delpino44@gmail.com> Date: Mon, 9 Nov 2020 11:08:25 +0100 Subject: [PATCH] Launch an UnexpectedError when grammar contains issues Number of grammar issues were previously output. This was useful for early language developments but always displaying information is irrelevant. Note grammar issues means that the grammar itself is buggy. It is not related to errors in user scripts. --- src/language/PugsParser.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/language/PugsParser.cpp b/src/language/PugsParser.cpp index efddefd1a..a82570a82 100644 --- a/src/language/PugsParser.cpp +++ b/src/language/PugsParser.cpp @@ -37,7 +37,11 @@ parser(const std::string& filename) { const size_t grammar_issues = analyze<language::grammar>(); - std::cout << rang::fgB::yellow << "grammar_issues=" << rang::fg::reset << grammar_issues << '\n'; + if (grammar_issues != 0) { + std::ostringstream os; + os << "invalid grammar: " << rang::fgB::yellow << grammar_issues << rang::fg::reset << " were detected!"; + throw UnexpectedError(os.str()); + } std::cout << rang::style::bold << "Parsing file " << rang::style::reset << rang::style::underline << filename << rang::style::reset << " ...\n"; -- GitLab