Merge pull request #712 from joakim-hove/udq-tokens

Internalize UDQ tokens in the UDQ define keyword
This commit is contained in:
Joakim Hove 2019-04-09 18:29:27 +02:00 committed by GitHub
commit 2997338eb2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 7 deletions

View File

@ -58,12 +58,10 @@ public:
UDQWellSet eval_wells(const UDQContext& context) const;
UDQSet eval(const UDQContext& context) const;
const std::string& keyword() const;
/*
Should not be internalized at all - and will go away; but temporarily needed for testing.
*/
std::vector<std::string> tokens;
const std::vector<std::string>& tokens() const;
UDQVarType var_type() const;
private:
std::vector<std::string> input_tokens;
const UDQParams& udq_params; // Beacuse of the shared RNG stream this must be a reference.
std::string m_keyword;
std::shared_ptr<UDQASTNode> ast;

View File

@ -122,7 +122,7 @@ UDQDefine::UDQDefine(const UDQParams& udq_params,
}
}
this->ast = std::make_shared<UDQASTNode>( UDQParser::parse(this->udq_params, tokens, parseContext, errors) );
this->tokens = tokens;
this->input_tokens = tokens;
}
@ -143,6 +143,9 @@ UDQVarType UDQDefine::var_type() const {
return this->m_var_type;
}
const std::vector<std::string>& UDQDefine::tokens() const {
return this->input_tokens;
}
const std::string& UDQDefine::keyword() const {
return this->m_keyword;

View File

@ -924,13 +924,13 @@ BOOST_AUTO_TEST_CASE(UDQPARSE_TEST1) {
UDQDefine def1(udqp, "WUBHP", {"1/(WWCT", "'W1*')"});
std::vector<std::string> tokens1 = {"1", "/", "(", "WWCT", "W1*", ")"};
BOOST_CHECK_EQUAL_COLLECTIONS(tokens1.begin(), tokens1.end(),
def1.tokens.begin(), def1.tokens.end());
def1.tokens().begin(), def1.tokens().end());
UDQDefine def2(udqp, "WUBHP", {"2*(1", "+" , "WBHP)"});
std::vector<std::string> tokens2 = {"2", "*", "(", "1", "+", "WBHP", ")"};
BOOST_CHECK_EQUAL_COLLECTIONS(tokens2.begin(), tokens2.end(),
def2.tokens.begin(), def2.tokens.end());
def2.tokens().begin(), def2.tokens().end());
}