Commit Graph

108 Commits

Author SHA1 Message Date
Bård Skaflestad
e7324ccd95 Parser.cpp: Include Missing Header
The implementation uses std::stack and therefore needs a declaration
of this type in scope.  This apparently built by accident earlier.
While here, also include a few other headers to make Parser.[hc]pp
more self-contained.
2020-03-22 17:06:38 +01:00
Joakim Hove
aed8c78af5 Move RestartConfig from EclipseState to Schedule 2020-02-19 12:35:07 +01:00
Arne Morten Kvarving
fb75bcd4e2 changed: use std::filesystem instead of boost::filesystem
since we still support g++-7, where filesystem is marked experimental,
we introduce a wrapper header and expose the namespace to use
as Opm::filesystem.

for gcc we unconditionally link with libstdc++fs in the python bindings.
the setup.py stuff links as c code, not c++ code, so it is not
automatically added on any gcc version. this might prove unportable
later.
2020-02-13 12:34:19 +01:00
Joakim Hove
f3bd813f46 Use ParserKeyword values in Parser instead std::unique_ptr<> 2019-09-13 16:21:31 +02:00
Joakim Hove
41bd1eb449 Add missing const to Parser methods 2019-09-05 08:14:55 +02:00
Joakim Hove
17e6599749 Add Parser overloads without ErrorGuard 2019-09-05 07:42:13 +02:00
Joakim Hove
4073722771 Basic support for parsing verbatim keywords with code 2019-09-04 15:20:13 +02:00
Joakim Hove
e3ade4dff9 Use reference instead of pointer 2019-08-15 11:51:08 +02:00
Joakim Hove
2cd6fa2f49 Add overloads without ParseContext and ErrorGuard - update all tests 2019-01-04 13:59:28 +01:00
Joakim Hove
bf52e6d123 Added ErrorGuard& arguments to library 2019-01-03 13:14:40 +01:00
Arne Morten Kvarving
18f15e7432 mark constructors as explicit 2017-06-09 17:38:42 +02:00
Jørgen Kvalsvik
331d61cba5 Parser.parseFile() assumes default parse context 2016-10-19 20:38:28 +02: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
1906bf4d16 Make EclipseGrid no longer use shared_ptr 2016-10-19 20:38:28 +02:00
Pål Grønås Drange
091dc196f3 Added parse functions for Parser, for simpler creation of state and grids 2016-05-06 12:21:41 +02:00
Jørgen Kvalsvik
41fc16ad92 Keep ParserKeyword instances; internalName removed
Internal names are deprecated, and instead added ParserKeyword instances
are maintained and kept for the lifetime of the ParserKeyword instance.
Querying keyword existence from python picks up on Deck names, expected
to always be the intended case, instead of internal names.
2016-05-03 12:59:57 +02:00
Jørgen Kvalsvik
64291e6cca Moved parseState out of Parser; source-file only
This function is not an obvious member of Parser, as it is just as
reliant on ParserState which is source-file private to Parser. Moves to
source file only, without externally-visible private symbol table entry.
2016-05-03 09:30:56 +02:00
Jørgen Kvalsvik
9031ca9406 Make tryParseKeyword/createRawKeyword non-visible
tryParseKeyword and createRawKeyword don't use anything non-public and
does not rely on any non-public parser state, so they are now
implemented as functions private/static in Parser.cpp
2016-05-03 09:19:23 +02:00
Jørgen Kvalsvik
07eea89c34 Remove redundant overloads
These overloads were written to allow testing, but with string_view
accepting char* they're unecessary and confusing.
2016-05-03 09:16:28 +02:00
Jørgen Kvalsvik
a1ae0e0067 Updated various functions to accept string_view
To take advantage of parser's internal string_view representation of
keyword names, several signatures have been updated to accept
string_view.
2016-05-03 09:16:27 +02:00
Jørgen Kvalsvik
82b1901841 Parser keyword maps uses string_view for keys
The use of string_view for keys allows comparison with keywords from the
file buffers to be compared directly, instead of having to go via
std::string. This removes the need for a series of (inherently)
unecessary copies.
2016-05-03 09:16:27 +02:00
Jørgen Kvalsvik
7d29d63bea Replace string with string_view in inner parser
Several inner parser functions modified to use string_view, to reduce
unecessary copying (and indirectly allocationg) related to passing
strings around.
2016-05-03 09:16:27 +02:00
Jørgen Kvalsvik
e5ee6105b7 Remove parseStream support; strict input reading
Replaces the external stream-support by reading the entire contents of
input files at once, rather than lazily through streams. Uses
stringstreams internally, but keeps the entire file in memory through
std::string

openString/File has been renamed to loadString/File
2016-05-03 09:16:27 +02:00
Jørgen Kvalsvik
4d7f97d322 Refactor ParseState to use explicit stack
Rewrites ParseState to use an explicit stack of open file streams
instead of spawning multiple ParseState objects. While recursion is
*the* most elegant to solve a typical include-file system, the global
nature of eclipse declarations make this clumsy (at best). Instead,
maintain an explicit stack of open files and logically parse the input
as if it was all concatenated into one large file.

Also adds some convenient ways of accessing the current (and
interesting) top of the stack.
2016-05-03 09:15:46 +02:00
Arne Morten Kvarving
5f197da8c7 changed: do not prototype boost::filesystem::path
this breaks with g++ 4.8 used in redhat builds.

/usr/include/boost148/boost/filesystem/v3/path.hpp:710:24 error: 'path'
is already declared in this scope.
2016-04-18 09:45:47 +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
650037afb2 Inlined title keyword handling 2016-03-14 08:29:54 +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
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
3ee3c023e6 Handle quotes when stripping off comments. 2015-08-24 20:06:01 +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
c0db611aa8 Added template method Parser::addKeyword<T>() 2015-06-08 11:29:20 +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
af249cefd7 Added method to get keyword from Parser. 2015-02-06 13:03:44 +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
Andreas Lauser
5bdb17f7c1 Parser: rename the internal parseStream() method to parseState()
there is still the public variant of Parser::parseStream() which
parses an arbitrary std::istream. the name of the state-taking variant
was just confusing, IMO...
2014-11-06 15:16:19 +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
c41f5ac2ed ParserLog: print messages to a stream
If no ParserLog object is provided, stdout is used by default. The
stream can also be used to write to a logfile or it can be omitted
entirely. thanks to [at] joakim-hove for insisting on it...
2014-10-10 12:40:35 +02:00