aontu 0.56.0 → 0.58.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/agentsmd.js +1 -1
- package/dist/alias.d.ts +3 -0
- package/dist/alias.js +59 -0
- package/dist/alias.js.map +1 -0
- package/dist/aontu.d.ts +5 -2
- package/dist/aontu.js +11 -3
- package/dist/aontu.js.map +1 -1
- package/dist/cli.d.ts +8 -2
- package/dist/cli.js +564 -21
- package/dist/cli.js.map +1 -1
- package/dist/ctx.d.ts +2 -0
- package/dist/ctx.js +1 -0
- package/dist/ctx.js.map +1 -1
- package/dist/escape.d.ts +5 -0
- package/dist/escape.js +455 -0
- package/dist/escape.js.map +1 -0
- package/dist/format.d.ts +9 -0
- package/dist/format.js +550 -55
- package/dist/format.js.map +1 -1
- package/dist/hints.js +74 -9
- package/dist/hints.js.map +1 -1
- package/dist/lang.js +374 -58
- package/dist/lang.js.map +1 -1
- package/dist/lower.d.ts +20 -0
- package/dist/lower.js +575 -0
- package/dist/lower.js.map +1 -0
- package/dist/lsp.d.ts +1 -1
- package/dist/lsp.js +4 -4
- package/dist/lsp.js.map +1 -1
- package/dist/mcp-server.js +2 -2
- package/dist/mcp-server.js.map +1 -1
- package/dist/mcp.d.ts +1 -0
- package/dist/mcp.js +40 -3
- package/dist/mcp.js.map +1 -1
- package/dist/mod-tool.js +8 -7
- package/dist/mod-tool.js.map +1 -1
- package/dist/mod.js +6 -6
- package/dist/mod.js.map +1 -1
- package/dist/render.d.ts +53 -0
- package/dist/render.js +542 -0
- package/dist/render.js.map +1 -0
- package/dist/sigdecl.js +1 -1
- package/dist/sigdecl.js.map +1 -1
- package/dist/std.d.ts +2 -0
- package/dist/std.js +498 -2
- package/dist/std.js.map +1 -1
- package/dist/template.d.ts +5 -0
- package/dist/template.js +257 -0
- package/dist/template.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/unify.js +43 -0
- package/dist/unify.js.map +1 -1
- package/dist/val/AggFuncVal.d.ts +1 -1
- package/dist/val/AggFuncVal.js +10 -21
- package/dist/val/AggFuncVal.js.map +1 -1
- package/dist/val/BagVal.js +1 -1
- package/dist/val/BagVal.js.map +1 -1
- package/dist/val/ConstraintVal.js +1 -1
- package/dist/val/EachFuncVal.d.ts +1 -1
- package/dist/val/EachFuncVal.js +9 -15
- package/dist/val/EachFuncVal.js.map +1 -1
- package/dist/val/EmitFuncVal.d.ts +42 -0
- package/dist/val/EmitFuncVal.js +531 -0
- package/dist/val/EmitFuncVal.js.map +1 -0
- package/dist/val/FilterFuncVal.js +9 -6
- package/dist/val/FilterFuncVal.js.map +1 -1
- package/dist/val/FormFuncVal.d.ts +14 -0
- package/dist/val/FormFuncVal.js +55 -0
- package/dist/val/FormFuncVal.js.map +1 -0
- package/dist/val/FuncBaseVal.d.ts +1 -0
- package/dist/val/FuncBaseVal.js +16 -0
- package/dist/val/FuncBaseVal.js.map +1 -1
- package/dist/val/MapVal.d.ts +2 -1
- package/dist/val/MapVal.js +2 -1
- package/dist/val/MapVal.js.map +1 -1
- package/dist/val/PackFuncVal.d.ts +1 -1
- package/dist/val/PackFuncVal.js +23 -20
- package/dist/val/PackFuncVal.js.map +1 -1
- package/dist/val/PlaceVal.d.ts +3 -1
- package/dist/val/PlaceVal.js +9 -6
- package/dist/val/PlaceVal.js.map +1 -1
- package/dist/val/RefVal.d.ts +3 -0
- package/dist/val/RefVal.js +156 -17
- package/dist/val/RefVal.js.map +1 -1
- package/dist/val/StrFuncVal.d.ts +32 -0
- package/dist/val/StrFuncVal.js +292 -0
- package/dist/val/StrFuncVal.js.map +1 -0
- package/dist/val/Val.d.ts +7 -1
- package/dist/val/Val.js +12 -1
- package/dist/val/Val.js.map +1 -1
- package/dist/val/members.d.ts +9 -0
- package/dist/val/members.js +52 -0
- package/dist/val/members.js.map +1 -0
- package/grammar/aontu.abnf +4 -3
- package/grammar/aontu.gbnf +4 -3
- package/grammar/aontu.lark +4 -3
- package/grammar/aontu.tmLanguage.json +1 -1
- package/package.json +1 -1
- package/skill/SKILL.md +4 -4
- package/skill/error-codes.md +1 -1
- package/skill/examples.md +1 -1
- package/skill/grammar-card.md +1 -1
- package/src/agentsmd.ts +1 -1
- package/src/alias.ts +112 -0
- package/src/aontu.ts +20 -2
- package/src/cli.ts +630 -23
- package/src/ctx.ts +13 -0
- package/src/escape.ts +371 -0
- package/src/format.ts +648 -56
- package/src/hints.ts +94 -9
- package/src/lang.ts +430 -63
- package/src/lower.ts +636 -0
- package/src/lsp.ts +4 -4
- package/src/mcp-server.ts +3 -2
- package/src/mcp.ts +43 -4
- package/src/mod-tool.ts +9 -8
- package/src/mod.ts +6 -6
- package/src/render.ts +727 -0
- package/src/sigdecl.ts +1 -1
- package/src/std.ts +506 -1
- package/src/template.ts +291 -0
- package/src/unify.ts +47 -0
- package/src/val/AggFuncVal.ts +10 -21
- package/src/val/BagVal.ts +1 -1
- package/src/val/ConstraintVal.ts +1 -1
- package/src/val/EachFuncVal.ts +9 -19
- package/src/val/EmitFuncVal.ts +738 -0
- package/src/val/FilterFuncVal.ts +12 -7
- package/src/val/FormFuncVal.ts +119 -0
- package/src/val/FuncBaseVal.ts +18 -0
- package/src/val/MapVal.ts +3 -2
- package/src/val/PackFuncVal.ts +24 -22
- package/src/val/PlaceVal.ts +9 -6
- package/src/val/RefVal.ts +167 -18
- package/src/val/StrFuncVal.ts +334 -0
- package/src/val/Val.ts +42 -1
- package/src/val/members.ts +86 -0
package/src/sigdecl.ts
CHANGED
|
@@ -6,6 +6,6 @@
|
|
|
6
6
|
// this copy is identical with the shared file.
|
|
7
7
|
|
|
8
8
|
const SIGDECL: string =
|
|
9
|
-
"# The call surface: one declaration line per built-in function\n# (docs/design/SIGNATURES.0.md). THIS FILE IS THE SOURCE — both ports\n# carry a build-time-inlined copy (ts/src/sigdecl.ts, go/sigdecl.txt;\n# `make sig` regenerates both, and each port's suite asserts its copy\n# is byte-identical with this file) and parse it at initialisation\n# with the signature grammar, a tabnas grammar (ts/src/sig.ts,\n# go/sig.go). The suites also round-trip every line:\n# render(parse(line)) must be the line exactly, in both ports.\n#\n# The syntax (rendered TypeScript-ish, honest about argument MODES):\n# line = name '(' [ arg {',' arg} ] ')' ':' type\n# arg = [mode] name ['?'] ':' type\n# | '...' name ':' '(' [mode] type {',' [mode] type} ')'\n# type = word {'|' word}\n# mode = 'capture' | 'template' | 'trial' | 'projector' | 'text'\n# `value` mode is unmarked. `constraint` is the result word for\n# residuals whose meet depends on the peer; `any` is the honest type\n# where a function is a wrapper.\nupper(s: string|number) : string\nlower(s: string|number) : string\ncopy(v: any) : any\npref(v: any) : any\nsuper(t: any) : any\ntype(t: any) : any\nhide(v: any) : any\nclose(m: any) : any\nopen(m: any) : any\nmove(v: any) : any\npath(capture p?: path) : path\nmap() : map\nlist() : list\nmin(n: number|string) : constraint\nmax(n: number|string) : constraint\nabove(n: number|string) : constraint\nbelow(n: number|string) : constraint\nre(text p: string) : constraint\nlength(n: number|constraint) : constraint\nkey(up?: integer|biginteger) : string\nunique(projector k?: string) : constraint\nneq(...vals: number|string) : constraint\nmust(trial c: any, text msg: string) : constraint\ndeprecate(v: any, r?: map) : any\nacyclic() : constraint\ninverse(projector k: string) : constraint\nrefer(template t?: any) : constraint\nrel(template t?: any) : constraint\npack(d: map|list, template t: any) : map\neach(d: map|list, template t?: any) : list\nfilter(d: map|list, trial c: any) : map|list\nmatch(s: any, ...pr: (trial any, any), dflt?: any) : any\nadd(a: number, b: number) : number\nsub(a: number, b: number) : number\nmul(a: number, b: number) : number\ndiv(a: number, b: number) : number\nmod(a: number, b: number) : number\nrem(a: number, b: number) : number\nsum(d: map|list) : number\nleast(d: map|list) : number\ngreatest(d: map|list) : number\npick(d: map|list, projector k: string|integer) : any\njoin(d: map|list, sep?: string) : string\n"
|
|
9
|
+
"# The call surface: one declaration line per built-in function\n# (docs/design/SIGNATURES.0.md). THIS FILE IS THE SOURCE — both ports\n# carry a build-time-inlined copy (ts/src/sigdecl.ts, go/sigdecl.txt;\n# `make sig` regenerates both, and each port's suite asserts its copy\n# is byte-identical with this file) and parse it at initialisation\n# with the signature grammar, a tabnas grammar (ts/src/sig.ts,\n# go/sig.go). The suites also round-trip every line:\n# render(parse(line)) must be the line exactly, in both ports.\n#\n# The syntax (rendered TypeScript-ish, honest about argument MODES):\n# line = name '(' [ arg {',' arg} ] ')' ':' type\n# arg = [mode] name ['?'] ':' type\n# | '...' name ':' '(' [mode] type {',' [mode] type} ')'\n# type = word {'|' word}\n# mode = 'capture' | 'template' | 'trial' | 'projector' | 'text'\n# `value` mode is unmarked. `constraint` is the result word for\n# residuals whose meet depends on the peer; `any` is the honest type\n# where a function is a wrapper.\nupper(s: string|number) : string\nlower(s: string|number) : string\ncopy(v: any) : any\npref(v: any) : any\nsuper(t: any) : any\ntype(t: any) : any\nhide(v: any) : any\nclose(m: any) : any\nopen(m: any) : any\nmove(v: any) : any\npath(capture p?: path) : path\nmap() : map\nlist() : list\nmin(n: number|string) : constraint\nmax(n: number|string) : constraint\nabove(n: number|string) : constraint\nbelow(n: number|string) : constraint\nre(text p: string) : constraint\nlength(n: number|constraint) : constraint\nkey(up?: integer|biginteger) : string\nunique(projector k?: string) : constraint\nneq(...vals: number|string) : constraint\nmust(trial c: any, text msg: string) : constraint\ndeprecate(v: any, r?: map) : any\nacyclic() : constraint\ninverse(projector k: string) : constraint\nrefer(template t?: any) : constraint\nrel(template t?: any) : constraint\npack(d: map|list, template t: any) : map\neach(d: map|list, template t?: any) : list\nform(d: map|list, template t: any) : list\nfilter(d: map|list, trial c: any) : map|list\nmatch(s: any, ...pr: (trial any, any), dflt?: any) : any\nadd(a: number, b: number) : number\nsub(a: number, b: number) : number\nmul(a: number, b: number) : number\ndiv(a: number, b: number) : number\nmod(a: number, b: number) : number\nrem(a: number, b: number) : number\nsum(d: map|list) : number\nleast(d: map|list) : number\ngreatest(d: map|list) : number\npick(d: map|list, projector k: string|integer) : any\njoin(d: map|list, sep?: string) : string\nesc(s: string, variant?: string) : string\nusc(s: string, variant?: string) : string\nrep(s: string, text p: string, text sub: string) : string\nsplit(s: string, sep: string|constraint) : list\nemit(s: map|list, template t: map|list) : list\n"
|
|
10
10
|
|
|
11
11
|
export { SIGDECL }
|
package/src/std.ts
CHANGED
|
@@ -60,7 +60,7 @@ std: {
|
|
|
60
60
|
const STD_VIEW = `# std/view --- the FIGURE VOCABULARY (VIEWS.0.md, "6. The view
|
|
61
61
|
# document"). A view document declares its figures as data, and a
|
|
62
62
|
# declaration is just a map: this is the schema for one, so a typo is
|
|
63
|
-
# refused where every other mistake in an
|
|
63
|
+
# refused where every other mistake in an aontu document is refused --
|
|
64
64
|
# at evaluation, by unification -- rather than by the verb that reads
|
|
65
65
|
# it afterwards.
|
|
66
66
|
#
|
|
@@ -127,9 +127,514 @@ view: {
|
|
|
127
127
|
`
|
|
128
128
|
|
|
129
129
|
|
|
130
|
+
// THE LANGUAGE-SUPPLIED MODELS (docs/design/MODELS.0.md D1;
|
|
131
|
+
// docs/design/RENDER.0.md P0 and P1). `aontu:NAME` is Node's device --
|
|
132
|
+
// a prefix no relative path, package name or module path can spell --
|
|
133
|
+
// so the resolver routes on it before any other leg and never touches
|
|
134
|
+
// the filesystem for it. Held in String.raw so the backslashes of the
|
|
135
|
+
// regexes reach the parser as written; no backtick, as above.
|
|
136
|
+
//
|
|
137
|
+
// aontu:code is the OUTPUT VOCABULARY: an instance of it is what a
|
|
138
|
+
// transform evaluates to and what `aontu render` folds to bytes.
|
|
139
|
+
// aontu:profile is the schema of a render profile, the data a unit of
|
|
140
|
+
// one language is rendered under. Both are pinned by canon and hash
|
|
141
|
+
// rows (test/spec/aontu-code.tsv, test/spec/aontu-profile.tsv).
|
|
142
|
+
const STD_CODE = String.raw`# aontu:code --- THE OUTPUT VOCABULARY. An aontu transform evaluates to
|
|
143
|
+
# an instance of this schema, and 'aontu render' turns the instance
|
|
144
|
+
# into bytes. Because it is an ordinary schema, a transform's result is
|
|
145
|
+
# checked by unification before anything is rendered.
|
|
146
|
+
#
|
|
147
|
+
# @"aontu:code"
|
|
148
|
+
# code: { units: [ { path: "out.py", lang: "python", decls: [
|
|
149
|
+
# { k: "frag", of: emit($.model, %rules) } ] } ] }
|
|
150
|
+
#
|
|
151
|
+
# TWO ESCAPES, both counted by the render report: {k: "text", lang,
|
|
152
|
+
# text} carries verbatim target syntax, and 'x' is an open per-backend
|
|
153
|
+
# rider. CONTAINER TYPES TAKE LEAVES ONLY: anything deeper is a named
|
|
154
|
+
# alias declaration plus a {k: "ref"}, which keeps this schema's meet
|
|
155
|
+
# linear. A FRAGMENT IS FLAT: each piece carries its own depth ('at'),
|
|
156
|
+
# so the renderer owns every prefix and no piece nests another; a bare
|
|
157
|
+
# string piece is a line at depth 0, and no inline text may hold a line
|
|
158
|
+
# terminator -- that is checked here, before any renderer runs.
|
|
159
|
+
#
|
|
160
|
+
# THE ROOT IS NOT type()-MARKED, on purpose: 'aontu render' reads the
|
|
161
|
+
# instance through generate(), and a type()-marked subtree does not
|
|
162
|
+
# generate. A document that includes this vocabulary and writes no
|
|
163
|
+
# units generates 'code: {units: []}', which is what it said.
|
|
164
|
+
#
|
|
165
|
+
# EXPERIMENTAL until the distribution layer can version it by
|
|
166
|
+
# canon-hash.
|
|
167
|
+
|
|
168
|
+
%name = string & re("^[A-Za-z_][A-Za-z0-9_]*$") & length(min(1) & max(255))
|
|
169
|
+
|
|
170
|
+
%text = close({ k:"text" lang:string & length(min(1)) text:string })
|
|
171
|
+
|
|
172
|
+
%doc = close({
|
|
173
|
+
text: string
|
|
174
|
+
deprecated?: close({ msg?:string use?:string since?:string })
|
|
175
|
+
})
|
|
176
|
+
|
|
177
|
+
%check = close({ c:"min" n:number exclusive:*false | boolean })
|
|
178
|
+
| close({ c:"max" n:number exclusive:*false | boolean })
|
|
179
|
+
| close({ c:"re" p:string })
|
|
180
|
+
| close({ c:"len" min?:integer & min(0) max?:integer & min(0) })
|
|
181
|
+
| close({ c:"unique" key?:%name })
|
|
182
|
+
| close({ c:"ne" of:[&: string | number | boolean] })
|
|
183
|
+
| close({ c:"must" note:string })
|
|
184
|
+
|
|
185
|
+
%prim = close({
|
|
186
|
+
k: "prim"
|
|
187
|
+
prim: "string" | "int" | "bigint" | "float" | "decimal" | "bool" | "null" | "any"
|
|
188
|
+
})
|
|
189
|
+
%ref = close({ k:"ref" name:%name unit?:string })
|
|
190
|
+
%leaf = %prim | %ref | %text
|
|
191
|
+
|
|
192
|
+
%type = %leaf
|
|
193
|
+
| close({ k:"list" of:%leaf })
|
|
194
|
+
| close({ k:"map" key:%leaf of:%leaf })
|
|
195
|
+
| close({ k:"opt" of:%leaf })
|
|
196
|
+
| close({ k:"union" of:[&: %leaf] })
|
|
197
|
+
| close({ k:"lit" of:[&: string | number | boolean | null] })
|
|
198
|
+
|
|
199
|
+
%field = close({
|
|
200
|
+
name: %name
|
|
201
|
+
type: %type
|
|
202
|
+
optional: *false | boolean
|
|
203
|
+
doc?: %doc
|
|
204
|
+
default?: string | number | boolean | null
|
|
205
|
+
check?: [&: %check]
|
|
206
|
+
rel?: close({ to:string name?:string })
|
|
207
|
+
x?: {}
|
|
208
|
+
})
|
|
209
|
+
|
|
210
|
+
%member = close({ name:%name value?:string | number doc?:%doc x?:{} })
|
|
211
|
+
%param = close({
|
|
212
|
+
name: %name
|
|
213
|
+
type: %type
|
|
214
|
+
default?: string | number | boolean | null
|
|
215
|
+
x?: {}
|
|
216
|
+
})
|
|
217
|
+
|
|
218
|
+
# THE FRAGMENT ALGEBRA. A line's inline pieces hold no terminator; a
|
|
219
|
+
# blank is its terminators alone; a raw is the one piece that may carry
|
|
220
|
+
# terminators, re-indented to its depth unless it says not to.
|
|
221
|
+
%inline = string & re("^[^\n\r]*$") | %ref
|
|
222
|
+
%line = close({ k:"line" at:*0 | integer & min(0) & max(64) of:[&: %inline] })
|
|
223
|
+
%blank = close({ k:"blank" n:*1 | integer & min(1) & max(16) })
|
|
224
|
+
%raw = close({
|
|
225
|
+
k: "raw"
|
|
226
|
+
at: *0 | integer & min(0) & max(64)
|
|
227
|
+
text: string
|
|
228
|
+
reindent: *true | boolean
|
|
229
|
+
})
|
|
230
|
+
%piece = %line | %blank | %raw | string & re("^[^\n\r]*$")
|
|
231
|
+
%frag = close({ k:"frag" of:[&: %piece] })
|
|
232
|
+
%body = %frag | close({ k:"abstract" })
|
|
233
|
+
|
|
234
|
+
%record = close({
|
|
235
|
+
k: "record"
|
|
236
|
+
name: %name
|
|
237
|
+
doc?: %doc
|
|
238
|
+
open: *false | boolean
|
|
239
|
+
fields: [&: %field]
|
|
240
|
+
entity?: string
|
|
241
|
+
check?: [&: %check]
|
|
242
|
+
x?: {}
|
|
243
|
+
})
|
|
244
|
+
%enum = close({ k:"enum" name:%name doc?:%doc members:[&: %member] x?:{} })
|
|
245
|
+
%alias = close({
|
|
246
|
+
k: "alias"
|
|
247
|
+
name: %name
|
|
248
|
+
doc?: %doc
|
|
249
|
+
type: %type
|
|
250
|
+
check?: [&: %check]
|
|
251
|
+
x?: {}
|
|
252
|
+
})
|
|
253
|
+
%const = close({
|
|
254
|
+
k: "const"
|
|
255
|
+
name: %name
|
|
256
|
+
doc?: %doc
|
|
257
|
+
type?: %type
|
|
258
|
+
value: string | number | boolean | null
|
|
259
|
+
x?: {}
|
|
260
|
+
})
|
|
261
|
+
%func = close({
|
|
262
|
+
k: "func"
|
|
263
|
+
name: %name
|
|
264
|
+
doc?: %doc
|
|
265
|
+
params: [&: %param]
|
|
266
|
+
returns?: %type
|
|
267
|
+
body: %body
|
|
268
|
+
x?: {}
|
|
269
|
+
})
|
|
270
|
+
|
|
271
|
+
%decl = %record | %enum | %alias | %const | %func | %text | %frag
|
|
272
|
+
|
|
273
|
+
%import = close({
|
|
274
|
+
from: string & length(min(1))
|
|
275
|
+
names?: [&: %name]
|
|
276
|
+
alias?: %name
|
|
277
|
+
x?: {}
|
|
278
|
+
})
|
|
279
|
+
|
|
280
|
+
%unit = close({
|
|
281
|
+
path: string & length(min(1))
|
|
282
|
+
lang: string & length(min(1))
|
|
283
|
+
pkg?: string
|
|
284
|
+
doc?: %doc
|
|
285
|
+
imports?: [&: %import]
|
|
286
|
+
decls: [&: %decl]
|
|
287
|
+
profile?: {}
|
|
288
|
+
x?: {}
|
|
289
|
+
})
|
|
290
|
+
|
|
291
|
+
%source = close({ path?:string hash?:string & re("^aon1-[A-Za-z0-9_-]+$") })
|
|
292
|
+
|
|
293
|
+
code: close({ source?:%source units:[&: %unit] })
|
|
294
|
+
`
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
const STD_PROFILE = String.raw`# aontu:profile --- THE PROFILE VOCABULARY. A profile is the data
|
|
298
|
+
# 'aontu render' applies to a unit of one language, and it is DATA and
|
|
299
|
+
# only data: a field belongs here only if the renderer applies it
|
|
300
|
+
# without looking at the shape of any node. Anything else is a lowering
|
|
301
|
+
# and lives in the transform.
|
|
302
|
+
#
|
|
303
|
+
# @"aontu:profile"
|
|
304
|
+
# profile: { lang: "python", indent: { unit: " ", width: 4 } }
|
|
305
|
+
#
|
|
306
|
+
# Three profiles are bundled with the engine -- aontu:lang/typescript,
|
|
307
|
+
# aontu:lang/go and aontu:lang/text -- and a unit is matched to one by
|
|
308
|
+
# its 'lang'. A fragment-only unit needs nothing beyond 'indent'.
|
|
309
|
+
#
|
|
310
|
+
# THE ROOT IS NOT type()-MARKED, for the reason aontu:code's is not:
|
|
311
|
+
# 'aontu render' reads a profile through generate().
|
|
312
|
+
#
|
|
313
|
+
# EXPERIMENTAL until the distribution layer can version it by
|
|
314
|
+
# canon-hash.
|
|
315
|
+
|
|
316
|
+
%name = string & re("^[A-Za-z_][A-Za-z0-9_]*$")
|
|
317
|
+
|
|
318
|
+
%case = "as-is" | "camel" | "pascal" | "snake" | "screaming" | "kebab"
|
|
319
|
+
|
|
320
|
+
%comment = close({ open?:string prefix?:string close?:string })
|
|
321
|
+
|
|
322
|
+
%form = close({
|
|
323
|
+
open: *"" | string
|
|
324
|
+
close: *"" | string
|
|
325
|
+
prec: *9 | integer & min(0) & max(9)
|
|
326
|
+
childPrec: *0 | integer & min(0) & max(9)
|
|
327
|
+
})
|
|
328
|
+
|
|
329
|
+
%profile = close({
|
|
330
|
+
lang: string & length(min(1))
|
|
331
|
+
lowering?: "typescript" | "go"
|
|
332
|
+
indent: close({
|
|
333
|
+
unit: *" " | string & length(min(1))
|
|
334
|
+
width: *2 | integer & min(0) & max(16)
|
|
335
|
+
})
|
|
336
|
+
comment?: close({ line?:%comment block?:%comment doc?:%comment })
|
|
337
|
+
str?: close({
|
|
338
|
+
quote: *"\"" | string & length(min(1) & max(1))
|
|
339
|
+
escape: { &: string }
|
|
340
|
+
})
|
|
341
|
+
ident?: close({
|
|
342
|
+
chars: *"ascii-word" | "ascii-word"
|
|
343
|
+
reserved?: [&: string]
|
|
344
|
+
case?: close({
|
|
345
|
+
record?: %case
|
|
346
|
+
field?: %case
|
|
347
|
+
enum?: %case
|
|
348
|
+
member?: %case
|
|
349
|
+
const?: %case
|
|
350
|
+
func?: %case
|
|
351
|
+
param?: %case
|
|
352
|
+
alias?: %case
|
|
353
|
+
})
|
|
354
|
+
acronyms?: [&: %name]
|
|
355
|
+
})
|
|
356
|
+
types?: close({
|
|
357
|
+
prim?: { &: string }
|
|
358
|
+
list?: %form
|
|
359
|
+
map?: %form
|
|
360
|
+
opt?: %form
|
|
361
|
+
union?: %form
|
|
362
|
+
lit?: %form
|
|
363
|
+
})
|
|
364
|
+
banner?: string
|
|
365
|
+
})
|
|
366
|
+
|
|
367
|
+
profile: %profile
|
|
368
|
+
`
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
// The text profile (RENDER.0.md D5): the profile of a fragment-only
|
|
372
|
+
// unit, and the fallback of every language without a lowering.
|
|
373
|
+
const STD_LANG_TEXT = String.raw`# aontu:lang/text --- THE TEXT PROFILE. The profile of a unit whose
|
|
374
|
+
# declarations are fragments and text escapes only: indentation, and
|
|
375
|
+
# nothing else, since a fold over fragments applies nothing else. Every
|
|
376
|
+
# language without a lowering renders under it (docs/design/RENDER.0.md
|
|
377
|
+
# D5), and a reference inline renders as its name, verbatim.
|
|
378
|
+
#
|
|
379
|
+
# EXPERIMENTAL until the distribution layer can version it by
|
|
380
|
+
# canon-hash.
|
|
381
|
+
|
|
382
|
+
@"aontu:profile"
|
|
383
|
+
|
|
384
|
+
profile: { lang:"text" indent:{ unit:" " width:2 } }
|
|
385
|
+
`
|
|
386
|
+
|
|
387
|
+
// THE TYPESCRIPT PROFILE (docs/design/RENDER.0.md D5, P5): the data the
|
|
388
|
+
// typescript lowering renders under -- two spaces, the JSDoc forms, the
|
|
389
|
+
// JavaScript string escapes by decimal code point, the reserved words,
|
|
390
|
+
// camel and pascal by role, no acronyms (TypeScript's `ledgerId` keeps
|
|
391
|
+
// its `Id`), and the type forms whose precedences put the parens in
|
|
392
|
+
// `(string | null)[]`. Byte-identical in both ports, pinned by hash.
|
|
393
|
+
const STD_LANG_TYPESCRIPT = String.raw`# aontu:lang/typescript --- THE TYPESCRIPT PROFILE. The data a unit of
|
|
394
|
+
# TypeScript renders under: indentation, the comment forms, the string
|
|
395
|
+
# quote and its escape table, the identifier rules and the type forms.
|
|
396
|
+
# The lowering of a declaration to an exported interface is code
|
|
397
|
+
# (docs/design/RENDER.0.md D5); everything the lowering reads without
|
|
398
|
+
# looking at the shape of a node is here.
|
|
399
|
+
#
|
|
400
|
+
# EXPERIMENTAL until the distribution layer can version it by
|
|
401
|
+
# canon-hash.
|
|
402
|
+
|
|
403
|
+
@"aontu:profile"
|
|
404
|
+
|
|
405
|
+
profile: {
|
|
406
|
+
lang: "typescript"
|
|
407
|
+
lowering: "typescript"
|
|
408
|
+
indent: { unit:" " width:2 }
|
|
409
|
+
comment: line: prefix: "// "
|
|
410
|
+
comment: block: { open:"/*" prefix:" * " close:" */" }
|
|
411
|
+
comment: doc: { open:"/**" prefix:" * " close:" */" }
|
|
412
|
+
str: quote: "\""
|
|
413
|
+
str: escape: "8": "\\b"
|
|
414
|
+
str: escape: "9": "\\t"
|
|
415
|
+
str: escape: "10": "\\n"
|
|
416
|
+
str: escape: "12": "\\f"
|
|
417
|
+
str: escape: "13": "\\r"
|
|
418
|
+
str: escape: "34": "\\\""
|
|
419
|
+
str: escape: "92": "\\\\"
|
|
420
|
+
ident: {
|
|
421
|
+
chars: "ascii-word"
|
|
422
|
+
reserved: [
|
|
423
|
+
"await"
|
|
424
|
+
"break"
|
|
425
|
+
"case"
|
|
426
|
+
"catch"
|
|
427
|
+
"class"
|
|
428
|
+
"const"
|
|
429
|
+
"continue"
|
|
430
|
+
"debugger"
|
|
431
|
+
"default"
|
|
432
|
+
"delete"
|
|
433
|
+
"do"
|
|
434
|
+
"else"
|
|
435
|
+
"enum"
|
|
436
|
+
"export"
|
|
437
|
+
"extends"
|
|
438
|
+
"false"
|
|
439
|
+
"finally"
|
|
440
|
+
"for"
|
|
441
|
+
"function"
|
|
442
|
+
"if"
|
|
443
|
+
"implements"
|
|
444
|
+
"import"
|
|
445
|
+
"in"
|
|
446
|
+
"instanceof"
|
|
447
|
+
"interface"
|
|
448
|
+
"let"
|
|
449
|
+
"new"
|
|
450
|
+
"null"
|
|
451
|
+
"package"
|
|
452
|
+
"private"
|
|
453
|
+
"protected"
|
|
454
|
+
"public"
|
|
455
|
+
"return"
|
|
456
|
+
"static"
|
|
457
|
+
"super"
|
|
458
|
+
"switch"
|
|
459
|
+
"this"
|
|
460
|
+
"throw"
|
|
461
|
+
"true"
|
|
462
|
+
"try"
|
|
463
|
+
"typeof"
|
|
464
|
+
"var"
|
|
465
|
+
"void"
|
|
466
|
+
"while"
|
|
467
|
+
"with"
|
|
468
|
+
"yield"
|
|
469
|
+
]
|
|
470
|
+
case: record: "pascal"
|
|
471
|
+
case: field: "camel"
|
|
472
|
+
case: enum: "pascal"
|
|
473
|
+
case: member: "pascal"
|
|
474
|
+
case: const: "camel"
|
|
475
|
+
case: func: "camel"
|
|
476
|
+
case: param: "camel"
|
|
477
|
+
case: alias: "pascal"
|
|
478
|
+
acronyms: []
|
|
479
|
+
}
|
|
480
|
+
types: prim: string: "string"
|
|
481
|
+
types: prim: int: "number"
|
|
482
|
+
types: prim: bigint: "bigint"
|
|
483
|
+
types: prim: float: "number"
|
|
484
|
+
types: prim: decimal: "string"
|
|
485
|
+
types: prim: bool: "boolean"
|
|
486
|
+
types: prim: null: "null"
|
|
487
|
+
types: prim: any: "unknown"
|
|
488
|
+
types: list: { close:"[]" childPrec:2 }
|
|
489
|
+
types: map: { open:"Record<" close:">" }
|
|
490
|
+
types: opt: { close:" | null" prec:1 childPrec:2 }
|
|
491
|
+
types: union: { prec:1 childPrec:2 }
|
|
492
|
+
types: lit: prec: 1
|
|
493
|
+
banner: "Code generated by aontu from {path}. DO NOT EDIT."
|
|
494
|
+
}
|
|
495
|
+
`
|
|
496
|
+
|
|
497
|
+
// THE GO PROFILE (docs/design/RENDER.0.md D5, P5): a tab, the line-comment
|
|
498
|
+
// doc form, the Go string escapes, the 25 keywords, pascal by role with
|
|
499
|
+
// the acronym set that makes `ledgerId` `LedgerID`, and the type forms
|
|
500
|
+
// -- `[]T`, `map[K]V`, `*T` -- none of which needs a paren.
|
|
501
|
+
// Byte-identical in both ports, pinned by hash.
|
|
502
|
+
const STD_LANG_GO = String.raw`# aontu:lang/go --- THE GO PROFILE. The data a unit of Go renders
|
|
503
|
+
# under: a tab of indentation, the comment forms, the string quote and
|
|
504
|
+
# its escape table, the identifier rules -- pascal by role, and the
|
|
505
|
+
# acronym set that spells ID and URL -- and the type forms. The lowering
|
|
506
|
+
# of a declaration to a struct type is code (docs/design/RENDER.0.md D5);
|
|
507
|
+
# everything the lowering reads without looking at the shape of a node
|
|
508
|
+
# is here.
|
|
509
|
+
#
|
|
510
|
+
# EXPERIMENTAL until the distribution layer can version it by
|
|
511
|
+
# canon-hash.
|
|
512
|
+
|
|
513
|
+
@"aontu:profile"
|
|
514
|
+
|
|
515
|
+
profile: {
|
|
516
|
+
lang: "go"
|
|
517
|
+
lowering: "go"
|
|
518
|
+
indent: { unit:"\t" width:1 }
|
|
519
|
+
comment: { line:prefix:"// " block:{ open:"/*" close:"*/" } doc:prefix:"// " }
|
|
520
|
+
str: quote: "\""
|
|
521
|
+
str: escape: "7": "\\a"
|
|
522
|
+
str: escape: "8": "\\b"
|
|
523
|
+
str: escape: "9": "\\t"
|
|
524
|
+
str: escape: "10": "\\n"
|
|
525
|
+
str: escape: "11": "\\v"
|
|
526
|
+
str: escape: "12": "\\f"
|
|
527
|
+
str: escape: "13": "\\r"
|
|
528
|
+
str: escape: "34": "\\\""
|
|
529
|
+
str: escape: "92": "\\\\"
|
|
530
|
+
ident: {
|
|
531
|
+
chars: "ascii-word"
|
|
532
|
+
reserved: [
|
|
533
|
+
"break"
|
|
534
|
+
"case"
|
|
535
|
+
"chan"
|
|
536
|
+
"const"
|
|
537
|
+
"continue"
|
|
538
|
+
"default"
|
|
539
|
+
"defer"
|
|
540
|
+
"else"
|
|
541
|
+
"fallthrough"
|
|
542
|
+
"for"
|
|
543
|
+
"func"
|
|
544
|
+
"go"
|
|
545
|
+
"goto"
|
|
546
|
+
"if"
|
|
547
|
+
"import"
|
|
548
|
+
"interface"
|
|
549
|
+
"map"
|
|
550
|
+
"package"
|
|
551
|
+
"range"
|
|
552
|
+
"return"
|
|
553
|
+
"select"
|
|
554
|
+
"struct"
|
|
555
|
+
"switch"
|
|
556
|
+
"type"
|
|
557
|
+
"var"
|
|
558
|
+
]
|
|
559
|
+
case: record: "pascal"
|
|
560
|
+
case: field: "pascal"
|
|
561
|
+
case: enum: "pascal"
|
|
562
|
+
case: member: "pascal"
|
|
563
|
+
case: const: "pascal"
|
|
564
|
+
case: func: "pascal"
|
|
565
|
+
case: param: "camel"
|
|
566
|
+
case: alias: "pascal"
|
|
567
|
+
acronyms: [
|
|
568
|
+
"ACL"
|
|
569
|
+
"API"
|
|
570
|
+
"ASCII"
|
|
571
|
+
"CPU"
|
|
572
|
+
"CSS"
|
|
573
|
+
"DNS"
|
|
574
|
+
"EOF"
|
|
575
|
+
"GUID"
|
|
576
|
+
"HTML"
|
|
577
|
+
"HTTP"
|
|
578
|
+
"HTTPS"
|
|
579
|
+
"ID"
|
|
580
|
+
"IP"
|
|
581
|
+
"JSON"
|
|
582
|
+
"LHS"
|
|
583
|
+
"QPS"
|
|
584
|
+
"RAM"
|
|
585
|
+
"RHS"
|
|
586
|
+
"RPC"
|
|
587
|
+
"SLA"
|
|
588
|
+
"SMTP"
|
|
589
|
+
"SQL"
|
|
590
|
+
"SSH"
|
|
591
|
+
"TCP"
|
|
592
|
+
"TLS"
|
|
593
|
+
"TTL"
|
|
594
|
+
"UDP"
|
|
595
|
+
"UI"
|
|
596
|
+
"UID"
|
|
597
|
+
"UUID"
|
|
598
|
+
"URI"
|
|
599
|
+
"URL"
|
|
600
|
+
"UTF8"
|
|
601
|
+
"VM"
|
|
602
|
+
"XML"
|
|
603
|
+
"XMPP"
|
|
604
|
+
"XSRF"
|
|
605
|
+
"XSS"
|
|
606
|
+
]
|
|
607
|
+
}
|
|
608
|
+
types: prim: string: "string"
|
|
609
|
+
types: prim: int: "int64"
|
|
610
|
+
types: prim: bigint: "string"
|
|
611
|
+
types: prim: float: "float64"
|
|
612
|
+
types: prim: decimal: "string"
|
|
613
|
+
types: prim: bool: "bool"
|
|
614
|
+
types: prim: null: "any"
|
|
615
|
+
types: prim: any: "any"
|
|
616
|
+
types: list: open: "[]"
|
|
617
|
+
types: map: open: "map["
|
|
618
|
+
types: opt: open: "*"
|
|
619
|
+
banner: "Code generated by aontu from {path}. DO NOT EDIT."
|
|
620
|
+
}
|
|
621
|
+
`
|
|
622
|
+
|
|
130
623
|
export const STD_SOURCES: Record<string, string> = {
|
|
131
624
|
'std/system': STD_SYSTEM,
|
|
132
625
|
'std/system.aon': STD_SYSTEM,
|
|
133
626
|
'std/view': STD_VIEW,
|
|
134
627
|
'std/view.aon': STD_VIEW,
|
|
628
|
+
'aontu:code': STD_CODE,
|
|
629
|
+
'aontu:lang/go': STD_LANG_GO,
|
|
630
|
+
'aontu:lang/text': STD_LANG_TEXT,
|
|
631
|
+
'aontu:lang/typescript': STD_LANG_TYPESCRIPT,
|
|
632
|
+
'aontu:profile': STD_PROFILE,
|
|
135
633
|
}
|
|
634
|
+
|
|
635
|
+
// The scheme of a language-supplied model, and the names it serves --
|
|
636
|
+
// the set the not-found message names, so a typo does not go looking
|
|
637
|
+
// on disk.
|
|
638
|
+
export const AONTU_SCHEME = 'aontu:'
|
|
639
|
+
export const AONTU_MODELS: string[] =
|
|
640
|
+
Object.keys(STD_SOURCES).filter((k) => k.startsWith(AONTU_SCHEME)).sort()
|