Repository navigation
Description
Pinned at 387735155da3; origin/main (71defb4c6) and origin/release/v0.5 (ed549c24f) read. A feature request; nothing was run for it.
Problem
stdlib/src has no TOML member on either line. A LexLean program that reads a project's configuration, a lock, or a register must write its own codec.
afflom/rule30 is doing that: a module of about 440 lines, reading only, with no printer. It is not pushed yet.
Why here
#276 lists what the self-hosted compiler needs: canonical JSON, sorting, hex and decimal, maps and sets. #274 moves config.rs and lock.rs to language 1.2, and those call toml::from_str today (config.rs:458, lock.rs:292). lexlean.toml and lexlean.lock are TOML, so the driver needs a reader, and it needs a canonical writer for lexlean lock. Neither issue names this, unless it is implied by #274. So this may belong as a member of #276.
Proposal
A module LexLeanStd.Toml, in the shape of the #276 members:
- A typed value and table, and a reader that refuses anything outside the subset with a line and a reason.
- A printer that gives the canonical form of the closed subset.
- A differential against the Rust oracle, as for
Jsonin #276 member 3 (SL-11): canonical JSON writing in the standard library (LexLeanStd.Json) — draft #363.
The subset rule30 uses:
- one
key = valueper line, with a bare key (A-Z a-z 0-9 _ -); - a value is a basic string on one line with the escapes
\",\\,\n,\t; a one-line array of such strings, with a trailing comma allowed; or a decimal integer without sign, underscore or leading zero; [[name]]opens a new table of the arrayname, and keys before the first header belong to the root table;- comments from
#, blank lines, spaces and tabs around tokens, LF or CRLF line ends; - UTF-8 text; anything else is refused.
lexlean.toml also has a [limits] table, which this subset lacks, so the compiler's subset is at least that much wider. The committed locks I read use only [[...]] headers. I did not check config.rs and lock.rs in detail.
Open questions
- Should the subset be defined by what the compiler's own files use, or wider?
- Should this build on the
Numeralmember (#276 member 1 (SL-09): hexadecimal and decimal in the standard library (LexLeanStd.Numeral) — draft #326, merged torelease/v0.4) and theOrdermember (#276 member 2 (SL-10): sorting and order in the standard library (LexLeanStd.Order) — draft #328, open)? Printing sorted keys and decimals would reuse them.
Activity