Split Keyword Recognition Into Two Parts
The 'base' checks that the input string looks like a valid keyword and, if so, matches the string against the builtin set of known keywords. The full keyword recognition process additionally includes those keywords that match against keyword collections, typically the SUMMARY section "meta" keywords in the *_PROBE files. We will use the 'base' recognition separately to introduce support for extension keywords with long--more than eight character--names.
This commit is contained in:
@@ -97,7 +97,30 @@ namespace Opm {
|
||||
bool hasKeyword( const std::string& ) const;
|
||||
const ParserKeyword& getKeyword(const std::string& name) const;
|
||||
|
||||
bool isRecognizedKeyword( const std::string_view& deckKeywordName) const;
|
||||
/// Whether or not string is a valid keyword.
|
||||
///
|
||||
/// The full keyword recognition process first verifies that the
|
||||
/// input string looks like a valid keyword and, if so matches that
|
||||
/// string against the builtin set of known keywords. The function
|
||||
/// additionally includes those keywords that match against keyword
|
||||
/// collections, typically the SUMMARY section "meta" keywords in
|
||||
/// the *_PROBE files.
|
||||
///
|
||||
/// \return Whether or not \p deckKeywordName is a builtin deck
|
||||
/// keyword or a known summary keyword.
|
||||
bool isRecognizedKeyword(std::string_view deckKeywordName) const;
|
||||
|
||||
/// Whether or not string is a valid keyword.
|
||||
///
|
||||
/// First checks that the input string looks like a valid keyword
|
||||
/// and, if so, matches the string against the builtin set of known
|
||||
/// keywords.
|
||||
///
|
||||
/// \param[in] deckKeywordName Potential deck keyword.
|
||||
///
|
||||
/// \return Whether or not \p deckKeywordName is a builtin deck keyword.
|
||||
bool isBaseRecognizedKeyword(std::string_view deckKeywordName) const;
|
||||
|
||||
const ParserKeyword& getParserKeywordFromDeckName(const std::string_view& deckKeywordName) const;
|
||||
std::vector<std::string> getAllDeckNames () const;
|
||||
|
||||
|
||||
@@ -883,7 +883,7 @@ newRawKeyword(const std::string& deck_name,
|
||||
}
|
||||
else {
|
||||
parserState.parseContext.handleUnknownKeyword(deck_name,
|
||||
KeywordLocation{
|
||||
KeywordLocation {
|
||||
deck_name,
|
||||
parserState.current_path().string(),
|
||||
parserState.line()
|
||||
@@ -1398,14 +1398,20 @@ bool parseState( ParserState& parserState, const Parser& parser ) {
|
||||
return (m_wildCardKeywords.count(internalKeywordName) > 0);
|
||||
}
|
||||
|
||||
bool Parser::isRecognizedKeyword(const std::string_view& name ) const {
|
||||
if( !ParserKeyword::validDeckName( name ) )
|
||||
bool Parser::isRecognizedKeyword(std::string_view name) const
|
||||
{
|
||||
if (! ParserKeyword::validDeckName(name)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if( m_deckParserKeywords.count( name ) )
|
||||
return true;
|
||||
return (this->m_deckParserKeywords.find(name) != this->m_deckParserKeywords.end())
|
||||
|| (this->matchingKeyword(name) != nullptr);
|
||||
}
|
||||
|
||||
return bool( matchingKeyword( name ) );
|
||||
bool Parser::isBaseRecognizedKeyword(std::string_view name) const
|
||||
{
|
||||
return ParserKeyword::validDeckName(name)
|
||||
&& (this->m_deckParserKeywords.find(name) != this->m_deckParserKeywords.end());
|
||||
}
|
||||
|
||||
void Parser::addParserKeyword( ParserKeyword parserKeyword ) {
|
||||
|
||||
Reference in New Issue
Block a user