@toon-format/spec 3.0.2 → 3.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/SPEC.md +3 -0
- package/package.json +1 -1
- package/tests/fixtures/decode/objects.json +27 -0
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# TOON Format Specification
|
|
2
2
|
|
|
3
3
|
[](./SPEC.md)
|
|
4
|
-
[](./tests/fixtures/)
|
|
5
5
|
[](./LICENSE)
|
|
6
6
|
|
|
7
7
|
This repository contains the official specification for **Token-Oriented Object Notation (TOON)**, a compact, human-readable encoding of the JSON data model for LLM prompts. It provides a lossless serialization of the same objects, arrays, and primitives as JSON, but in a syntax that minimizes tokens and makes structure easy for models to follow.
|
package/SPEC.md
CHANGED
|
@@ -349,6 +349,8 @@ Note: The ABNF grammar above cannot enforce that the delimiter used in the field
|
|
|
349
349
|
|
|
350
350
|
Note: The grammar above specifies header syntax. TOON's grammar is deliberately designed to prioritize human readability and token efficiency over strict LR(1) parseability. This requires some context-sensitive parsing (particularly for tabular row disambiguation in Section 9.3), which is a deliberate design tradeoff. Reference implementations demonstrate that deterministic parsing is achievable with modest lookahead.
|
|
351
351
|
|
|
352
|
+
Between the closing bracket `]` of the bracket segment and the opening brace `{` of a fields segment (or the colon `:` if no fields segment is present), only whitespace MAY appear. If a decoder encounters non-whitespace content in these positions (e.g., additional bracket expressions like `[bar]`), the line MUST NOT be interpreted as an array header. Decoders SHOULD fall through to key-value parsing (Section 8), treating the entire pre-colon content as a literal key.
|
|
353
|
+
|
|
352
354
|
Decoding requirements:
|
|
353
355
|
- The bracket segment MUST parse as a non-negative integer length N.
|
|
354
356
|
- If a trailing tab or pipe appears inside the brackets, it selects the active delimiter; otherwise comma is active.
|
|
@@ -729,6 +731,7 @@ When strict mode is enabled (default), decoders MUST error on the following cond
|
|
|
729
731
|
- Missing colon in key context.
|
|
730
732
|
- Invalid escape sequences or unterminated strings in quoted tokens.
|
|
731
733
|
- Delimiter mismatch (detected via width/count checks and header scope).
|
|
734
|
+
- Non-whitespace content between a valid bracket segment and the colon (or fields segment). Such lines MUST NOT be parsed as array headers. Decoders MUST NOT silently discard content in these positions.
|
|
732
735
|
|
|
733
736
|
### 14.3 Indentation Errors
|
|
734
737
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toon-format/spec",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.0.
|
|
4
|
+
"version": "3.0.3",
|
|
5
5
|
"packageManager": "pnpm@10.30.1",
|
|
6
6
|
"description": "Official specification for Token-Oriented Object Notation (TOON)",
|
|
7
7
|
"author": "Johann Schopplich <hello@johannschopplich.com>",
|
|
@@ -118,6 +118,33 @@
|
|
|
118
118
|
},
|
|
119
119
|
"specSection": "8"
|
|
120
120
|
},
|
|
121
|
+
{
|
|
122
|
+
"name": "treats extra brackets after valid array segment as literal key",
|
|
123
|
+
"input": "foo[1][bar]: 10",
|
|
124
|
+
"expected": {
|
|
125
|
+
"foo[1][bar]": 10
|
|
126
|
+
},
|
|
127
|
+
"specSection": "6",
|
|
128
|
+
"note": "Non-whitespace [bar] between ] and : prevents array header interpretation"
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"name": "treats non-integer bracket content as literal key",
|
|
132
|
+
"input": "foo[bar][1]: 20",
|
|
133
|
+
"expected": {
|
|
134
|
+
"foo[bar][1]": 20
|
|
135
|
+
},
|
|
136
|
+
"specSection": "6",
|
|
137
|
+
"note": "[bar] fails integer parsing; line is not an array header"
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
"name": "treats text between bracket segment and colon as literal key",
|
|
141
|
+
"input": "foo[2]extra: a,b",
|
|
142
|
+
"expected": {
|
|
143
|
+
"foo[2]extra": "a,b"
|
|
144
|
+
},
|
|
145
|
+
"specSection": "6",
|
|
146
|
+
"note": "Non-whitespace content between ] and : prevents array header interpretation"
|
|
147
|
+
},
|
|
121
148
|
{
|
|
122
149
|
"name": "parses quoted key with braces",
|
|
123
150
|
"input": "\"{key}\": 5",
|