From 896076011248b0e0feef5631881c01e8ac4bed7e Mon Sep 17 00:00:00 2001 From: binarycat Date: Wed, 21 May 2025 10:21:28 -0500 Subject: [PATCH] KQL: swap around order of comparisons to reduce local ambiguity generally in {A,E}BNF, if one literal is a prefix of another, the longer one is specified first, otherwise the shorter one will always match, either causing a spurious error or a parsing ambiguity, unless using a parser architecture which automatically resolved local ambiguities by collecting alternatives. this is something the rest of the KDL and KQL specs do well, but it seems this case slipped through the cracks. --- QUERY-SPEC.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/QUERY-SPEC.md b/QUERY-SPEC.md index 25ad7c69..8f8b8838 100644 --- a/QUERY-SPEC.md +++ b/QUERY-SPEC.md @@ -125,7 +125,7 @@ type-matcher := "(" q-ws* ")" | $type accessor-matcher := "[" q-ws* (comparison | accessor)? q-ws* "]" 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 := "=" | "!=" | ">" | "<" | ">=" | "<=" | "^=" | "$=" | "*=" +matcher-operator := "=" | "!=" | ">=" | "<=" | ">" | "<" | "^=" | "$=" | "*=" q-ws := $node-space ```