From 7ab86588c08cf1965ebfa4e9e169c3108661c14e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kat=20March=C3=A1n?= Date: Sun, 11 Feb 2024 21:05:23 -0800 Subject: [PATCH] iterate a bit on KQL --- CHANGELOG.md | 3 +++ QUERY-SPEC.md | 16 ++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f203cd..2404944 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -74,4 +74,7 @@ spaces for that purpose. * The "any sibling" selector is now `++` instead of `~`, for consistency with the new descendant selector. +* Some parsing logic around the grammar has changed. +* Multi- and single-line comments are now supported, as well as line + continuations with `\`. * Map operators have been removed entirely. diff --git a/QUERY-SPEC.md b/QUERY-SPEC.md index d67f9b2..114a75c 100644 --- a/QUERY-SPEC.md +++ b/QUERY-SPEC.md @@ -104,18 +104,22 @@ Then the following queries are valid: ## Full Grammar -For rules that are not defined in this grammar, see [the KDL grammar](https://github.com/kdl-org/kdl/blob/main/SPEC.md#full-grammar). +Rules that are not defined in this grammar are prefixed with `$`, see [the KDL +grammar](https://github.com/kdl-org/kdl/blob/main/SPEC.md#full-grammar) for +what they expand to. ``` -query-str := bom? query +query-str := $bom? query query := selector q-ws* "||" q-ws* query | selector selector := filter q-ws* selector-operator q-ws* selector | filter selector-operator := ">>" | ">" | "++" | "+" -filter := ( "top(" q-ws* ")" | "(" q-ws* ")" | type ) string? accessor-matcher* +filter := "top(" q-ws* ")" | matchers +matchers := type-matcher $string? accessor-matcher* | $string accessor-matcher* | accessor-matcher+ +type-matcher := "(" q-ws* ")" | $type accessor-matcher := "[" q-ws* (comparison | accessor)? q-ws* "]" -comparison := accessor q-ws* matcher-operator q-ws* (type | identifier | string | number | keyword) -accessor := "val(" q-ws* integer q-ws* ")" | "prop(" q-ws* identifier q-ws* ")" | "name(" q-ws* ")" | "tag(" q-ws* ")" | "values(" q-ws* ")" | "props(" q-ws* ")" | identifier +comparison := accessor q-ws* matcher-operator q-ws* ($type | $string | $number | $keyword) +accessor := "val(" q-ws* $integer q-ws* ")" | "prop(" q-ws* $string q-ws* ")" | "name(" q-ws* ")" | "tag(" q-ws* ")" | "values(" q-ws* ")" | "props(" q-ws* ")" | $string matcher-operator := "=" | "!=" | ">" | "<" | ">=" | "<=" | "^=" | "$=" | "*=" -q-ws := unicode-space +q-ws := $plain-node-space ```