11# The KDL Document Language
22
3- > [ !WARNING]
4- > The main branch of this repository shows the latest v2.0.0 draft, which is a
5- > work in progress and not considered the "mainline" KDL yet. Most KDL
6- > implementations in the wild are based on the [ v1.0.0
7- > spec] ( https://github.com/kdl-org/kdl/tree/1.0.0 ) instead, so you may want to
8- > refer to that if you're using KDL today.
9-
103KDL is a small, pleasant document language with XML-like node semantics that
114looks like you're invoking a bunch of CLI commands! It's meant to be used both
12- as a serialization format and a configuration language, much like JSON, YAML,
13- or XML. It looks like this:
5+ as a serialization format and a configuration language, much like JSON, YAML, or
6+ XML. It looks like this:
147
158``` kdl
169package {
@@ -51,27 +44,37 @@ package {
5144}
5245```
5346
47+ For more details, see the [ overview below] ( #overview ) .
48+
5449There's a living [ specification] ( SPEC.md ) , as well as various
5550[ implementations] ( #implementations ) . You can also check out the [ FAQ] ( #faq ) to
5651answer all your burning questions!
5752
58- The current version of the KDL spec is ` 2.0.0-draft.8 ` .
53+ The current version of the KDL spec is
54+ [ KDL 2.0.0] ( https://github.com/kdl-org/kdl/blob/2.0.0/SPEC.md ) . For legacy KDL,
55+ please refer to the [ KDL 1.0.0
56+ spec] ( https://github.com/kdl-org/kdl/blob/2.0.0/SPEC_v1.md ) . All users are
57+ encouraged to migrate. [ Migration is forward-and-backward-compatible and
58+ safe] ( https://github.com/kdl-org/kdl/blob/2.0.0/SPEC.md#compatibility ) , and can
59+ be automated.
5960
60- In addition to a spec for KDL itself, there are also standard specs for [ a KDL
61- Query Language] ( QUERY-SPEC.md ) based on CSS selectors, and [ a KDL Schema
61+ In addition to a spec for KDL itself, there are specifications for [ a KDL Query
62+ Language] ( QUERY-SPEC.md ) based on CSS selectors, and [ a KDL Schema
6263Language] ( SCHEMA-SPEC.md ) loosely based on JSON Schema.
6364
6465The language is based on [ SDLang] ( https://sdlang.org ) , with a [ number of
6566modifications and clarifications on its syntax and behavior] ( #why-not-sdlang ) .
67+ We are grateful for their work as an inspiration to ours.
6668
67- [ Play with it in your browser!] ( https://kdl-play.danini.dev/ )
69+ [ Play with it in your browser (currently v1 only) !] ( https://kdl-play.danini.dev/ )
6870
6971## Design and Discussion
7072
71- KDL 2.0 design is still in progress. Discussions and questions about the format
72- should happen over on the [ discussions
73- page] ( https://github.com/kdl-org/kdl/discussions ) . Feel free to jump in and give
74- us your 2 cents!
73+ KDL 2.0.0 has been finalized, and no further changes are expected. For questions
74+ about KDL and discussions, please see the [ discussions
75+ page] ( https://github.com/kdl-org/kdl/discussions ) . For minor editorial fixes or
76+ critical spec errata, please feel free to [ file an
77+ issue] ( https://github.com/kdl-org/kdl/issues ) .
7578
7679## Used By
7780
@@ -92,26 +95,38 @@ of some examples of KDL in the wild (either v1, v2, or both):
9295
9396## Implementations
9497
95- * Rust: [ kdl-rs] ( https://github.com/kdl-org/kdl-rs ) , [ knuffel] ( https://crates.io/crates/knuffel/ ) (latter includes derive macro), and [ kaydle] ( https://github.com/Lucretiel/kaydle ) (serde-based)
96- * JavaScript: [ kdljs] ( https://github.com/kdl-org/kdljs ) , [ @virtualstate/kdl ] ( https://github.com/virtualstate/kdl ) (query only, JSX based)
97- * Ruby: [ kdl-rb] ( https://github.com/danini-the-panini/kdl-rb )
98- * Dart: [ kdl-dart] ( https://github.com/danini-the-panini/kdl-dart )
99- * Java: [ kdl4j] ( https://github.com/hkolbeck/kdl4j )
100- * PHP: [ kdl-php] ( https://github.com/kdl-org/kdl-php )
101- * Python: [ kdl-py] ( https://github.com/tabatkins/kdlpy ) , [ cuddle] ( https://github.com/djmattyg007/python-cuddle ) , [ ckdl] ( https://github.com/tjol/ckdl )
102- * Elixir: [ kuddle] ( https://github.com/IceDragon200/kuddle )
103- * XSLT: [ xml2kdl] ( https://github.com/Devasta/XML2KDL )
104- * Haskell: [ Hustle] ( https://github.com/fuzzypixelz/Hustle )
105- * .NET: [ Kadlet] ( https://github.com/oledfish/Kadlet )
106- * C: [ ckdl] ( https://github.com/tjol/ckdl )
107- * C++: [ kdlpp] ( https://github.com/tjol/ckdl ) (part of ckdl, requires C++20)
108- * OCaml: [ ocaml-kdl] ( https://github.com/Bannerets/ocaml-kdl )
109- * Nim: [ kdl-nim] ( https://github.com/Patitotective/kdl-nim )
110- * Common Lisp: [ kdlcl] ( https://github.com/chee/kdlcl )
111- * Go: [ gokdl] ( https://github.com/lunjon/gokdl ) , [ kdl-go] ( https://github.com/sblinch/kdl-go )
112- * Swift: [ kdl-swift] ( https://github.com/danini-the-panini/kdl-swift )
113- * Crystal: [ kdl-cr] ( https://github.com/danini-the-panini/kdl-cr )
114- * Lua: [ kdlua] ( https://github.com/danini-the-panini/kdlua )
98+ > [ !INFO] There are two major versions of KDL. Different libraries may support one or the
99+ > other, or even provide a "hybrid" mode where both versions are attempted, since
100+ > there's no data ambiguity between v1 and v2 documents.
101+
102+ | Language | Implementation | v1 | v2 | Notes |
103+ | ---| ---| ---| ---| ---|
104+ | C | [ ckdl] ( https://github.com/tjol/ckdl ) | ✅ | ✅ | |
105+ | C#/.NET | [ Kadlet] ( https://github.com/oledfish/Kadlet ) | ✅ | ✖️ | |
106+ | C++ | [ kdlpp] ( https://github.com/tjol/ckdl ) | ✅ | ✅ | part of ckdl, requires C++20 |
107+ | Common Lisp | [ kdlcl] ( https://github.com/chee/kdlcl ) | ✅ | ✖️ | |
108+ | Crystal | [ kdl-cr] ( https://github.com/danini-the-panini/kdl-cr ) | ✅ | ✖️ | |
109+ | Dart | [ kdl-dart] ( https://github.com/danini-the-panini/kdl-dart ) | ✅ | ✖️ | |
110+ | Elixir | [ kuddle] ( https://github.com/IceDragon200/kuddle ) | ✅ | ✅ | |
111+ | Go | [ gokdl] ( https://github.com/lunjon/gokdl ) | ✅ | ✖️ | |
112+ | Go | [ kdl-go] ( https://github.com/sblinch/kdl-go ) | ✅ | ✖️ | |
113+ | Haskell | [ Hustle] ( https://github.com/fuzzypixelz/Hustle ) | ✅ | ✖️ | |
114+ | Java | [ kdl4j] ( https://github.com/hkolbeck/kdl4j ) | ✅ | ✖️ | |
115+ | JavaScript | [ @bgotink/kdl ] ( https://github.com/bgotink/kdl ) | ✅ | ✅ | Format/comment-preserving parser |
116+ | JavaScript | [ @virtualstate/kdl ] ( https://github.com/virtualstate/kdl ) | ✅ | ✖️ | query only, JSX based |
117+ | JavaScript | [ kdljs] ( https://github.com/kdl-org/kdljs ) | ✅ | ✖️ | |
118+ | Lua | [ kdlua] ( https://github.com/danini-the-panini/kdlua ) | ✅ | ✖️ | |
119+ | Nim | [ kdl-nim] ( https://github.com/Patitotective/kdl-nim ) | ✅ | ✖️ | |
120+ | OCaml | [ ocaml-kdl] ( https://github.com/Bannerets/ocaml-kdl ) | ✅ | ✖️ | |
121+ | PHP | [ kdl-php] ( https://github.com/kdl-org/kdl-php ) | ✅ | ✖️ | |
122+ | Python | [ ckdl] ( https://github.com/tjol/ckdl ) | ✅ | ✅ | |
123+ | Python | [ cuddle] ( https://github.com/djmattyg007/python-cuddle ) | ✅ | ✖️ | |
124+ | Python | [ kdl-py] ( https://github.com/tabatkins/kdlpy ) | ✅ | ✅ | |
125+ | Ruby | [ kdl-rb] ( https://github.com/danini-the-panini/kdl-rb ) | ✅ | ✖️ | |
126+ | Rust | [ kdl-rs] ( https://github.com/kdl-org/kdl-rs ) | ✅ | ✅ | Format/comment-preserving parser |
127+ | Rust | [ knus] ( https://crates.io/crates/knus/ ) | ✅ | ✖️ | Serde-_ style_ derive macros (not actual Serde) |
128+ | Swift | [ kdl-swift] ( https://github.com/danini-the-panini/kdl-swift ) | ✅ | ✖️ | |
129+ | XSLT | [ xml2kdl] ( https://github.com/Devasta/XML2KDL ) | ✅ | ✖️ | |
115130
116131## Compatibility Test Suite
117132
@@ -123,11 +138,13 @@ entirety, but in the future, may be required to in order to be included here.
123138
124139## Editor Support
125140
126- * [ VS Code ] ( https://marketplace.visualstudio .com/items?itemName=kdl-org. kdl&ssr=false#review-details )
141+ * [ Intellij IDEA ] ( https://plugins.jetbrains .com/plugin/20136- kdl-document-language )
127142* [ Sublime Text] ( https://packagecontrol.io/packages/KDL )
143+ * [ TreeSitter] ( https://github.com/tree-sitter-grammars/tree-sitter-kdl ) (neovim, among others)
144+ * [ VS Code] ( https://marketplace.visualstudio.com/items?itemName=kdl-org.kdl&ssr=false#review-details ) \*
128145* [ vim] ( https://github.com/imsnif/kdl.vim )
129- * [ neovim ] ( https://github.com/tree-sitter-grammars/tree-sitter-kdl )
130- * [ Intellij IDEA ] ( https://plugins.jetbrains.com/plugin/20136-kdl-document-language )
146+
147+ \* Supports KDL 2.0.0
131148
132149## Overview
133150
@@ -167,21 +184,21 @@ Nodes without children are terminated by a newline, a semicolon, or the end of
167184a file stream:
168185
169186``` kdl
170- node1; node2; node3;
187+ node1; node2; node3
171188```
172189
173190### Values
174191
175192KDL supports 4 data types:
176193
177194* Strings: ` unquoted ` , ` "hello world" ` , or ` #"hello world"# `
178- * Numbers: ` 123.45 `
195+ * Numbers: ` 123.45 ` , ` 0xdeadbeef ` , ` #inf ` , ` #-inf ` , ` #nan `
179196* Booleans: ` #true ` and ` #false `
180197* Null: ` #null `
181198
182199#### Strings
183200
184- It supports three different formats for string input: identifiers , quoted, and raw.
201+ It supports three different formats for string input: unquoted , quoted, and raw.
185202
186203``` kdl
187204node1 this-is-a-string
@@ -234,10 +251,10 @@ other-raw ##"hello#"world"##
234251
235252#### Numbers
236253
237- There are 4 ways to represent numbers in KDL. KDL does not prescribe any
238- representation for these numbers, and it's entirely up to individual
239- implementations whether to represent all numbers with a single type, or to
240- have different representations for different forms.
254+ There are 4 ways to represent numbers in KDL, plus 3 float keywords. KDL does
255+ not prescribe any representation for these numbers, and it's entirely up to
256+ individual implementations whether to represent all numbers with a single type,
257+ or to have different representations for different forms.
241258
242259KDL has regular decimal-radix numbers, with optional decimal part, as well as
243260an optional exponent.
@@ -255,6 +272,13 @@ my-octal 0o755
255272my-binary 0b10101101
256273```
257274
275+ If you're intending to represent IEEE 754 floats, there are three special
276+ keywords you can use:
277+
278+ ``` kdl
279+ special-floats #inf #-inf #nan
280+ ```
281+
258282Finally, all numbers can have underscores to help readability:
259283
260284``` kdl
0 commit comments