Compare commits
3
Commits
v1.1.0
..
942c4b1489
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
942c4b1489 | ||
|
|
8f0eae6604 | ||
|
|
1c7329aeea |
@@ -105,6 +105,6 @@ jobs:
|
|||||||
run: go build -o bin/interpres-decode ./cmd/interpres-decode
|
run: go build -o bin/interpres-decode ./cmd/interpres-decode
|
||||||
|
|
||||||
- name: Compliance suite
|
- name: Compliance suite
|
||||||
# interpres implements TOML 1.0 and 1.1; the mode is pinned so an upstream
|
# interpres implements TOML 1.1; the mode is pinned so an upstream
|
||||||
# default change cannot silently move the corpus.
|
# default change cannot silently move the corpus.
|
||||||
run: bin/toml-test test -decoder=bin/interpres-decode -toml=1.1
|
run: bin/toml-test test -decoder=bin/interpres-decode -toml=1.1
|
||||||
|
|||||||
@@ -11,6 +11,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
-
|
-
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- TOML 1.1 is the acceptance contract, and TOML 1.0 is not. The compliance
|
||||||
|
suite runs the 1.1 corpus alone, and the promise that every 1.0 document
|
||||||
|
parses exactly as before is withdrawn. Nothing that parses today stops
|
||||||
|
parsing: the 1.0 valid corpus still passes in full. The documents whose
|
||||||
|
verdict changes are the ones 1.1 relaxed, such as the `\xHH` escape
|
||||||
|
sequences 1.0 rejected.
|
||||||
|
- The module path carries the /v2 suffix the Go toolchain requires of
|
||||||
|
every major version 2 module: imports change to
|
||||||
|
`sourcedock.dev/petrbalvin/interpres/v2`.
|
||||||
|
|
||||||
## [1.1.0] - 2026-09-18
|
## [1.1.0] - 2026-09-18
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
# interpres
|
# interpres
|
||||||
|
|
||||||
A TOML 1.0 and 1.1 parser and encoder for Go, written with the standard
|
A TOML 1.1 parser and encoder for Go, written with the standard library
|
||||||
library alone. `interpres` (Latin for *interpreter*) gives zero-dependency
|
alone. `interpres` (Latin for *interpreter*) gives zero-dependency
|
||||||
programs an `encoding/json`-style API for reading and writing TOML, and passes
|
programs an `encoding/json`-style API for reading and writing TOML, and passes
|
||||||
the entire official [toml-test](https://github.com/toml-lang/toml-test) suite:
|
the entire official [toml-test](https://github.com/toml-lang/toml-test) suite:
|
||||||
214 valid and 467 invalid cases, zero failures.
|
214 valid and 467 invalid cases, zero failures.
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
- **Full TOML 1.0 and 1.1**: bare, quoted and dotted keys; tables and arrays of
|
- **Full TOML 1.1**: bare, quoted and dotted keys; tables and arrays of
|
||||||
tables; basic and literal strings including multiline, with the 1.1 `\e` and
|
tables; basic and literal strings including multiline, with the 1.1 `\e` and
|
||||||
`\xHH` escapes; integers in the four radixes with `_` separators; floats with
|
`\xHH` escapes; integers in the four radixes with `_` separators; floats with
|
||||||
exponents, `inf` and `nan`; booleans; the four date-time kinds, seconds
|
exponents, `inf` and `nan`; booleans; the four date-time kinds, seconds
|
||||||
@@ -29,7 +29,7 @@ the entire official [toml-test](https://github.com/toml-lang/toml-test) suite:
|
|||||||
As a library:
|
As a library:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
go get sourcedock.dev/petrbalvin/interpres
|
go get sourcedock.dev/petrbalvin/interpres/v2
|
||||||
```
|
```
|
||||||
|
|
||||||
Requires Go 1.27.1 or newer. The module imports only the standard library.
|
Requires Go 1.27.1 or newer. The module imports only the standard library.
|
||||||
|
|||||||
+1
-1
@@ -7,7 +7,7 @@ releases do not receive them.
|
|||||||
|
|
||||||
| Version | Supported |
|
| Version | Supported |
|
||||||
|---|---|
|
|---|---|
|
||||||
| 1.0.0 | yes |
|
| 1.1.0 | yes |
|
||||||
| older releases | no |
|
| older releases | no |
|
||||||
|
|
||||||
## Reporting a vulnerability
|
## Reporting a vulnerability
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"sourcedock.dev/petrbalvin/interpres"
|
"sourcedock.dev/petrbalvin/interpres/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"sourcedock.dev/petrbalvin/interpres"
|
"sourcedock.dev/petrbalvin/interpres/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestRunParsesValidTOML(t *testing.T) {
|
func TestRunParsesValidTOML(t *testing.T) {
|
||||||
|
|||||||
+5
-6
@@ -1,16 +1,15 @@
|
|||||||
# API
|
# API
|
||||||
|
|
||||||
The library exports the surface below from the `sourcedock.dev/petrbalvin/interpres`
|
The library exports the surface below from the `sourcedock.dev/petrbalvin/interpres/v2`
|
||||||
package. The snippets assume:
|
package. The snippets assume:
|
||||||
|
|
||||||
```go
|
```go
|
||||||
import "sourcedock.dev/petrbalvin/interpres"
|
import "sourcedock.dev/petrbalvin/interpres/v2"
|
||||||
```
|
```
|
||||||
|
|
||||||
The parser accepts TOML 1.0 documents plus the TOML 1.1 extensions: date-times
|
The parser implements TOML 1.1: date-times and times without seconds, the
|
||||||
and times without seconds, the `\e` and `\xHH` escape sequences, and
|
`\e` and `\xHH` escape sequences, and multi-line inline tables with comments
|
||||||
multi-line inline tables with comments and trailing commas. The encoder emits
|
and trailing commas. The encoder emits TOML 1.1.
|
||||||
TOML 1.0, which is valid under both versions.
|
|
||||||
|
|
||||||
## Functions
|
## Functions
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ source tree; nothing is aspirational.
|
|||||||
## Overview
|
## Overview
|
||||||
|
|
||||||
interpres is one public library package, one command, and one example. The
|
interpres is one public library package, one command, and one example. The
|
||||||
library implements the whole of TOML 1.0 and 1.1, decoding and encoding, in the
|
library implements the whole of TOML 1.1, decoding and encoding, in the
|
||||||
standard library alone; the command wraps the parser for the toml-test
|
standard library alone; the command wraps the parser for the toml-test
|
||||||
compliance harness, against which it stands at 214 valid and 467 invalid cases
|
compliance harness, against which it stands at 214 valid and 467 invalid cases
|
||||||
with zero failures; the example demonstrates the API.
|
with zero failures; the example demonstrates the API.
|
||||||
@@ -43,7 +43,7 @@ Inside the library package, one file owns one concern:
|
|||||||
|
|
||||||
| File | Responsibility |
|
| File | Responsibility |
|
||||||
|---|---|
|
|---|---|
|
||||||
| `parser.go` | The recursive-descent parser. Produces the `map[string]any` tree and enforces the structural rules of TOML 1.0 and 1.1 (table redefinitions, dotted keys, arrays of tables, multi-line inline tables). Reports a 1-based line on failure. |
|
| `parser.go` | The recursive-descent parser. Produces the `map[string]any` tree and enforces the structural rules of TOML 1.1 (table redefinitions, dotted keys, arrays of tables, multi-line inline tables). Reports a 1-based line on failure. |
|
||||||
| `number.go` | Strict numeric tokens: integers in the four radixes with `_` separators, and floats including `inf` and `nan`. Rejects leading zeros, misplaced underscores and malformed fractions. |
|
| `number.go` | Strict numeric tokens: integers in the four radixes with `_` separators, and floats including `inf` and `nan`. Rejects leading zeros, misplaced underscores and malformed fractions. |
|
||||||
| `datetime.go` | The three local date-time wrapper types and `parseDateTime`, which classifies a token into the four date-time kinds under the strict TOML grammar. |
|
| `datetime.go` | The three local date-time wrapper types and `parseDateTime`, which classifies a token into the four date-time kinds under the strict TOML grammar. |
|
||||||
| `decode.go` | Maps the parsed tree onto Go values by reflection: struct fields, maps, slices, scalar conversion with overflow checks, `Unmarshaler` dispatch. |
|
| `decode.go` | Maps the parsed tree onto Go values by reflection: struct fields, maps, slices, scalar conversion with overflow checks, `Unmarshaler` dispatch. |
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@ the toml-test harness adapter, and it also validates documents. Install it
|
|||||||
with Go itself, no release assets involved:
|
with Go itself, no release assets involved:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
go install sourcedock.dev/petrbalvin/interpres/cmd/interpres-decode@latest
|
go install sourcedock.dev/petrbalvin/interpres/v2/cmd/interpres-decode@latest
|
||||||
```
|
```
|
||||||
|
|
||||||
## Synopsis
|
## Synopsis
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"sourcedock.dev/petrbalvin/interpres"
|
"sourcedock.dev/petrbalvin/interpres/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
// document is a small but realistic configuration: it has scalars, a
|
// document is a small but realistic configuration: it has scalars, a
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
module sourcedock.dev/petrbalvin/interpres
|
module sourcedock.dev/petrbalvin/interpres/v2
|
||||||
|
|
||||||
go 1.27.1
|
go 1.27.1
|
||||||
|
|||||||
+1
-2
@@ -198,8 +198,7 @@ type Unmarshaler interface {
|
|||||||
UnmarshalTOML(data any) error
|
UnmarshalTOML(data any) error
|
||||||
}
|
}
|
||||||
|
|
||||||
// Marshal returns the TOML encoding of v. The output stays within TOML 1.0,
|
// Marshal returns the TOML encoding of v. The output is valid TOML 1.1.
|
||||||
// so it is valid under both TOML 1.0 and 1.1.
|
|
||||||
//
|
//
|
||||||
// Marshal traverses v using reflection and applies the following rules:
|
// Marshal traverses v using reflection and applies the following rules:
|
||||||
//
|
//
|
||||||
|
|||||||
Reference in New Issue
Block a user