d1ac752de6
This is a big commit, but it breaks into two conceptual pieces. The first is to "parse without copying". We replace a stream of an owned collection of edn::ValueAndSpan and instead have a stream of a borrowed collection of &edn::ValueAndSpan references. (Generally, this is represented as an iterator over a slice, but it can be over other things too.) Cloning such iterators is constant time, which improves on cloning an owned collection of edn::ValueAndSpan, which is linear time in the length of the collection and additional time depending on the complexity of the EDN values. The second conceptual piece is to parse keyword maps using a special parser and a macro to build the parser implementations. Before, we created a new edn::ValueAndSpan::Map to represent a keyword map in vector form; since we're working with &edn::ValueAndSpan references now, we can't create an &edn::ValueAndSpan reference with an appropriate lifetime. Therefore we generalize the concept of iteration slightly and turn keyword maps in map form into linear iterators by flattening the value maps. This is a potentially obscuring transformation, so we have to take care to protect against some failure cases. (See the comments and the tests in the code.) After these changes, parsing using `combine` is linear time (and reasonably fast).
12 lines
254 B
TOML
12 lines
254 B
TOML
[package]
|
|
name = "mentat_parser_utils"
|
|
version = "0.1.0"
|
|
authors = ["Victor Porof <vporof@mozilla.com>", "Richard Newman <rnewman@mozilla.com>"]
|
|
workspace = ".."
|
|
|
|
[dependencies]
|
|
combine = "2.3.2"
|
|
itertools = "0.5.9"
|
|
|
|
[dependencies.edn]
|
|
path = "../edn"
|