1pub struct KeywordInfo {
12 pub word: &'static str,
13 pub meaning: &'static str,
14}
15
16pub const KEYWORDS: &[KeywordInfo] = &[
18 k("Bool", "The boolean base type."),
19 k(
20 "Bytes",
21 "The binary base type — an immutable octet sequence, erased to `Uint8Array` (`Bytes.fromUtf8(s)`).",
22 ),
23 k(
24 "Duration",
25 "The time-span base type, in milliseconds (`5.minutes`).",
26 ),
27 k("Effect", "The effectful-computation type, `Effect[T]`."),
28 k("Err", "The error variant of `Result`."),
29 k("Float", "The floating-point base type."),
30 k(
31 "Instant",
32 "The absolute-time base type, in epoch milliseconds (`Clock.now()`).",
33 ),
34 k("Int", "The integer base type."),
35 k(
36 "JsonError",
37 "The JSON-decode error type, `Result[T, JsonError]` from `Json.decode`.",
38 ),
39 k("None", "The empty variant of `Option`."),
40 k("Ok", "The success variant of `Result`."),
41 k("Option", "The optional-value type, `Option[T]`."),
42 k("Result", "The success-or-error type, `Result[T, E]`."),
43 k("Some", "The present variant of `Option`."),
44 k("String", "The string base type."),
45 k(
46 "ValidationError",
47 "The error type returned by a refined type's `.of`.",
48 ),
49 k(
50 "actor",
51 "Declare an actor — a boundary contract a handler consumes via `by`.",
52 ),
53 k(
54 "adapter",
55 "Declare an adapter — the host boundary (capability contract + binding).",
56 ),
57 k("agent", "Declare a stateful, keyed agent inside a context."),
58 k("and", "Combine refinement predicates (`where A and B`)."),
59 k("as", "Alias a consumed context (`consumes X as Y`)."),
60 k(
61 "binding",
62 "Name an adapter's TypeScript binding module (`binding \"<module>\"`).",
63 ),
64 k(
65 "by",
66 "Name the actor a handler consumes (`on … by <name>: <Actor>`).",
67 ),
68 k(
69 "capability",
70 "Declare a capability (a dependency interface) in a context.",
71 ),
72 k(
73 "case",
74 "Declare a test case inside a `suite` (`case \"…\" { … }`).",
75 ),
76 k(
77 "commons",
78 "Declare a pure, stateless module of types and functions.",
79 ),
80 k(
81 "consumes",
82 "Declare a dependency on another context's services.",
83 ),
84 k(
85 "context",
86 "Declare a deployable context (services, agents, capabilities).",
87 ),
88 k(
89 "cron",
90 "The cron protocol on a service header (`from cron`).",
91 ),
92 k("else", "The alternative branch of an `if` expression."),
93 k("enum", "Declare a payloadless sum type (`enum { A, B }`)."),
94 k(
95 "expect",
96 "Assert a predicate inside a test case (`expect <bool-predicate>`).",
97 ),
98 k("exports", "Declare which types a context exposes, and how."),
99 k("false", "The boolean literal `false`."),
100 k("fn", "Declare a function."),
101 k(
102 "from",
103 "Name the protocol a service conforms to (`service X from http`).",
104 ),
105 k("given", "Declare the capabilities a handler requires."),
106 k(
107 "http",
108 "The HTTP protocol on a service header (`from http`).",
109 ),
110 k("if", "A conditional expression."),
111 k(
112 "implies",
113 "Logical implication (`P implies Q` ≡ `!P || Q`), used in invariant predicates.",
114 ),
115 k(
116 "invariant",
117 "Declare an agent invariant — a predicate that must hold of every committed state.",
118 ),
119 k(
120 "is",
121 "Test a value against a variant pattern, yielding a `Bool`.",
122 ),
123 k(
124 "let",
125 "Bind a local value (`let x = …`, or `let x <- …` for an effect).",
126 ),
127 k(
128 "match",
129 "Pattern-match over a sum type, `Result`, or `Option`.",
130 ),
131 k(
132 "mocks",
133 "Provide a mock capability implementation in a test.",
134 ),
135 k(
136 "on",
137 "Begin a handler declaration (`on call`, `on GET(…)`, `on message`, `on open`/`on close`).",
138 ),
139 k(
140 "opaque",
141 "Declare an opaque type, or export a type opaquely.",
142 ),
143 k(
144 "property",
145 "Declare a generative test inside a `suite` (`property \"…\" { for all … }`).",
146 ),
147 k(
148 "protocol",
149 "Reserved keyword (protocols are a closed, compiler-known set).",
150 ),
151 k("provides", "Provide an implementation of a capability."),
152 k(
153 "queue",
154 "The queue protocol on a service header (`from queue(\"name\")`).",
155 ),
156 k(
157 "record",
158 "Reserved keyword (records are written `type X = { … }`).",
159 ),
160 k("self", "The current agent instance, inside a handler."),
161 k(
162 "service",
163 "Declare a service (a group of handlers) in a context.",
164 ),
165 k(
166 "suite",
167 "Declare a test suite targeting a unit (`suite <target> { case … }`).",
168 ),
169 k(
170 "transparent",
171 "Export a type with its structure visible (`exports transparent { … }`).",
172 ),
173 k("true", "The boolean literal `true`."),
174 k(
175 "type",
176 "Declare a type: alias, record, sum, opaque, or refined.",
177 ),
178 k("uses", "Bring a commons into scope."),
179 k("where", "Attach refinement predicates to a base type."),
180 k(
181 "wires",
182 "List the contexts a `suite integration` stands up as Workers.",
183 ),
184];
185
186const fn k(word: &'static str, meaning: &'static str) -> KeywordInfo {
187 KeywordInfo { word, meaning }
188}
189
190pub fn render_markdown() -> String {
192 let mut out = String::new();
193 out.push_str("# Keywords\n\n");
194 out.push_str(
195 "<!-- GENERATED FILE — do not edit by hand.\n \
196 Source: bynkc/src/keywords.rs (`render_markdown`).\n \
197 Regenerate with: BYNK_BLESS=1 cargo test -p bynkc --test keywords_reference -->\n\n",
198 );
199 out.push_str(
200 "Every reserved keyword, with a one-line description. Reserved words cannot \
201 be used as identifiers.\n\n",
202 );
203 out.push_str(&format!(
204 "There are **{}** reserved keywords.\n\n",
205 KEYWORDS.len()
206 ));
207 out.push_str("| Keyword | Meaning |\n|---|---|\n");
208 for info in KEYWORDS {
209 out.push_str(&format!("| `{}` | {} |\n", info.word, info.meaning));
210 }
211 out
212}