[parser-utils] Determine a pattern for using combine to parse tuples #155

Open
opened 2020-08-06 16:55:52 +00:00 by gburd · 0 comments
gburd commented 2020-08-06 16:55:52 +00:00 (Migrated from github.com)

This is follow-up to https://github.com/mozilla/mentat/pull/393#discussion_r109059135. It's not easy to parse two streams in lock-step using combine; this would be handy for parsing maps, which iterate naturally as (k, v) pairs. In response I flatten into a sequence [k1 v1 k2 v2 ...], which combine handles just fine.

combine takes tuples to mean order: that is, (p1, p2) expects p1 to succeed (possibly consuming input) and then p2 to succeed, starting after the input that p1 consumed.

Suppose for the moment that instead (p1, p2) means to parse p1 on the first element of tuples and p2 on the second element of tuples. I don't know how sensible this is; for example, what would (many(p1), p2) do? I'm filing this to have a place to leave thoughts as they come to us.

This is follow-up to https://github.com/mozilla/mentat/pull/393#discussion_r109059135. It's not easy to parse two streams in lock-step using `combine`; this would be handy for parsing maps, which iterate naturally as `(k, v)` pairs. In response I flatten into a sequence `[k1 v1 k2 v2 ...]`, which `combine` handles just fine. `combine` takes tuples to mean order: that is, `(p1, p2)` expects `p1` to succeed (possibly consuming input) and then `p2` to succeed, starting after the input that `p1` consumed. Suppose for the moment that instead `(p1, p2)` means to parse `p1` on the first element of tuples and `p2` on the second element of tuples. I don't know how sensible this is; for example, what would `(many(p1), p2)` do? I'm filing this to have a place to leave thoughts as they come to us.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: greg/mentat#155
No description provided.