@formaui-net/nexo 0.0.0 → 1.0.0-preview.1
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/LICENSE +202 -0
- package/NOTICE +2 -0
- package/README.md +148 -6
- package/package.json +23 -3
- package/src/common/ArrayUtils.mjs +16 -0
- package/src/common/ObjectUtils.mjs +33 -0
- package/src/language/DefinitionLocations.mjs +41 -0
- package/src/language/DefinitionValidator.mjs +1265 -0
- package/src/language/DefinitionWriter.mjs +475 -0
- package/src/language/Dictionary.mjs +52 -0
- package/src/language/Evaluator.mjs +3480 -0
- package/src/language/ImportedVocabulary.mjs +137 -0
- package/src/language/Imports.mjs +141 -0
- package/src/language/Index.mjs +29 -0
- package/src/language/LanguageResolver.mjs +4068 -0
- package/src/language/Limits.mjs +78 -0
- package/src/language/LineStructure.mjs +385 -0
- package/src/language/Lowering.mjs +453 -0
- package/src/language/MemberSelector.mjs +89 -0
- package/src/language/Names.mjs +65 -0
- package/src/language/NexoError.mjs +145 -0
- package/src/language/Pair.mjs +21 -0
- package/src/language/ParameterBindings.mjs +361 -0
- package/src/language/ParsedTexts.mjs +62 -0
- package/src/language/Parser.mjs +1817 -0
- package/src/language/Range.mjs +51 -0
- package/src/language/RecentlyUsed.mjs +50 -0
- package/src/language/ResolvedDefinition.mjs +219 -0
- package/src/language/ResultPath.mjs +101 -0
- package/src/language/ScopeLocals.mjs +102 -0
- package/src/language/StructureTypes.mjs +48 -0
- package/src/language/SyntaxTree.mjs +203 -0
- package/src/language/TextLocations.mjs +185 -0
- package/src/language/TextPositions.mjs +23 -0
- package/src/language/Tokenizer.mjs +917 -0
- package/src/language/Type.mjs +401 -0
- package/src/language/TypeChecker.mjs +449 -0
- package/src/language/ValueCapture.mjs +315 -0
- package/src/language/Versions.mjs +14 -0
- package/src/language/vocabulary/Declarations.mjs +64 -0
- package/src/language/vocabulary/ItemPositions.mjs +48 -0
- package/src/language/vocabulary/ListOrdering.mjs +145 -0
- package/src/language/vocabulary/MemberFailure.mjs +21 -0
- package/src/language/vocabulary/NexoModule.mjs +1119 -0
- package/src/language/vocabulary/NexoRegistry.mjs +1540 -0
- package/src/language/vocabulary/TypeNameScope.mjs +63 -0
- package/src/language/vocabulary/Vocabulary.mjs +640 -0
- package/src/nexo.d.ts +743 -0
- package/src/nexo.js +338 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeNameScope — where a type name is read, which decides the types it names: a declaration's, a declared binding's or a script's, each its declaring module, its imports and whether it reaches every module
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export class TypeNameScope {
|
|
6
|
+
/** The module whose own types the scope's unqualified names find before any other but a type import's, or null where none declares the name being read. @type {string | null} */
|
|
7
|
+
#declaringModule;
|
|
8
|
+
|
|
9
|
+
/** The scope's imports, in a definition's shape, whose local names qualify a type name and whose types an unqualified one finds. @type {readonly object[]} */
|
|
10
|
+
#imports;
|
|
11
|
+
|
|
12
|
+
/** Whether an unqualified name finds every registered module's types alike, Nexo's own among them, as a declared binding's does. */
|
|
13
|
+
#reachesEveryModule;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @param {string | null} declaringModule The module declaring the name being read, for a declaration's scope.
|
|
17
|
+
* @param {readonly object[]} imports The scope's imports, in a definition's shape.
|
|
18
|
+
* @param {boolean} reachesEveryModule Whether an unqualified name finds every registered module's types alike.
|
|
19
|
+
*/
|
|
20
|
+
constructor(declaringModule, imports, reachesEveryModule) {
|
|
21
|
+
this.#declaringModule = declaringModule;
|
|
22
|
+
this.#imports = Object.freeze([...imports]);
|
|
23
|
+
this.#reachesEveryModule = reachesEveryModule;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** The scope of a declaration's notation: its module's own types, Nexo's, and those of the modules a structured type imports, a name qualified by any registered module's own name. */
|
|
27
|
+
static createDeclarationScope(moduleName, importedModuleNames) {
|
|
28
|
+
return new TypeNameScope(moduleName, importedModuleNames.map(module => Object.freeze({ module })), false);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** The scope of a script's type names: its type imports' names first, then Nexo's own types, then its imported modules', a name qualified by the local name an import gives a module alone. */
|
|
32
|
+
static createScriptScope(imports) {
|
|
33
|
+
return new TypeNameScope(null, imports, false);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** @type {TypeNameScope | undefined} */
|
|
37
|
+
static #bindingScope;
|
|
38
|
+
|
|
39
|
+
/** The scope of a binding's declared type: every registered module's public types alike, Nexo's own among them, a name qualified by any registered module's own name; a script's imports never take part. */
|
|
40
|
+
static get bindingScope() {
|
|
41
|
+
return TypeNameScope.#bindingScope ??= new TypeNameScope(null, [], true);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** The module the scope's own types are read in, or null where the scope has none. */
|
|
45
|
+
get declaringModule() {
|
|
46
|
+
return this.#declaringModule;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** The scope's imports, in a definition's shape. */
|
|
50
|
+
get imports() {
|
|
51
|
+
return this.#imports;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Whether an unqualified name finds every registered module's types alike. */
|
|
55
|
+
get reachesEveryModule() {
|
|
56
|
+
return this.#reachesEveryModule;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** Whether a name qualified by a registered module's own name reaches that module where no import gives it, as a declaration's and a binding's scope do, and a script's, whose imports alone qualify, never does. */
|
|
60
|
+
get namesModulesByOwnName() {
|
|
61
|
+
return this.#declaringModule !== null || this.#reachesEveryModule;
|
|
62
|
+
}
|
|
63
|
+
}
|