Added ParseMode::randomSlash setting.
This commit is contained in:
@@ -26,6 +26,7 @@ namespace Opm {
|
||||
ParseMode::ParseMode() {
|
||||
unknownKeyword = InputError::THROW_EXCEPTION;
|
||||
randomText = InputError::THROW_EXCEPTION;
|
||||
randomSlash = InputError::THROW_EXCEPTION;
|
||||
missingDIMSKeyword = InputError::THROW_EXCEPTION;
|
||||
unsupportedScheduleGeoModifiers = InputError::THROW_EXCEPTION;
|
||||
}
|
||||
|
||||
@@ -81,7 +81,14 @@ namespace Opm {
|
||||
*/
|
||||
InputError::Action randomText;
|
||||
|
||||
/*
|
||||
It turns out that random '/' - i.e. typically an extra slash
|
||||
which is not needed - is quite common. This is therefor a
|
||||
special case treatment of the 'randomText' behaviour.
|
||||
*/
|
||||
InputError::Action randomSlash;
|
||||
|
||||
|
||||
/*
|
||||
For some keywords the number of records (i.e. size) is given
|
||||
as an item in another keyword. A typical example is the
|
||||
|
||||
@@ -107,8 +107,16 @@ namespace Opm {
|
||||
|
||||
void handleRandomText(const std::string& keywordString ) const {
|
||||
std::stringstream msg;
|
||||
InputError::Action action = parseMode.randomText;
|
||||
msg << "String \'" << keywordString << "\' not formatted/recognized as valid keyword at: " << dataFile << ":" << lineNR;
|
||||
InputError::Action action;
|
||||
|
||||
if (keywordString == "/") {
|
||||
action = parseMode.randomSlash;
|
||||
msg << "Extra '/' detected at: " << dataFile << ":" << lineNR;
|
||||
} else {
|
||||
action = parseMode.randomText;
|
||||
msg << "String \'" << keywordString << "\' not formatted/recognized as valid keyword at: " << dataFile << ":" << lineNR;
|
||||
}
|
||||
|
||||
if (action == InputError::THROW_EXCEPTION)
|
||||
throw std::invalid_argument( msg.str() );
|
||||
else {
|
||||
|
||||
@@ -129,3 +129,27 @@ BOOST_AUTO_TEST_CASE( CheckUnsoppertedInSCHEDULE ) {
|
||||
parseMode.unsupportedScheduleGeoModifiers = InputError::THROW_EXCEPTION;
|
||||
BOOST_CHECK_THROW( Schedule( parseMode , grid , deck , ioconfig ), std::invalid_argument );
|
||||
}
|
||||
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(TestRandomSlash) {
|
||||
const char * deck =
|
||||
"SCHEDULE\n"
|
||||
"TSTEP\n"
|
||||
" 10 10 10 /\n"
|
||||
"/\n";
|
||||
|
||||
|
||||
ParseMode parseMode;
|
||||
Parser parser(false);
|
||||
|
||||
|
||||
parser.addKeyword<ParserKeywords::TSTEP>();
|
||||
parser.addKeyword<ParserKeywords::SCHEDULE>();
|
||||
parseMode.randomSlash = InputError::THROW_EXCEPTION;
|
||||
BOOST_CHECK_THROW( parser.parseString( deck , parseMode ) , std::invalid_argument);
|
||||
|
||||
parseMode.randomSlash = InputError::IGNORE;
|
||||
BOOST_CHECK_NO_THROW( parser.parseString( deck , parseMode ) );
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user