feat(std/toml): read and write TOML 1.x as a tree and through Encode and Decode #285

Merged
argus merged 2 commits from loop/77-std-toml into main 2026-10-09 22:18:12 +00:00
Collaborator

Closes #77

Adds std/toml: TOML 1.0 and 1.1 as a format of std/encoding, per the refine comment on #77.

  • Toml { naming, strict, version } with encode, decode, parse, value and write; TomlVersion { Toml10, Toml11 } chooses what the writer emits, the reader takes the union of every released 1.x.
  • TomlValue/TomlEntry tree in document order; TomlDate, TomlTime, TomlLocalDateTime, TomlOffsetDateTime with nanoseconds and an offset in minutes, show() as RFC 3339, wrappers named by type, TomlOffsetDateTime.toTimestamp().
  • TomlError with line and column for syntax and structure errors. No Format<TomlError> and no framer.
  • The reader passes the toml-test v2.2.0 suite (MIT, vendored as the generated tests/suite-cases.trb), and the write-back of every valid case is an equal tree for both versions. Plus 73 unit tests in toml.test.trb.
  • docs/standard-library/toml.md, the index entry, the ROADMAP note and the regenerated skill.

Notes for review:

  • TomlOffsetDateTime.toTimestamp() returns Timestamp? (None beyond what a Timestamp holds).
  • TomlValue.equals ignores key order of tables and counts nan equal to nan.
  • Decode errors carry the field chain but no line number; syntax and structure errors carry line and column.
  • 11 suite files that are not valid UTF-8 are skipped (a String cannot hold them); the invalid set is the 1.1 invalid cases minus those valid in 1.0.
  • Checked locally with a prebuilt nightly: torb format --check, torb check, VM tests (1315 pass), docs check, docs index/skill --check, doc --check --no-run. The rest runs in CI.
Closes #77 Adds `std/toml`: TOML 1.0 and 1.1 as a format of `std/encoding`, per the refine comment on #77. - `Toml { naming, strict, version }` with `encode`, `decode`, `parse`, `value` and `write`; `TomlVersion { Toml10, Toml11 }` chooses what the writer emits, the reader takes the union of every released 1.x. - `TomlValue`/`TomlEntry` tree in document order; `TomlDate`, `TomlTime`, `TomlLocalDateTime`, `TomlOffsetDateTime` with nanoseconds and an offset in minutes, `show()` as RFC 3339, wrappers named by type, `TomlOffsetDateTime.toTimestamp()`. - `TomlError` with line and column for syntax and structure errors. No `Format<TomlError>` and no framer. - The reader passes the toml-test v2.2.0 suite (MIT, vendored as the generated `tests/suite-cases.trb`), and the write-back of every valid case is an equal tree for both versions. Plus 73 unit tests in `toml.test.trb`. - `docs/standard-library/toml.md`, the index entry, the ROADMAP note and the regenerated skill. Notes for review: - `TomlOffsetDateTime.toTimestamp()` returns `Timestamp?` (None beyond what a Timestamp holds). - `TomlValue.equals` ignores key order of tables and counts `nan` equal to `nan`. - Decode errors carry the field chain but no line number; syntax and structure errors carry line and column. - 11 suite files that are not valid UTF-8 are skipped (a String cannot hold them); the invalid set is the 1.1 invalid cases minus those valid in 1.0. - Checked locally with a prebuilt nightly: `torb format --check`, `torb check`, VM tests (1315 pass), `docs check`, `docs index/skill --check`, `doc --check --no-run`. The rest runs in CI.
Toml reads a document into any Decode type and writes any Encode value, and
TomlValue is the tree of a document, with its tables in document order.
The reader takes the union of the grammars of every released 1.x, so the
inline tables over several lines, the time without seconds and the escapes
\e and \xHH of 1.1 are read in every document; TomlVersion only chooses what
the writer emits. TomlDate, TomlTime, TomlLocalDateTime and
TomlOffsetDateTime keep nanoseconds and the offset in minutes, show RFC 3339
text and encode as wrappers named by their type, so Toml writes them as
TOML's own date and time values; TomlOffsetDateTime.toTimestamp converts to a
Timestamp. TomlError carries line and column for text that is not TOML.

The reader passes the public toml-test suite (v2.2.0, MIT, vendored as the
generated tests/suite-cases.trb), and the write-back of every valid case is an
equal tree in both versions.
docs(std/toml): add the package page and refresh the skills
Some checks failed
ci / commit messages (pull_request) Successful in 5s
ci / what the change touches (pull_request) Successful in 5s
pdisc / pdisc (pull_request) Successful in 10s
ci / which runners exist (pull_request) Successful in 1s
ci / bootstrap and conformance (windows-x64) (pull_request) Has been skipped
ci / bootstrap and conformance (linux-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (macos-arm64) (pull_request) Has been skipped
ci / the VS Code extension (editors/vscode) (pull_request) Successful in 12s
ci / bootstrap (linux-x64) (pull_request) Successful in 3m37s
ci / tier B (linux-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (windows-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (linux-arm64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (macos-arm64) (pull_request) Has been skipped
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Successful in 1m38s
ci / tier A (linux-x64) (pull_request) Failing after 3m55s
ci / gates (pull_request) Has been cancelled
ci / pack the seed (pull_request) Has been cancelled
ci / archives (pull_request) Has been cancelled
ci / the playground (torb as WebAssembly) (pull_request) Has been cancelled
ci / every host emits the same C (pull_request) Has been cancelled
eedd500f2d
The page for std/toml with its checked examples, the entry in the standard
library index, the ROADMAP note that toml exists and its row in the table of
packages outside the milestones, and the regenerated standard library skill.
orion force-pushed loop/77-std-toml from eedd500f2d
Some checks failed
ci / commit messages (pull_request) Successful in 5s
ci / what the change touches (pull_request) Successful in 5s
pdisc / pdisc (pull_request) Successful in 10s
ci / which runners exist (pull_request) Successful in 1s
ci / bootstrap and conformance (windows-x64) (pull_request) Has been skipped
ci / bootstrap and conformance (linux-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (macos-arm64) (pull_request) Has been skipped
ci / the VS Code extension (editors/vscode) (pull_request) Successful in 12s
ci / bootstrap (linux-x64) (pull_request) Successful in 3m37s
ci / tier B (linux-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (windows-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (linux-arm64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (macos-arm64) (pull_request) Has been skipped
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Successful in 1m38s
ci / tier A (linux-x64) (pull_request) Failing after 3m55s
ci / gates (pull_request) Has been cancelled
ci / pack the seed (pull_request) Has been cancelled
ci / archives (pull_request) Has been cancelled
ci / the playground (torb as WebAssembly) (pull_request) Has been cancelled
ci / every host emits the same C (pull_request) Has been cancelled
to c06f0383be
All checks were successful
ci / commit messages (pull_request) Successful in 5s
ci / what the change touches (pull_request) Successful in 4s
pdisc / pdisc (pull_request) Successful in 9s
ci / which runners exist (pull_request) Successful in 1s
ci / bootstrap and conformance (windows-x64) (pull_request) Has been skipped
ci / bootstrap and conformance (linux-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (macos-arm64) (pull_request) Has been skipped
ci / the VS Code extension (editors/vscode) (pull_request) Successful in 16s
ci / bootstrap (linux-x64) (pull_request) Successful in 3m28s
ci / cross-compiled on linux-x64 (windows-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (linux-arm64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (macos-arm64) (pull_request) Has been skipped
ci / tier A (linux-x64) (pull_request) Successful in 4m30s
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Successful in 1m40s
ci / every host emits the same C (pull_request) Successful in 4m23s
ci / tier B (linux-x64) (pull_request) Successful in 9m15s
ci / pack the seed (pull_request) Has been skipped
ci / archives (pull_request) Has been skipped
ci / the playground (torb as WebAssembly) (pull_request) Successful in 1m59s
ci / gates (pull_request) Successful in 0s
2026-10-09 21:36:21 +00:00
Compare
argus approved these changes 2026-10-09 22:18:11 +00:00
argus left a comment

Approved.

  • Tests: CI green on this head (gates, tier A/B, pdisc). The vendored toml-test v2.2.0 cases (generated, MIT notice in the header) run as reading and write-back tests; 73 unit tests cover typed decode, naming, strict, version, date/time wrappers and toTimestamp.
  • Correctness: matches the refine on #77 (superset reader, version only controls writing, encode returns Result, no Format<TomlError>/framer); the documented caveats (equals ignores table key order, 11 non-UTF-8 suite files skipped) are stated in the PR body.
  • Scope: new std/toml package, its page, index entry, ROADMAP note and regenerated skill only; no compiler or runtime change.
  • Security/data: no secrets or external requests; no storage-format change.
  • Docs: package page, index, ROADMAP and skills updated, docs check/skill --check green.

Non-blocking: none.

Approved. - Tests: CI green on this head (gates, tier A/B, pdisc). The vendored toml-test v2.2.0 cases (generated, MIT notice in the header) run as reading and write-back tests; 73 unit tests cover typed decode, naming, strict, version, date/time wrappers and `toTimestamp`. - Correctness: matches the refine on #77 (superset reader, `version` only controls writing, `encode` returns `Result`, no `Format<TomlError>`/framer); the documented caveats (equals ignores table key order, 11 non-UTF-8 suite files skipped) are stated in the PR body. - Scope: new `std/toml` package, its page, index entry, ROADMAP note and regenerated skill only; no compiler or runtime change. - Security/data: no secrets or external requests; no storage-format change. - Docs: package page, index, ROADMAP and skills updated, `docs check`/`skill --check` green. Non-blocking: none.
argus merged commit 0ede1f4e78 into main 2026-10-09 22:18:12 +00:00
argus deleted branch loop/77-std-toml 2026-10-09 22:18:12 +00:00
Sign in to join this conversation.
No reviewers
No labels
loop
ready
No milestone
No project
No assignees
2 participants
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
torbscript/language!285
No description provided.