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:
parent
382d449ebb
commit
fff0c9cdf0
@ -160,8 +160,9 @@ namespace Opm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Parser::isRecognizedKeyword(const std::string& deckKeywordName) const {
|
bool Parser::isRecognizedKeyword(const std::string& deckKeywordName) const {
|
||||||
if (!ParserKeyword::validDeckName(deckKeywordName, /*acceptLowerCase=*/true))
|
if (!ParserKeyword::validDeckName(deckKeywordName)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (m_deckParserKeywords.count(deckKeywordName) > 0)
|
if (m_deckParserKeywords.count(deckKeywordName) > 0)
|
||||||
return true;
|
return true;
|
||||||
|
@ -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)
|
if (name.length() > ParserConst::maxKeywordLength)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!isupper(name[0]) && !(acceptLowerCaseLetters && islower(name[0])))
|
if (!isupper(name[0]))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -241,14 +241,13 @@ namespace Opm {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ParserKeyword::validDeckName(const std::string& name, bool acceptLowerCaseLetters) {
|
bool ParserKeyword::validDeckName(const std::string& name) {
|
||||||
if (!validNameStart(name, acceptLowerCaseLetters))
|
if (!validNameStart(name))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (size_t i = 1; i < name.length(); i++) {
|
for (size_t i = 1; i < name.length(); i++) {
|
||||||
char c = name[i];
|
char c = name[i];
|
||||||
if (!isupper(c) &&
|
if (!isupper(c) &&
|
||||||
!(acceptLowerCaseLetters && islower(c)) &&
|
|
||||||
!isdigit(c) &&
|
!isdigit(c) &&
|
||||||
c != '-' &&
|
c != '-' &&
|
||||||
c != '_' &&
|
c != '_' &&
|
||||||
|
@ -106,7 +106,7 @@ namespace Opm {
|
|||||||
|
|
||||||
static std::string getDeckName(const std::string& rawString);
|
static std::string getDeckName(const std::string& rawString);
|
||||||
static bool validInternalName(const std::string& name);
|
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;
|
bool hasMatchRegex() const;
|
||||||
void setMatchRegex(const std::string& deckNameRegexp);
|
void setMatchRegex(const std::string& deckNameRegexp);
|
||||||
bool matches(const std::string& deckKeywordName) const;
|
bool matches(const std::string& deckKeywordName) const;
|
||||||
@ -162,7 +162,7 @@ namespace Opm {
|
|||||||
ParserKeywordActionEnum m_action;
|
ParserKeywordActionEnum m_action;
|
||||||
std::string m_Description;
|
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 initDeckNames( const Json::JsonObject& jsonConfig );
|
||||||
void initSectionNames( const Json::JsonObject& jsonConfig );
|
void initSectionNames( const Json::JsonObject& jsonConfig );
|
||||||
void initMatchRegex( const Json::JsonObject& jsonObject );
|
void initMatchRegex( const Json::JsonObject& jsonObject );
|
||||||
|
@ -138,7 +138,7 @@ namespace Opm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool RawKeyword::isValidKeyword(const std::string& keywordCandidate) {
|
bool RawKeyword::isValidKeyword(const std::string& keywordCandidate) {
|
||||||
return ParserKeyword::validDeckName(keywordCandidate, /*acceptLowerCase=*/true);
|
return ParserKeyword::validDeckName(keywordCandidate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -62,11 +62,7 @@ BOOST_AUTO_TEST_CASE(RawKeywordSetKeywordInitialWhitespaceInKeywordThrows) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(constructor_mixedCaseName_throws) {
|
BOOST_AUTO_TEST_CASE(constructor_mixedCaseName_throws) {
|
||||||
// raw keywords may be lower-case even if this is not allowed in valid deck
|
BOOST_CHECK_THROW(RawKeyword("Test", Raw::SLASH_TERMINATED , "FILE" , 10U), std::invalid_argument);
|
||||||
// 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_AUTO_TEST_CASE(RawKeywordSetKeywordInitialTabInKeywordThrows) {
|
BOOST_AUTO_TEST_CASE(RawKeywordSetKeywordInitialTabInKeywordThrows) {
|
||||||
|
Loading…
Reference in New Issue
Block a user