KDL 2.0 grammar for tree-sitter
Adapted from the official KDL 2.0 spec
This grammar implements the KDL 2.0 specification with breaking changes from KDL 1.0.
Boolean and null values now require the # prefix:
// KDL 1.0
node true false null
// KDL 2.0
node #true #false #nullRaw strings use a new syntax with # delimiters instead of the r prefix:
// KDL 1.0
node r"raw string"
node r#"with hash"#
// KDL 2.0
node #"raw string"#
node ##"with hash"##Support for triple-quoted multi-line strings:
node """
This is a
multi-line string
"""Note: Opening delimiter must be followed immediately by a newline. Closing delimiter must be on its own line with optional leading whitespace.
- Removed:
\/(forward slash escape) - Added:
\s(space character U+0020)
// KDL 2.0 escapes
node "quote: \" backslash: \\ space: \s newline: \n"Documents can optionally start with a version marker:
/- kdl-version 2
node "content"Line continuations now support EOF:
node \The Byte Order Mark (U+FEFF) is now only allowed as the first character in a document, not as general whitespace.
✅ Fully Implemented:
- Tagged literals (
#true,#false,#null) - Raw string syntax (
#"..."#) - String escape changes (
\sadded,\/removed) - Line continuation with EOF support
- Optional version marker
- BOM restrictions
🚧 In Progress:
- Multi-line string support (parser implemented, needs testing)
- Character validation for banned code points
- Test suite updates for KDL 2.0 syntax
To migrate KDL 1.0 documents to KDL 2.0:
- Add
#prefix to all boolean and null values - Change raw strings from
r"..."to#"..."# - Replace
\/escapes with/(no escape needed) - Optionally use
\sfor explicit space escapes
See the original repository for installation instructions.