1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// Copyright 2024-2026 Jonathan Shook
// SPDX-License-Identifier: Apache-2.0
//! Cursor-constructor sugar registry.
//!
//! A *cursor sugar* lets a node module (vectordata, future
//! tabular sources, etc.) recognize a non-standard `cursor x =
//! foo(...)` form and rewrite it into:
//!
//! 1. A synthetic constructor expression (typically `range(...)`)
//! that the standard extent-resolution path can drive, and
//! 2. Zero or more auxiliary bindings to emit after the cursor's
//! input ports are wired — typical examples are an
//! init-time prebuffer call and per-field projection bindings
//! (`<cursor>__vector := vector_at("ds:profile",
//! <cursor>__ordinal)`).
//!
//! The core compiler stays agnostic: it walks the inventory of
//! registered handlers, picks the first match, and applies the
//! rewrite. Adding a new sugar form is a single
//! `inventory::submit!` plus a handler function — no compile.rs
//! change required.
use crateExpr;
use cratePortType;
/// A handler that recognizes one or more cursor-constructor
/// shapes and produces a [`CursorSugar`] rewrite. Return:
/// - `Ok(Some(s))` when the handler matched and the rewrite
/// should be applied.
/// - `Ok(None)` when this handler isn't responsible for the
/// given constructor — the dispatch loop continues on to the
/// next handler.
/// - `Err(msg)` when the handler matched the *name* but the
/// arguments don't validate. The caller surfaces the error
/// directly (with the cursor name prepended).
pub type CursorSugarFn = fn
;
/// One inventory entry. Handlers self-name for diagnostic
/// listings (`describe gk cursor-sugar`, future) and so the
/// dispatcher can attribute errors to the right module.
collect!;
/// The rewrite returned by a sugar handler.
/// One binding emitted by sugar after cursor input wiring.
///
/// If `projection` is `Some`, the binding's output wire is
/// promoted to a cursor projection — both registered on the
/// `SourceSchema.projections` list and added as a kernel output
/// the runtime can read.
/// Walk the inventory and dispatch to the first handler that
/// matches `constructor`. Returns the rewrite to apply, `None`
/// if no handler matches, or the handler's error.