Commit Graph

163 Commits

Author SHA1 Message Date
chflo
82bef27b8f Support symlink 2016-04-01 15:36:38 +02:00
Jørgen Kvalsvik
046afdd3be RawKeyword iterator support
Since RawRecords now has automatic storage, managed by std::list,
offering iterators is feasible. The random access
RawKeyword::getRecord's real use was accessing the records in order,
which now is handled via iterators.
2016-03-30 12:47:33 +02:00
Jørgen Kvalsvik
0da5cadc75 RawRecords auto store, strings moved to RawRecord
The accumulated strings are moved into RawRecords, which reduces
execution time (rough measurements indicates 4-8%). To facilitate this,
RawRecords are stored directly in the vector in favour of via
shared_ptrs.
2016-03-22 08:58:48 +01:00
chflo
f2ed1ba7ea Moved OpmLog from opm-parser to opm-common 2016-03-21 22:07:49 +01: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
cee22efd99 Pass readValueToken string_view 2016-03-14 08:55:02 +01:00
Jørgen Kvalsvik
7440acaa6a Replaces boost::trim_right with faster version
boost::trim_right loses a lot of performance from being locale aware.
Since this is not a problem for our ASCII fortran-type files, ignore
this issue and use isspace for trimming.
2016-03-14 08:29:54 +01:00
Jørgen Kvalsvik
650037afb2 Inlined title keyword handling 2016-03-14 08:29:54 +01:00
Jørgen Kvalsvik
798084676a RawRecord uses string_view internally
Modifies RawRecord to internally use string_view instead of copies of
the substrings. This *vastly* reduces copying in the processing of each
record and subsequently improves performance. Reduces total memory usage
in Deck construction.
2016-03-14 08:29:53 +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
7eb52f1023 Removes DeckKeyword's dependency on ParserKeyword
The completely constructed Deck isn't supposed to have any relationship
with the Parser structures (which are completely stateless in terms of
input data), and ParserKeyword in DeckKeyword was an anomaly. With
recent refactorings this lead to subtle lifetime issues.

This patch breaks this dependency and cleans up DeckKeyword accordingly,
while changing checkDeck to now take the parser as an additional
argument, to look up whether or not some DeckKeyword is in the right
section. This now also means that Parser* objects can be destroyed once
the Deck is created.

The Section::checkSectionTopology has been moved to Parser.cpp. It is a
temporary home for the feature to make the project compile nicely (i.e.
createKeywordList can be compiled as before, without introducing a
circular dependency on itself via Parser.cpp), until some proper cleanup
of the parser code has been done. It never really fully belonged in
Section.cpp anyway, so this is a first step in the direction of some
slight renaming.
2016-02-18 13:27:24 +01:00
Jørgen Kvalsvik
f0ae5db131 opm-parser adoption of Deck automatic ownership
Since the Deck* family of classes have changed their interfaces to no
longer use shared_ptr, a lot of code broke. This patch fixes all
problems in tests, other signatures and accesses to now use the new Deck
interfaces.
2016-02-18 13:27:24 +01:00
Jørgen Kvalsvik
dc5afd5236 DeckKeyword::ParserKeyword to regular pointer 2016-02-18 13:26:55 +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
Joakim Hove
14428ee000 Merge pull request #656 from jokva/master
Build system improvements & dependency/header cleanup
2016-01-21 11:59:06 +01:00
Jørgen Kvalsvik
f404828d63 Cleans up headers to improve build preformance
This is an effort to improve build performance.  Several includes
scattered across the project are either unused or partially used (i.e.
just used to import a type name, not depending on the actual contents of
the header file).

Replaces a lot of these includes with forward declarations.
2016-01-21 09:22:06 +01:00
Joakim Hove
db2fe56f9b Added overload for Parser::addParserKeyword() 2016-01-19 13:39:58 +01:00
Joakim Hove
1018c9ef4c Use Deck* and Deck& instead of shared_ptr<Deck>. 2016-01-12 12:16:27 +01:00
Joakim Hove
c1e94f788f ParseMode::PARSE_EXTRA_DATA
Extra elements in the input record are handled with
ParseMode::handleError() with the new error mode PARSE_EXTRA_DATA.
2015-09-28 13:43:22 +02:00
Joakim Hove
3ee3c023e6 Handle quotes when stripping off comments. 2015-08-24 20:06:01 +02:00
Joakim Hove
d26428dd52 Reimplmented ParseMode based on string keys.
Completely reimplemented the ParseMode class. Now the main datastructure
is a map<string,action> where the possible error situations are the
keys. This approach allows for a much more flexible
setting/filtering/querying of the ParseMode settings.
2015-08-10 14:27:53 +02:00
Joakim Hove
35d22ca526 Fixed bug with nested includes 2015-08-07 10:58:34 +02:00
Joakim Hove
5c55af2f86 Trim spaces before detecting randomSlash. 2015-08-07 10:22:00 +02:00
Joakim Hove
91bd434963 Added ParseMode::randomSlash setting. 2015-08-06 15:12:51 +02:00
Joakim Hove
19eac286a0 Added ParseMode::missingDIMSkeyword 2015-08-05 22:02:11 +02:00
Joakim Hove
5e64d0f147 Added parser error for 'random text'.
Previously random text in the input deck which was not formatted as a
valid keyword header was simply ignored; i.e. this

   DIMENS
     10 10 10 /

   Mohaha random gibbersih - not according to any Spec.

   GRID

Would suprisingly parse just fine. This will now be handled according
to the ParseMode::randomText setting. Observe that as a side effect of
this it turned out that many of the test datasets had additional
terminating slashes which were now detected as 'ranomdText'.
2015-08-05 22:02:10 +02:00
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
b83b4b614e Claenup ParserState constructors. 2015-06-18 08:06:41 +02:00
Joakim Hove
875fd86c3c Added strict flag to parser:
Have added a new bool strict flag to the parsing functions, if the
strict flag is set to false the parser will just skip lines with unknwon
keywords, including pure garbage in the input. I.e. for a deck like:

TABDIMS
  1 1 1 /

Crap - not a keyword at all

-- Correctly formatted - unknown keyword
IGNORED
  0 1 /

The parser will load the TABDIMS keyword correctly, and skip the rest.
2015-06-18 08:06:40 +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
Fredrik Gundersen
574deeff18 Clean up and fix indentation 2015-04-01 13:37:55 +02:00
Fredrik Gundersen
89960331cf Rewrite of constructor to support g++4.4 2015-04-01 13:34:23 +02:00
Fredrik Gundersen
5401b828ba Changed to use C++11 syntax for constructor 2015-04-01 08:49:36 +02:00
Fredrik Gundersen
a64c3a62bf Added new constuctor with PATHS parameter 2015-03-31 13:30:02 +02:00
Joakim Hove
9fb229ccd7 Replaced references to logger with OpmLog::addMessage() 2015-03-04 22:14:31 +01:00
Joakim Hove
3a60605d99 Removed most of the functionality from CounterLog 2015-03-04 22:12:53 +01:00
Joakim Hove
25bff6480d Renamed MessageCounter -> CounterLog 2015-03-04 22:12:52 +01:00
Joakim Hove
d3277543ec Renamed existing Logger -> MessageCounter 2015-03-04 22:09:54 +01:00
Joakim Hove
875f591a1b Changed ParserKeyword to use vector of records 2015-02-20 00:21:32 +01:00
Joakim Hove
eda7b60f54 Handle missing xxxDIMS keywords
For some keywords the number of records is given as the value of an item
in another keyword, for instance the number of records in the EQUIL
keyword is given by NTEQUL item in the EQLDIMS keyword.

If the EQLDIMS keyword is not given in the deck the Parser will consult
the default values of EQLDIMS keyword; i.e. a missing keyword is treated
as all-defaulted.
2015-02-06 13:04:17 +01:00
Joakim Hove
af249cefd7 Added method to get keyword from Parser. 2015-02-06 13:03:44 +01:00
chflo
26a4a1d57d OPM-145: Removed action-related code from Parser class 2015-01-14 10:08:40 +01:00
Andreas Lauser
e12a0aab1b parser main loop: handle unknown sized keywords in a better way 2014-12-19 10:59:12 +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
Joakim Hove
b585655a5c Changes in the log class:
1. Moved to from eclipse/Parser -> eclipse/Log
 2. Renamed ParserLog -> OpmLog
2014-12-15 17:36:10 +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
Joakim Hove
994932738d Merge pull request #339 from andlaus/low_level_improvments
Low level improvments
2014-12-11 11:49:32 +01:00