This is a TOML parser. It supports TOML 0.2.0, including arrays-of-tables. As of 2022-08-06 it passes 286/314 tests in toml-test (testing against version 0.4.0). Click the "TOML Compliance" badge for logs of toml-test.
This code is a fork of Greg Hendershott's TOML parser. This version is available on pkgs.racket-lang.org.
Installation
raco pkg install --auto toml
Usage
(require toml)
(parse-toml s) ;; where `s` is a `string?`
Goals
-
Pass all toml-test tests for TOML 0.2.0.
-
Provide useful error messages with positions (line:col:ofs). Do so for both syntax errors and semantic errors (such as table conflicts).
-
Return a Racket
hasheq
that satisfies thejson
library'sjsexpr?
predicate, so that you can run it throughjsexpr->string
to produce a JSON string.Caveat: Any TOML datetime values are
date
structs, which won't satisfyjsexpr?
. Originally I parsed these to acurrent-seconds
-style integer value. Buttoml-tests
needs things to be tagged with types, so that's why I had to switch. I should probably provide a conversion function to turn any such instances back into a datetime string so that it can be passed tojsexpr->string
.