kdl-org / kdl

the kdl document language specifications
https://kdl.dev
Other
1.07k stars 61 forks source link

KQL: Add pseudo-matchers (aka pseudo-classes) #373

Open zkat opened 5 months ago

zkat commented 5 months ago

We should add support for pseudo-matchers that we can extend KQL with going forward. We can use the reserved # for the matcher keywords, so:

// select all `foo` nodes that do _not_ have a value.
foo#not([val()])

You can also chain them:

// Select all foo nodes without a value but only if they are the first children.
foo#not([val()])#first-child

We can then add support for tree-structural pseudo-matchers and functional pseudo-matchers.

This will of course increase implementation burden, but it'll also make KQL much more useful (and familiar).