mentat/db/src
Nick Alexander 5369f03464 Improve parsing of nested edn::ValueAndSpan streams. r=rnewman (#393)
* Pre: Expose more in edn.

* Pre: Make it easier to work with ValueAndSpan.

with_spans() is a temporary hack, needed only because I don't care to
parse the bootstrap assertions from text right now.

* Part 1a: Add `value_and_span` for parsing nested `edn::ValueAndSpan` instances.

I wasn't able to abstract over `edn::Value` and `edn::ValueAndSpan`;
there are multiple obstacles.  I chose to roll with
`edn::ValueAndSpan` since it exposes the additional span information
that we will want to form good error messages in the future.

* Part 1b: Add keyword_map() parsing an `edn::Value::Vector` into an `edn::Value::map`.

* Part 1c: Add `Log`/`.log(...)` for logging parser progress.

This is a terrible hack, but it sure helps to debug complicated nested
parsers.  I don't even know what a principled approach would look
like; since our parser combinators are so frequently expressed in
code, it's hard to imagine a data-driven interpreter that can help
debug things.

* Part 2: Use `value_and_span` apparatus in tx-parser/.

I break an abstraction boundary by returning a value column
`edn::ValueAndSpan` rather than just an `edn::Value`.  That is, the
transaction processor shouldn't care where the `edn::Value` it is
processing arose -- even we care to track that information we should
bake it into the `Entity` type.  We do this because we need to
dynamically parse the value column to support nested maps, and parsing
requires a full `edn::ValueAndSpan`.  Alternately, we could cheat and
fake the spans when parsing nested maps, but that's potentially
expensive.

* Part 3: Use `value_and_span` apparatus in query-parser/.

* Part 4: Use `value_and_span` apparatus in root crate.

* Review comment: Make Span and SpanPosition Copy.

* Review comment: nits.

* Review comment: Make `or` be `or_exactly`.

I baked the eof checking directly into the parser, rather than using
the skip and eof parsers.  I also took the time to restore some tests
that were mistakenly commented out.

* Review comment: Extract and use def_matches_* macros.

* Review comment: .map() as late as possible.
2017-04-06 10:06:28 -07:00
..
add_retract_alter_set.rs Schema alteration. Fixes #294 and #295. (#370) r=rnewman 2017-03-20 13:18:59 -07:00
bootstrap.rs Improve parsing of nested edn::ValueAndSpan streams. r=rnewman (#393) 2017-04-06 10:06:28 -07:00
db.rs Improve parsing of nested edn::ValueAndSpan streams. r=rnewman (#393) 2017-04-06 10:06:28 -07:00
debug.rs Use Rc for TypedValue, Variable, and query Ident keywords. (#395) r=nalexander 2017-04-02 21:38:36 -07:00
entids.rs Schema alteration. Fixes #294 and #295. (#370) r=rnewman 2017-03-20 13:18:59 -07:00
errors.rs Lookup refs, nested vector values, map notation. Fixes #180, fixes #183, fixes #284. (#382) r=rnewman 2017-03-27 16:30:04 -07:00
internal_types.rs Lookup refs, nested vector values, map notation. Fixes #180, fixes #183, fixes #284. (#382) r=rnewman 2017-03-27 16:30:04 -07:00
lib.rs #260 Convert Schema into edn::Value (#384) r=nalexander, r=rnewman 2017-03-30 11:08:36 +01:00
metadata.rs Use Rc for TypedValue, Variable, and query Ident keywords. (#395) r=nalexander 2017-04-02 21:38:36 -07:00
schema.rs Add tests for validate_schema_map (#391) r=rnewman 2017-03-30 11:07:49 +01:00
tx.rs Improve parsing of nested edn::ValueAndSpan streams. r=rnewman (#393) 2017-04-06 10:06:28 -07:00
types.rs Collect tempids after upsert resolution. Fixes #299. (#365) r=rnewman 2017-03-20 11:34:38 -07:00
upsert_resolution.rs Lookup refs, nested vector values, map notation. Fixes #180, fixes #183, fixes #284. (#382) r=rnewman 2017-03-27 16:30:04 -07:00