semantifold 0.3.0 → 0.5.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 +61 -15
- package/build/index.d.ts +52 -2
- package/build/index.d.ts.map +1 -1
- package/build/index.js +60 -8
- package/build/src/artifact-path.d.ts +23 -1
- package/build/src/artifact-path.d.ts.map +1 -1
- package/build/src/artifact-path.js +45 -3
- package/build/src/artifacts.d.ts.map +1 -1
- package/build/src/artifacts.js +66 -1
- package/build/src/backends/android.d.ts +49 -0
- package/build/src/backends/android.d.ts.map +1 -0
- package/build/src/backends/android.js +1274 -0
- package/build/src/backends/c-validation.d.ts.map +1 -1
- package/build/src/backends/c-validation.js +7 -3
- package/build/src/backends/cpp-validation.d.ts.map +1 -1
- package/build/src/backends/cpp-validation.js +7 -3
- package/build/src/backends/csharp.js +7 -1
- package/build/src/backends/dart-runtime.d.ts +2 -0
- package/build/src/backends/dart-runtime.d.ts.map +1 -0
- package/build/src/backends/dart-runtime.js +41 -0
- package/build/src/backends/dart.d.ts +20 -0
- package/build/src/backends/dart.d.ts.map +1 -0
- package/build/src/backends/dart.js +321 -0
- package/build/src/backends/effects.d.ts +60 -0
- package/build/src/backends/effects.d.ts.map +1 -0
- package/build/src/backends/effects.js +746 -0
- package/build/src/backends/go.js +18 -4
- package/build/src/backends/identifiers.d.ts +36 -4
- package/build/src/backends/identifiers.d.ts.map +1 -1
- package/build/src/backends/identifiers.js +160 -10
- package/build/src/backends/index.d.ts.map +1 -1
- package/build/src/backends/index.js +27 -4
- package/build/src/backends/ios.d.ts +68 -0
- package/build/src/backends/ios.d.ts.map +1 -0
- package/build/src/backends/ios.js +1503 -0
- package/build/src/backends/java.d.ts.map +1 -1
- package/build/src/backends/java.js +429 -36
- package/build/src/backends/javascript.d.ts +6 -0
- package/build/src/backends/javascript.d.ts.map +1 -1
- package/build/src/backends/javascript.js +380 -24
- package/build/src/backends/kotlin-runtime.d.ts +3 -0
- package/build/src/backends/kotlin-runtime.d.ts.map +1 -0
- package/build/src/backends/kotlin-runtime.js +29 -0
- package/build/src/backends/kotlin.d.ts +33 -0
- package/build/src/backends/kotlin.d.ts.map +1 -0
- package/build/src/backends/kotlin.js +138 -0
- package/build/src/backends/native-validation.d.ts +2 -2
- package/build/src/backends/native-validation.d.ts.map +1 -1
- package/build/src/backends/native-validation.js +2 -2
- package/build/src/backends/ordered-expressions.d.ts.map +1 -1
- package/build/src/backends/ordered-expressions.js +39 -7
- package/build/src/backends/php-stdlib-support.d.ts +19 -0
- package/build/src/backends/php-stdlib-support.d.ts.map +1 -0
- package/build/src/backends/php-stdlib-support.js +227 -0
- package/build/src/backends/php.d.ts.map +1 -1
- package/build/src/backends/php.js +448 -33
- package/build/src/backends/program.d.ts +83 -0
- package/build/src/backends/program.d.ts.map +1 -0
- package/build/src/backends/program.js +1309 -0
- package/build/src/backends/python.js +7 -1
- package/build/src/backends/ruby.d.ts.map +1 -1
- package/build/src/backends/ruby.js +310 -24
- package/build/src/backends/rust-runtime.d.ts +7 -0
- package/build/src/backends/rust-runtime.d.ts.map +1 -0
- package/build/src/backends/rust-runtime.js +32 -0
- package/build/src/backends/rust-validation.d.ts +9 -0
- package/build/src/backends/rust-validation.d.ts.map +1 -0
- package/build/src/backends/rust-validation.js +78 -0
- package/build/src/backends/rust.d.ts +24 -0
- package/build/src/backends/rust.d.ts.map +1 -0
- package/build/src/backends/rust.js +344 -0
- package/build/src/backends/scalars.d.ts +14 -6
- package/build/src/backends/scalars.d.ts.map +1 -1
- package/build/src/backends/scalars.js +167 -17
- package/build/src/backends/shared.d.ts +23 -4
- package/build/src/backends/shared.d.ts.map +1 -1
- package/build/src/backends/shared.js +2174 -62
- package/build/src/backends/stdlib-support.d.ts +14 -0
- package/build/src/backends/stdlib-support.d.ts.map +1 -0
- package/build/src/backends/stdlib-support.js +237 -0
- package/build/src/backends/swift-runtime.d.ts +3 -0
- package/build/src/backends/swift-runtime.d.ts.map +1 -0
- package/build/src/backends/swift-runtime.js +14 -0
- package/build/src/backends/swift.d.ts +8 -0
- package/build/src/backends/swift.d.ts.map +1 -0
- package/build/src/backends/swift.js +127 -0
- package/build/src/backends/typescript.d.ts.map +1 -1
- package/build/src/backends/typescript.js +344 -24
- package/build/src/backends/wasm.d.ts +43 -0
- package/build/src/backends/wasm.d.ts.map +1 -0
- package/build/src/backends/wasm.js +2164 -0
- package/build/src/backends/writer.d.ts +255 -4
- package/build/src/backends/writer.d.ts.map +1 -1
- package/build/src/backends/writer.js +491 -3
- package/build/src/diagnostic.d.ts +4 -3
- package/build/src/diagnostic.d.ts.map +1 -1
- package/build/src/diagnostic.js +5 -3
- package/build/src/frontends/c.d.ts.map +1 -1
- package/build/src/frontends/c.js +5 -3
- package/build/src/frontends/cpp.d.ts.map +1 -1
- package/build/src/frontends/cpp.js +5 -3
- package/build/src/frontends/csharp.d.ts.map +1 -1
- package/build/src/frontends/csharp.js +7 -3
- package/build/src/frontends/dart.d.ts +10 -0
- package/build/src/frontends/dart.d.ts.map +1 -0
- package/build/src/frontends/dart.js +913 -0
- package/build/src/frontends/index.d.ts +3 -1
- package/build/src/frontends/index.d.ts.map +1 -1
- package/build/src/frontends/index.js +15 -5
- package/build/src/frontends/java.d.ts +110 -1
- package/build/src/frontends/java.d.ts.map +1 -1
- package/build/src/frontends/java.js +1725 -70
- package/build/src/frontends/javascript-typescript.d.ts +69 -1
- package/build/src/frontends/javascript-typescript.d.ts.map +1 -1
- package/build/src/frontends/javascript-typescript.js +1825 -93
- package/build/src/frontends/kotlin.d.ts +10 -0
- package/build/src/frontends/kotlin.d.ts.map +1 -0
- package/build/src/frontends/kotlin.js +685 -0
- package/build/src/frontends/php.d.ts +118 -1
- package/build/src/frontends/php.d.ts.map +1 -1
- package/build/src/frontends/php.js +1583 -76
- package/build/src/frontends/program.d.ts +74 -0
- package/build/src/frontends/program.d.ts.map +1 -0
- package/build/src/frontends/program.js +989 -0
- package/build/src/frontends/ruby.d.ts +68 -1
- package/build/src/frontends/ruby.d.ts.map +1 -1
- package/build/src/frontends/ruby.js +1446 -101
- package/build/src/frontends/rust-parser.d.ts +11 -0
- package/build/src/frontends/rust-parser.d.ts.map +1 -0
- package/build/src/frontends/rust-parser.js +15 -0
- package/build/src/frontends/rust.d.ts +14 -0
- package/build/src/frontends/rust.d.ts.map +1 -0
- package/build/src/frontends/rust.js +715 -0
- package/build/src/frontends/scalars.d.ts +10 -0
- package/build/src/frontends/scalars.d.ts.map +1 -1
- package/build/src/frontends/scalars.js +28 -2
- package/build/src/frontends/swift.d.ts +10 -0
- package/build/src/frontends/swift.d.ts.map +1 -0
- package/build/src/frontends/swift.js +860 -0
- package/build/src/frontends/types.d.ts +186 -0
- package/build/src/frontends/types.d.ts.map +1 -0
- package/build/src/frontends/types.js +634 -0
- package/build/src/language-registry.d.ts +46 -4
- package/build/src/language-registry.d.ts.map +1 -1
- package/build/src/language-registry.js +177 -13
- package/build/src/mapping.d.ts +2 -2
- package/build/src/mapping.d.ts.map +1 -1
- package/build/src/mapping.js +31 -10
- package/build/src/semantic/capabilities.d.ts +66 -0
- package/build/src/semantic/capabilities.d.ts.map +1 -0
- package/build/src/semantic/capabilities.js +649 -0
- package/build/src/semantic/effects.d.ts +26 -0
- package/build/src/semantic/effects.d.ts.map +1 -0
- package/build/src/semantic/effects.js +764 -0
- package/build/src/semantic/generics.d.ts +23 -0
- package/build/src/semantic/generics.d.ts.map +1 -0
- package/build/src/semantic/generics.js +61 -0
- package/build/src/semantic/lifetime.d.ts +37 -0
- package/build/src/semantic/lifetime.d.ts.map +1 -0
- package/build/src/semantic/lifetime.js +527 -0
- package/build/src/semantic/provenance.d.ts +9 -2
- package/build/src/semantic/provenance.d.ts.map +1 -1
- package/build/src/semantic/provenance.js +462 -20
- package/build/src/semantic/scalars.d.ts +11 -0
- package/build/src/semantic/scalars.d.ts.map +1 -1
- package/build/src/semantic/scalars.js +16 -1
- package/build/src/semantic/stdlib.d.ts +254 -0
- package/build/src/semantic/stdlib.d.ts.map +1 -0
- package/build/src/semantic/stdlib.js +880 -0
- package/build/src/semantic/types.d.ts +3108 -178
- package/build/src/semantic/types.d.ts.map +1 -1
- package/build/src/semantic/types.js +730 -15
- package/build/src/semantic/validate.d.ts +85 -5
- package/build/src/semantic/validate.d.ts.map +1 -1
- package/build/src/semantic/validate.js +2576 -98
- package/build/src/stdlib-facades.d.ts +304 -0
- package/build/src/stdlib-facades.d.ts.map +1 -0
- package/build/src/stdlib-facades.js +1167 -0
- package/build/src/stdlib-negotiation.d.ts +69 -0
- package/build/src/stdlib-negotiation.d.ts.map +1 -0
- package/build/src/stdlib-negotiation.js +403 -0
- package/build/src/stdlib-providers.d.ts +72 -0
- package/build/src/stdlib-providers.d.ts.map +1 -0
- package/build/src/stdlib-providers.js +339 -0
- package/build/src/toolchains.d.ts +55 -1
- package/build/src/toolchains.d.ts.map +1 -1
- package/build/src/toolchains.js +15 -4
- package/docs/android.md +79 -0
- package/docs/architecture.md +47 -13
- package/docs/dart.md +60 -0
- package/docs/goals.md +3 -3
- package/docs/ios.md +121 -0
- package/docs/kotlin.md +42 -0
- package/docs/language-support.md +238 -26
- package/docs/multi-file-modules.md +52 -0
- package/docs/parser-qualification.md +121 -8
- package/docs/plans/2026-09-05-standard-library-portability.md +10 -10
- package/docs/rust.md +88 -0
- package/docs/source-maps.md +17 -7
- package/docs/specification.md +5 -0
- package/docs/standard-library-portability.md +39 -8
- package/docs/swift.md +44 -0
- package/docs/testing.md +381 -4
- package/docs/webassembly.md +52 -0
- package/index.js +66 -8
- package/node_modules/semantifold-tree-sitter-legacy-internal/README.md +2 -2
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-rust/LICENSE +21 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-rust/README.md +45 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-rust/binding.gyp +30 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-rust/bindings/node/binding.cc +20 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-rust/bindings/node/binding_test.js +9 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-rust/bindings/node/index.d.ts +28 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-rust/bindings/node/index.js +11 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-rust/grammar.js +1630 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-rust/package.json +64 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-rust/prebuilds/darwin-arm64/tree-sitter-rust.node +0 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-rust/prebuilds/darwin-x64/tree-sitter-rust.node +0 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-rust/prebuilds/linux-arm64/tree-sitter-rust.node +0 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-rust/prebuilds/linux-x64/tree-sitter-rust.node +0 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-rust/prebuilds/win32-arm64/tree-sitter-rust.node +0 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-rust/prebuilds/win32-x64/tree-sitter-rust.node +0 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-rust/queries/highlights.scm +159 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-rust/queries/injections.scm +9 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-rust/queries/tags.scm +60 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-rust/src/grammar.json +9405 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-rust/src/node-types.json +5399 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-rust/src/parser.c +192569 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-rust/src/scanner.c +393 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-rust/src/tree_sitter/alloc.h +54 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-rust/src/tree_sitter/array.h +290 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-rust/src/tree_sitter/parser.h +266 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-rust/tree-sitter-rust.wasm +0 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-rust/tree-sitter.json +53 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/package.json +3 -2
- package/node_modules/semantifold-tree-sitter-legacy-internal/src/c.js +5 -4
- package/package.json +5 -2
- package/src/artifact-path.js +47 -2
- package/src/artifacts.js +67 -0
- package/src/backends/android.js +1370 -0
- package/src/backends/c-validation.js +6 -1
- package/src/backends/cpp-validation.js +6 -1
- package/src/backends/csharp.js +3 -0
- package/src/backends/dart-runtime.js +41 -0
- package/src/backends/dart.js +326 -0
- package/src/backends/effects.js +705 -0
- package/src/backends/go.js +14 -2
- package/src/backends/identifiers.js +166 -9
- package/src/backends/index.js +27 -2
- package/src/backends/ios.js +1612 -0
- package/src/backends/java.js +454 -36
- package/src/backends/javascript.js +389 -23
- package/src/backends/kotlin-runtime.js +29 -0
- package/src/backends/kotlin.js +144 -0
- package/src/backends/native-validation.js +1 -1
- package/src/backends/ordered-expressions.js +40 -6
- package/src/backends/php-stdlib-support.js +239 -0
- package/src/backends/php.js +469 -32
- package/src/backends/program.js +1408 -0
- package/src/backends/python.js +3 -0
- package/src/backends/ruby.js +326 -23
- package/src/backends/rust-runtime.js +34 -0
- package/src/backends/rust-validation.js +75 -0
- package/src/backends/rust.js +335 -0
- package/src/backends/scalars.js +141 -16
- package/src/backends/shared.js +2314 -115
- package/src/backends/stdlib-support.js +234 -0
- package/src/backends/swift-runtime.js +14 -0
- package/src/backends/swift.js +132 -0
- package/src/backends/typescript.js +349 -23
- package/src/backends/wasm.js +2208 -0
- package/src/backends/writer.js +545 -2
- package/src/diagnostic.js +4 -2
- package/src/frontends/c.js +4 -2
- package/src/frontends/cpp.js +4 -2
- package/src/frontends/csharp.js +4 -2
- package/src/frontends/dart.js +963 -0
- package/src/frontends/index.js +14 -4
- package/src/frontends/java.js +1977 -69
- package/src/frontends/javascript-typescript.js +2046 -102
- package/src/frontends/kotlin.js +713 -0
- package/src/frontends/php.js +1725 -79
- package/src/frontends/program.js +1062 -0
- package/src/frontends/ruby.js +1624 -98
- package/src/frontends/rust-parser.js +18 -0
- package/src/frontends/rust.js +714 -0
- package/src/frontends/scalars.js +31 -1
- package/src/frontends/swift.js +893 -0
- package/src/frontends/types.js +750 -0
- package/src/language-registry.js +182 -12
- package/src/mapping.js +33 -9
- package/src/semantic/capabilities.js +671 -0
- package/src/semantic/effects.js +737 -0
- package/src/semantic/generics.js +58 -0
- package/src/semantic/lifetime.js +517 -0
- package/src/semantic/provenance.js +412 -19
- package/src/semantic/scalars.js +17 -0
- package/src/semantic/stdlib.js +921 -0
- package/src/semantic/types.js +810 -14
- package/src/semantic/validate.js +2934 -209
- package/src/stdlib-facades.js +1211 -0
- package/src/stdlib-negotiation.js +446 -0
- package/src/stdlib-providers.js +377 -0
- package/src/toolchains.js +16 -3
package/index.js
CHANGED
|
@@ -1,16 +1,25 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
|
|
3
3
|
import {parseSource} from "./src/frontends/index.js"
|
|
4
|
+
import {parseProgramSource} from "./src/frontends/program.js"
|
|
4
5
|
import {generateArtifactSource, generateSource} from "./src/backends/index.js"
|
|
6
|
+
import {generateProgramArtifacts} from "./src/backends/program.js"
|
|
5
7
|
import {createGeneratedArtifactSet as constructArtifactSet} from "./src/artifacts.js"
|
|
6
|
-
import {SemantifoldDiagnostic} from "./src/diagnostic.js"
|
|
8
|
+
import {SemantifoldDiagnostic, unsupportedCapability} from "./src/diagnostic.js"
|
|
7
9
|
import {languageRegistry} from "./src/language-registry.js"
|
|
10
|
+
import {kotlinArtifactMetadata} from "./src/backends/kotlin.js"
|
|
11
|
+
import {preflightEffectCapabilities} from "./src/backends/effects.js"
|
|
8
12
|
|
|
9
13
|
const artifactBackendRoles = new Set(["text", "binary", "application"])
|
|
10
14
|
|
|
11
15
|
export {SemantifoldDiagnostic}
|
|
16
|
+
export {createCapabilityAuthority} from "./src/semantic/capabilities.js"
|
|
12
17
|
export {languageCapabilities, supportedLanguages} from "./src/language-registry.js"
|
|
13
18
|
export {createGeneratedArtifactSet} from "./src/artifacts.js"
|
|
19
|
+
export {createStdlibContractRegistry, listStdlibModules, resolveStdlibModule} from "./src/semantic/stdlib.js"
|
|
20
|
+
export {createStdlibProviderRegistry, listStdlibProviders} from "./src/stdlib-providers.js"
|
|
21
|
+
export {negotiateStdlibProviders} from "./src/stdlib-negotiation.js"
|
|
22
|
+
export {createStdlibFacadeRegistry, listStdlibFacades, resolveStdlibFacade} from "./src/stdlib-facades.js"
|
|
14
23
|
export {createByteMapping, parseByteMapping, stringifyByteMapping} from "./src/binary-mapping.js"
|
|
15
24
|
export {canonicalToolchains, discoverCanonicalToolchain, discoverToolchain} from "./src/toolchains.js"
|
|
16
25
|
export {runAcceptanceStages} from "./src/acceptance.js"
|
|
@@ -37,12 +46,25 @@ export {
|
|
|
37
46
|
* @param {string} input.filename - Source filename used in diagnostics.
|
|
38
47
|
* @param {import("./src/semantic/types.js").SemanticLanguage} input.language - Source language.
|
|
39
48
|
* @param {string} input.source - Source text.
|
|
49
|
+
* @param {Readonly<import("./src/semantic/types.js").CapabilityAuthority> | import("./src/semantic/types.js").CapabilityAuthorityInput} [input.capabilityAuthority] - Explicit compiler authority.
|
|
40
50
|
* @returns {import("./src/semantic/types.js").SemanticModule} Semantic module.
|
|
41
51
|
*/
|
|
42
52
|
export function parse(input) {
|
|
43
53
|
return parseSource(input)
|
|
44
54
|
}
|
|
45
55
|
|
|
56
|
+
/**
|
|
57
|
+
* Parses a complete explicit multi-source project into one resolved semantic program.
|
|
58
|
+
* @param {object} input - Program parse request.
|
|
59
|
+
* @param {string} input.entryModule - Stable identity of the sole entry module.
|
|
60
|
+
* @param {{filename: string, id: string, language: import("./src/semantic/types.js").SemanticLanguage, source: string}[]} input.sources - Complete caller-supplied source set.
|
|
61
|
+
* @param {Readonly<import("./src/semantic/types.js").CapabilityAuthority> | import("./src/semantic/types.js").CapabilityAuthorityInput} [input.capabilityAuthority] - Explicit compiler authority shared by every program module.
|
|
62
|
+
* @returns {import("./src/semantic/types.js").SemanticProgram} Semantic program.
|
|
63
|
+
*/
|
|
64
|
+
export function parseProgram(input) {
|
|
65
|
+
return parseProgramSource(input)
|
|
66
|
+
}
|
|
67
|
+
|
|
46
68
|
/**
|
|
47
69
|
* Generates target-language source from a shared semantic module.
|
|
48
70
|
* @param {object} input - Generation request.
|
|
@@ -69,16 +91,34 @@ export function generateArtifact(input) {
|
|
|
69
91
|
return generateArtifactSource(input)
|
|
70
92
|
}
|
|
71
93
|
|
|
94
|
+
/**
|
|
95
|
+
* Generates a deterministic mapped artifact set for a complete semantic program.
|
|
96
|
+
* @param {object} input - Program generation request.
|
|
97
|
+
* @param {import("./src/semantic/types.js").BackendLanguage} input.language - Registered program target.
|
|
98
|
+
* @param {import("./src/semantic/types.js").SemanticProgram} input.program - Complete resolved program.
|
|
99
|
+
* @param {"text" | "application"} [input.role] - Explicit role; omitted preserves text generation.
|
|
100
|
+
* @param {import("./src/semantic/types.js").IosApplicationConfigurationInput | import("./src/semantic/types.js").AndroidApplicationConfigurationInput} [input.configuration] - Application configuration.
|
|
101
|
+
* @param {import("./src/semantic/types.js").IosApplicationAssetInput[] | import("./src/semantic/types.js").AndroidApplicationInputFile[]} [input.assets] - Exact caller assets.
|
|
102
|
+
* @param {import("./src/semantic/types.js").AndroidApplicationInputFile[]} [input.resources] - Exact Android caller resources.
|
|
103
|
+
* @returns {import("./src/semantic/types.js").GeneratedArtifactSet} Complete generated set.
|
|
104
|
+
*/
|
|
105
|
+
export function generateProgramArtifactSet(input) {
|
|
106
|
+
return generateProgramArtifacts(input)
|
|
107
|
+
}
|
|
108
|
+
|
|
72
109
|
/**
|
|
73
110
|
* Generates a deterministic artifact set for one semantic module.
|
|
74
111
|
* @param {object} input - Artifact-set generation request.
|
|
75
|
-
* @param {
|
|
112
|
+
* @param {import("./src/semantic/types.js").BackendLanguage} input.language - Registered target language or platform ID.
|
|
76
113
|
* @param {import("./src/semantic/types.js").SemanticModule} input.module - Semantic module.
|
|
77
114
|
* @param {"text" | "binary" | "application"} [input.role] - Requested backend artifact role.
|
|
78
115
|
* @param {string} [input.filename] - Safe output path for a text target.
|
|
79
116
|
* @param {"none" | "external" | "inline"} [input.mapDirective] - JavaScript-family map directive.
|
|
80
117
|
* @param {string} [input.sourceMapFilename] - External map filename.
|
|
81
118
|
* @param {{filename: string, content: string, language?: import("./src/semantic/types.js").SemanticLanguage}[]} [input.sources] - Original sources.
|
|
119
|
+
* @param {import("./src/semantic/types.js").IosApplicationConfigurationInput | import("./src/semantic/types.js").AndroidApplicationConfigurationInput} [input.configuration] - Application configuration.
|
|
120
|
+
* @param {import("./src/semantic/types.js").IosApplicationAssetInput[] | import("./src/semantic/types.js").AndroidApplicationInputFile[]} [input.assets] - Exact caller assets.
|
|
121
|
+
* @param {import("./src/semantic/types.js").AndroidApplicationInputFile[]} [input.resources] - Exact Android caller resources.
|
|
82
122
|
* @returns {import("./src/semantic/types.js").GeneratedArtifactSet} Complete generated set.
|
|
83
123
|
*/
|
|
84
124
|
export function generateArtifactSet(input) {
|
|
@@ -89,7 +129,7 @@ export function generateArtifactSet(input) {
|
|
|
89
129
|
message: "Artifact-set generation requires a request object."
|
|
90
130
|
})
|
|
91
131
|
}
|
|
92
|
-
const {filename, language, mapDirective, module, role = "text", sourceMapFilename, sources} = input
|
|
132
|
+
const {assets, configuration, filename, language, mapDirective, module, resources, role = "text", sourceMapFilename, sources} = input
|
|
93
133
|
|
|
94
134
|
if (typeof language != "string" || language.length == 0) {
|
|
95
135
|
throw new SemantifoldDiagnostic({
|
|
@@ -105,11 +145,27 @@ export function generateArtifactSet(input) {
|
|
|
105
145
|
message: "Artifact backend role must be 'text', 'binary', or 'application'."
|
|
106
146
|
})
|
|
107
147
|
}
|
|
148
|
+
const target = languageRegistry.record(language)
|
|
149
|
+
preflightEffectCapabilities(module, /** @type {import("./src/semantic/types.js").BackendLanguage} */ (language))
|
|
150
|
+
const genericDeclaration = [...module?.records ?? [], ...module?.functions ?? []]
|
|
151
|
+
.find((declaration) => (declaration?.typeParameters?.length ?? 0) > 0)
|
|
152
|
+
|
|
153
|
+
if (genericDeclaration && !target.features.typeParametersAndGenerics) {
|
|
154
|
+
unsupportedCapability(/** @type {import("./src/semantic/types.js").BackendLanguage} */ (language),
|
|
155
|
+
"Task 012 type parameters and generics", genericDeclaration.location ?? module.location)
|
|
156
|
+
}
|
|
108
157
|
|
|
109
|
-
if (
|
|
110
|
-
|
|
158
|
+
if (Array.isArray(module?.records) && module.records.length > 0 && !target.features.closedRecords) {
|
|
159
|
+
unsupportedCapability(/** @type {import("./src/semantic/types.js").BackendLanguage} */ (language),
|
|
160
|
+
"Task 009 closed records", module.records[0].location ?? module.location)
|
|
161
|
+
}
|
|
111
162
|
|
|
112
|
-
|
|
163
|
+
if (Array.isArray(module?.classes) && module.classes.length > 0 && !target.features.referenceClasses) {
|
|
164
|
+
unsupportedCapability(/** @type {import("./src/semantic/types.js").BackendLanguage} */ (language),
|
|
165
|
+
"Task 033 reference classes", module.classes[0].location ?? module.location)
|
|
166
|
+
}
|
|
167
|
+
if (role == "text") {
|
|
168
|
+
if (target.artifactMultiplicity == "multiple") {
|
|
113
169
|
const backend = languageRegistry.resolve(language, "textBackend", module?.location)
|
|
114
170
|
|
|
115
171
|
return constructArtifactSet(backend({filename, language, mapDirective, module, sourceMapFilename, sources}))
|
|
@@ -127,7 +183,7 @@ export function generateArtifactSet(input) {
|
|
|
127
183
|
const artifacts = [{
|
|
128
184
|
content: artifact.code,
|
|
129
185
|
contentKind: "text",
|
|
130
|
-
mediaType: /** @type {string} */ (
|
|
186
|
+
mediaType: /** @type {string} */ (target.mediaType),
|
|
131
187
|
ownership: "generated",
|
|
132
188
|
path: artifact.filename,
|
|
133
189
|
provenance: {
|
|
@@ -157,6 +213,7 @@ export function generateArtifactSet(input) {
|
|
|
157
213
|
|
|
158
214
|
return constructArtifactSet({
|
|
159
215
|
artifacts,
|
|
216
|
+
...(language == "kotlin" ? {metadata: kotlinArtifactMetadata} : {}),
|
|
160
217
|
target: language
|
|
161
218
|
})
|
|
162
219
|
}
|
|
@@ -164,5 +221,6 @@ export function generateArtifactSet(input) {
|
|
|
164
221
|
const registryRole = role == "binary" ? "binaryBackend" : "applicationBackend"
|
|
165
222
|
const backend = languageRegistry.resolve(language, registryRole, module?.location)
|
|
166
223
|
|
|
167
|
-
return constructArtifactSet(backend(
|
|
224
|
+
return constructArtifactSet(backend(language == "android" ? input :
|
|
225
|
+
{assets, configuration, filename, language, mapDirective, module, resources, sourceMapFilename, sources}))
|
|
168
226
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
This package is private implementation code bundled only inside the root `semantifold` distribution. It is not published or exported by Semantifold.
|
|
4
4
|
|
|
5
|
-
`parseCst(source, language = "c")` selects exactly "c" or "
|
|
5
|
+
`parseCst(source, language = "c")` selects exactly "c", "cpp" or "rust" and serializes that official grammar’s results into recursively frozen `semantifold.parser-cst` version 1 plain data with UTF-16 indices and positions. Native Parser, Tree, Node, and language handles never leave this package.
|
|
6
6
|
|
|
7
|
-
The package owns exact `tree-sitter@0.21.1`, `tree-sitter-c@0.23.2` and `tree-sitter-
|
|
7
|
+
The package owns exact `tree-sitter@0.21.1`, `tree-sitter-c@0.23.2`, `tree-sitter-cpp@0.23.4` and `tree-sitter-rust@0.23.1` dependencies. npm bundles their registry contents, including licenses, platform prebuilds, and source fallbacks, into the root tarball.
|
package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-rust/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017 Maxim Sokolov
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-rust/README.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# tree-sitter-rust
|
|
2
|
+
|
|
3
|
+
[![CI][ci]](https://github.com/tree-sitter/tree-sitter-rust/actions/workflows/ci.yml)
|
|
4
|
+
[![discord][discord]](https://discord.gg/w7nTvsVJhm)
|
|
5
|
+
[![matrix][matrix]](https://matrix.to/#/#tree-sitter-chat:matrix.org)
|
|
6
|
+
[![crates][crates]](https://crates.io/crates/tree-sitter-rust)
|
|
7
|
+
[![npm][npm]](https://www.npmjs.com/package/tree-sitter-rust)
|
|
8
|
+
[![pypi][pypi]](https://pypi.org/project/tree-sitter-rust)
|
|
9
|
+
|
|
10
|
+
Rust grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter).
|
|
11
|
+
|
|
12
|
+
## Features
|
|
13
|
+
|
|
14
|
+
- **Speed** — When initially parsing a file, `tree-sitter-rust` takes around two to three times
|
|
15
|
+
as long as rustc's hand-written parser.
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
$ wc -l examples/ast.rs
|
|
19
|
+
2157 examples/ast.rs
|
|
20
|
+
|
|
21
|
+
$ rustc -Z unpretty=ast-tree -Z time-passes examples/ast.rs | head -n0
|
|
22
|
+
time: 0.002; rss: 55MB -> 60MB ( +5MB) parse_crate
|
|
23
|
+
|
|
24
|
+
$ tree-sitter parse examples/ast.rs --quiet --time
|
|
25
|
+
examples/ast.rs 6.48 ms 9908 bytes/ms
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
But if you _edit_ the file after parsing it, tree-sitter can generally _update_
|
|
29
|
+
the previous existing syntax tree to reflect your edit in less than a millisecond,
|
|
30
|
+
thanks to its incremental parsing system.
|
|
31
|
+
|
|
32
|
+
## References
|
|
33
|
+
|
|
34
|
+
- [The Rust Reference](https://doc.rust-lang.org/reference/) — While Rust does
|
|
35
|
+
not have a specification, the reference tries to describe its working in detail.
|
|
36
|
+
It tends to be out of date.
|
|
37
|
+
- [Keywords](https://doc.rust-lang.org/stable/book/appendix-01-keywords.html) and
|
|
38
|
+
[Operators and Symbols](https://doc.rust-lang.org/stable/book/appendix-02-operators.html).
|
|
39
|
+
|
|
40
|
+
[ci]: https://img.shields.io/github/actions/workflow/status/tree-sitter/tree-sitter-rust/ci.yml?logo=github&label=CI
|
|
41
|
+
[discord]: https://img.shields.io/discord/1063097320771698699?logo=discord&label=discord
|
|
42
|
+
[matrix]: https://img.shields.io/matrix/tree-sitter-chat%3Amatrix.org?logo=matrix&label=matrix
|
|
43
|
+
[npm]: https://img.shields.io/npm/v/tree-sitter-rust?logo=npm
|
|
44
|
+
[crates]: https://img.shields.io/crates/v/tree-sitter-rust?logo=rust
|
|
45
|
+
[pypi]: https://img.shields.io/pypi/v/tree-sitter-rust?logo=pypi&logoColor=ffd242
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"targets": [
|
|
3
|
+
{
|
|
4
|
+
"target_name": "tree_sitter_rust_binding",
|
|
5
|
+
"dependencies": [
|
|
6
|
+
"<!(node -p \"require('node-addon-api').targets\"):node_addon_api_except",
|
|
7
|
+
],
|
|
8
|
+
"include_dirs": [
|
|
9
|
+
"src",
|
|
10
|
+
],
|
|
11
|
+
"sources": [
|
|
12
|
+
"bindings/node/binding.cc",
|
|
13
|
+
"src/parser.c",
|
|
14
|
+
"src/scanner.c",
|
|
15
|
+
],
|
|
16
|
+
"conditions": [
|
|
17
|
+
["OS!='win'", {
|
|
18
|
+
"cflags_c": [
|
|
19
|
+
"-std=c11",
|
|
20
|
+
],
|
|
21
|
+
}, { # OS == "win"
|
|
22
|
+
"cflags_c": [
|
|
23
|
+
"/std:c11",
|
|
24
|
+
"/utf-8",
|
|
25
|
+
],
|
|
26
|
+
}],
|
|
27
|
+
],
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#include <napi.h>
|
|
2
|
+
|
|
3
|
+
typedef struct TSLanguage TSLanguage;
|
|
4
|
+
|
|
5
|
+
extern "C" TSLanguage *tree_sitter_rust();
|
|
6
|
+
|
|
7
|
+
// "tree-sitter", "language" hashed with BLAKE2
|
|
8
|
+
const napi_type_tag LANGUAGE_TYPE_TAG = {
|
|
9
|
+
0x8AF2E5212AD58ABF, 0xD5006CAD83ABBA16
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
Napi::Object Init(Napi::Env env, Napi::Object exports) {
|
|
13
|
+
exports["name"] = Napi::String::New(env, "rust");
|
|
14
|
+
auto language = Napi::External<TSLanguage>::New(env, tree_sitter_rust());
|
|
15
|
+
language.TypeTag(&LANGUAGE_TYPE_TAG);
|
|
16
|
+
exports["language"] = language;
|
|
17
|
+
return exports;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
NODE_API_MODULE(tree_sitter_rust_binding, Init)
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
type BaseNode = {
|
|
2
|
+
type: string;
|
|
3
|
+
named: boolean;
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
type ChildNode = {
|
|
7
|
+
multiple: boolean;
|
|
8
|
+
required: boolean;
|
|
9
|
+
types: BaseNode[];
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
type NodeInfo =
|
|
13
|
+
| (BaseNode & {
|
|
14
|
+
subtypes: BaseNode[];
|
|
15
|
+
})
|
|
16
|
+
| (BaseNode & {
|
|
17
|
+
fields: { [name: string]: ChildNode };
|
|
18
|
+
children: ChildNode[];
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
type Language = {
|
|
22
|
+
name: string;
|
|
23
|
+
language: unknown;
|
|
24
|
+
nodeTypeInfo: NodeInfo[];
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
declare const language: Language;
|
|
28
|
+
export = language;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const root = require("path").join(__dirname, "..", "..");
|
|
2
|
+
|
|
3
|
+
module.exports =
|
|
4
|
+
typeof process.versions.bun === "string"
|
|
5
|
+
// Support `bun build --compile` by being statically analyzable enough to find the .node file at build-time
|
|
6
|
+
? require(`../../prebuilds/${process.platform}-${process.arch}/tree-sitter-rust.node`)
|
|
7
|
+
: require("node-gyp-build")(root);
|
|
8
|
+
|
|
9
|
+
try {
|
|
10
|
+
module.exports.nodeTypeInfo = require("../../src/node-types.json");
|
|
11
|
+
} catch (_) {}
|