Add small struct DeckKeyword::Location to simplify error reporting
This commit is contained in:
@@ -33,7 +33,6 @@ namespace Opm {
|
||||
|
||||
DeckKeyword::DeckKeyword(const ParserKeyword& parserKeyword) :
|
||||
m_keywordName(parserKeyword.getName()),
|
||||
m_lineNumber(-1),
|
||||
m_isDataKeyword(false),
|
||||
m_slashTerminated(true),
|
||||
parser_keyword(parserKeyword)
|
||||
@@ -42,7 +41,6 @@ namespace Opm {
|
||||
|
||||
DeckKeyword::DeckKeyword(const ParserKeyword& parserKeyword, const std::string& keywordName) :
|
||||
m_keywordName(keywordName),
|
||||
m_lineNumber(-1),
|
||||
m_isDataKeyword(false),
|
||||
m_slashTerminated(true),
|
||||
parser_keyword(parserKeyword)
|
||||
@@ -190,20 +188,19 @@ namespace Opm {
|
||||
}
|
||||
|
||||
void DeckKeyword::setLocation(const std::pair<const std::string&, std::size_t>& location) {
|
||||
m_fileName = location.first;
|
||||
m_lineNumber = location.second;
|
||||
this->m_location = Location(location.first, location.second);
|
||||
}
|
||||
|
||||
const std::string& DeckKeyword::getFileName() const {
|
||||
return m_fileName;
|
||||
return this->m_location.filename;
|
||||
}
|
||||
|
||||
int DeckKeyword::getLineNumber() const {
|
||||
return m_lineNumber;
|
||||
return this->m_location.lineno;
|
||||
}
|
||||
|
||||
std::pair<std::string, std::size_t> DeckKeyword::location() const {
|
||||
return std::make_pair( this->getFileName(), this->getLineNumber() );
|
||||
const DeckKeyword::Location& DeckKeyword::location() const {
|
||||
return this->m_location;
|
||||
}
|
||||
|
||||
void DeckKeyword::setDataKeyword(bool isDataKeyword_) {
|
||||
|
||||
@@ -84,7 +84,7 @@ void Quantity::add_arg(const std::string& arg) {
|
||||
this->args.push_back(strip_quotes(arg));
|
||||
}
|
||||
|
||||
Condition::Condition(const std::vector<std::string>& tokens, const std::pair<std::string, std::size_t>& location) {
|
||||
Condition::Condition(const std::vector<std::string>& tokens, const DeckKeyword::Location& location) {
|
||||
this->lhs = Quantity(tokens[0]);
|
||||
std::size_t token_index = 1;
|
||||
|
||||
@@ -105,7 +105,7 @@ Condition::Condition(const std::vector<std::string>& tokens, const std::pair<std
|
||||
}
|
||||
|
||||
if (token_index >= tokens.size())
|
||||
throw std::invalid_argument("Could not determine right hand side / comparator for ACTIONX keyword at " + location.first + ":" + std::to_string(location.second));
|
||||
throw std::invalid_argument("Could not determine right hand side / comparator for ACTIONX keyword at " + location.filename + ":" + std::to_string(location.lineno));
|
||||
|
||||
this->rhs = Quantity(tokens[token_index]);
|
||||
token_index++;
|
||||
|
||||
Reference in New Issue
Block a user