@dancrumb/cant-compiler 0.0.0-stage → 0.10.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/dist/bodies.d.ts +33 -0
- package/dist/bodies.d.ts.map +1 -0
- package/dist/bodies.js +512 -0
- package/dist/bodies.js.map +1 -0
- package/dist/check.d.ts +18 -0
- package/dist/check.d.ts.map +1 -0
- package/dist/check.js +30 -0
- package/dist/check.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +90 -0
- package/dist/cli.js.map +1 -0
- package/dist/compile.d.ts +20 -0
- package/dist/compile.d.ts.map +1 -0
- package/dist/compile.js +777 -0
- package/dist/compile.js.map +1 -0
- package/dist/constants.d.ts +22 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +262 -0
- package/dist/constants.js.map +1 -0
- package/dist/declarations.d.ts +54 -0
- package/dist/declarations.d.ts.map +1 -0
- package/dist/declarations.js +202 -0
- package/dist/declarations.js.map +1 -0
- package/dist/diagnostic.d.ts +19 -0
- package/dist/diagnostic.d.ts.map +1 -0
- package/dist/diagnostic.js +27 -0
- package/dist/diagnostic.js.map +1 -0
- package/dist/entities.d.ts +32 -0
- package/dist/entities.d.ts.map +1 -0
- package/dist/entities.js +235 -0
- package/dist/entities.js.map +1 -0
- package/dist/evaluate.d.ts +30 -0
- package/dist/evaluate.d.ts.map +1 -0
- package/dist/evaluate.js +79 -0
- package/dist/evaluate.js.map +1 -0
- package/dist/host.d.ts +8 -0
- package/dist/host.d.ts.map +1 -0
- package/dist/host.js +13 -0
- package/dist/host.js.map +1 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/manifest.d.ts +23 -0
- package/dist/manifest.d.ts.map +1 -0
- package/dist/manifest.js +93 -0
- package/dist/manifest.js.map +1 -0
- package/dist/modules.d.ts +84 -0
- package/dist/modules.d.ts.map +1 -0
- package/dist/modules.js +259 -0
- package/dist/modules.js.map +1 -0
- package/dist/program.d.ts +24 -0
- package/dist/program.d.ts.map +1 -0
- package/dist/program.js +38 -0
- package/dist/program.js.map +1 -0
- package/dist/resolve.d.ts +24 -0
- package/dist/resolve.d.ts.map +1 -0
- package/dist/resolve.js +203 -0
- package/dist/resolve.js.map +1 -0
- package/dist/stdlib.d.ts +12 -0
- package/dist/stdlib.d.ts.map +1 -0
- package/dist/stdlib.js +38 -0
- package/dist/stdlib.js.map +1 -0
- package/dist/typecheck.d.ts +52 -0
- package/dist/typecheck.d.ts.map +1 -0
- package/dist/typecheck.js +1408 -0
- package/dist/typecheck.js.map +1 -0
- package/dist/types.d.ts +130 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +199 -0
- package/dist/types.js.map +1 -0
- package/dist/weave.d.ts +3 -0
- package/dist/weave.d.ts.map +1 -0
- package/dist/weave.js +40 -0
- package/dist/weave.js.map +1 -0
- package/package.json +47 -3
- package/README.md +0 -3
package/dist/bodies.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Identifier } from '@dancrumb/cant-shared';
|
|
2
|
+
import { type Diagnostic } from './diagnostic.ts';
|
|
3
|
+
import { type LoadedProgram } from './modules.ts';
|
|
4
|
+
import type { References } from './resolve.ts';
|
|
5
|
+
/** A name given a value inside a declaration: a parameter, an assigned identifier or a loop variable. */
|
|
6
|
+
export interface LocalBinding {
|
|
7
|
+
kind: 'parameter' | 'local' | 'loop' | 'field';
|
|
8
|
+
/** Where the name is declared. */
|
|
9
|
+
declaration: Identifier;
|
|
10
|
+
}
|
|
11
|
+
/** Which local binding each identifier in an expression refers to. */
|
|
12
|
+
export type Locals = Map<Identifier, LocalBinding>;
|
|
13
|
+
/**
|
|
14
|
+
* Resolve the names inside expressions and statements, in every module: identifiers, calls and
|
|
15
|
+
* enum members, with the local scopes of docs/adr/0018-immutable-identifiers.md and
|
|
16
|
+
* docs/adr/0020-action-parameters.md. Reports:
|
|
17
|
+
*
|
|
18
|
+
* - names that can't be found, or that name something that can't be used there, such as an
|
|
19
|
+
* action used as a value, or a call of something that isn't an action;
|
|
20
|
+
* - an identifier assigned twice in one block (docs/adr/0018-immutable-identifiers.md);
|
|
21
|
+
* - `break` or `continue` outside a loop (docs/adr/0007-actions.md);
|
|
22
|
+
* - arguments that don't match the action's parameters, in calls and in triggers
|
|
23
|
+
* (docs/adr/0020-action-parameters.md), and unknown `TestCase` parameters;
|
|
24
|
+
* - enum members the enum doesn't have (docs/adr/0013-enums.md);
|
|
25
|
+
* - built-in values that don't exist, or are used where they can't be (docs/adr/0024-built-in-values.md).
|
|
26
|
+
*
|
|
27
|
+
* Resolved top-level names are added to `references`, and local ones to the returned `locals`.
|
|
28
|
+
*/
|
|
29
|
+
export declare function resolveBodies(program: LoadedProgram, references: References): {
|
|
30
|
+
locals: Locals;
|
|
31
|
+
diagnostics: Diagnostic[];
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=bodies.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bodies.d.ts","sourceRoot":"","sources":["../src/bodies.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAOV,UAAU,EAKX,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAS,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAA4C,KAAK,aAAa,EAAkC,MAAM,cAAc,CAAC;AAC5H,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,yGAAyG;AACzG,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,WAAW,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC;IAC/C,kCAAkC;IAClC,WAAW,EAAE,UAAU,CAAC;CACzB;AAED,sEAAsE;AACtE,MAAM,MAAM,MAAM,GAAG,GAAG,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;AAkDnD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,UAAU,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,UAAU,EAAE,CAAA;CAAE,CAS3H"}
|
package/dist/bodies.js
ADDED
|
@@ -0,0 +1,512 @@
|
|
|
1
|
+
import { MAIN_NAMESPACE } from './declarations.js';
|
|
2
|
+
import { error } from './diagnostic.js';
|
|
3
|
+
import { describeName, hasNamespace, symbolsNamed } from './modules.js';
|
|
4
|
+
/** The built-in values of docs/adr/0024-built-in-values.md, and where each can be written. */
|
|
5
|
+
const BUILT_INS = new Set(['subject', 'anonymous', 'defined', 'id', 'entity', 'all', 'result', 'error', 'now', 'request', 'message']);
|
|
6
|
+
const ALLOWED_BUILT_INS = {
|
|
7
|
+
action: new Set(['subject', 'now']),
|
|
8
|
+
field: new Set(['subject', 'now']),
|
|
9
|
+
// A constant, and a source's parameters, must be constant expressions, which built-ins never are.
|
|
10
|
+
constant: new Set(),
|
|
11
|
+
'source parameters': new Set(),
|
|
12
|
+
trigger: new Set(['subject', 'now', 'result', 'request', 'message']),
|
|
13
|
+
assertions: new Set(['subject', 'now', 'result', 'error', 'request', 'message']),
|
|
14
|
+
};
|
|
15
|
+
/** Where docs/adr/0024-built-in-values.md lets each built-in be used, for error messages. */
|
|
16
|
+
const WHERE = {
|
|
17
|
+
subject: 'in any trigger or action',
|
|
18
|
+
now: 'in any trigger or action, but not in a constant expression',
|
|
19
|
+
result: 'only in a trigger',
|
|
20
|
+
request: 'only in a trigger on a source that provides it',
|
|
21
|
+
message: 'only in a trigger on a source that provides it',
|
|
22
|
+
error: "only in a test case's `assertions`",
|
|
23
|
+
anonymous: 'only after `@subject is`',
|
|
24
|
+
defined: 'only after `@subject is`',
|
|
25
|
+
all: 'only in an entity\'s `expose` and `hide` blocks, and in `passes @all`',
|
|
26
|
+
entity: "only as a member name in a test case's `subject`",
|
|
27
|
+
id: 'nowhere: it cannot be read in Cant code',
|
|
28
|
+
};
|
|
29
|
+
/** The parameters of the `TestCase` source (docs/adr/0037-test-case-trigger-source.md, 0026). */
|
|
30
|
+
const TEST_CASE_PARAMETERS = new Set(['name', 'subject', 'now']);
|
|
31
|
+
/** A block's names, and the blocks around it. */
|
|
32
|
+
class Scope {
|
|
33
|
+
names = new Map();
|
|
34
|
+
parent;
|
|
35
|
+
constructor(parent) {
|
|
36
|
+
this.parent = parent;
|
|
37
|
+
}
|
|
38
|
+
find(name) {
|
|
39
|
+
return this.names.get(name) ?? this.parent?.find(name);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Resolve the names inside expressions and statements, in every module: identifiers, calls and
|
|
44
|
+
* enum members, with the local scopes of docs/adr/0018-immutable-identifiers.md and
|
|
45
|
+
* docs/adr/0020-action-parameters.md. Reports:
|
|
46
|
+
*
|
|
47
|
+
* - names that can't be found, or that name something that can't be used there, such as an
|
|
48
|
+
* action used as a value, or a call of something that isn't an action;
|
|
49
|
+
* - an identifier assigned twice in one block (docs/adr/0018-immutable-identifiers.md);
|
|
50
|
+
* - `break` or `continue` outside a loop (docs/adr/0007-actions.md);
|
|
51
|
+
* - arguments that don't match the action's parameters, in calls and in triggers
|
|
52
|
+
* (docs/adr/0020-action-parameters.md), and unknown `TestCase` parameters;
|
|
53
|
+
* - enum members the enum doesn't have (docs/adr/0013-enums.md);
|
|
54
|
+
* - built-in values that don't exist, or are used where they can't be (docs/adr/0024-built-in-values.md).
|
|
55
|
+
*
|
|
56
|
+
* Resolved top-level names are added to `references`, and local ones to the returned `locals`.
|
|
57
|
+
*/
|
|
58
|
+
export function resolveBodies(program, references) {
|
|
59
|
+
const locals = new Map();
|
|
60
|
+
const diagnostics = [];
|
|
61
|
+
for (const module of program.modules.values()) {
|
|
62
|
+
new BodyResolver(module, references, locals, (diagnostic) => {
|
|
63
|
+
diagnostics.push({ ...diagnostic, file: module.path });
|
|
64
|
+
}).run();
|
|
65
|
+
}
|
|
66
|
+
return { locals, diagnostics };
|
|
67
|
+
}
|
|
68
|
+
class BodyResolver {
|
|
69
|
+
namespace = MAIN_NAMESPACE;
|
|
70
|
+
context = 'action';
|
|
71
|
+
loops = 0;
|
|
72
|
+
module;
|
|
73
|
+
references;
|
|
74
|
+
locals;
|
|
75
|
+
report;
|
|
76
|
+
constructor(module, references, locals, report) {
|
|
77
|
+
this.module = module;
|
|
78
|
+
this.references = references;
|
|
79
|
+
this.locals = locals;
|
|
80
|
+
this.report = report;
|
|
81
|
+
}
|
|
82
|
+
run() {
|
|
83
|
+
for (const declaration of this.module.program?.children ?? []) {
|
|
84
|
+
switch (declaration.type) {
|
|
85
|
+
case 'namespace':
|
|
86
|
+
this.namespace = declaration.name.value;
|
|
87
|
+
break;
|
|
88
|
+
case 'action':
|
|
89
|
+
this.action(declaration);
|
|
90
|
+
break;
|
|
91
|
+
case 'const':
|
|
92
|
+
this.context = 'constant';
|
|
93
|
+
this.expression(declaration.value, new Scope());
|
|
94
|
+
break;
|
|
95
|
+
case 'model':
|
|
96
|
+
this.fields(declaration.fields);
|
|
97
|
+
break;
|
|
98
|
+
case 'errorDeclaration':
|
|
99
|
+
if (Array.isArray(declaration.data))
|
|
100
|
+
this.fields(declaration.data);
|
|
101
|
+
break;
|
|
102
|
+
case 'trigger':
|
|
103
|
+
this.trigger(declaration);
|
|
104
|
+
break;
|
|
105
|
+
default:
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
// ----- Declarations -----
|
|
111
|
+
action(declaration) {
|
|
112
|
+
this.context = 'action';
|
|
113
|
+
// Parameters are in a block around the body, and a default can use any other parameter,
|
|
114
|
+
// before or after it in the list (docs/adr/0020-action-parameters.md).
|
|
115
|
+
const parameters = new Scope();
|
|
116
|
+
for (const parameter of declaration.parameters) {
|
|
117
|
+
parameters.names.set(parameter.name.value, { kind: 'parameter', declaration: parameter.name });
|
|
118
|
+
}
|
|
119
|
+
for (const parameter of declaration.parameters) {
|
|
120
|
+
if (parameter.defaultValue !== undefined)
|
|
121
|
+
this.expression(parameter.defaultValue, parameters);
|
|
122
|
+
}
|
|
123
|
+
this.block(declaration.children, new Scope(parameters));
|
|
124
|
+
}
|
|
125
|
+
/** A model's or an error's fields, whose defaults can use the object's other fields (docs/adr/0027-object-shapes.md). */
|
|
126
|
+
fields(fields) {
|
|
127
|
+
this.context = 'field';
|
|
128
|
+
const scope = new Scope();
|
|
129
|
+
for (const field of fields)
|
|
130
|
+
scope.names.set(field.name.value, { kind: 'field', declaration: field.name });
|
|
131
|
+
for (const field of fields)
|
|
132
|
+
if (field.defaultValue !== undefined)
|
|
133
|
+
this.expression(field.defaultValue, scope);
|
|
134
|
+
}
|
|
135
|
+
trigger(declaration) {
|
|
136
|
+
const scope = new Scope();
|
|
137
|
+
const testCase = declaration.source.value === 'TestCase';
|
|
138
|
+
this.context = 'source parameters';
|
|
139
|
+
for (const parameter of declaration.parameters ?? []) {
|
|
140
|
+
if (testCase && !TEST_CASE_PARAMETERS.has(parameter.name.value)) {
|
|
141
|
+
this.report(error('unknown-parameter', `The TestCase source has no parameter called ${parameter.name.value}. Its parameters are name, subject and now.`, parameter.name.position));
|
|
142
|
+
}
|
|
143
|
+
this.expression(parameter.value, scope, testCase && parameter.name.value === 'subject');
|
|
144
|
+
}
|
|
145
|
+
if (testCase && !(declaration.parameters ?? []).some((parameter) => parameter.name.value === 'name')) {
|
|
146
|
+
this.report(error('missing-parameter', 'A test case needs a `name` parameter.', declaration.source.position));
|
|
147
|
+
}
|
|
148
|
+
this.context = 'trigger';
|
|
149
|
+
if (declaration.auth !== undefined)
|
|
150
|
+
this.expression(declaration.auth, scope);
|
|
151
|
+
for (const argument of declaration.arguments ?? [])
|
|
152
|
+
this.expression(argument.value, scope);
|
|
153
|
+
const action = this.references.get(declaration.action);
|
|
154
|
+
if (action?.declaration?.type === 'action') {
|
|
155
|
+
this.checkArguments(action.declaration, (declaration.arguments ?? []).map((argument) => ({ name: argument.name, position: argument.position })), declaration.action.position);
|
|
156
|
+
}
|
|
157
|
+
this.context = 'assertions';
|
|
158
|
+
for (const assertion of declaration.assertions ?? []) {
|
|
159
|
+
this.expression(assertion.test, scope);
|
|
160
|
+
this.expression(assertion.message, scope);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
// ----- Statements -----
|
|
164
|
+
block(statements, scope) {
|
|
165
|
+
for (const statement of statements)
|
|
166
|
+
this.statement(statement, scope);
|
|
167
|
+
}
|
|
168
|
+
statement(statement, scope) {
|
|
169
|
+
switch (statement.type) {
|
|
170
|
+
case 'expressionStatement':
|
|
171
|
+
this.expression(statement.expression, scope);
|
|
172
|
+
break;
|
|
173
|
+
case 'assignment':
|
|
174
|
+
this.expression(statement.value, scope);
|
|
175
|
+
if (statement.target.type === 'identifier')
|
|
176
|
+
this.declare(statement.target, scope, 'local');
|
|
177
|
+
else
|
|
178
|
+
this.expression(statement.target, scope);
|
|
179
|
+
break;
|
|
180
|
+
case 'delete':
|
|
181
|
+
this.expression(statement.target, scope);
|
|
182
|
+
break;
|
|
183
|
+
case 'ignoredStatement':
|
|
184
|
+
this.statement(statement.statement, scope);
|
|
185
|
+
break;
|
|
186
|
+
case 'return':
|
|
187
|
+
if (statement.argument !== undefined && statement.argument.type !== 'nothing') {
|
|
188
|
+
this.expression(statement.argument, scope);
|
|
189
|
+
}
|
|
190
|
+
break;
|
|
191
|
+
case 'raise':
|
|
192
|
+
for (const argument of statement.arguments ?? [])
|
|
193
|
+
this.expression(argument.value, scope);
|
|
194
|
+
if (statement.data !== undefined)
|
|
195
|
+
this.expression(statement.data, scope);
|
|
196
|
+
break;
|
|
197
|
+
case 'pass':
|
|
198
|
+
this.expression(statement.argument, scope);
|
|
199
|
+
break;
|
|
200
|
+
case 'assert':
|
|
201
|
+
this.expression(statement.test, scope);
|
|
202
|
+
if (statement.message !== undefined)
|
|
203
|
+
this.expression(statement.message, scope);
|
|
204
|
+
break;
|
|
205
|
+
case 'break':
|
|
206
|
+
case 'continue':
|
|
207
|
+
if (this.loops === 0) {
|
|
208
|
+
this.report(error('outside-loop', `\`${statement.type}\` can only be used inside a \`for\` or \`while\` loop.`, statement.position));
|
|
209
|
+
}
|
|
210
|
+
break;
|
|
211
|
+
case 'for': {
|
|
212
|
+
this.expression(statement.iterable, scope);
|
|
213
|
+
// The loop variable is a new constant on each pass, in the loop's own block, so the
|
|
214
|
+
// body can't assign to it (docs/adr/0018-immutable-identifiers.md).
|
|
215
|
+
const body = new Scope(scope);
|
|
216
|
+
this.declare(statement.variable, body, 'loop');
|
|
217
|
+
this.loop(() => {
|
|
218
|
+
this.block(statement.children, body);
|
|
219
|
+
});
|
|
220
|
+
break;
|
|
221
|
+
}
|
|
222
|
+
case 'while':
|
|
223
|
+
this.expression(statement.test, scope);
|
|
224
|
+
this.loop(() => {
|
|
225
|
+
this.block(statement.children, new Scope(scope));
|
|
226
|
+
});
|
|
227
|
+
break;
|
|
228
|
+
case 'if':
|
|
229
|
+
this.expression(statement.test, scope);
|
|
230
|
+
for (const branch of statement.children) {
|
|
231
|
+
if (branch.type === 'if')
|
|
232
|
+
this.statement(branch, scope);
|
|
233
|
+
else
|
|
234
|
+
this.block(branch.children, new Scope(scope));
|
|
235
|
+
}
|
|
236
|
+
break;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
loop(body) {
|
|
240
|
+
this.loops += 1;
|
|
241
|
+
body();
|
|
242
|
+
this.loops -= 1;
|
|
243
|
+
}
|
|
244
|
+
/** Give a name its value in this block. A name can only be assigned once in a block, but can shadow one from an enclosing block. */
|
|
245
|
+
declare(name, scope, kind) {
|
|
246
|
+
const earlier = scope.names.get(name.value);
|
|
247
|
+
if (earlier !== undefined) {
|
|
248
|
+
this.report(error('reassignment', earlier.kind === 'loop'
|
|
249
|
+
? `${name.value} is the loop's variable, so the loop body can't assign to it. Every identifier is a constant.`
|
|
250
|
+
: `${name.value} has already been assigned in this block, on line ${String(earlier.declaration.position.start.line)}. Every identifier is a constant, so it can only be assigned once; a nested block can declare a new ${name.value} that shadows it.`, name.position));
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
scope.names.set(name.value, { kind, declaration: name });
|
|
254
|
+
this.locals.set(name, { kind, declaration: name });
|
|
255
|
+
}
|
|
256
|
+
// ----- Expressions -----
|
|
257
|
+
expression(expression, scope, testCaseSubject = false) {
|
|
258
|
+
switch (expression.type) {
|
|
259
|
+
case 'identifier':
|
|
260
|
+
this.value(expression, scope);
|
|
261
|
+
break;
|
|
262
|
+
case 'qualifiedIdentifier':
|
|
263
|
+
this.value(expression, scope);
|
|
264
|
+
break;
|
|
265
|
+
case 'builtIn':
|
|
266
|
+
this.builtIn(expression);
|
|
267
|
+
break;
|
|
268
|
+
case 'string':
|
|
269
|
+
for (const part of expression.parts)
|
|
270
|
+
if (part.type === 'interpolation')
|
|
271
|
+
this.expression(part.expression, scope);
|
|
272
|
+
break;
|
|
273
|
+
case 'array':
|
|
274
|
+
case 'set':
|
|
275
|
+
for (const element of expression.elements)
|
|
276
|
+
this.expression(element, scope);
|
|
277
|
+
break;
|
|
278
|
+
case 'object':
|
|
279
|
+
for (const item of expression.items) {
|
|
280
|
+
if (item.name.type === 'builtIn' && !(testCaseSubject && item.name.name === 'entity')) {
|
|
281
|
+
this.report(error('misplaced-built-in', `@${item.name.name} can't be a member's name here. A built-in name can only be a member's name as @entity, in a test case's \`subject\`.`, item.name.position));
|
|
282
|
+
continue;
|
|
283
|
+
}
|
|
284
|
+
// `@entity` holds a type, the subject's entity, not a value.
|
|
285
|
+
if (testCaseSubject && item.name.type === 'builtIn' && item.name.name === 'entity') {
|
|
286
|
+
this.subjectEntity(item.value);
|
|
287
|
+
continue;
|
|
288
|
+
}
|
|
289
|
+
this.expression(item.value, scope);
|
|
290
|
+
}
|
|
291
|
+
if (testCaseSubject && !expression.items.some((item) => item.name.type === 'builtIn' && item.name.name === 'entity')) {
|
|
292
|
+
this.report(error('missing-entity', "A test case's `subject` needs an @entity member, naming the subject's entity.", expression.position));
|
|
293
|
+
}
|
|
294
|
+
break;
|
|
295
|
+
case 'member':
|
|
296
|
+
if (!this.enumMember(expression, scope))
|
|
297
|
+
this.expression(expression.object, scope);
|
|
298
|
+
break;
|
|
299
|
+
case 'index':
|
|
300
|
+
this.expression(expression.object, scope);
|
|
301
|
+
this.expression(expression.index, scope);
|
|
302
|
+
break;
|
|
303
|
+
case 'call':
|
|
304
|
+
this.call(expression, scope);
|
|
305
|
+
break;
|
|
306
|
+
case 'unary':
|
|
307
|
+
this.expression(expression.argument, scope);
|
|
308
|
+
break;
|
|
309
|
+
case 'binary':
|
|
310
|
+
this.expression(expression.left, scope);
|
|
311
|
+
this.expression(expression.right, scope);
|
|
312
|
+
break;
|
|
313
|
+
case 'instanceOf':
|
|
314
|
+
this.expression(expression.value, scope);
|
|
315
|
+
break;
|
|
316
|
+
case 'canPredicate':
|
|
317
|
+
this.builtIn(expression.subject);
|
|
318
|
+
if (expression.group !== undefined)
|
|
319
|
+
this.expression(expression.group, scope);
|
|
320
|
+
break;
|
|
321
|
+
case 'rolePredicate':
|
|
322
|
+
this.builtIn(expression.subject);
|
|
323
|
+
this.expression(expression.group, scope);
|
|
324
|
+
break;
|
|
325
|
+
case 'isPredicate':
|
|
326
|
+
this.builtIn(expression.subject);
|
|
327
|
+
if (expression.subjectType.type === 'builtIn') {
|
|
328
|
+
const name = expression.subjectType.name;
|
|
329
|
+
if (name !== 'anonymous' && name !== 'defined') {
|
|
330
|
+
this.report(error('misplaced-built-in', `@${name} isn't a kind of subject. After \`@subject is\`, write @anonymous, @defined, or a subject entity.`, expression.subjectType.position));
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
break;
|
|
334
|
+
case 'number':
|
|
335
|
+
case 'boolean':
|
|
336
|
+
case 'dateTime':
|
|
337
|
+
case 'duration':
|
|
338
|
+
break;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
/** The entity a test case's `subject` names in its `@entity` member (docs/adr/0037-test-case-trigger-source.md). */
|
|
342
|
+
subjectEntity(value) {
|
|
343
|
+
if (value.type !== 'identifier' && value.type !== 'qualifiedIdentifier') {
|
|
344
|
+
this.report(error('wrong-kind', '@entity must name a subject entity.', value.position));
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
const symbol = this.topLevel(value).find((candidate) => candidate.kind === 'type');
|
|
348
|
+
if (symbol === undefined) {
|
|
349
|
+
this.report(error('unknown-name', `There is no entity called ${describeName(value)}.`, value.position));
|
|
350
|
+
}
|
|
351
|
+
else if (symbol.typeKind !== 'entity') {
|
|
352
|
+
this.report(error('wrong-kind', `${describeName(value)} isn't an entity, so it can't be a test case's subject.`, value.position));
|
|
353
|
+
}
|
|
354
|
+
else {
|
|
355
|
+
this.references.set(value, symbol);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
/** The top-level symbols a name could mean where it appears. */
|
|
359
|
+
topLevel(name) {
|
|
360
|
+
if (name.type === 'qualifiedIdentifier') {
|
|
361
|
+
return hasNamespace(this.module, name.namespace.value)
|
|
362
|
+
? symbolsNamed(this.module, name.namespace.value, name.name.value)
|
|
363
|
+
: [];
|
|
364
|
+
}
|
|
365
|
+
return symbolsNamed(this.module, this.namespace, name.value);
|
|
366
|
+
}
|
|
367
|
+
/** A name used as a value: a local, or a top-level constant. */
|
|
368
|
+
value(name, scope) {
|
|
369
|
+
if (name.type === 'identifier') {
|
|
370
|
+
const local = scope.find(name.value);
|
|
371
|
+
if (local !== undefined) {
|
|
372
|
+
this.locals.set(name, local);
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
if (name.type === 'qualifiedIdentifier' && !hasNamespace(this.module, name.namespace.value)) {
|
|
377
|
+
this.report(error('unknown-namespace', `There is no namespace called ${name.namespace.value} in this module.`, name.namespace.position));
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
const candidates = this.topLevel(name);
|
|
381
|
+
const constant = candidates.find((candidate) => candidate.kind === 'const');
|
|
382
|
+
if (constant !== undefined) {
|
|
383
|
+
this.references.set(name, constant);
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
const other = candidates[0];
|
|
387
|
+
if (other === undefined) {
|
|
388
|
+
this.report(error('unknown-name', `There is nothing called ${describeName(name)} here.`, name.position));
|
|
389
|
+
}
|
|
390
|
+
else if (other.kind === 'action') {
|
|
391
|
+
this.report(error('action-as-value', `${describeName(name)} is an action, so it can only be called, as in ${describeName(name)}(…).`, name.position));
|
|
392
|
+
}
|
|
393
|
+
else if (other.typeKind === 'enum') {
|
|
394
|
+
this.report(error('type-as-value', `${describeName(name)} is an enum. Name one of its members, as in ${describeName(name)}.Member.`, name.position));
|
|
395
|
+
}
|
|
396
|
+
else {
|
|
397
|
+
this.report(error('type-as-value', `${describeName(name)} is a type, not a value.`, name.position));
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
/** `Status.InProgress`, when `Status` names an enum and isn't shadowed by a local. Returns whether it was one. */
|
|
401
|
+
enumMember(expression, scope) {
|
|
402
|
+
const object = expression.object;
|
|
403
|
+
if (object.type !== 'identifier' && object.type !== 'qualifiedIdentifier')
|
|
404
|
+
return false;
|
|
405
|
+
if (object.type === 'identifier' && scope.find(object.value) !== undefined)
|
|
406
|
+
return false;
|
|
407
|
+
const candidates = this.topLevel(object);
|
|
408
|
+
if (candidates.some((candidate) => candidate.kind === 'const'))
|
|
409
|
+
return false;
|
|
410
|
+
const symbol = candidates.find((candidate) => candidate.typeKind === 'enum');
|
|
411
|
+
if (symbol === undefined)
|
|
412
|
+
return false;
|
|
413
|
+
this.references.set(object, symbol);
|
|
414
|
+
const declaration = symbol.declaration;
|
|
415
|
+
if (declaration?.type === 'enumDeclaration' && !declaration.members.some((member) => member.name.value === expression.property.value)) {
|
|
416
|
+
this.report(error('unknown-enum-member', `${describeName(object)} has no member called ${expression.property.value}.`, expression.property.position));
|
|
417
|
+
}
|
|
418
|
+
return true;
|
|
419
|
+
}
|
|
420
|
+
call(expression, scope) {
|
|
421
|
+
for (const argument of expression.arguments)
|
|
422
|
+
this.expression(argument.value, scope);
|
|
423
|
+
const callee = expression.callee;
|
|
424
|
+
if (callee.type !== 'identifier' && callee.type !== 'qualifiedIdentifier') {
|
|
425
|
+
this.report(error('not-callable', 'Only an action can be called, by its name. Cant has no methods, so a member of a value can\'t be called.', callee.position));
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
428
|
+
if (callee.type === 'identifier' && scope.find(callee.value) !== undefined) {
|
|
429
|
+
this.report(error('not-callable', `${callee.value} is a local value, not an action, so it can't be called.`, callee.position));
|
|
430
|
+
return;
|
|
431
|
+
}
|
|
432
|
+
if (callee.type === 'qualifiedIdentifier' && !hasNamespace(this.module, callee.namespace.value)) {
|
|
433
|
+
this.report(error('unknown-namespace', `There is no namespace called ${callee.namespace.value} in this module.`, callee.namespace.position));
|
|
434
|
+
return;
|
|
435
|
+
}
|
|
436
|
+
const candidates = this.topLevel(callee);
|
|
437
|
+
const action = candidates.find((candidate) => candidate.kind === 'action');
|
|
438
|
+
if (action === undefined) {
|
|
439
|
+
this.report(candidates.length === 0
|
|
440
|
+
? error('unknown-name', `There is no action called ${describeName(callee)} here.`, callee.position)
|
|
441
|
+
: error('not-callable', `${describeName(callee)} isn't an action, so it can't be called.`, callee.position));
|
|
442
|
+
return;
|
|
443
|
+
}
|
|
444
|
+
this.references.set(callee, action);
|
|
445
|
+
if (action.declaration?.type === 'action') {
|
|
446
|
+
this.checkCallArguments(action.declaration, expression.arguments, callee.position);
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
// ----- Arguments: docs/adr/0020-action-parameters.md -----
|
|
450
|
+
/** Match a call's arguments to the action's parameters, with the short forms calls allow. */
|
|
451
|
+
checkCallArguments(action, args, position) {
|
|
452
|
+
const parameterNames = new Set(action.parameters.map((parameter) => parameter.name.value));
|
|
453
|
+
const required = action.parameters.filter((parameter) => !parameter.optional);
|
|
454
|
+
const given = [];
|
|
455
|
+
let unmatched = false;
|
|
456
|
+
for (const argument of args) {
|
|
457
|
+
if (argument.name !== undefined) {
|
|
458
|
+
given.push({ name: argument.name, position: argument.position });
|
|
459
|
+
}
|
|
460
|
+
else if (argument.value.type === 'identifier' && parameterNames.has(argument.value.value)) {
|
|
461
|
+
// The matching-identifier form: `SetStatus(invoiceId)` passes `invoiceId := invoiceId`.
|
|
462
|
+
given.push({ name: argument.value, position: argument.position });
|
|
463
|
+
}
|
|
464
|
+
else if (args.length === 1 && required.length === 1 && required[0] !== undefined) {
|
|
465
|
+
// The one required parameter, unnamed.
|
|
466
|
+
given.push({ name: required[0].name, position: argument.position });
|
|
467
|
+
}
|
|
468
|
+
else {
|
|
469
|
+
unmatched = true;
|
|
470
|
+
this.report(error('unnamed-argument', args.length === 1
|
|
471
|
+
? `${action.name.value} doesn't have exactly one required parameter, so this argument needs a name, as in name := value.`
|
|
472
|
+
: 'An argument without a name must be the only argument. Name every argument, as in name := value.', argument.position));
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
// An argument that couldn't be matched may be the one a missing parameter is for, so
|
|
476
|
+
// missing parameters are only reported when every argument was matched.
|
|
477
|
+
this.checkArguments(action, given, position, !unmatched);
|
|
478
|
+
}
|
|
479
|
+
/** Report unknown, repeated and missing parameters, given the parameter each argument is for. */
|
|
480
|
+
checkArguments(action, given, position, reportMissing = true) {
|
|
481
|
+
const parameters = new Map(action.parameters.map((parameter) => [parameter.name.value, parameter]));
|
|
482
|
+
const seen = new Set();
|
|
483
|
+
for (const { name, position: at } of given) {
|
|
484
|
+
if (!parameters.has(name.value)) {
|
|
485
|
+
this.report(error('unknown-parameter', `${action.name.value} has no parameter called ${name.value}.`, at));
|
|
486
|
+
}
|
|
487
|
+
else if (seen.has(name.value)) {
|
|
488
|
+
this.report(error('duplicate-argument', `${name.value} is given more than once.`, at));
|
|
489
|
+
}
|
|
490
|
+
seen.add(name.value);
|
|
491
|
+
}
|
|
492
|
+
const missing = action.parameters.filter((parameter) => !parameter.optional && !seen.has(parameter.name.value));
|
|
493
|
+
if (reportMissing && missing.length > 0) {
|
|
494
|
+
this.report(error('missing-argument', `${action.name.value} needs ${missing.map((parameter) => parameter.name.value).join(', ')}, which ${missing.length === 1 ? "isn't" : "aren't"} given.`, position));
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
// ----- Built-in values -----
|
|
498
|
+
builtIn(builtIn) {
|
|
499
|
+
const name = builtIn.name;
|
|
500
|
+
if (!BUILT_INS.has(name)) {
|
|
501
|
+
this.report(error('unknown-built-in', `There is no built-in value called @${name}.`, builtIn.position));
|
|
502
|
+
return;
|
|
503
|
+
}
|
|
504
|
+
if (!ALLOWED_BUILT_INS[this.context].has(name)) {
|
|
505
|
+
const here = this.context === 'constant' || this.context === 'source parameters'
|
|
506
|
+
? 'here, since this must be a constant expression'
|
|
507
|
+
: 'here';
|
|
508
|
+
this.report(error('misplaced-built-in', `@${name} can't be used ${here}. It can be used ${WHERE[name] ?? 'nowhere'}.`, builtIn.position));
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
//# sourceMappingURL=bodies.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bodies.js","sourceRoot":"","sources":["../src/bodies.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,KAAK,EAAmB,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAsD,MAAM,cAAc,CAAC;AAa5H,8FAA8F;AAC9F,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,CAAC,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC;AAKtI,MAAM,iBAAiB,GAAyC;IAC9D,MAAM,EAAE,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KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,SAAS,EACtJ,QAAQ,CACT,CACF,CAAC;QACJ,CAAC;IACH,CAAC;IAED,8BAA8B;IAEtB,OAAO,CAAC,OAAgB;QAC9B,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QAC1B,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACzB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,kBAAkB,EAAE,sCAAsC,IAAI,GAAG,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;YACxG,OAAO;QACT,CAAC;QACD,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YAC/C,MAAM,IAAI,GACR,IAAI,CAAC,OAAO,KAAK,UAAU,IAAI,IAAI,CAAC,OAAO,KAAK,mBAAmB;gBACjE,CAAC,CAAC,gDAAgD;gBAClD,CAAC,CAAC,MAAM,CAAC;YACb,IAAI,CAAC,MAAM,CACT,KAAK,CAAC,oBAAoB,EAAE,IAAI,IAAI,kBAAkB,IAAI,oBAAoB,KAAK,CAAC,IAAI,CAAC,IAAI,SAAS,GAAG,EAAE,OAAO,CAAC,QAAQ,CAAC,CAC7H,CAAC;QACJ,CAAC;IACH,CAAC;CACF"}
|
package/dist/check.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type Program } from '@dancrumb/cant-shared';
|
|
2
|
+
import { type ModuleSymbols } from './declarations.ts';
|
|
3
|
+
import { type Diagnostic } from './diagnostic.ts';
|
|
4
|
+
export interface CheckResult {
|
|
5
|
+
/** The module's syntax tree, unless it has a syntax error. */
|
|
6
|
+
program?: Program;
|
|
7
|
+
/** The module's declarations, unless it has a syntax error. */
|
|
8
|
+
symbols?: ModuleSymbols;
|
|
9
|
+
/** Every problem found, in the order the passes found them. Empty when the module is valid so far. */
|
|
10
|
+
diagnostics: Diagnostic[];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Check one module of Cant source. For now, this parses it, reporting a syntax error if there is
|
|
14
|
+
* one, and gathers its declarations, reporting names that are declared twice. Resolving names
|
|
15
|
+
* and checking types are still to come.
|
|
16
|
+
*/
|
|
17
|
+
export declare function check(source: string): CheckResult;
|
|
18
|
+
//# sourceMappingURL=check.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../src/check.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,OAAO,EAAE,MAAM,uBAAuB,CAAC;AACxE,OAAO,EAAuB,KAAK,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EAAS,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAEzD,MAAM,WAAW,WAAW;IAC1B,8DAA8D;IAC9D,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,+DAA+D;IAC/D,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,sGAAsG;IACtG,WAAW,EAAE,UAAU,EAAE,CAAC;CAC3B;AAED;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,CAmBjD"}
|
package/dist/check.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { parse, ParseError } from '@dancrumb/cant-shared';
|
|
2
|
+
import { collectDeclarations } from './declarations.js';
|
|
3
|
+
import { error } from './diagnostic.js';
|
|
4
|
+
/**
|
|
5
|
+
* Check one module of Cant source. For now, this parses it, reporting a syntax error if there is
|
|
6
|
+
* one, and gathers its declarations, reporting names that are declared twice. Resolving names
|
|
7
|
+
* and checking types are still to come.
|
|
8
|
+
*/
|
|
9
|
+
export function check(source) {
|
|
10
|
+
let program;
|
|
11
|
+
try {
|
|
12
|
+
program = parse(source);
|
|
13
|
+
}
|
|
14
|
+
catch (caught) {
|
|
15
|
+
if (!(caught instanceof ParseError))
|
|
16
|
+
throw caught;
|
|
17
|
+
const { start, end } = caught.location;
|
|
18
|
+
return {
|
|
19
|
+
diagnostics: [
|
|
20
|
+
error('syntax', caught.message, {
|
|
21
|
+
start: { line: start.line, column: start.column, offset: start.offset },
|
|
22
|
+
end: { line: end.line, column: end.column, offset: end.offset },
|
|
23
|
+
}),
|
|
24
|
+
],
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
const { symbols, diagnostics } = collectDeclarations(program);
|
|
28
|
+
return { program, symbols, diagnostics };
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=check.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check.js","sourceRoot":"","sources":["../src/check.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,UAAU,EAAgB,MAAM,uBAAuB,CAAC;AACxE,OAAO,EAAE,mBAAmB,EAAsB,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EAAE,KAAK,EAAmB,MAAM,iBAAiB,CAAC;AAWzD;;;;GAIG;AACH,MAAM,UAAU,KAAK,CAAC,MAAc;IAClC,IAAI,OAAgB,CAAC;IACrB,IAAI,CAAC;QACH,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;IAC1B,CAAC;IAAC,OAAO,MAAM,EAAE,CAAC;QAChB,IAAI,CAAC,CAAC,MAAM,YAAY,UAAU,CAAC;YAAE,MAAM,MAAM,CAAC;QAClD,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,MAAM,CAAC,QAAQ,CAAC;QACvC,OAAO;YACL,WAAW,EAAE;gBACX,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAC,OAAO,EAAE;oBAC9B,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE;oBACvE,GAAG,EAAE,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE;iBAChE,CAAC;aACH;SACF,CAAC;IACJ,CAAC;IAED,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,mBAAmB,CAAC,OAAO,CAAC,CAAC;IAC9D,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC;AAC3C,CAAC"}
|
package/dist/cli.d.ts
ADDED