This is a TOML parser. It supports TOML v0.2.0, including arrays-of-tables. As of 2014-06-29 it passes all 64 tests in toml-test.
The format came to my attention after I read that Mozilla Rust's package manager is using this format. Since there isn't currently a Racket parser for TOML, I thought I'd create one.
(require toml)
(parse-toml s) ;; where is a `string?`
-
Pass all toml-test tests.
-
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
.
Uses Parsack, a Parsec-like monadic parser combinator library implementation in Racket.