|
@@ -24,6 +24,7 @@ struct cmListFileParser
|
|
cmListFileParser(cmListFile* lf, cmMakefile* mf, const char* filename);
|
|
cmListFileParser(cmListFile* lf, cmMakefile* mf, const char* filename);
|
|
~cmListFileParser();
|
|
~cmListFileParser();
|
|
void IssueFileOpenError(std::string const& text) const;
|
|
void IssueFileOpenError(std::string const& text) const;
|
|
|
|
+ void IssueError(std::string const& text) const;
|
|
bool ParseFile();
|
|
bool ParseFile();
|
|
bool ParseFunction(const char* name, long line);
|
|
bool ParseFunction(const char* name, long line);
|
|
bool AddArgument(cmListFileLexer_Token* token,
|
|
bool AddArgument(cmListFileLexer_Token* token,
|
|
@@ -62,6 +63,18 @@ void cmListFileParser::IssueFileOpenError(const std::string& text) const
|
|
this->Makefile->IssueMessage(cmake::FATAL_ERROR, text);
|
|
this->Makefile->IssueMessage(cmake::FATAL_ERROR, text);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+void cmListFileParser::IssueError(const std::string& text) const
|
|
|
|
+{
|
|
|
|
+ cmListFileContext lfc;
|
|
|
|
+ lfc.FilePath = this->FileName;
|
|
|
|
+ lfc.Line = cmListFileLexer_GetCurrentLine(this->Lexer);
|
|
|
|
+ cmListFileBacktrace lfbt = this->Backtrace;
|
|
|
|
+ lfbt = lfbt.Push(lfc);
|
|
|
|
+ this->Makefile->GetCMakeInstance()->IssueMessage(cmake::FATAL_ERROR, text,
|
|
|
|
+ lfbt);
|
|
|
|
+ cmSystemTools::SetFatalErrorOccured();
|
|
|
|
+}
|
|
|
|
+
|
|
bool cmListFileParser::ParseFile()
|
|
bool cmListFileParser::ParseFile()
|
|
{
|
|
{
|
|
// Open the file.
|
|
// Open the file.
|
|
@@ -98,22 +111,18 @@ bool cmListFileParser::ParseFile()
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
std::ostringstream error;
|
|
std::ostringstream error;
|
|
- error << "Error in cmake code at\n"
|
|
|
|
- << this->FileName << ":" << token->line << ":\n"
|
|
|
|
- << "Parse error. Expected a newline, got "
|
|
|
|
|
|
+ error << "Parse error. Expected a newline, got "
|
|
<< cmListFileLexer_GetTypeAsString(this->Lexer, token->type)
|
|
<< cmListFileLexer_GetTypeAsString(this->Lexer, token->type)
|
|
<< " with text \"" << token->text << "\".";
|
|
<< " with text \"" << token->text << "\".";
|
|
- cmSystemTools::Error(error.str().c_str());
|
|
|
|
|
|
+ this->IssueError(error.str());
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
std::ostringstream error;
|
|
std::ostringstream error;
|
|
- error << "Error in cmake code at\n"
|
|
|
|
- << this->FileName << ":" << token->line << ":\n"
|
|
|
|
- << "Parse error. Expected a command name, got "
|
|
|
|
|
|
+ error << "Parse error. Expected a command name, got "
|
|
<< cmListFileLexer_GetTypeAsString(this->Lexer, token->type)
|
|
<< cmListFileLexer_GetTypeAsString(this->Lexer, token->type)
|
|
<< " with text \"" << token->text << "\".";
|
|
<< " with text \"" << token->text << "\".";
|
|
- cmSystemTools::Error(error.str().c_str());
|
|
|
|
|
|
+ this->IssueError(error.str());
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -156,18 +165,15 @@ bool cmListFileParser::ParseFunction(const char* name, long line)
|
|
<< cmListFileLexer_GetCurrentLine(this->Lexer) << ":\n"
|
|
<< cmListFileLexer_GetCurrentLine(this->Lexer) << ":\n"
|
|
<< "Parse error. Function missing opening \"(\".";
|
|
<< "Parse error. Function missing opening \"(\".";
|
|
/* clang-format on */
|
|
/* clang-format on */
|
|
- cmSystemTools::Error(error.str().c_str());
|
|
|
|
|
|
+ this->IssueError(error.str());
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
if (token->type != cmListFileLexer_Token_ParenLeft) {
|
|
if (token->type != cmListFileLexer_Token_ParenLeft) {
|
|
std::ostringstream error;
|
|
std::ostringstream error;
|
|
- error << "Error in cmake code at\n"
|
|
|
|
- << this->FileName << ":"
|
|
|
|
- << cmListFileLexer_GetCurrentLine(this->Lexer) << ":\n"
|
|
|
|
- << "Parse error. Expected \"(\", got "
|
|
|
|
|
|
+ error << "Parse error. Expected \"(\", got "
|
|
<< cmListFileLexer_GetTypeAsString(this->Lexer, token->type)
|
|
<< cmListFileLexer_GetTypeAsString(this->Lexer, token->type)
|
|
<< " with text \"" << token->text << "\".";
|
|
<< " with text \"" << token->text << "\".";
|
|
- cmSystemTools::Error(error.str().c_str());
|
|
|
|
|
|
+ this->IssueError(error.str());
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -219,25 +225,25 @@ bool cmListFileParser::ParseFunction(const char* name, long line)
|
|
} else {
|
|
} else {
|
|
// Error.
|
|
// Error.
|
|
std::ostringstream error;
|
|
std::ostringstream error;
|
|
- error << "Error in cmake code at\n"
|
|
|
|
- << this->FileName << ":"
|
|
|
|
- << cmListFileLexer_GetCurrentLine(this->Lexer) << ":\n"
|
|
|
|
- << "Parse error. Function missing ending \")\". "
|
|
|
|
|
|
+ error << "Parse error. Function missing ending \")\". "
|
|
<< "Instead found "
|
|
<< "Instead found "
|
|
<< cmListFileLexer_GetTypeAsString(this->Lexer, token->type)
|
|
<< cmListFileLexer_GetTypeAsString(this->Lexer, token->type)
|
|
<< " with text \"" << token->text << "\".";
|
|
<< " with text \"" << token->text << "\".";
|
|
- cmSystemTools::Error(error.str().c_str());
|
|
|
|
|
|
+ this->IssueError(error.str());
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
std::ostringstream error;
|
|
std::ostringstream error;
|
|
- error << "Error in cmake code at\n"
|
|
|
|
- << this->FileName << ":" << lastLine << ":\n"
|
|
|
|
- << "Parse error. Function missing ending \")\". "
|
|
|
|
|
|
+ cmListFileContext lfc;
|
|
|
|
+ lfc.FilePath = this->FileName;
|
|
|
|
+ lfc.Line = lastLine;
|
|
|
|
+ cmListFileBacktrace lfbt = this->Backtrace;
|
|
|
|
+ lfbt = lfbt.Push(lfc);
|
|
|
|
+ error << "Parse error. Function missing ending \")\". "
|
|
<< "End of file reached.";
|
|
<< "End of file reached.";
|
|
- cmSystemTools::Error(error.str().c_str());
|
|
|
|
-
|
|
|
|
|
|
+ this->Makefile->GetCMakeInstance()->IssueMessage(cmake::FATAL_ERROR,
|
|
|
|
+ error.str(), lfbt);
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -252,17 +258,21 @@ bool cmListFileParser::AddArgument(cmListFileLexer_Token* token,
|
|
bool isError = (this->Separation == SeparationError ||
|
|
bool isError = (this->Separation == SeparationError ||
|
|
delim == cmListFileArgument::Bracket);
|
|
delim == cmListFileArgument::Bracket);
|
|
std::ostringstream m;
|
|
std::ostringstream m;
|
|
- /* clang-format off */
|
|
|
|
- m << "Syntax " << (isError? "Error":"Warning") << " in cmake code at\n"
|
|
|
|
- << " " << this->FileName << ":" << token->line << ":"
|
|
|
|
- << token->column << "\n"
|
|
|
|
|
|
+ cmListFileContext lfc;
|
|
|
|
+ lfc.FilePath = this->FileName;
|
|
|
|
+ lfc.Line = token->line;
|
|
|
|
+ cmListFileBacktrace lfbt = this->Backtrace;
|
|
|
|
+ lfbt = lfbt.Push(lfc);
|
|
|
|
+
|
|
|
|
+ m << "Syntax " << (isError ? "Error" : "Warning") << " in cmake code at "
|
|
|
|
+ << "column " << token->column << "\n"
|
|
<< "Argument not separated from preceding token by whitespace.";
|
|
<< "Argument not separated from preceding token by whitespace.";
|
|
/* clang-format on */
|
|
/* clang-format on */
|
|
if (isError) {
|
|
if (isError) {
|
|
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, m.str());
|
|
|
|
|
|
+ this->Makefile->GetCMakeInstance()->IssueMessage(cmake::FATAL_ERROR, m.str(), lfbt);
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
- this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, m.str());
|
|
|
|
|
|
+ this->Makefile->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING, m.str(), lfbt);
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|