OPM-17: First attempt to handle END and ENDINC keywords

This commit is contained in:
Atle Haugan
2014-01-24 10:01:17 +01:00
parent 581bf74e9a
commit ef11a2331f
5 changed files with 32 additions and 4 deletions
@@ -38,6 +38,10 @@ add_executable(runParseACTION ParseACTION.cpp)
target_link_libraries(runParseACTION Parser ${Boost_LIBRARIES})
add_test(NAME runParseACTION WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH} COMMAND runParseACTION)
add_executable(runParseEND ParseEND.cpp)
target_link_libraries(runParseEND Parser ${Boost_LIBRARIES})
add_test(NAME runParseEND WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH} COMMAND runParseEND)
add_executable(runIncludeTest IncludeTest.cpp)
target_link_libraries(runIncludeTest Parser ${Boost_LIBRARIES})
add_test(NAME runIncludeTest WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH} COMMAND runIncludeTest)
@@ -36,7 +36,7 @@ using namespace Opm;
using namespace boost::filesystem;
void
createDeckWithInclude(path& datafile)
createDeckWithInclude(path& datafile, bool addEndIncKeyword)
{
path root = unique_path("/tmp/%%%%-%%%%");
path absoluteInclude = root / "absolute.include";
@@ -77,6 +77,10 @@ createDeckWithInclude(path& datafile)
path relativeInclude = root / "relative.include";
std::ofstream of(relativeInclude.string().c_str());
if (addEndIncKeyword) {
of << "ENDINC" << std::endl;
of << "/" << std::endl;
}
of << "START" << std::endl;
of << " 10 'FEB' 2012 /" << std::endl;
of.close();
@@ -96,6 +100,7 @@ createDeckWithInclude(path& datafile)
of2 << "/" << std::endl;
of2.close();
}
std::cout << datafile << std::endl;
}
@@ -106,7 +111,7 @@ createDeckWithInclude(path& datafile)
BOOST_AUTO_TEST_CASE(parse_fileWithWWCTKeyword_deckReturned) {
path datafile;
ParserPtr parser(new Parser());
createDeckWithInclude (datafile);
createDeckWithInclude (datafile, false);
DeckConstPtr deck = parser->parseFile(datafile.string());
BOOST_CHECK( deck->hasKeyword("DIMENS"));
@@ -114,3 +119,14 @@ BOOST_AUTO_TEST_CASE(parse_fileWithWWCTKeyword_deckReturned) {
BOOST_CHECK( deck->hasKeyword("GRIDUNIT"));
}
BOOST_AUTO_TEST_CASE(parse_fileWithENDINCKeyword_deckReturned) {
path datafile;
ParserPtr parser(new Parser());
createDeckWithInclude (datafile, true);
DeckConstPtr deck = parser->parseFile(datafile.string());
BOOST_CHECK( deck->hasKeyword("DIMENS"));
BOOST_CHECK( !deck->hasKeyword("START"));
BOOST_CHECK( deck->hasKeyword("GRIDUNIT"));
}
+7 -1
View File
@@ -186,7 +186,13 @@ namespace Opm {
while (true) {
bool streamOK = tryParseKeyword(parserState);
if (parserState->rawKeyword) {
if (parserState->rawKeyword->getKeywordName() == Opm::RawConsts::include) {
if (parserState->rawKeyword->getKeywordName() == Opm::RawConsts::end) {
break;
}
else if (parserState->rawKeyword->getKeywordName() == Opm::RawConsts::endinclude) {
break;
}
else if (parserState->rawKeyword->getKeywordName() == Opm::RawConsts::include) {
RawRecordConstPtr firstRecord = parserState->rawKeyword->getRecord(0);
std::string includeFileString = firstRecord->getItem(0);
boost::filesystem::path includeFile(includeFileString);
+2
View File
@@ -29,6 +29,8 @@ namespace Opm {
const char quote = '\'';
const std::string separators = "\t ";
const std::string include = "INCLUDE";
const std::string end = "END";
const std::string endinclude = "ENDINC";
const unsigned int maxKeywordLength = 8;
}
}
+1 -1
View File
@@ -1 +1 @@
{"name":"END", "action":"IGNORE_WARNING"}
{"name" : "END"}