Commit Graph

2305 Commits

Author SHA1 Message Date
Jørgen Kvalsvik
caa10631b0 IOConfig::handle* takes references over shared_ptr 2016-05-09 14:56:04 +02:00
Jørgen Kvalsvik
1d5ae5ea55 EclipseGrid::getNXYZ which returns xyz as array 2016-05-09 14:55:24 +02:00
Jørgen Kvalsvik
ee8710d3cb SummaryConfig does not require EclipseState
Rewrite construction to accept EclipseState components instead of the
full state. Enables having SummaryConfig as a member in EclipseState.
2016-05-09 14:55:24 +02:00
Jørgen Kvalsvik
28ae15cf0f Move getRegions into 3DProperties 2016-05-09 14:55:24 +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
Pål Grønås Drange
b8b1ba9528 ParseContext is now a member of EclipseState
* EclipseState now copies input ParseContext and keeps it as member
* Made the argument (ParseContext) default as ParseContext()
* Now you can make a new EclipseState with only deck as argument
* Removed test that tested address equality of ParseContext objects
2016-05-06 11:37:26 +02:00
Joakim Hove
350297e8ec Merge pull request #792 from jokva/bugfixes
Bugfixes
2016-05-04 09:30:30 +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
Pål Grønås Drange
672b240e00 fixed bug in Parser, use openRootFile 2016-05-03 15:22:34 +02:00
Pål Grønås Drange
d9eb3ebf86 Added test for IOConfigBaseName and fixed a self-introduced bug in E.S. 2016-05-03 14:07:01 +02:00
Jørgen Kvalsvik
0966a9cb8c Fix RawKeywor tests to reflect assumptions 2016-05-03 13:39:36 +02:00
Pål Grønås Drange
3a3ec10649 moved initialization of primary's to header, fixed rebase 2016-05-03 13:22:57 +02:00
Pål Grønås Drange
5a7dcc5427 Made FaultCollection reference in State thereby fixing compiler warn 2016-05-03 13:22:57 +02:00
Pål Grønås Drange
63e452167c Introduce deckptr-less EclipseState and EclipseGrid 2016-05-03 13:22:56 +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
ba5983483e Throw on error from fread 2016-05-03 09:30:57 +02:00
Jørgen Kvalsvik
dcc3668fdd Rename strip_after -> find_terimnator 2016-05-03 09:30:57 +02:00
Jørgen Kvalsvik
8cb64dad72 Encapsulate ParserState's internals. 2016-05-03 09:30:57 +02:00
Jørgen Kvalsvik
ff301622b6 Append newline to input; remove branch in getline
By allowing getline to assume that the next line always starts after the
found \n *or* that after the found newline is the \0, we can avoid a
branch and potential stall.
2016-05-03 09:30:57 +02:00
Jørgen Kvalsvik
8014ec817c Prefer empty over size 2016-05-03 09:30:56 +02:00
Jørgen Kvalsvik
a7d18cd8df Reindentation. 2016-05-03 09:30:56 +02:00
Jørgen Kvalsvik
de3db110c9 Replace static with anon namespace
This is done to hide symbols such as class definitions in addition to
functions.
2016-05-03 09:30:56 +02:00
Jørgen Kvalsvik
de691c0bd5 Replace ParserState shared_ptr with auto var 2016-05-03 09:30:56 +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
6df67c7de2 Encapsulate getline behaviour onto ParserState
A getline implementation that carries mostly the same assumptions as
istream::getline. Requires ParserState::done() to always be checked (for
negative) to safely retrieve the next line.

Enables tryParseKeywords and friend to only maintain a high level view
of the parsing procedure, and not deal with stream positioning.
2016-05-03 09:19:23 +02:00
Jørgen Kvalsvik
9cf2c9fd98 Formalised stack semantics for input in parser
Moves the storage/lifetime components of ParserState into its own
helper utility class. Splits the implementation responsibility so that
all input data and state is handled by the InputStack, and "global"
information is managed directly by ParserState.
2016-05-03 09:19:22 +02:00
Jørgen Kvalsvik
120a30e94b Replace std::isspace in parser; add \r to is_sep 2016-05-03 09:16:28 +02:00
Jørgen Kvalsvik
1622a5bd49 Use explicit loop invariant in loadFromDeckKeyword
gcc doesn't seem to do this for us.
2016-05-03 09:16:28 +02:00
Jørgen Kvalsvik
784a1a5d78 Replace std::isspace with hand-rolled version
Profiling indicate isspace isn't inlined properly, so we replace it with
a hand-rolled easier-to-inline version.
2016-05-03 09:16:28 +02:00
Jørgen Kvalsvik
60c20f8057 Explicitly store loop invariants in assertSIData
Profiling shows that gcc isn't recognising these as loop invariants, so
we help it a little bit by explicitly storing them.
2016-05-03 09:16:28 +02:00
Jørgen Kvalsvik
8a4eb5279c Splitting records with string_view; test updates
The splitting of RawRecords into individual symbols uses string_view.
Also updates tests since RawRecord now assumes that the record string it
receives is complete and does *not* contain the terminating slash.
2016-05-03 09:16:28 +02:00
Jørgen Kvalsvik
a105f3a193 string_view char* constructor 2016-05-03 09:16:28 +02:00
Jørgen Kvalsvik
c2b5da457c Re-implement is_separator to use isspace 2016-05-03 09:16:28 +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
6b64796d49 Add char* constructor to string_view
Mostly relevant for testing, this enables string_view to work as
expected with string literals.
2016-05-03 09:16:28 +02:00
Jørgen Kvalsvik
bfa3f799b9 Improved fast path in number parsing
Since string_view uses char* for representation, there is no longer a
need to copy into a local char array for most code paths (only when the
input must be modified due to fortran float formatting).
2016-05-03 09:16:28 +02:00
Jørgen Kvalsvik
b648719513 Base string_view on char*, not string::iterator
By representing string_view as char* instead of
std::string::const_iterator the string_view class bring possibly
slightly lower overhead, but mostly enables some optimisations.
2016-05-03 09:16:27 +02:00
Jørgen Kvalsvik
bda128ee23 front/back support in string_view 2016-05-03 09:16:27 +02:00
Jørgen Kvalsvik
cb29336a44 Remove all non-data before parsing begins
Perform a pre-pass over the input and remove everything that isn't
interesting. Preserves empty lines to provide accurate line number for
diagnostics/error output.
2016-05-03 09:16:27 +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
a93507087d string_view operator< and operator== support
In order for string_view to be useful as container member and sorting,
it has to support operator< and operator==
2016-05-03 09:16:27 +02:00
Jørgen Kvalsvik
096e843d08 Moved special-casing of TITLE to RawKeyword
Replaces the special-casing of the TITLE keyword where a terminating
slash is added onto the record with a non-mutating version.
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
1edc6887be Replace parser stringstreams with string_view
Replaces the parser's dependence on streams with string_view, which
won't copy to its internal buffers. Involves hand-rolling std::getline
for string_view to preserve stream-like behaviour.
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
db6bb58f60 Remove redundant application of uppercase()
When considering if a keyword is valid, the parser procedures convert
the same string to uppercase twice, with copies. This behaviour has been
changed, and ParserKeyword now assumes it will be given a
correctly-formatted keyword to look up.
2016-05-03 09:15:46 +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
Jørgen Kvalsvik
83555a52a1 Minor restructuring in Parser::getKeyword* 2016-05-03 09:15:46 +02:00