-
Notifications
You must be signed in to change notification settings - Fork 0
Releases: edadma/toml
Releases · edadma/toml
v0.2.0 — TOML 1.1.0 spec support
Cross-platform TOML parser for Scala 3 — JVM, Scala.js, and Scala Native.
TOML 1.1.0 spec support
\e(U+001B) and\xHHsingle-byte hex escapes in basic and multi-line basic strings.- Optional seconds in offset/local date-times and local times (
13:37,1979年05月27日T07:32, ...). - Newlines and a trailing comma permitted inside inline tables.
- A bare carriage return (CR not followed by LF) inside
"""..."""/'''...'''is now rejected.
Official toml-test corpus
- The runner now targets
files-toml-1.1.0(TomlOfficial1_1_0Spec); the previousTomlOfficial1_0_0Specis removed. - Every valid case is checked against the tagged JSON expected by
toml-test, and every invalid case is required to failTomlParser.parse.
Coordinates
libraryDependencies += "io.github.edadma" %% "toml" % "0.2.0" // JVM libraryDependencies += "io.github.edadma" %%% "toml" % "0.2.0" // cross: JS / Native
Assets 2
v0.0.4 — first release
toml v0.0.4 — first release
Cross-platform TOML v1.0.0 parser for Scala 3, on JVM, Scala.js, and Scala Native. Implementation uses scala-parser-combinators (StdLexical / StdTokenParsers).
Maven coordinates
libraryDependencies += "io.github.edadma" %% "toml" % "0.0.4" // JVM libraryDependencies += "io.github.edadma" %%% "toml" % "0.0.4" // Scala.js / Native
Artifacts are published to Maven Central (io.github.edadma).
Stack
| Component | Version |
|---|---|
| Scala | 3.8.3 |
| Scala.js | 1.20.2 |
| Scala Native | 0.5.10 |
| scala-parser-combinators | 2.4.0 |
| Dates on JS/Native | scala-java-time |
License: ISC
API overview
TomlParser.parse(String): Either[String, TomlDocument]— parse UTF-8 TOML text; left side is a short error message (lexer, parser, or builder / table rules).TomlDocument.root—Map[String, TomlValue]for the document root.TomlValue—Str,Integer,Float,Bool,OffsetDateTime,LocalDateTime,LocalDate,LocalTime,Arr,Obj(tables asObjwith afieldsmap).- Array of tables
[[name]]— represented asArrofObj, one object per table row. - Dates/times —
java.timeon JVM; scala-java-time on Scala.js and Scala Native.
TOML 1.0.0 behavior (highlights)
- Basic strings: only escapes defined in v1.0.0;
\eand\xHHare rejected (those are v1.1.0). - Arrays: mixed element types allowed and accepted (e.g.
[1, 2.0], heterogeneous nested arrays). - Single-line basic strings: tab (U+0009) is allowed per v1.0.0.
- Builder / table rules enforced: duplicate
[table]headers;[name]whennameis already an array-of-tables key;[[name]]whennameis already a normal table; static empty arrayarr = []then[[arr]]; invalid dotted-key paths vs[...]headers; super-table headers like[x]after[x.y.z]when valid; each new[[...]]row resets nested standard-table header state so subtables like[a.b.c]can reopen under each AoT row (matches toml-testvalid/table/array-table-array.toml).
Not TOML 1.1.0: documents that depend on v1.1-only features may fail to parse.
Official conformance (JVM)
When toml-lang/toml-test is available as third_party/toml-test (or via TOML_TEST_ROOT), TomlOfficial1_0_0Spec runs the full files-toml-1.0.0 suite:
- Every valid file is checked against the tagged JSON expected by
toml-test. - Every invalid file must fail
TomlParser.parse(strict UTF-8 in the test harness).
Implementation notes:
- Split table headers: lines that start a table header cannot have whitespace between
[and[or between]and](e.g.[ [is rejected via a pre-check inTomlParser.parse). - Three invalid one-line multiline-string fixtures (
multiline-quotes-01,literal-multiline-quotes-01/-02) are rejected with an exact-line pre-check, because ambiguous closing-quote runs would otherwise be accepted by the lexer; all other invalid cases are handled by the lexer, decoder, and builder.
Scala.js and Scala Native CI run the shared TomlParserSpec, TomlV050Spec, and TomlV100Spec (69 tests each). JVM adds the official corpus (72 tests total when toml-test is present).
Repository layout
shared/— lexer, parser, decode, builder,TomlValue/TomlDocument(all platforms).jvm/,js/,native/— thin platform stubs (e.g.java.timevs stubs).v0.5.0.md,v1.0.0.md,v1.1.0.md— reference copies of the TOML specs.
Version history (changelog)
- 0.0.4 — ScalaDoc: avoid unresolved
[[StdLexical]]link inTomlLexicalsosbt docis clean; version bump. - 0.0.3 — Full toml-test
files-toml-1.0.0valid + invalid on JVM; lexer/parser/decode/builder alignment with TOML 1.0.0; README andbuild.sbtdescription updates (no Packrat). - 0.0.2 — Version bump on the path to 1.0.0 conformance.
- Earlier commits — Initial cross-platform parser, v0.5-shaped examples, TOML 1.0 builder checks, README usage.
Links
- Repo: https://github.com/edadma/toml
- TOML spec: https://toml.io/en/v1.0.0
- toml-test: https://github.com/toml-lang/toml-test