Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Releases: edadma/toml

v0.2.0 — TOML 1.1.0 spec support

27 May 18:59
@edadma edadma

Choose a tag to compare

Cross-platform TOML parser for Scala 3 — JVM, Scala.js, and Scala Native.

TOML 1.1.0 spec support

  • \e (U+001B) and \xHH single-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 previous TomlOfficial1_0_0Spec is removed.
  • Every valid case is checked against the tagged JSON expected by toml-test, and every invalid case is required to fail TomlParser.parse.

Coordinates

libraryDependencies += "io.github.edadma" %% "toml" % "0.2.0" // JVM
libraryDependencies += "io.github.edadma" %%% "toml" % "0.2.0" // cross: JS / Native
Assets 2
Loading

v0.0.4 — first release

13 Apr 16:16
@edadma edadma

Choose a tag to compare

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.rootMap[String, TomlValue] for the document root.
  • TomlValueStr, Integer, Float, Bool, OffsetDateTime, LocalDateTime, LocalDate, LocalTime, Arr, Obj (tables as Obj with a fields map).
  • Array of tables [[name]] — represented as Arr of Obj, one object per table row.
  • Dates/timesjava.time on 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; \e and \xHH are 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] when name is already an array-of-tables key; [[name]] when name is already a normal table; static empty array arr = [] 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-test valid/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 in TomlParser.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.time vs 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 in TomlLexical so sbt doc is clean; version bump.
  • 0.0.3 — Full toml-test files-toml-1.0.0 valid + invalid on JVM; lexer/parser/decode/builder alignment with TOML 1.0.0; README and build.sbt description 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

Loading

AltStyle によって変換されたページ (->オリジナル) /