diff --git a/opm/parser/eclipse/Applications/Schedule.cpp b/opm/parser/eclipse/Applications/Schedule.cpp index 96138bcc5..233d1485c 100644 --- a/opm/parser/eclipse/Applications/Schedule.cpp +++ b/opm/parser/eclipse/Applications/Schedule.cpp @@ -14,7 +14,7 @@ int main(int /* argc */, char** argv) { Opm::ParserPtr parser(new Opm::Parser()); std::string file = argv[1]; - Opm::DeckConstPtr deck = parser->parseFile(file, false); + Opm::DeckConstPtr deck = parser->parseFile(file); Opm::Schedule sched( deck ); std::cout << "Wells: " << sched.numWells() << std::endl; diff --git a/opm/parser/eclipse/Applications/opm-eclkwtest.cpp b/opm/parser/eclipse/Applications/opm-eclkwtest.cpp index 8bce4f4c1..9dfb8a23c 100644 --- a/opm/parser/eclipse/Applications/opm-eclkwtest.cpp +++ b/opm/parser/eclipse/Applications/opm-eclkwtest.cpp @@ -67,7 +67,7 @@ int main(int argc, char** argv) { Opm::ParserPtr parser(new Opm::Parser()); std::string file = argv[1]; Opm::ParserLogPtr parserLog(new Opm::ParserLog); - Opm::DeckConstPtr deck = parser->parseFile(file, true, parserLog); + Opm::DeckConstPtr deck = parser->parseFile(file, parserLog); printDeckDiagnostics(deck, parserLog, printKeywords); diff --git a/opm/parser/eclipse/IntegrationTests/BoxTest.cpp b/opm/parser/eclipse/IntegrationTests/BoxTest.cpp index f6e77d2a7..04034c3b0 100644 --- a/opm/parser/eclipse/IntegrationTests/BoxTest.cpp +++ b/opm/parser/eclipse/IntegrationTests/BoxTest.cpp @@ -34,7 +34,7 @@ EclipseState makeState(const std::string& fileName, ParserLogPtr parserLog); EclipseState makeState(const std::string& fileName, ParserLogPtr parserLog) { ParserPtr parser(new Parser( )); boost::filesystem::path boxFile(fileName); - DeckPtr deck = parser->parseFile(boxFile.string() , false); + DeckPtr deck = parser->parseFile(boxFile.string()); EclipseState state(deck, parserLog); return state; } diff --git a/opm/parser/eclipse/IntegrationTests/CheckDeckValidity.cpp b/opm/parser/eclipse/IntegrationTests/CheckDeckValidity.cpp index 41a007d9c..ac993274e 100644 --- a/opm/parser/eclipse/IntegrationTests/CheckDeckValidity.cpp +++ b/opm/parser/eclipse/IntegrationTests/CheckDeckValidity.cpp @@ -101,33 +101,4 @@ BOOST_AUTO_TEST_CASE( KeywordInCorrectSection ) { // this fails because of the incorrect BOX keyword BOOST_CHECK(!Opm::checkDeck(deck, parserLog, Opm::SectionTopology | Opm::KeywordSection)); } - - { - // deck contains an unknown keyword "FOO" - const char *incorrectDeckString = - "RUNSPEC\n" - "FOO\n" - "DIMENS\n" - "3 3 3 /\n" - "GRID\n" - "DXV\n" - "1 1 1 /\n" - "DYV\n" - "1 1 1 /\n" - "DZV\n" - "1 1 1 /\n" - "TOPS\n" - "9*100 /\n" - "PROPS\n" - "SOLUTION\n" - "SCHEDULE\n"; - - auto deck = parser->parseString(incorrectDeckString, /*strict=*/false); - Opm::ParserLogPtr parserLog(new Opm::ParserLog()); - BOOST_CHECK(!Opm::checkDeck(deck, parserLog)); - - // this is supposed to succeed as we ensure everything except that all keywords - // are known - BOOST_CHECK(Opm::checkDeck(deck, parserLog, ~Opm::UnknownKeywords)); - } } diff --git a/opm/parser/eclipse/IntegrationTests/IntegrationTests.cpp b/opm/parser/eclipse/IntegrationTests/IntegrationTests.cpp index 26b4ed6d1..c24d0696a 100644 --- a/opm/parser/eclipse/IntegrationTests/IntegrationTests.cpp +++ b/opm/parser/eclipse/IntegrationTests/IntegrationTests.cpp @@ -203,17 +203,9 @@ BOOST_AUTO_TEST_CASE(parse_fileWithBPRKeyword_dataiscorrect) { /***************** Testing non-recognized keywords ********************/ -BOOST_AUTO_TEST_CASE(parse_unknownkeywordWithnonstrictparsing_keywordmarked) { +BOOST_AUTO_TEST_CASE(parse_unknownkeyword_exceptionthrown) { ParserPtr parser(new Parser()); - DeckPtr deck = parser->parseFile("testdata/integration_tests/someobscureelements.data", false); - BOOST_CHECK_EQUAL(4U, deck->size()); - DeckKeywordConstPtr unknown = deck->getKeyword("GRUDINT"); - BOOST_CHECK(!unknown->isKnown()); -} - -BOOST_AUTO_TEST_CASE(parse_unknownkeywordWithstrictparsing_exceptionthrown) { - ParserPtr parser(new Parser()); - BOOST_CHECK_THROW( parser->parseFile("testdata/integration_tests/someobscureelements.data", true), std::invalid_argument); + BOOST_CHECK_THROW( parser->parseFile("testdata/integration_tests/someobscureelements.data"), std::invalid_argument); } /*********************Testing truncated (default) records ***************************/ diff --git a/opm/parser/eclipse/IntegrationTests/ParseACTION.cpp b/opm/parser/eclipse/IntegrationTests/ParseACTION.cpp index 134d7dbed..94315ec78 100644 --- a/opm/parser/eclipse/IntegrationTests/ParseACTION.cpp +++ b/opm/parser/eclipse/IntegrationTests/ParseACTION.cpp @@ -50,10 +50,10 @@ BOOST_AUTO_TEST_CASE( parse_ACTION_OK ) { BOOST_REQUIRE( parser->isRecognizedKeyword( "WCONHIST" )); BOOST_REQUIRE( parser->isRecognizedKeyword( "THROW" )); - BOOST_REQUIRE_THROW( parser->parseFile( actionFile2.string() , false) , std::invalid_argument ); + BOOST_REQUIRE_THROW( parser->parseFile(actionFile2.string()) , std::invalid_argument ); ParserLogPtr parserLog(new ParserLog); - DeckPtr deck = parser->parseFile(actionFile.string() , false, parserLog); + DeckPtr deck = parser->parseFile(actionFile.string(), parserLog); DeckKeywordConstPtr kw1 = deck->getKeyword("WCONHIST" , 0); BOOST_CHECK_EQUAL( 3U , kw1->size() ); @@ -76,14 +76,10 @@ BOOST_AUTO_TEST_CASE( parse_ACTION_OK ) { BOOST_CHECK_EQUAL( false , deck->hasKeyword( "DIMENS" )); - BOOST_CHECK_EQUAL( 2U , parserLog->size() ); + BOOST_CHECK_EQUAL( 1U , parserLog->size() ); { BOOST_CHECK_EQUAL( actionFile.string() , parserLog->getFileName(0)); BOOST_CHECK_EQUAL( 2U , parserLog->getLineNumber(0)); } - { - BOOST_CHECK_EQUAL( actionFile.string() , parserLog->getFileName(1)); - BOOST_CHECK_EQUAL( 6U , parserLog->getLineNumber(1)); - } } diff --git a/opm/parser/eclipse/IntegrationTests/ParseEND.cpp b/opm/parser/eclipse/IntegrationTests/ParseEND.cpp index 1826413ae..b2cb52775 100644 --- a/opm/parser/eclipse/IntegrationTests/ParseEND.cpp +++ b/opm/parser/eclipse/IntegrationTests/ParseEND.cpp @@ -39,7 +39,7 @@ BOOST_AUTO_TEST_CASE( parse_END_OK ) { ParserPtr parser(new Parser()); boost::filesystem::path fileWithTitleKeyword("testdata/integration_tests/END/END1.txt"); - DeckPtr deck = parser->parseFile (fileWithTitleKeyword.string(), true); + DeckPtr deck = parser->parseFile(fileWithTitleKeyword.string()); BOOST_CHECK_EQUAL(size_t(1), deck->size()); BOOST_CHECK_EQUAL (true, deck->hasKeyword("OIL")); @@ -51,7 +51,7 @@ BOOST_AUTO_TEST_CASE( parse_ENDINC_OK ) { ParserPtr parser(new Parser()); boost::filesystem::path fileWithTitleKeyword("testdata/integration_tests/END/ENDINC1.txt"); - DeckPtr deck = parser->parseFile (fileWithTitleKeyword.string(), true); + DeckPtr deck = parser->parseFile(fileWithTitleKeyword.string()); BOOST_CHECK_EQUAL(size_t(1), deck->size()); BOOST_CHECK_EQUAL (true, deck->hasKeyword("OIL")); diff --git a/opm/parser/eclipse/IntegrationTests/ParseTITLE.cpp b/opm/parser/eclipse/IntegrationTests/ParseTITLE.cpp index 9251ca153..253b01730 100644 --- a/opm/parser/eclipse/IntegrationTests/ParseTITLE.cpp +++ b/opm/parser/eclipse/IntegrationTests/ParseTITLE.cpp @@ -40,7 +40,7 @@ BOOST_AUTO_TEST_CASE( parse_TITLE_OK ) { ParserPtr parser(new Parser()); boost::filesystem::path fileWithTitleKeyword("testdata/integration_tests/TITLE/TITLE1.txt"); - DeckPtr deck = parser->parseFile (fileWithTitleKeyword.string(), true); + DeckPtr deck = parser->parseFile(fileWithTitleKeyword.string()); BOOST_CHECK_EQUAL(size_t(2), deck->size()); BOOST_CHECK_EQUAL (true, deck->hasKeyword("TITLE")); diff --git a/opm/parser/eclipse/Parser/Parser.cpp b/opm/parser/eclipse/Parser/Parser.cpp index ab8dc3b72..7a62ac7e7 100644 --- a/opm/parser/eclipse/Parser/Parser.cpp +++ b/opm/parser/eclipse/Parser/Parser.cpp @@ -39,11 +39,9 @@ namespace Opm { size_t lineNR; std::shared_ptr inputstream; RawKeywordPtr rawKeyword; - bool strictParsing; std::string nextKeyword; - ParserState(const boost::filesystem::path &inputDataFile, DeckPtr deckToFill, const boost::filesystem::path &commonRootPath, bool useStrictParsing) { + ParserState(const boost::filesystem::path &inputDataFile, DeckPtr deckToFill, const boost::filesystem::path &commonRootPath) { lineNR = 0; - strictParsing = useStrictParsing; dataFile = inputDataFile; deck = deckToFill; rootPath = commonRootPath; @@ -61,18 +59,16 @@ namespace Opm { } } - ParserState(const std::string &inputData, DeckPtr deckToFill, bool useStrictParsing) { + ParserState(const std::string &inputData, DeckPtr deckToFill) { lineNR = 0; - strictParsing = useStrictParsing; dataFile = ""; deck = deckToFill; initSuccessful = true; inputstream.reset(new std::istringstream(inputData)); } - ParserState(std::shared_ptr inputStream, DeckPtr deckToFill, bool useStrictParsing) { + ParserState(std::shared_ptr inputStream, DeckPtr deckToFill) { lineNR = 0; - strictParsing = useStrictParsing; dataFile = ""; deck = deckToFill; initSuccessful = true; @@ -93,9 +89,9 @@ namespace Opm { is retained in the current implementation. */ - DeckPtr Parser::parseFile(const std::string &dataFileName, bool strictParsing, ParserLogPtr parserLog) const { + DeckPtr Parser::parseFile(const std::string &dataFileName, ParserLogPtr parserLog) const { - std::shared_ptr parserState(new ParserState(dataFileName, DeckPtr(new Deck()), getRootPathFromFile(dataFileName), strictParsing)); + std::shared_ptr parserState(new ParserState(dataFileName, DeckPtr(new Deck()), getRootPathFromFile(dataFileName))); // warn if the file we'd like to parse does not exist or is not readable if (!parserState->initSuccessful) @@ -110,9 +106,9 @@ namespace Opm { return parserState->deck; } - DeckPtr Parser::parseString(const std::string &data, bool strictParsing, ParserLogPtr parserLog) const { + DeckPtr Parser::parseString(const std::string &data, ParserLogPtr parserLog) const { - std::shared_ptr parserState(new ParserState(data, DeckPtr(new Deck()), strictParsing)); + std::shared_ptr parserState(new ParserState(data, DeckPtr(new Deck()))); parseState(parserState); applyUnitsToDeck(parserState->deck); @@ -123,8 +119,8 @@ namespace Opm { return parserState->deck; } - DeckPtr Parser::parseStream(std::shared_ptr inputStream, bool strictParsing, ParserLogPtr parserLog) const { - std::shared_ptr parserState(new ParserState(inputStream, DeckPtr(new Deck()), strictParsing)); + DeckPtr Parser::parseStream(std::shared_ptr inputStream, ParserLogPtr parserLog) const { + std::shared_ptr parserState(new ParserState(inputStream, DeckPtr(new Deck()))); parseState(parserState); applyUnitsToDeck(parserState->deck); @@ -284,7 +280,7 @@ namespace Opm { boost::filesystem::path includeFile = getIncludeFilePath(parserState, includeFileAsString); - std::shared_ptr newParserState (new ParserState(includeFile.string(), parserState->deck, parserState->rootPath, parserState->strictParsing)); + std::shared_ptr newParserState (new ParserState(includeFile.string(), parserState->deck, parserState->rootPath)); if (!newParserState->initSuccessful) throw std::invalid_argument("Included file '" + includeFile.string() + "' does not exist or is not readable."); @@ -371,13 +367,8 @@ namespace Opm { } return RawKeywordPtr(new RawKeyword(keywordString, parserState->dataFile.string() , parserState->lineNR , targetSize , parserKeyword->isTableCollection())); } - } else { - if (parserState->strictParsing) { - throw std::invalid_argument("Keyword " + keywordString + " not recognized "); - } else { - return RawKeywordPtr(new RawKeyword(keywordString, parserState->dataFile.string(), parserState->lineNR , 0)); - } - } + } else + throw std::invalid_argument("Keyword " + keywordString + " not recognized "); } diff --git a/opm/parser/eclipse/Parser/Parser.hpp b/opm/parser/eclipse/Parser/Parser.hpp index f7368b49d..9997fe3f7 100644 --- a/opm/parser/eclipse/Parser/Parser.hpp +++ b/opm/parser/eclipse/Parser/Parser.hpp @@ -47,9 +47,9 @@ namespace Opm { Parser(bool addDefault = true); /// The starting point of the parsing process. The supplied file is parsed, and the resulting Deck is returned. - DeckPtr parseFile(const std::string &dataFile, bool strictParsing=true, ParserLogPtr parserLog = std::make_shared(&std::cout)) const; - DeckPtr parseString(const std::string &data, bool strictParsing=true, ParserLogPtr parserLog = std::make_shared(&std::cout)) const; - DeckPtr parseStream(std::shared_ptr inputStream, bool strictParsing=true, ParserLogPtr parserLog = std::make_shared(&std::cout)) const; + DeckPtr parseFile(const std::string &dataFile, ParserLogPtr parserLog = std::make_shared(&std::cout)) const; + DeckPtr parseString(const std::string &data, ParserLogPtr parserLog = std::make_shared(&std::cout)) const; + DeckPtr parseStream(std::shared_ptr inputStream, ParserLogPtr parserLog = std::make_shared(&std::cout)) const; /// Method to add ParserKeyword instances, these holding type and size information about the keywords and their data. void addParserKeyword(ParserKeywordConstPtr parserKeyword); diff --git a/testdata/integration_tests/ACTION/ACTION.txt b/testdata/integration_tests/ACTION/ACTION.txt index 6a0d5b973..3f56f4064 100644 --- a/testdata/integration_tests/ACTION/ACTION.txt +++ b/testdata/integration_tests/ACTION/ACTION.txt @@ -1,8 +1,4 @@ -UNRECOGNIZED - This Keyword should give a warning at line 2/ - - DIMENS -- /This is flagged as IGNORE_WARNING - and should give a warning at line: 6 10 10 10 /