math: Reject unexpected expression input explicitly

Switch to C++ exceptions for lexer/parser error handling.
Teach the lexer/parser to fail on unexpected input.
This commit is contained in:
Daniel Franke
2018-05-18 21:59:46 +02:00
committed by Brad King
parent 5b0f73a15a
commit 7c4c13ffef
12 changed files with 183 additions and 120 deletions

View File

@@ -36,11 +36,11 @@ bool cmMathCommand::HandleExprCommand(std::vector<std::string> const& args)
const std::string& outputVariable = args[1];
const std::string& expression = args[2];
this->Makefile->AddDefinition(outputVariable, "ERROR");
cmExprParserHelper helper;
if (!helper.ParseString(expression.c_str(), 0)) {
std::string e = "cannot parse the expression: \"" + expression + "\": ";
e += helper.GetError();
this->SetError(e);
this->SetError(helper.GetError());
return false;
}