Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions ez.lock.toml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ narHash = "sha256-FLTyFw5HkOrl/T6E8hbs/XVwL05oGmcJARW9I9eHdgA="
[tools]
[tools.bolt]
git = "https://github.com/Emerging-Patterns/bolt"
rev = "bee8f22cc127b2336a46f6af5c9cca51122759c5"
tag = "v1.3.4"
rev = "02fb09377f5c0fbddb5f6b7c32c8ab4ae14240df"
tag = "v1.8.0"
root = "."
narHash = "sha256-ufakKA4HHNdx9vXD1z1x6GxtxHhUtr2LbiS1A+hf2M8="
narHash = "sha256-53zE+3lZ/jn9GvIeGoavvNMaFyUs5dEFWd7fwP49TlM="
6 changes: 3 additions & 3 deletions ez.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ entry = "main.bend"
[tools]
[tools.bolt]
git = "https://github.com/Emerging-Patterns/bolt"
rev = "bee8f22cc127b2336a46f6af5c9cca51122759c5"
tag = "v1.3.4"
rev = "02fb09377f5c0fbddb5f6b7c32c8ab4ae14240df"
tag = "v1.8.0"
root = "."
narHash = "sha256-ufakKA4HHNdx9vXD1z1x6GxtxHhUtr2LbiS1A+hf2M8="
narHash = "sha256-53zE+3lZ/jn9GvIeGoavvNMaFyUs5dEFWd7fwP49TlM="
9 changes: 6 additions & 3 deletions toml/toml.bend
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,14 @@ def head.of(segs: List<&2, String>) -> String:
# a table's section, when it holds a pair or no table. A table that holds
# only tables is the parent a dotted header implies, which ez never writes a
# pair into; old ledgers and locks name no such table, so it is no section.
# (segs arrive innermost first, as `tables` builds them; the header reads
# them outermost first)
def sect.put(skip: Bool, +ps: List<&2, Kv>, +segs: List<&2, String>) -> List<&2, Sect>:
match skip:
case True{}:
[]
case False{}:
[Sect{head.of(segs), ps}]
[Sect{head.of(List.reverse(&2, String, segs)), ps}]

def sect.keep(+ps: List<&2, Kv>, parent: Bool, +segs: List<&2, String>) -> List<&2, Sect>:
sect.put(Bool.and(List.is_empty(&2, Kv, ps), parent), ps, segs)
Expand All @@ -280,13 +282,14 @@ def table.sects(+segs: List<&2, String>, +sub: List<&2, E.Val>, inner: List<&2,
List.append(&2, Sect, sect.keep(pairs.of(sub), has.table(sub), segs), inner)

# the sections of every table among a table's rows, in document order: each
# table's own section, then the tables in it, then the tables after it
# table's own section, then the tables in it, then the tables after it. The
# path to the table is kept innermost first, so a level prepends its name.
def tables(rows: List<&2, E.Val>, +segs: List<&2, String>) -> List<&2, Sect>:
match rows:
case []:
[]
case E.VPair{name, E.VHead{_path, +sub}} <> tl:
+at = List.append(&2, String, segs, [name])
+at : List<&2, String> = name <> segs
List.append(&2, Sect, table.sects(at, sub, tables(sub, at)), tables(tl, segs))
case _hd <> tl:
tables(tl, segs)
Expand Down
Loading