kdl icon indicating copy to clipboard operation
kdl copied to clipboard

make support for raw and multiline strings optional in KQL

Open lolbinarycat opened this issue 6 months ago β€’ 8 comments

I am writing a KQL implementation in rust, and I am using parser combinators to ensure things match the spec as closely as possible.

The "non-greedy repetition" that is described in the grammar doesn't even seem to be a fully coherent operation within a recursive decent parser without backtracking.

The utility of these syntactic constructs within kql seems questionable at best, and it would greatly simplify implementation.

lolbinarycat avatar Jun 30 '25 19:06 lolbinarycat

I don't think we should encourage language impls that don't support KDL. If you would like to document that your KQL tool doesn't support those language features, that's just fine; they might indeed not be very useful for you. But in general, KQL documents are KDL documents and should have the same syntax.

A little more confusingly to me, KQL is designed to let you query a KDL document. If you're writing a parser that can't easily support these string types, how are you planning to handle KDL docs that include them?

tabatkins avatar Jun 30 '25 21:06 tabatkins

The KQL impl i'm writing pulls in a seperate KDL impl which doesn't expose its AST or parsers.

lolbinarycat avatar Jul 01 '25 06:07 lolbinarycat

kdl-rs is also written with a parser combinator library. It handles the backtracking just fine imo

zkat avatar Jul 01 '25 15:07 zkat

https://github.com/kdl-org/kdl-rs/blob/main/src/v2_parser.rs#L1253-L1366 Here’s the raw string impl

zkat avatar Jul 01 '25 15:07 zkat

Guess I have to just write a repeat_till combinator?

Even without that, these two parsers together would be half the size of all my current parsering logic combined.

Doesn't exactly refute my point about complexity.

lolbinarycat avatar Jul 02 '25 15:07 lolbinarycat

Even without that, these two parsers together would be half the size of all my current parsering logic combined. Doesn't exactly refute my point about complexity.

Your point, as I understand it, is to request a change to the language where a primary motivator is to make implementations easier.

Personally, I very much value KDL's emphasis on human-workability. One can search far and wide for data languages that:

  1. handle multiline strings well.
  2. offer convenient ways to write raw strings.
  3. are sane to parse

Here's my summary:

format multiline? raw string? parsing complexity
JSON ❌ ❌ 🍰
JSON5 βŒβ‘  ❌ 🍰
KDL βœ… βœ… 🍰
TOML βœ… βœ… βš™οΈ
RON βœ… βœ… βš™οΈ
XML βœ… βœ…β‘‘ 🌢️πŸ”₯πŸš½β‘’
YAML βœ… ❌ 🌢️πŸ”₯πŸš½β‘£
  • 🍰 simple
  • βš™οΈ moderate
  • 🌢️πŸ”₯🚽 call the doctor
  • β‘  line continuation \ doesn't count in my book
  • β‘‘ <![CDATA[...]]>
  • β‘’ context-sensitive
  • β‘£ context-free with a large spec

xpe avatar Oct 14 '25 19:10 xpe

@xpe you seem to be under the impression I am requesting a change to KDL, not KQL. A fair comparison would be between jsonpath or XPath, neither of which support multiline or raw strings according to my cursory research.

lolbinarycat avatar Oct 14 '25 19:10 lolbinarycat

@xpe you seem to be under the impression I am requesting a change to KDL, not KQL. A fair comparison would be between jsonpath or XPath, neither of which support multiline or raw strings according to my cursory research.

Whoops. Sorry about that.

xpe avatar Oct 15 '25 00:10 xpe