Revert "also eat keywords containing lowercase letters"

this was inadvertedly merged. the real fix is to make the parser
case-insensitive...
This commit is contained in:
Andreas Lauser 2014-11-07 14:23:08 +01:00
parent 382d449ebb
commit fff0c9cdf0
5 changed files with 12 additions and 16 deletions

View File

@ -160,8 +160,9 @@ namespace Opm {
}
bool Parser::isRecognizedKeyword(const std::string& deckKeywordName) const {
if (!ParserKeyword::validDeckName(deckKeywordName, /*acceptLowerCase=*/true))
if (!ParserKeyword::validDeckName(deckKeywordName)) {
return false;
}
if (m_deckParserKeywords.count(deckKeywordName) > 0)
return true;
@ -309,8 +310,8 @@ namespace Opm {
"The keyword " + parserState->rawKeyword->getKeywordName() + " is ignored - this might potentially affect the results");
} else {
DeckKeywordPtr deckKeyword(new DeckKeyword(parserState->rawKeyword->getKeywordName(), false));
deckKeyword->setLocation(parserState->rawKeyword->getFilename(),
parserState->rawKeyword->getLineNR());
deckKeyword->setLocation(parserState->rawKeyword->getFilename(),
parserState->rawKeyword->getLineNR());
parserState->deck->addKeyword(deckKeyword);
parserState->parserLog.addWarning(parserState->dataFile.string(),
parserState->rawKeyword->getLineNR(),

View File

@ -202,11 +202,11 @@ namespace Opm {
}
bool ParserKeyword::validNameStart(const std::string& name, bool acceptLowerCaseLetters) {
bool ParserKeyword::validNameStart(const std::string& name) {
if (name.length() > ParserConst::maxKeywordLength)
return false;
if (!isupper(name[0]) && !(acceptLowerCaseLetters && islower(name[0])))
if (!isupper(name[0]))
return false;
return true;
@ -241,14 +241,13 @@ namespace Opm {
return result;
}
bool ParserKeyword::validDeckName(const std::string& name, bool acceptLowerCaseLetters) {
if (!validNameStart(name, acceptLowerCaseLetters))
bool ParserKeyword::validDeckName(const std::string& name) {
if (!validNameStart(name))
return false;
for (size_t i = 1; i < name.length(); i++) {
char c = name[i];
if (!isupper(c) &&
!(acceptLowerCaseLetters && islower(c)) &&
!isdigit(c) &&
c != '-' &&
c != '_' &&

View File

@ -106,7 +106,7 @@ namespace Opm {
static std::string getDeckName(const std::string& rawString);
static bool validInternalName(const std::string& name);
static bool validDeckName(const std::string& name, bool acceptLowerCaseLetters = false);
static bool validDeckName(const std::string& name);
bool hasMatchRegex() const;
void setMatchRegex(const std::string& deckNameRegexp);
bool matches(const std::string& deckKeywordName) const;
@ -162,7 +162,7 @@ namespace Opm {
ParserKeywordActionEnum m_action;
std::string m_Description;
static bool validNameStart(const std::string& name, bool acceptLowerCaseLetters);
static bool validNameStart(const std::string& name);
void initDeckNames( const Json::JsonObject& jsonConfig );
void initSectionNames( const Json::JsonObject& jsonConfig );
void initMatchRegex( const Json::JsonObject& jsonObject );

View File

@ -138,7 +138,7 @@ namespace Opm {
}
bool RawKeyword::isValidKeyword(const std::string& keywordCandidate) {
return ParserKeyword::validDeckName(keywordCandidate, /*acceptLowerCase=*/true);
return ParserKeyword::validDeckName(keywordCandidate);
}

View File

@ -62,11 +62,7 @@ BOOST_AUTO_TEST_CASE(RawKeywordSetKeywordInitialWhitespaceInKeywordThrows) {
}
BOOST_AUTO_TEST_CASE(constructor_mixedCaseName_throws) {
// raw keywords may be lower-case even if this is not allowed in valid deck
// names... (this will produce a warning if the deck is checked.)
RawKeyword("Test", Raw::SLASH_TERMINATED , "FILE" , 10U);
RawKeyword("test", Raw::SLASH_TERMINATED , "FILE" , 10U);
BOOST_CHECK_THROW(RawKeyword keyword("1test", Raw::SLASH_TERMINATED , "FILE" , 10U), std::invalid_argument);
BOOST_CHECK_THROW(RawKeyword("Test", Raw::SLASH_TERMINATED , "FILE" , 10U), std::invalid_argument);
}
BOOST_AUTO_TEST_CASE(RawKeywordSetKeywordInitialTabInKeywordThrows) {