From 728b3e0a1d51c2626177f5cb49964d7a25b96f4f Mon Sep 17 00:00:00 2001 From: Lars Willighagen Date: Tue, 27 Sep 2022 15:51:12 +0200 Subject: [PATCH] Add draft grammar for KQL 1.0.0 --- QUERY-SPEC.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/QUERY-SPEC.md b/QUERY-SPEC.md index 7ab1b46..24696fd 100644 --- a/QUERY-SPEC.md +++ b/QUERY-SPEC.md @@ -101,3 +101,21 @@ Then the following queries are valid: * `dependencies > []` * -> fetches all direct-child nodes of any `dependencies` nodes in the document. In this case, it will fetch both `miette` and `winapi` nodes. + +## Full Grammar + +Note: 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). + +``` +query := selector q-ws* "||" q-ws* query | selector +selector := filter q-ws* selector-operator q-ws* selector | filter +selector-operator := ">" | "+" | "~" | "" +filter := matcher+ +matcher := "top()"| "()" | identifier | type | accessor-matcher +accessor-matcher := "[" (comparison | accessor)? "]" +comparison := accessor q-ws* matcher-operator q-ws* (type | string | number | keyword) +accessor := "val(" number ")" | "prop(" identifier ")" | "name()" | "tag()" | "values()" | "props()" | identifier +matcher-operator := "=" | "!=" | ">" | "<" | ">=" | "<=" | "^=" | "$=" | "*=" + +q-ws := bom | unicode-space +```