Commit Graph

46 Commits

Author SHA1 Message Date
Joakim Hove
733af54777 Added struct ParseMode to control parse behaviour.
- Introduce a very simple class ParseMode which will become a simple
   value object which can be used to control the behavior when errors
   and inconsistencies are encountered in the parse and EclipseState
   construction phases.

 - Added ParseMode instance as second argument to all parseXXX()
   methods.
2015-08-05 22:02:09 +02:00
Joakim Hove
1161e1098c Rewritten code generation:
With this commit the generation of built in keywords is completely
changed. The most important changes include:

  1) We have autogenerated a class for each keyword in the new
     ParserKeywords { ... } namespace.

  2) The autogenerated classes derive from ParserKeyword, and the
     default constructor will build of a fully initialized
     ParserKeyword instance, i.e. the keyword used to parse the EQUIL
     keyword can be instantiated as simple as:

         ParserKeywords::EQUIL kw;

  3) The generated keywords have built in static constants for keyword
     and item names, and item default values. That way it should be
     possible for the compiler to catch trivial errors like trying to
     access the keyword "PoRO"; also the the access to default values
     means that properties can be initialized without actually
     insantiating a DeckKeyword.

  4) Two new classes Generator/KeywordLoader and
     Generator/KeywordGenerator have been created, with the help of
     these classes the keyword generation code is significantly
     simplified.
2015-06-08 11:29:18 +02:00
Joakim Hove
62e7f2a3aa Moved item management from Keyword to record.
Withe this commit the ParserRecord objects are created as needed by the
ParserKeyword; i.e a parserkeyword can in principle be totally without a
record.
2015-02-26 19:55:06 +01:00
Joakim Hove
875f591a1b Changed ParserKeyword to use vector of records 2015-02-20 00:21:32 +01:00
Andreas Lauser
0262b333fd make items which do not have a default un-defaultable
this was a much more common problem than it seemed initially...
2014-12-18 11:43:52 +01:00
Andreas Lauser
c1988ad8a3 get rid of the 'strict parsing' concept
this is the 'Joakim-style' variant of the patch, i.e., an exception
will always be thrown if an unknown keyword is encountered.
2014-12-11 12:43:12 +01:00
Andreas Lauser
ea38a25af4 remove all trailing white space
this is just the result of

```
find -iname "*.[ch]pp" | xargs sed -i "s/ *$//"
find opm/parser/share/keywords -type f |  xargs sed -i "s/ *$//"
```

so if it causes conflicts with other patches, the others should get
priority. The rationale behind this patch is that some people tell
their editor to remove white space which leads to larger than
necessary patches...
2014-12-08 16:34:28 +01:00
Andreas Lauser
fbf6008da4 Parser: rename and split canParseKeyword to isRecognizedKeyword
which is more what the method does because the keyword can still
contain an error in its data which would make it non-parseable.

While at it, split the method into a "get keyword name from input
line" and "is a valid keyword name" part. (this will be needed later.)
2014-11-05 13:08:04 +01:00
Andreas Lauser
b72df6f406 make ParserItems always defaultable
i.e. remove the defaultSet() method and its friends. this is required
to be able to specify defaults in DATA items like grid properties or
saturation tables. e.g.

SGL
10*0.1 10* 10*0.2 /

would not be possible without this. If no meaningful default for an
item is defined, float and double items get NaN, int items get -1 and
string ones get an empty string. The hope is that if these values get
used in the simulation, they will make the result obviously
incorrect. (Whether a data point of an item was defaulted can be
queried using item->defaultApplied(index).)
2014-09-15 12:17:03 +02:00
Andreas Lauser
539c7a23ae make the defaults of an item settable per data point
instead of for the whole item...
2014-09-15 12:17:03 +02:00
Joakim Hove
bf35919c6f Default: Changed default handling in ParserItem
This is the first of several large commits changing several aspects of
the handling of defaults. The overall main purpose of these changes is
to protect against using non sensible values in the case the values have
not been sensibly specified in the deck. The changes in this commit
include:

 1. The "default default" values to be used when an item without an
    explicit default are defaulted are removed completely.

 2. If a ParserItem is queried for a default value when no default has
    been assigned it will raise an exception.
2014-09-03 10:37:00 +02:00
Andreas Lauser
f754bd9c45 fix some screw-up with internal vs deck names
Parser::hasKeyword() was called with deckNames but looked up the map
for internal names. This patch renames the method to hasDeckName(),
renames Parser::getKeyword() to Parser::getKeywordFromDeckName() and
adapts/extends the tests.
2014-07-01 17:07:43 +02:00
Andreas Lauser
fe638c2fc8 separate the internal keyword names and the deck names more clearly
so far, these two concepts were partially mingled in Opm::Parser...
2014-06-29 14:32:06 +02:00
Andreas Lauser
d820a4d435 change construction of ParserKeyword objects to the factory paradigm
this makes it more explicit what the object is supposed to represent.
2014-06-11 15:08:58 +02:00
Andreas Lauser
d71cb1aa51 parser integration test: use std::istream as a template argument for std::shared_ptr
gcc 4.4 has problems with such implicit conversions...
2014-05-20 13:27:37 +02:00
Andreas Lauser
0d92cd43b0 export possibility to parse an arbitrary std::istream
this has the potential to reduce the memory requirements of the parser
for opm-benchmarks considerably and is quite easy to add since
internally all parsing happend on istreams anyway...

The parser integration test has been extended to test the new method
as well as `parseString()` which was omitted previously. (I wonder who
introduced this without changing the test. ;)
2014-05-20 12:12:12 +02:00
Arne Morten Kvarving
3827ddca64 fixed: mark static symbols as such to quell warnings 2014-05-15 14:46:16 +02:00
Andreas Lauser
9a09fa29af rename Parser::parse to Parser::parseFile and add Parser::parseData
Parser::parseData is quite useful for unit tests to prevent them
spilling files to everything. Also, what was formerly
Parser::parseFile has been renamed to Parser::parseStream and slightly
modified to not be specific for std::ifstream.
2014-01-10 14:51:56 +01:00
Joakim Hove
f1e9230911 Merge remote-tracking branch 'upstream/master' into norne-keywords 2013-12-02 13:21:00 +01:00
Kristian Flikka
1d0135da5e Removed use of boost::shared_ptr, replaced with std::shared_ptr 2013-12-02 13:07:01 +01:00
Joakim Hove
abd0905171 Changed parser to support parsing of keywords with wildcard like
"TVDP*". An importtant change is that we now query the parser
canParseKeyword() instead of hasKeyword().
2013-12-01 09:28:14 +01:00
Joakim Hove
b99d5d75cc Removed explicit keyword loading 2013-10-08 14:19:05 +02:00
Joakim Hove
97750f851f Explicit cast 0 - > (size_t) 0 2013-10-01 16:36:49 +02:00
Joakim Hove
1ff18bb38a Removed constructor with one global JSON config file + addedd optional flag to include all built in keywords 2013-09-14 22:39:43 +02:00
Kristian Flikka
480d14934b Added test for a case with fully, partial and empty record body, defaults are added 2013-08-26 15:17:52 +02:00
Kristian Flikka
375332eb99 Added check if rawRecord is empty, then default is used. Added some json data 2013-08-23 14:20:32 +02:00
Joakim Hove
b630140316 Merged upstream/master 2013-08-23 09:30:23 +02:00
Kristian Flikka
8b4d052f9c Added parameter to parse function to indicate if strict (exception throwing) parsing should be performed 2013-08-21 14:54:38 +02:00
Kristian Flikka
5f1c2722b5 Now also reading unrecognized keywords, labeled such in DeckKeyword class 2013-08-21 10:41:18 +02:00
Kristian Flikka
c7fa8a2e0a Moved testdata into integration test folder. Added build folder to gitignore 2013-08-21 09:35:38 +02:00
Kristian Flikka
002ab45f77 Removed commented test 2013-08-21 08:51:00 +02:00
Joakim Hove
9848ef4d25 Updated integrationtest by adding summary keyword to parser 2013-08-21 07:41:06 +02:00
Joakim Hove
a0a20425f6 Updated tests to reflect that RawDeck has been removed 2013-08-13 14:51:33 +02:00
Joakim Hove
75954575d5 Changed Deck::getKeyword() to take an additional inde argument 2013-08-01 10:57:25 +02:00
Joakim Hove
a8d4a22894 Renamed DeckRecord::get() -> DeckRecord::getItem() 2013-08-01 09:52:49 +02:00
Joakim Hove
8bc176d63e Added full(?) Parser configuration from json 2013-07-31 17:58:05 +02:00
Joakim Hove
db60ee2b56 Removed setRecord() method ParserKeyword. Instead ParserRecord is created during ParserKeyword construction 2013-07-31 15:02:00 +02:00
Joakim Hove
b7397ca502 Parser instantiated with json config file 2013-07-31 11:30:52 +02:00
Kristian Flikka
d79745ce4f Changed some KEYWORD->Keyword instances, search and replace hickup 2013-06-20 15:40:45 +02:00
Kristian Flikka
f1660460dc Replaced all instances of KW with Keyword. We can afford it. 2013-06-20 15:30:37 +02:00
Kristian Flikka
5fa04e5377 Added/implemented XStringItem for Parser and Deck, with tests. Added integration test for WWCT keyword. Moved DeckItem tests into type-specific files. Removed unused file. 2013-06-20 13:56:11 +02:00
Kristian Flikka
2cce97f115 Split parser function, to make more modular and testable. Moved integrationtests from ParserTests into Integration tests. 2013-06-18 10:28:30 +02:00
Kristian Flikka
fbb468342d Finished up the last pieces for a simple BPR keyword vertical. 2013-06-04 14:32:30 +02:00
Kristian Flikka
b43d95c5a2 Starting to wrap up from the top, added the missing DeckKW, and refactored a bit in some of the Raw classes that returned the internal structure 2013-06-03 15:54:16 +02:00
Joakim Hove
c596b086c8 Started integration testing 2013-05-30 10:11:12 +02:00
Kristian Flikka
6e20bfda09 Added Deck class (empty), and some integration tests. WIP 2013-05-27 14:27:22 +02:00