Commit Graph

70 Commits

Author SHA1 Message Date
Atgeirr Flø Rasmussen
8527e646a1 Improve tests by checking for present keyword. 2017-02-10 13:02:21 +01:00
Atgeirr Flø Rasmussen
b82d9eb9b3 Add tests and test files with backslashes in INCLUDE paths. 2017-02-09 21:17:14 +01:00
Jørgen Kvalsvik
a22196546a ParserItem no longer requires heap alloc
Redesign of ParserItem so that its sum type nature no longer mandates
indirection, but rather a tag check on all operations. Because of this,
ParserRecords can now store ParserItems directly, and iterators are no
longer iterators to pointers, but behave like normal vector iterators.
2016-11-07 12:24:38 +01:00
Jørgen Kvalsvik
f9cb516b99 Remove DeckPtr+ParserPtr aliases
Remove the deprecated DeckPtr and ParserPtr aliases and removes
shared_ptr<Deck> and friends from all interfaces.
2016-10-19 20:38:28 +02:00
Jørgen Kvalsvik
ca2985d5a0 Fix warnings in ParserTests 2016-07-13 23:40:09 +02:00
Joakim Hove
f2e94061d8 Added Json config for new keywords. 2016-07-13 14:56:15 +02:00
Joakim Hove
10bf441076 Added ParseContext::PARSE_MISSING_INCLUDE 2016-06-15 17:34:44 +02:00
Jørgen Kvalsvik
f56a2d61d0 Strip commas from the input deck
Some decks use comma to separate items in a record, but the comma adds
no extra information and is essentially ignored. Post-process the file
after cleaning it and replace all commas with whitespace.

Considering the record "foo bar , , , baz" / baz will silently be moved
to the third item, but handling that situation is a **lot** more
difficult and time consuming and not worth the effort for now.
Additionally, we have yet to receive decks that fail in such a manner,
nor are we sure if it is even a valid record in Eclipse.
2016-06-14 12:57:05 +02:00
Jørgen Kvalsvik
1f2c2ba98d Name cases where TITLE is unset
When the TITLE keyword was present in the deck, but no parameter was
given the parser would consume the next keyword as the simulation TITLE.
Override this by writing a default TITLE if it's unset.
2016-05-03 15:42:30 +02:00
Joakim Hove
f0158f6ca3 Merge pull request #718 from jokva/fix-uninitialised-values
Initialisation and memory errors fixed
2016-03-17 13:56:48 +01:00
Liu Ming
705a9dc168 rename ParseMode as ParseContex in Parser folder. 2016-03-16 16:34:58 +08:00
Jørgen Kvalsvik
47ca6d31cc Remove unused dropParserKeyword
This method is not used at all, but creates noise in tests and is broken
(iterator invalidation).
2016-03-15 15:14:10 +01:00
Jørgen Kvalsvik
7bc3c79301 PATHS keyword has global scope.
ECLIPSE resolves path aliases defined in an included file globally, i.e.
/
|> include.inc
|-- PATHS 'alias' 'path/to/dir'
|> main.data
|-- INCLUDE 'include.inc' /
| [...]
|-- INCLUDE '$alias/file.inc' /

will resolve as 'path/to/dir/file.inc'. This behaviour is now adopted by
opm-parser.
2016-02-22 10:16:12 +01:00
Jørgen Kvalsvik
78e1ab9db5 Parser stores keywords as unique_ptr
Removes shared_ptr< ParserKeyword > exchange in Parser interface and
replaces it with unique_ptr storage and raw pointers for return values.
This has some implications:

* addParserKeyword() no longer takes shared_ptr<>, but unique_ptr&&
  addParserKeyword has been modified to create unique_ptr instead of
  shared_ptr.

* generated-source/ParserKeyword* no longer use make_shared which had a
  -massive- impact on compile times, which are now more-or-less
  trivialised (on my machine: 7.5s -> 1s per file). This because the
  compiler no longer generates a bunch of forwarding make_shared
  instances of subclasses that are immediately thrown away, but rather
  uses an inline make_unique that instantiates the -parent- class
  unique_ptr.
2016-02-19 14:19:41 +01:00
Jørgen Kvalsvik
a187d58502 Removes unused function in ParserTests 2016-02-19 14:04:17 +01:00
Jørgen Kvalsvik
4b98943665 Replaces unecessary header includes with fwd decls
Every header is self-contained and includes only what it must to
function, relying on users include what they need in source files,
adopting a pay-what-you-use model (in particular for internal
dependencies).
2016-01-26 13:23:22 +01:00
Kjell W. Kongsvik
dc0cc45e89 Allowed parser keywords without items 2015-09-15 16:43:01 +02:00
Joakim Hove
3ee3c023e6 Handle quotes when stripping off comments. 2015-08-24 20:06:01 +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
875f591a1b Changed ParserKeyword to use vector of records 2015-02-20 00:21:32 +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
a4f55f5f8d JSON keyword definitions: make the "sections" item mandatory
the empty list can be used which means that the keyword may occur in
any section. (which is useful for e.g. section delimiters.)
2014-10-13 16:06:09 +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
09c5a24473 add GROUP_PROBE 2014-06-29 14:32:06 +02:00
Andreas Lauser
d4409dbae0 add BLOCK_PROBE 2014-06-29 14:32:06 +02:00
Andreas Lauser
49b48662ef change the TVDP keywords to use regular expressions instead of wildcards 2014-06-29 14:32:06 +02:00
Andreas Lauser
5f949c11c3 add support for parser keywords specifying to multiple deck keywords
Say hello to the complete set of well, region, field and group output
specifiers soon...
2014-06-13 13:17:03 +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
Arne Morten Kvarving
3827ddca64 fixed: mark static symbols as such to quell warnings 2014-05-15 14:46:16 +02:00
Atgeirr Flø Rasmussen
79e4d51597 Renamed local variable to avoid shadowing. 2014-04-15 09:49:04 +02:00
Atle Haugan
ed17058ad3 Renamed FLOAT to DOUBLE in JSON files, tests and some code using the enum 2014-02-17 15:02:40 +01:00
Atle Haugan
c9cda9916f Code improvements based on code review feedback 2014-01-08 15:03:16 +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
76a9cbb0b8 Updated test to check a return value 2013-10-25 17:31:48 +02:00
Roland Kaufmann
781ef04a0e Compare size with unsigned int literal
Surprisingly, some compilers (notably GCC 4.6.3) will issue a warning
when comparing a literal which is clearly positive to an unsigned type,
when looking for a suitable instantiation in Boost. This is fixed by
making the literal unsigned too, so there's no doubt.
2013-10-22 23:39:49 +02:00
Joakim Hove
1cc16de2bd Added test for replace keyword functionality 2013-10-18 10:17:48 +02:00
Joakim Hove
b63244228d Added Parser::dropKeyword() 2013-10-09 08:22:43 +02:00
Joakim Hove
9986916ca7 Fixing parser tests 2013-09-17 17:45:42 +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
e55d52654d Added test to check that getKeyword throws when asked for non-existing keyword 2013-08-27 10:10:12 +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
be882b6b27 Removed commented test 2013-08-23 12:18:38 +02:00
Joakim Hove
b630140316 Merged upstream/master 2013-08-23 09:30:23 +02:00
Joakim Hove
df031007db Added items: to all inline config strings 2013-08-23 00:20:07 +02:00
Joakim Hove
dfca913462 Added method to load keyword configurations from directory 2013-08-21 12:50:21 +02:00
Kristian Flikka
002ab45f77 Removed commented test 2013-08-21 08:51:00 +02:00
Kristian Flikka
89daeea561 Renamed newRawKeyword to createRawKeyword. Minor refactoring 2013-08-21 08:44:46 +02:00
Joakim Hove
47d29cc804 Added parser->size() and parser->loadKeywordFromFile() 2013-08-19 22:37:48 +02:00