quarb 0.1.0

Query engine for arbors (tree-spanned graphs)
Documentation

The Quarb query engine.

Quarb is a query language for arbors — tree-spanned graphs. This crate is the engine: it lexes and parses a query, then evaluates it against an [AstAdapter] that maps some data source onto the arbor model.

It currently implements tree navigation in full (child, descendant, parent, ancestor, and sibling hops; proximal/distal reach; root and leaf anchors; literal, glob, and ~(...) regex name matching; <trait> filters), scalar projection (:: properties, ::: core metadata, ::; adapter metadata), [...] predicates (comparisons, and/or/not/!, structural conditions, index selection), || union, -> / <- crosslink navigation, path patterns ((...) groups with subpath alternation and +/*/{m,n} quantifiers — simple-path expansion under the adapter's quantifier bound), and the register system: per-capsa | f transforms, @| f whole-context aggregation, | . push and | $. recall of breadcrumbs, and | .(expr) subcontexts for grouped aggregation. It also does correlation: E1 <=> E2[…$*1…] joins two contexts, a predicate referencing a prior expression's context via $*N. It also resolves cross-references: ::prop~> maps a reference to its target node (a JSON adapter follows a $ref JSON Pointer). The reverse resolution <~ and pattern search => are not built yet. See doc/impl.tex.

# use quarb::{AstAdapter, NodeId, QueryResult, run};
# struct Empty;
# impl AstAdapter for Empty {
#     fn root(&self) -> NodeId { NodeId(0) }
#     fn children(&self, _: NodeId) -> Vec<NodeId> { vec![] }
#     fn name(&self, _: NodeId) -> Option<String> { None }
# }
let hits = run("//*.rs", &Empty).unwrap();
assert!(matches!(hits, QueryResult::Nodes(ns) if ns.is_empty()));