Expand description
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.
let hits = run("//*.rs", &Empty).unwrap();
assert!(matches!(hits, QueryResult::Nodes(ns) if ns.is_empty()));Re-exports§
pub use adapter::AllowShell;pub use adapter::AstAdapter;pub use adapter::NodeId;pub use adapter::QuantifierBound;pub use adapter::WithNow;
Modules§
- adapter
- The adapter surface: how a data source plugs into the engine.
- highlight
- Syntax highlighting for query text — one tokenizer, three emits.
- quantity
- The quantital fragment: unit-text parsing behind
Value::Quantity(spec: The Quantital Fragment). - reflect
- Reflection: the query arbor.
- temporal
- The temporal fragment: ISO-8601 parsing and formatting, and the
civil-calendar arithmetic behind
Value::InstantandValue::Duration.
Structs§
- Defs
- A table of named fragments (
def &name: body;), expanded at parse time. Names are unique; a definition may invoke only earlier definitions, so recursion is impossible by construction.
Enums§
- Quarb
Error - Errors raised while lexing, parsing, or executing a query.
- Query
Result - The result of evaluating a query: a node set, or,—,after a projection,—,a list of scalar values (one per node).
- Value
- A projected scalar value.
Functions§
- expand
- Parse
query(expanding defs) and render it back to canonical query text — the expansion lens (qua --expand). Pure fragments only: a data-aware macro (&name!) needsexpand_with. - expand_
with - Like
expand, with the dataset at hand, so data-aware macros (&name!) can read it at expansion time. - parse_
defs - Parse a definitions file —
def &name(params): body;statements only — into a fragment table forrun_with_defs. - run
- Lex, parse, and evaluate
queryagainstadapter. - run_
traced - Like
run, but returning the final capsae as(node, topic)pairs, so each result value still knows which node produced it — the provenance-bearing form used by typed emission (qua --daiv). ANonetopic is a node result. - run_
traced_ with_ defs - Like
run_traced, with a pre-seeded fragment table. - run_
with_ defs - Like
run, with a pre-seeded fragment table (a--defsfile); inlinedefstatements extend it. - sha256
- The SHA-256 digest of
data, as 32 raw bytes (FIPS 180-4). - sha256_
hex - The SHA-256 digest of
data, as lowercase hex.
Type Aliases§
- Result
- Convenience alias for engine results.