semantifold 0.1.1 → 0.3.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 +42 -10
- package/build/index.d.ts +32 -3
- package/build/index.d.ts.map +1 -1
- package/build/index.js +99 -4
- package/build/src/acceptance.d.ts +32 -0
- package/build/src/acceptance.d.ts.map +1 -0
- package/build/src/acceptance.js +358 -0
- package/build/src/array.d.ts +7 -0
- package/build/src/array.d.ts.map +1 -0
- package/build/src/array.js +18 -0
- package/build/src/artifact-path.d.ts +13 -0
- package/build/src/artifact-path.d.ts.map +1 -0
- package/build/src/artifact-path.js +30 -0
- package/build/src/artifacts.d.ts +7 -0
- package/build/src/artifacts.d.ts.map +1 -0
- package/build/src/artifacts.js +389 -0
- package/build/src/backends/c-runtime.d.ts +3 -0
- package/build/src/backends/c-runtime.d.ts.map +1 -0
- package/build/src/backends/c-runtime.js +151 -0
- package/build/src/backends/c-validation.d.ts +12 -0
- package/build/src/backends/c-validation.d.ts.map +1 -0
- package/build/src/backends/c-validation.js +85 -0
- package/build/src/backends/c.d.ts +31 -0
- package/build/src/backends/c.d.ts.map +1 -0
- package/build/src/backends/c.js +308 -0
- package/build/src/backends/cpp-runtime.d.ts +3 -0
- package/build/src/backends/cpp-runtime.d.ts.map +1 -0
- package/build/src/backends/cpp-runtime.js +99 -0
- package/build/src/backends/cpp-validation.d.ts +9 -0
- package/build/src/backends/cpp-validation.d.ts.map +1 -0
- package/build/src/backends/cpp-validation.js +74 -0
- package/build/src/backends/cpp.d.ts +16 -0
- package/build/src/backends/cpp.d.ts.map +1 -0
- package/build/src/backends/cpp.js +285 -0
- package/build/src/backends/csharp.d.ts +20 -0
- package/build/src/backends/csharp.d.ts.map +1 -0
- package/build/src/backends/csharp.js +259 -0
- package/build/src/backends/go.d.ts +20 -0
- package/build/src/backends/go.d.ts.map +1 -0
- package/build/src/backends/go.js +374 -0
- package/build/src/backends/identifiers.d.ts +12 -0
- package/build/src/backends/identifiers.d.ts.map +1 -1
- package/build/src/backends/identifiers.js +79 -2
- package/build/src/backends/index.d.ts.map +1 -1
- package/build/src/backends/index.js +27 -37
- package/build/src/backends/native-validation.d.ts +9 -0
- package/build/src/backends/native-validation.d.ts.map +1 -0
- package/build/src/backends/native-validation.js +59 -0
- package/build/src/backends/ordered-expressions.d.ts +74 -0
- package/build/src/backends/ordered-expressions.d.ts.map +1 -0
- package/build/src/backends/ordered-expressions.js +159 -0
- package/build/src/backends/python.d.ts +8 -0
- package/build/src/backends/python.d.ts.map +1 -0
- package/build/src/backends/python.js +162 -0
- package/build/src/backends/scalars.d.ts.map +1 -1
- package/build/src/backends/scalars.js +8 -2
- package/build/src/backends/shared.d.ts.map +1 -1
- package/build/src/backends/shared.js +67 -19
- package/build/src/binary-mapping.d.ts +32 -0
- package/build/src/binary-mapping.d.ts.map +1 -0
- package/build/src/binary-mapping.js +285 -0
- package/build/src/diagnostic.d.ts +36 -4
- package/build/src/diagnostic.d.ts.map +1 -1
- package/build/src/diagnostic.js +42 -3
- package/build/src/frontends/c-parser.d.ts +20 -0
- package/build/src/frontends/c-parser.d.ts.map +1 -0
- package/build/src/frontends/c-parser.js +14 -0
- package/build/src/frontends/c.d.ts +220 -0
- package/build/src/frontends/c.d.ts.map +1 -0
- package/build/src/frontends/c.js +750 -0
- package/build/src/frontends/cpp-parser.d.ts +11 -0
- package/build/src/frontends/cpp-parser.d.ts.map +1 -0
- package/build/src/frontends/cpp-parser.js +15 -0
- package/build/src/frontends/cpp.d.ts +227 -0
- package/build/src/frontends/cpp.d.ts.map +1 -0
- package/build/src/frontends/cpp.js +784 -0
- package/build/src/frontends/csharp.d.ts +14 -0
- package/build/src/frontends/csharp.d.ts.map +1 -0
- package/build/src/frontends/csharp.js +708 -0
- package/build/src/frontends/go.d.ts +15 -0
- package/build/src/frontends/go.d.ts.map +1 -0
- package/build/src/frontends/go.js +712 -0
- package/build/src/frontends/index.d.ts.map +1 -1
- package/build/src/frontends/index.js +5 -23
- package/build/src/frontends/python.d.ts +14 -0
- package/build/src/frontends/python.d.ts.map +1 -0
- package/build/src/frontends/python.js +615 -0
- package/build/src/frontends/scalars.d.ts.map +1 -1
- package/build/src/frontends/scalars.js +21 -1
- package/build/src/language-registry.d.ts +113 -0
- package/build/src/language-registry.d.ts.map +1 -0
- package/build/src/language-registry.js +421 -0
- package/build/src/mapping.js +3 -2
- package/build/src/semantic/location.d.ts +7 -0
- package/build/src/semantic/location.d.ts.map +1 -1
- package/build/src/semantic/location.js +10 -1
- package/build/src/semantic/provenance.js +3 -3
- package/build/src/semantic/types.d.ts +399 -2
- package/build/src/semantic/types.d.ts.map +1 -1
- package/build/src/semantic/types.js +110 -2
- package/build/src/subprocess.d.ts +38 -0
- package/build/src/subprocess.d.ts.map +1 -0
- package/build/src/subprocess.js +233 -0
- package/build/src/timeout.d.ts +8 -0
- package/build/src/timeout.d.ts.map +1 -0
- package/build/src/timeout.js +11 -0
- package/build/src/toolchains.d.ts +107 -0
- package/build/src/toolchains.d.ts.map +1 -0
- package/build/src/toolchains.js +417 -0
- package/docs/architecture.md +23 -5
- package/docs/c.md +60 -0
- package/docs/cpp.md +61 -0
- package/docs/goals.md +4 -2
- package/docs/language-support.md +46 -6
- package/docs/parser-qualification.md +219 -0
- package/docs/plans/2026-09-05-standard-library-portability.md +46 -0
- package/docs/source-maps.md +38 -5
- package/docs/standard-library-portability.md +190 -0
- package/docs/testing.md +131 -3
- package/index.js +109 -4
- package/node_modules/node-addon-api/LICENSE.md +9 -0
- package/node_modules/node-addon-api/README.md +95 -0
- package/node_modules/node-addon-api/common.gypi +21 -0
- package/node_modules/node-addon-api/except.gypi +25 -0
- package/node_modules/node-addon-api/index.js +14 -0
- package/node_modules/node-addon-api/napi-inl.deprecated.h +186 -0
- package/node_modules/node-addon-api/napi-inl.h +7250 -0
- package/node_modules/node-addon-api/napi.h +3463 -0
- package/node_modules/node-addon-api/node_addon_api.gyp +42 -0
- package/node_modules/node-addon-api/node_api.gyp +9 -0
- package/node_modules/node-addon-api/noexcept.gypi +26 -0
- package/node_modules/node-addon-api/nothing.c +0 -0
- package/node_modules/node-addon-api/package-support.json +21 -0
- package/node_modules/node-addon-api/package.json +481 -0
- package/node_modules/node-addon-api/tools/README.md +73 -0
- package/node_modules/node-addon-api/tools/check-napi.js +99 -0
- package/node_modules/node-addon-api/tools/clang-format.js +71 -0
- package/node_modules/node-addon-api/tools/conversion.js +301 -0
- package/node_modules/node-gyp-build/LICENSE +21 -0
- package/node_modules/node-gyp-build/README.md +58 -0
- package/node_modules/node-gyp-build/SECURITY.md +5 -0
- package/node_modules/node-gyp-build/bin.js +84 -0
- package/node_modules/node-gyp-build/build-test.js +19 -0
- package/node_modules/node-gyp-build/index.js +6 -0
- package/node_modules/node-gyp-build/node-gyp-build.js +207 -0
- package/node_modules/node-gyp-build/optional.js +7 -0
- package/node_modules/node-gyp-build/package.json +43 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/LICENSE +15 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/README.md +7 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/LICENSE +21 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/README.md +90 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/binding.gyp +79 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/index.js +895 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/package.json +62 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/prebuilds/darwin-arm64/tree-sitter.node +0 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/prebuilds/darwin-x64/tree-sitter.node +0 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/prebuilds/linux-x64/tree-sitter.node +0 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/prebuilds/win32-x64/tree-sitter.node +0 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/src/addon_data.h +47 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/src/binding.cc +35 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/src/conversions.cc +140 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/src/conversions.h +22 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/src/language.cc +106 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/src/language.h +17 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/src/logger.cc +70 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/src/logger.h +19 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/src/lookaheaditerator.cc +122 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/src/lookaheaditerator.h +33 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/src/node.cc +1056 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/src/node.h +30 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/src/parser.cc +298 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/src/parser.h +35 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/src/query.cc +383 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/src/query.h +39 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/src/tree.cc +307 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/src/tree.h +45 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/src/tree_cursor.cc +213 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/src/tree_cursor.h +52 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/tree-sitter.d.ts +211 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/vendor/tree-sitter/lib/include/tree_sitter/api.h +1266 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/vendor/tree-sitter/lib/src/alloc.c +48 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/vendor/tree-sitter/lib/src/alloc.h +41 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/vendor/tree-sitter/lib/src/array.h +290 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/vendor/tree-sitter/lib/src/atomic.h +68 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/vendor/tree-sitter/lib/src/clock.h +146 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/vendor/tree-sitter/lib/src/error_costs.h +11 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/vendor/tree-sitter/lib/src/get_changed_ranges.c +501 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/vendor/tree-sitter/lib/src/get_changed_ranges.h +36 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/vendor/tree-sitter/lib/src/host.h +21 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/vendor/tree-sitter/lib/src/language.c +221 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/vendor/tree-sitter/lib/src/language.h +299 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/vendor/tree-sitter/lib/src/length.h +52 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/vendor/tree-sitter/lib/src/lexer.c +419 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/vendor/tree-sitter/lib/src/lexer.h +49 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/vendor/tree-sitter/lib/src/lib.c +14 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/vendor/tree-sitter/lib/src/node.c +774 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/vendor/tree-sitter/lib/src/parser.c +2151 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/vendor/tree-sitter/lib/src/parser.h +230 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/vendor/tree-sitter/lib/src/point.h +62 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/vendor/tree-sitter/lib/src/query.c +4134 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/vendor/tree-sitter/lib/src/reduce_action.h +34 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/vendor/tree-sitter/lib/src/reusable_node.h +95 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/vendor/tree-sitter/lib/src/stack.c +899 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/vendor/tree-sitter/lib/src/stack.h +133 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/vendor/tree-sitter/lib/src/subtree.c +1060 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/vendor/tree-sitter/lib/src/subtree.h +382 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/vendor/tree-sitter/lib/src/tree.c +165 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/vendor/tree-sitter/lib/src/tree.h +31 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/vendor/tree-sitter/lib/src/tree_cursor.c +714 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/vendor/tree-sitter/lib/src/tree_cursor.h +48 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/ICU_SHA +1 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/LICENSE +414 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/README.md +29 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/ptypes.h +1 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/umachine.h +448 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/urename.h +1 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/utf.h +1 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/utf16.h +733 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/utf8.h +881 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode.h +50 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/vendor/tree-sitter/lib/src/wasm/stdlib-symbols.txt +23 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/vendor/tree-sitter/lib/src/wasm/stdlib.c +109 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/vendor/tree-sitter/lib/src/wasm/wasm-stdlib.h +1294 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/vendor/tree-sitter/lib/src/wasm_store.c +1823 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter/vendor/tree-sitter/lib/src/wasm_store.h +31 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-c/LICENSE +21 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-c/README.md +18 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-c/binding.gyp +29 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-c/bindings/node/binding.cc +20 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-c/bindings/node/binding_test.js +9 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-c/bindings/node/index.d.ts +28 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-c/bindings/node/index.js +11 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-c/grammar.js +1470 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-c/package.json +60 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-c/prebuilds/darwin-arm64/tree-sitter-c.node +0 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-c/prebuilds/darwin-x64/tree-sitter-c.node +0 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-c/prebuilds/linux-arm64/tree-sitter-c.node +0 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-c/prebuilds/linux-x64/tree-sitter-c.node +0 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-c/prebuilds/win32-arm64/tree-sitter-c.node +0 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-c/prebuilds/win32-x64/tree-sitter-c.node +0 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-c/queries/highlights.scm +81 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-c/queries/tags.scm +9 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-c/src/grammar.json +9735 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-c/src/node-types.json +4614 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-c/src/parser.c +119615 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-c/src/tree_sitter/alloc.h +54 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-c/src/tree_sitter/array.h +290 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-c/src/tree_sitter/parser.h +266 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-c/tree-sitter-c.wasm +0 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-c/tree-sitter.json +43 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-cpp/LICENSE +21 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-cpp/README.md +22 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-cpp/binding.gyp +30 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-cpp/bindings/node/binding.cc +20 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-cpp/bindings/node/binding_test.js +9 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-cpp/bindings/node/index.d.ts +28 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-cpp/bindings/node/index.js +11 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-cpp/grammar.js +1436 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-cpp/package.json +61 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-cpp/prebuilds/darwin-arm64/tree-sitter-cpp.node +0 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-cpp/prebuilds/darwin-x64/tree-sitter-cpp.node +0 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-cpp/prebuilds/linux-arm64/tree-sitter-cpp.node +0 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-cpp/prebuilds/linux-x64/tree-sitter-cpp.node +0 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-cpp/prebuilds/win32-arm64/tree-sitter-cpp.node +0 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-cpp/prebuilds/win32-x64/tree-sitter-cpp.node +0 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-cpp/queries/highlights.scm +70 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-cpp/queries/injections.scm +3 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-cpp/queries/tags.scm +15 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-cpp/src/grammar.json +17084 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-cpp/src/node-types.json +7997 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-cpp/src/parser.c +530368 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-cpp/src/scanner.c +148 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-cpp/src/tree_sitter/alloc.h +54 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-cpp/src/tree_sitter/array.h +290 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-cpp/src/tree_sitter/parser.h +266 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-cpp/tree-sitter-cpp.wasm +0 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/node_modules/tree-sitter-cpp/tree-sitter.json +55 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/package.json +22 -0
- package/node_modules/semantifold-tree-sitter-legacy-internal/src/c.js +152 -0
- package/node_modules/tree-sitter/LICENSE +21 -0
- package/node_modules/tree-sitter/README.md +128 -0
- package/node_modules/tree-sitter/binding.gyp +88 -0
- package/node_modules/tree-sitter/index.js +950 -0
- package/node_modules/tree-sitter/package.json +76 -0
- package/node_modules/tree-sitter/prebuilds/darwin-arm64/tree-sitter.node +0 -0
- package/node_modules/tree-sitter/prebuilds/darwin-x64/tree-sitter.node +0 -0
- package/node_modules/tree-sitter/prebuilds/linux-arm64/tree-sitter.node +0 -0
- package/node_modules/tree-sitter/prebuilds/linux-x64/tree-sitter.node +0 -0
- package/node_modules/tree-sitter/prebuilds/win32-arm64/tree-sitter.node +0 -0
- package/node_modules/tree-sitter/prebuilds/win32-x64/tree-sitter.node +0 -0
- package/node_modules/tree-sitter/src/addon_data.h +47 -0
- package/node_modules/tree-sitter/src/binding.cc +35 -0
- package/node_modules/tree-sitter/src/conversions.cc +140 -0
- package/node_modules/tree-sitter/src/conversions.h +22 -0
- package/node_modules/tree-sitter/src/language.cc +105 -0
- package/node_modules/tree-sitter/src/language.h +17 -0
- package/node_modules/tree-sitter/src/logger.cc +70 -0
- package/node_modules/tree-sitter/src/logger.h +19 -0
- package/node_modules/tree-sitter/src/lookaheaditerator.cc +122 -0
- package/node_modules/tree-sitter/src/lookaheaditerator.h +33 -0
- package/node_modules/tree-sitter/src/node.cc +1088 -0
- package/node_modules/tree-sitter/src/node.h +30 -0
- package/node_modules/tree-sitter/src/parser.cc +332 -0
- package/node_modules/tree-sitter/src/parser.h +35 -0
- package/node_modules/tree-sitter/src/query.cc +425 -0
- package/node_modules/tree-sitter/src/query.h +40 -0
- package/node_modules/tree-sitter/src/tree.cc +316 -0
- package/node_modules/tree-sitter/src/tree.h +45 -0
- package/node_modules/tree-sitter/src/tree_cursor.cc +213 -0
- package/node_modules/tree-sitter/src/tree_cursor.h +52 -0
- package/node_modules/tree-sitter/tree-sitter.d.ts +1083 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/include/tree_sitter/api.h +1478 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/alloc.c +48 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/alloc.h +41 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/array.h +291 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/atomic.h +68 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/clock.h +146 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/error_costs.h +11 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/get_changed_ranges.c +523 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/get_changed_ranges.h +36 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/host.h +21 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/language.c +293 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/language.h +293 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/length.h +52 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/lexer.c +483 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/lexer.h +54 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/lib.c +12 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/node.c +875 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/parser.c +2297 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/parser.h +286 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/point.h +48 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/portable/endian.h +241 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/query.c +4347 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/reduce_action.h +34 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/reusable_node.h +95 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/stack.c +912 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/stack.h +133 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/subtree.c +1034 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/subtree.h +399 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/tree.c +170 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/tree.h +31 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/tree_cursor.c +716 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/tree_cursor.h +48 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/ts_assert.h +11 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/ICU_SHA +1 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/LICENSE +414 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/README.md +29 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/ptypes.h +1 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/umachine.h +448 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/urename.h +1 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/utf.h +1 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/utf16.h +733 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/utf8.h +881 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode.h +75 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/wasm/stdlib-symbols.txt +24 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/wasm/stdlib.c +137 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/wasm/wasm-stdlib.h +1314 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/wasm_store.c +1937 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/wasm_store.h +31 -0
- package/package.json +24 -6
- package/src/acceptance.js +380 -0
- package/src/array.js +19 -0
- package/src/artifact-path.js +34 -0
- package/src/artifacts.js +420 -0
- package/src/backends/c-runtime.js +151 -0
- package/src/backends/c-validation.js +83 -0
- package/src/backends/c.js +308 -0
- package/src/backends/cpp-runtime.js +99 -0
- package/src/backends/cpp-validation.js +70 -0
- package/src/backends/cpp.js +285 -0
- package/src/backends/csharp.js +270 -0
- package/src/backends/go.js +383 -0
- package/src/backends/identifiers.js +80 -1
- package/src/backends/index.js +23 -32
- package/src/backends/native-validation.js +64 -0
- package/src/backends/ordered-expressions.js +161 -0
- package/src/backends/python.js +175 -0
- package/src/backends/scalars.js +8 -1
- package/src/backends/shared.js +64 -17
- package/src/binary-mapping.js +305 -0
- package/src/diagnostic.js +34 -2
- package/src/frontends/c-parser.js +17 -0
- package/src/frontends/c.js +780 -0
- package/src/frontends/cpp-parser.js +18 -0
- package/src/frontends/cpp.js +816 -0
- package/src/frontends/csharp.js +759 -0
- package/src/frontends/go.js +770 -0
- package/src/frontends/index.js +5 -20
- package/src/frontends/python.js +689 -0
- package/src/frontends/scalars.js +20 -0
- package/src/language-registry.js +454 -0
- package/src/mapping.js +2 -1
- package/src/semantic/location.js +10 -0
- package/src/semantic/provenance.js +2 -2
- package/src/semantic/types.js +124 -1
- package/src/subprocess.js +232 -0
- package/src/timeout.js +12 -0
- package/src/toolchains.js +448 -0
- package/tsconfig.json +1 -0
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
import {createHash} from "node:crypto"
|
|
4
|
+
import {unsupportedCapability} from "../diagnostic.js"
|
|
5
|
+
|
|
6
|
+
/** @typedef {import("../semantic/types.js").Expression} Expression */
|
|
7
|
+
/** @typedef {import("../semantic/types.js").SemanticTypeName} Scalar */
|
|
8
|
+
/** @typedef {{expression: Expression, path: string, type: Scalar, name?: string}} PlannedValue */
|
|
9
|
+
/** @typedef {{result: PlannedValue, operands: PlannedValue[], rightSteps?: PlannedStep[]}} PlannedStep */
|
|
10
|
+
/** @typedef {Array<string | number | boolean | Signature>} Signature */
|
|
11
|
+
|
|
12
|
+
/** Private occurrence-based native expression sequencer; it never rewrites the IR. */
|
|
13
|
+
export class OrderedExpressionPlanner {
|
|
14
|
+
/**
|
|
15
|
+
* Indexes already validated callable return types.
|
|
16
|
+
* @param {import("../semantic/types.js").SemanticModule} module - Validated module.
|
|
17
|
+
* @param {"c" | "cpp"} [language] - Owning backend diagnostic language.
|
|
18
|
+
*/
|
|
19
|
+
constructor(module, language = "c") {
|
|
20
|
+
this.language = language
|
|
21
|
+
this.functions = new Map(module.functions.map((declaration) => [declaration.name, declaration.returnType.name]))
|
|
22
|
+
this.nextTemporary = 1
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Resolves an expression type from the validated lexical environment.
|
|
27
|
+
* @param {Expression} expression - Semantic expression.
|
|
28
|
+
* @param {Map<string, Scalar>} bindings - Lexical scalar types.
|
|
29
|
+
* @returns {Scalar} Exact semantic result type.
|
|
30
|
+
*/
|
|
31
|
+
type(expression, bindings) {
|
|
32
|
+
if (expression.kind == "IntegerLiteral") return "integer"
|
|
33
|
+
if (expression.kind == "BooleanLiteral") return "boolean"
|
|
34
|
+
if (expression.kind == "StringLiteral") return "string"
|
|
35
|
+
if (expression.kind == "UnaryExpression" || expression.kind == "BinaryExpression") return expression.type
|
|
36
|
+
const type = expression.kind == "CallExpression" ? this.functions.get(expression.callee) : bindings.get(expression.name)
|
|
37
|
+
|
|
38
|
+
if (!type) return unsupportedCapability(this.language, "unresolved expression type", expression.location)
|
|
39
|
+
return type
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Plans one expression in semantic order, keeping the short-circuit RHS conditional.
|
|
44
|
+
* @param {Expression} expression - Original occurrence.
|
|
45
|
+
* @param {string} path - Occurrence path.
|
|
46
|
+
* @param {Map<string, Scalar>} bindings - Lexical types.
|
|
47
|
+
* @param {PlannedStep[]} steps - Enclosing ordered prelude.
|
|
48
|
+
* @returns {PlannedValue} Pure final value.
|
|
49
|
+
*/
|
|
50
|
+
plan(expression, path, bindings, steps) {
|
|
51
|
+
const result = {expression, path, type: this.type(expression, bindings)}
|
|
52
|
+
|
|
53
|
+
if (!["CallExpression", "UnaryExpression", "BinaryExpression"].includes(expression.kind)) return result
|
|
54
|
+
const operands = []
|
|
55
|
+
/** @type {PlannedStep[] | undefined} */
|
|
56
|
+
let rightSteps
|
|
57
|
+
|
|
58
|
+
if (expression.kind == "CallExpression") {
|
|
59
|
+
for (const [index, argument] of expression.arguments.entries()) operands.push(this.plan(argument, `${path}/arguments/${index}`, bindings, steps))
|
|
60
|
+
} else if (expression.kind == "UnaryExpression") operands.push(this.plan(expression.operand, `${path}/operand`, bindings, steps))
|
|
61
|
+
else if (expression.kind == "BinaryExpression") {
|
|
62
|
+
operands.push(this.plan(expression.left, `${path}/left`, bindings, steps))
|
|
63
|
+
if (expression.operation == "BooleanAnd" || expression.operation == "BooleanOr") {
|
|
64
|
+
const planned = {...result, name: this.allocate(expression)}
|
|
65
|
+
|
|
66
|
+
rightSteps = []
|
|
67
|
+
operands.push(this.plan(expression.right, `${path}/right`, bindings, rightSteps))
|
|
68
|
+
steps.push({operands, result: planned, rightSteps})
|
|
69
|
+
return planned
|
|
70
|
+
}
|
|
71
|
+
operands.push(this.plan(expression.right, `${path}/right`, bindings, steps))
|
|
72
|
+
}
|
|
73
|
+
const planned = {...result, name: this.allocate(expression)}
|
|
74
|
+
|
|
75
|
+
steps.push({operands, result: planned})
|
|
76
|
+
return planned
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Allocates one bounded deterministic occurrence name.
|
|
81
|
+
* @param {Expression} expression - Related expression.
|
|
82
|
+
* @returns {string} Reserved temporary name.
|
|
83
|
+
*/
|
|
84
|
+
allocate(expression) {
|
|
85
|
+
if (this.nextTemporary > 999999) return unsupportedCapability(this.language, "ordered-expression occurrence limit", expression.location)
|
|
86
|
+
return `semantifold_ordered_${String(this.nextTemporary++).padStart(6, "0")}`
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Binds a region marker to its semantic consumer and expression, independently of locations.
|
|
92
|
+
* The digest detects edits; structural CST validation remains mandatory and authoritative.
|
|
93
|
+
* @param {import("../semantic/types.js").Statement} statement - Reconstructed or original statement.
|
|
94
|
+
* @returns {string} Stable SHA-256 profile signature.
|
|
95
|
+
*/
|
|
96
|
+
export function statementSignature(statement) {
|
|
97
|
+
const consumer = statement.kind == "LocalDeclaration" ? [statement.kind, statement.name, statement.type.name, statement.mutable] :
|
|
98
|
+
statement.kind == "AssignmentStatement" ? [statement.kind, statement.target.name] : [statement.kind]
|
|
99
|
+
const expression = statement.kind == "IfStatement" ? statement.condition : statement.kind == "LocalDeclaration" ? statement.initializer : statement.expression
|
|
100
|
+
|
|
101
|
+
return createHash("sha256").update(JSON.stringify([consumer, expressionSignature(expression)])).digest("hex")
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Serializes only the closed semantic expression fields.
|
|
106
|
+
* @param {Expression} expression - Expression occurrence.
|
|
107
|
+
* @returns {Signature} Signature data.
|
|
108
|
+
*/
|
|
109
|
+
function expressionSignature(expression) {
|
|
110
|
+
if (expression.kind == "IdentifierExpression") return [expression.kind, expression.name]
|
|
111
|
+
if (expression.kind == "IntegerLiteral" || expression.kind == "BooleanLiteral" || expression.kind == "StringLiteral") return [expression.kind, expression.value]
|
|
112
|
+
if (expression.kind == "CallExpression") return [expression.kind, expression.callee, ...expression.arguments.map(expressionSignature)]
|
|
113
|
+
if (expression.kind == "UnaryExpression") return [expression.kind, expression.operation, expression.type, expressionSignature(expression.operand)]
|
|
114
|
+
return [expression.kind, expression.operation, expression.type, expressionSignature(expression.left), expressionSignature(expression.right)]
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** @typedef {{id: string, steps: PlannedStep[], value: PlannedValue}} StatementPlan */
|
|
118
|
+
/**
|
|
119
|
+
* Plans every occurrence before constructing a writer or exposing either artifact.
|
|
120
|
+
* @param {import("../semantic/types.js").SemanticModule} module - Validated module.
|
|
121
|
+
* @param {"c" | "cpp"} [language] - Native diagnostic owner.
|
|
122
|
+
* @returns {Map<string, StatementPlan>} Plans indexed by semantic occurrence path.
|
|
123
|
+
*/
|
|
124
|
+
export function planNativeModule(module, language = "c") {
|
|
125
|
+
const planner = new OrderedExpressionPlanner(module, language)
|
|
126
|
+
/** @type {Map<string, StatementPlan>} */
|
|
127
|
+
const plans = new Map()
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Plans one lexical block with independent branch environments.
|
|
131
|
+
* @param {import("../semantic/types.js").Block} block - Semantic block.
|
|
132
|
+
* @param {string} path - Occurrence path.
|
|
133
|
+
* @param {Map<string, import("../semantic/types.js").SemanticTypeName>} inherited - Visible types.
|
|
134
|
+
* @returns {void}
|
|
135
|
+
*/
|
|
136
|
+
function visit(block, path, inherited) {
|
|
137
|
+
const bindings = new Map(inherited)
|
|
138
|
+
|
|
139
|
+
block.statements.forEach((statement, index) => {
|
|
140
|
+
const statementPath = `${path}/statements/${index}`
|
|
141
|
+
const field = statement.kind == "IfStatement" ? "condition" : statement.kind == "LocalDeclaration" ? "initializer" : "expression"
|
|
142
|
+
const expression = statement.kind == "IfStatement" ? statement.condition : statement.kind == "LocalDeclaration" ? statement.initializer : statement.expression
|
|
143
|
+
/** @type {PlannedStep[]} */
|
|
144
|
+
const steps = []
|
|
145
|
+
const value = planner.plan(expression, `${statementPath}/${field}`, bindings, steps)
|
|
146
|
+
|
|
147
|
+
if (plans.size >= 999999) unsupportedCapability(language, "ordered statement limit", statement.location)
|
|
148
|
+
plans.set(statementPath, {id: String(plans.size + 1).padStart(6, "0"), steps, value})
|
|
149
|
+
if (statement.kind == "LocalDeclaration") bindings.set(statement.name, statement.type.name)
|
|
150
|
+
if (statement.kind == "IfStatement") {
|
|
151
|
+
visit(statement.consequent, `${statementPath}/consequent`, bindings)
|
|
152
|
+
if (statement.alternate) visit(statement.alternate, `${statementPath}/alternate`, bindings)
|
|
153
|
+
}
|
|
154
|
+
})
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
module.functions.forEach((declaration, index) => visit(declaration.body, `/functions/${index}/body`,
|
|
158
|
+
new Map(declaration.parameters.map((parameter) => [parameter.name, parameter.type.name]))))
|
|
159
|
+
visit(module.entryPoint.body, "/entryPoint/body", new Map())
|
|
160
|
+
return plans
|
|
161
|
+
}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
import {emitExpression} from "./shared.js"
|
|
4
|
+
import {emitScalarType} from "./scalars.js"
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Emits one deterministic standalone Python program.
|
|
8
|
+
* @param {import("../semantic/types.js").SemanticModule} module - Semantic module.
|
|
9
|
+
* @param {import("./writer.js").SourceWriter} writer - Source-aware writer.
|
|
10
|
+
* @returns {void}
|
|
11
|
+
*/
|
|
12
|
+
export function generatePython(module, writer) {
|
|
13
|
+
module.functions.forEach((declaration, functionIndex) => {
|
|
14
|
+
if (functionIndex > 0) writer.synthetic("\n\n", "declaration separator", [declaration])
|
|
15
|
+
|
|
16
|
+
writer.mapped("def", {mappingKind: "anchor", node: declaration})
|
|
17
|
+
writer.synthetic(" ", "function spacing", [declaration])
|
|
18
|
+
writer.mapped(declaration.name, {mappingKind: "exact", node: declaration, role: "name"})
|
|
19
|
+
writer.mapped("(", {mappingKind: "anchor", node: declaration})
|
|
20
|
+
declaration.parameters.forEach((parameter, parameterIndex) => {
|
|
21
|
+
const parameterPath = `/functions/${functionIndex}/parameters/${parameterIndex}`
|
|
22
|
+
|
|
23
|
+
if (parameterIndex > 0) writer.synthetic(", ", "parameter separator", [declaration])
|
|
24
|
+
writer.mapped(parameter.name, {mappingKind: "exact", node: parameter, path: parameterPath, role: "name"})
|
|
25
|
+
writer.synthetic(": ", "Python annotation separator", [parameter], [parameterPath])
|
|
26
|
+
writer.mapped(emitScalarType("python", parameter.type), {
|
|
27
|
+
mappingKind: "exact",
|
|
28
|
+
node: parameter.type,
|
|
29
|
+
path: `${parameterPath}/type`,
|
|
30
|
+
role: "type"
|
|
31
|
+
})
|
|
32
|
+
})
|
|
33
|
+
writer.mapped(")", {mappingKind: "anchor", node: declaration})
|
|
34
|
+
writer.synthetic(" -> ", "Python return annotation separator", [declaration])
|
|
35
|
+
writer.mapped(emitScalarType("python", declaration.returnType), {
|
|
36
|
+
mappingKind: "exact",
|
|
37
|
+
node: declaration.returnType,
|
|
38
|
+
path: `/functions/${functionIndex}/returnType`,
|
|
39
|
+
role: "type"
|
|
40
|
+
})
|
|
41
|
+
writer.mapped(":", {mappingKind: "anchor", node: declaration})
|
|
42
|
+
writer.synthetic("\n", "line break", [declaration])
|
|
43
|
+
emitBlock(writer, declaration.body, " ", `/functions/${functionIndex}/body`)
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
writer.synthetic("\n\n", "entry-point separator", [module.entryPoint])
|
|
47
|
+
emitBlock(writer, module.entryPoint.body, "", "/entryPoint/body")
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Emits one Python indentation block, using pass only for an empty semantic block.
|
|
52
|
+
* @param {import("./writer.js").SourceWriter} writer - Source-aware writer.
|
|
53
|
+
* @param {import("../semantic/types.js").Block} block - Semantic block.
|
|
54
|
+
* @param {string} indent - Leading indentation.
|
|
55
|
+
* @param {string} path - Exact block path.
|
|
56
|
+
* @returns {void}
|
|
57
|
+
*/
|
|
58
|
+
function emitBlock(writer, block, indent, path) {
|
|
59
|
+
if (block.statements.length == 0) {
|
|
60
|
+
writer.synthetic(`${indent}pass\n`, "Python empty block", [block], [path])
|
|
61
|
+
return
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
block.statements.forEach((statement, index) => emitStatement(writer, statement, indent, `${path}/statements/${index}`))
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Emits one supported Python statement.
|
|
69
|
+
* @param {import("./writer.js").SourceWriter} writer - Source-aware writer.
|
|
70
|
+
* @param {import("../semantic/types.js").Statement} statement - Semantic statement.
|
|
71
|
+
* @param {string} indent - Leading indentation.
|
|
72
|
+
* @param {string} path - Exact statement path.
|
|
73
|
+
* @returns {void}
|
|
74
|
+
*/
|
|
75
|
+
function emitStatement(writer, statement, indent, path) {
|
|
76
|
+
if (statement.kind == "LocalDeclaration" || statement.kind == "AssignmentStatement") {
|
|
77
|
+
emitLocal(writer, statement, indent, path)
|
|
78
|
+
return
|
|
79
|
+
}
|
|
80
|
+
if (statement.kind == "IfStatement") {
|
|
81
|
+
emitIf(writer, statement, indent, path, "if")
|
|
82
|
+
return
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
writer.synthetic(indent, "indentation", [statement], [path])
|
|
86
|
+
if (statement.kind == "ReturnStatement") {
|
|
87
|
+
writer.mapped("return", {mappingKind: "anchor", node: statement, path})
|
|
88
|
+
writer.synthetic(" ", "return spacing", [statement], [path])
|
|
89
|
+
emitExpression(writer, statement.expression, `${path}/expression`, "python", identity)
|
|
90
|
+
writer.synthetic("\n", "line break", [statement], [path])
|
|
91
|
+
return
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
writer.mapped("print", {mappingKind: "anchor", node: statement, path})
|
|
95
|
+
writer.mapped("(", {mappingKind: "anchor", node: statement, path})
|
|
96
|
+
emitExpression(writer, statement.expression, `${path}/expression`, "python", identity)
|
|
97
|
+
writer.mapped(")", {mappingKind: "anchor", node: statement, path})
|
|
98
|
+
writer.synthetic("\n", "line break", [statement], [path])
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Emits a Python if or elif and its optional alternative.
|
|
103
|
+
* @param {import("./writer.js").SourceWriter} writer - Source-aware writer.
|
|
104
|
+
* @param {import("../semantic/types.js").IfStatement} statement - Branch.
|
|
105
|
+
* @param {string} indent - Leading indentation.
|
|
106
|
+
* @param {string} path - Exact branch path.
|
|
107
|
+
* @param {"if" | "elif"} keyword - Branch keyword.
|
|
108
|
+
* @returns {void}
|
|
109
|
+
*/
|
|
110
|
+
function emitIf(writer, statement, indent, path, keyword) {
|
|
111
|
+
writer.synthetic(indent, "indentation", [statement], [path])
|
|
112
|
+
writer.mapped(keyword, {mappingKind: "anchor", node: statement, path})
|
|
113
|
+
writer.synthetic(" ", "conditional spacing", [statement], [path])
|
|
114
|
+
emitExpression(writer, statement.condition, `${path}/condition`, "python", identity)
|
|
115
|
+
writer.mapped(":", {mappingKind: "anchor", node: statement.consequent, path: `${path}/consequent`})
|
|
116
|
+
writer.synthetic("\n", "line break", [statement], [path])
|
|
117
|
+
emitBlock(writer, statement.consequent, `${indent} `, `${path}/consequent`)
|
|
118
|
+
|
|
119
|
+
if (!statement.alternate) return
|
|
120
|
+
if (statement.alternate.statements.length == 1 && statement.alternate.statements[0].kind == "IfStatement") {
|
|
121
|
+
emitIf(writer, statement.alternate.statements[0], indent, `${path}/alternate/statements/0`, "elif")
|
|
122
|
+
return
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
writer.synthetic(indent, "indentation", [statement], [path])
|
|
126
|
+
writer.mapped("else", {mappingKind: "anchor", node: statement, path})
|
|
127
|
+
writer.mapped(":", {mappingKind: "anchor", node: statement.alternate, path: `${path}/alternate`})
|
|
128
|
+
writer.synthetic("\n", "line break", [statement], [path])
|
|
129
|
+
emitBlock(writer, statement.alternate, `${indent} `, `${path}/alternate`)
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Emits one annotated local declaration or plain assignment.
|
|
134
|
+
* @param {import("./writer.js").SourceWriter} writer - Source-aware writer.
|
|
135
|
+
* @param {import("../semantic/types.js").LocalStatement} statement - Local statement.
|
|
136
|
+
* @param {string} indent - Leading indentation.
|
|
137
|
+
* @param {string} path - Exact statement path.
|
|
138
|
+
* @returns {void}
|
|
139
|
+
*/
|
|
140
|
+
function emitLocal(writer, statement, indent, path) {
|
|
141
|
+
if (statement.kind == "LocalDeclaration" && !statement.mutable) {
|
|
142
|
+
writer.synthetic(`${indent}# @semantifold-immutable\n`, "Python immutable local carrier", [statement], [path])
|
|
143
|
+
}
|
|
144
|
+
writer.synthetic(indent, "indentation", [statement], [path])
|
|
145
|
+
|
|
146
|
+
if (statement.kind == "AssignmentStatement") {
|
|
147
|
+
writer.mapped(statement.target.name, {mappingKind: "exact", node: statement.target, path: `${path}/target`, role: "name"})
|
|
148
|
+
writer.synthetic(" ", "assignment spacing", [statement], [path])
|
|
149
|
+
writer.mapped("=", {mappingKind: "exact", node: statement, path, role: "operator"})
|
|
150
|
+
writer.synthetic(" ", "assignment spacing", [statement], [path])
|
|
151
|
+
emitExpression(writer, statement.expression, `${path}/expression`, "python", identity)
|
|
152
|
+
writer.synthetic("\n", "line break", [statement], [path])
|
|
153
|
+
return
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
writer.mapped(statement.name, {mappingKind: "exact", node: statement, path, role: "name"})
|
|
157
|
+
writer.synthetic(": ", "Python annotation separator", [statement], [path])
|
|
158
|
+
writer.mapped(emitScalarType("python", statement.type), {
|
|
159
|
+
mappingKind: "exact", node: statement.type, path: `${path}/type`, role: "type"
|
|
160
|
+
})
|
|
161
|
+
writer.synthetic(" ", "assignment spacing", [statement], [path])
|
|
162
|
+
writer.mapped("=", {mappingKind: "exact", node: statement, path, role: "operator"})
|
|
163
|
+
writer.synthetic(" ", "assignment spacing", [statement], [path])
|
|
164
|
+
emitExpression(writer, statement.initializer, `${path}/initializer`, "python", identity)
|
|
165
|
+
writer.synthetic("\n", "line break", [statement], [path])
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Returns one unchanged Python identifier.
|
|
170
|
+
* @param {string} name - Semantic identifier.
|
|
171
|
+
* @returns {string} Unchanged Python identifier.
|
|
172
|
+
*/
|
|
173
|
+
function identity(name) {
|
|
174
|
+
return name
|
|
175
|
+
}
|
package/src/backends/scalars.js
CHANGED
|
@@ -2,9 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
/** @type {Readonly<Record<import("../semantic/types.js").SemanticLanguage, Readonly<Record<import("../semantic/types.js").SemanticTypeName, string>>>>} */
|
|
4
4
|
const targetScalarTypes = Object.freeze({
|
|
5
|
+
cpp: Object.freeze({boolean: "bool", integer: "std::int64_t", string: "std::string"}),
|
|
6
|
+
c: Object.freeze({boolean: "bool", integer: "int64_t", string: "SemantifoldString"}),
|
|
7
|
+
csharp: Object.freeze({boolean: "bool", integer: "long", string: "string"}),
|
|
8
|
+
go: Object.freeze({boolean: "bool", integer: "int64", string: "string"}),
|
|
5
9
|
java: Object.freeze({boolean: "boolean", integer: "int", string: "String"}),
|
|
6
10
|
javascript: Object.freeze({boolean: "boolean", integer: "number", string: "string"}),
|
|
7
11
|
php: Object.freeze({boolean: "bool", integer: "int", string: "string"}),
|
|
12
|
+
python: Object.freeze({boolean: "bool", integer: "int", string: "str"}),
|
|
8
13
|
ruby: Object.freeze({boolean: "bool", integer: "Integer", string: "String"}),
|
|
9
14
|
typescript: Object.freeze({boolean: "boolean", integer: "number", string: "string"})
|
|
10
15
|
})
|
|
@@ -34,7 +39,9 @@ export function emitStringLiteral(language, value) {
|
|
|
34
39
|
|
|
35
40
|
if (typeof literal != "string") throw new TypeError("A validated semantic string did not serialize.")
|
|
36
41
|
|
|
37
|
-
|
|
42
|
+
const escapedLineSeparators = literal.replaceAll("\u2028", "\\u2028").replaceAll("\u2029", "\\u2029")
|
|
43
|
+
|
|
44
|
+
return language == "csharp" ? escapedLineSeparators.replaceAll("\u0085", "\\u0085") : escapedLineSeparators
|
|
38
45
|
}
|
|
39
46
|
|
|
40
47
|
/**
|
package/src/backends/shared.js
CHANGED
|
@@ -7,12 +7,12 @@ import {emitStringLiteral} from "./scalars.js"
|
|
|
7
7
|
|
|
8
8
|
/** @type {Readonly<Record<import("../semantic/types.js").SemanticUnaryOperation, string>>} */
|
|
9
9
|
const unaryOperationSyntax = Object.freeze({BooleanNot: "!", IntegerNegate: "-"})
|
|
10
|
-
/** @type {Readonly<Record<import("../semantic/types.js").SemanticBinaryOperation, Readonly<{default: string, php?: string, strict?: string}>>>} */
|
|
10
|
+
/** @type {Readonly<Record<import("../semantic/types.js").SemanticBinaryOperation, Readonly<{default: string, php?: string, python?: string, strict?: string}>>>} */
|
|
11
11
|
const binaryOperationSyntax = Object.freeze({
|
|
12
|
-
BooleanAnd: Object.freeze({default: "&&"}),
|
|
12
|
+
BooleanAnd: Object.freeze({default: "&&", python: "and"}),
|
|
13
13
|
BooleanEqual: Object.freeze({default: "==", strict: "==="}),
|
|
14
14
|
BooleanNotEqual: Object.freeze({default: "!=", strict: "!=="}),
|
|
15
|
-
BooleanOr: Object.freeze({default: "||"}),
|
|
15
|
+
BooleanOr: Object.freeze({default: "||", python: "or"}),
|
|
16
16
|
IntegerAdd: Object.freeze({default: "+"}),
|
|
17
17
|
IntegerEqual: Object.freeze({default: "==", strict: "==="}),
|
|
18
18
|
IntegerGreaterThan: Object.freeze({default: ">"}),
|
|
@@ -34,11 +34,20 @@ const binaryOperationSyntax = Object.freeze({
|
|
|
34
34
|
* @returns {void}
|
|
35
35
|
*/
|
|
36
36
|
export function validateBackendModule(module, language) {
|
|
37
|
+
if (!module || typeof module != "object" || Array.isArray(module)) {
|
|
38
|
+
return unsupportedCapability(language, "missing or invalid module", undefined)
|
|
39
|
+
}
|
|
37
40
|
if (module.kind != "Module") unsupportedCapability(language, module.kind, module.location)
|
|
41
|
+
if (!Array.isArray(module.functions) || !module.entryPoint || typeof module.entryPoint != "object" ||
|
|
42
|
+
module.entryPoint.kind != "EntryPoint") unsupportedCapability(language, "missing or invalid module members", module.location)
|
|
38
43
|
if (module.functions.length == 0) unsupportedCapability(language, "module without functions", module.location)
|
|
39
44
|
validateBlock(module.entryPoint.body, language, module.entryPoint.location)
|
|
40
45
|
|
|
41
46
|
for (const functionDeclaration of module.functions) {
|
|
47
|
+
if (!functionDeclaration || typeof functionDeclaration != "object" || Array.isArray(functionDeclaration) ||
|
|
48
|
+
functionDeclaration.kind != "FunctionDeclaration" || !Array.isArray(functionDeclaration.parameters)) {
|
|
49
|
+
unsupportedCapability(language, "missing or invalid function declaration", module.location)
|
|
50
|
+
}
|
|
42
51
|
validateTargetBindingIdentifier(language, functionDeclaration.name, "function", functionDeclaration.location)
|
|
43
52
|
|
|
44
53
|
if (functionDeclaration.parameters.length != 2) {
|
|
@@ -47,10 +56,11 @@ export function validateBackendModule(module, language) {
|
|
|
47
56
|
validateBlock(functionDeclaration.body, language, functionDeclaration.location)
|
|
48
57
|
|
|
49
58
|
for (const parameter of functionDeclaration.parameters) {
|
|
59
|
+
if (!parameter || typeof parameter != "object" || Array.isArray(parameter) || parameter.kind != "Parameter") {
|
|
60
|
+
unsupportedCapability(language, "missing or invalid parameter", functionDeclaration.location)
|
|
61
|
+
}
|
|
50
62
|
validateTargetBindingIdentifier(language, parameter.name, "parameter", parameter.location)
|
|
51
|
-
|
|
52
63
|
}
|
|
53
|
-
|
|
54
64
|
}
|
|
55
65
|
validateScaffoldingNames(module, language)
|
|
56
66
|
validateBackendTypes(module, language)
|
|
@@ -63,11 +73,17 @@ export function validateBackendModule(module, language) {
|
|
|
63
73
|
* @returns {void}
|
|
64
74
|
*/
|
|
65
75
|
function validateScaffoldingNames(module, language) {
|
|
66
|
-
const ownedEntryNames = language == "
|
|
76
|
+
const ownedEntryNames = language == "go" ? new Set(["fmt", "int64", "bool", "string", "true", "false"]) :
|
|
77
|
+
language == "csharp" ? new Set(["System"]) : language == "java" ? new Set(["args", "System"]) :
|
|
67
78
|
["javascript", "typescript"].includes(language) ? new Set(["console"]) : new Set()
|
|
68
|
-
const ownedPrintReceiverNames = language == "
|
|
79
|
+
const ownedPrintReceiverNames = language == "go" ? new Set(["fmt", "int64", "bool", "string", "true", "false"]) :
|
|
80
|
+
language == "csharp" || language == "java" ? new Set(["System"]) :
|
|
69
81
|
["javascript", "typescript"].includes(language) ? new Set(["console"]) : new Set()
|
|
70
|
-
const ownedCallableNames =
|
|
82
|
+
const ownedCallableNames = language == "go" ? new Set(["main", "init", "fmt", "int64", "bool", "string", "true", "false"]) :
|
|
83
|
+
language == "csharp" ? new Set([
|
|
84
|
+
"Equals", "Finalize", "GetHashCode", "GetType", "Main", "MemberwiseClone", "Program", "ReferenceEquals", "System", "ToString"
|
|
85
|
+
]) :
|
|
86
|
+
["javascript", "typescript"].includes(language) ? new Set(["console"]) :
|
|
71
87
|
language == "ruby" ? new Set(["puts"]) : new Set()
|
|
72
88
|
|
|
73
89
|
for (const statement of allStatements(module.entryPoint.body)) {
|
|
@@ -229,6 +245,10 @@ function validateExpression(expression, language, ownerLocation, allowJavaNegate
|
|
|
229
245
|
if (language == "java" && !validNegatedMinimumOperand && (candidate.value < -2147483648 || candidate.value > 2147483647)) {
|
|
230
246
|
unsupportedCapability(language, "integer literal outside signed 32-bit int range", location)
|
|
231
247
|
}
|
|
248
|
+
if ((language == "csharp" || language == "go" || language == "c" || language == "cpp") && candidate.value < 0 ||
|
|
249
|
+
(language == "c" || language == "cpp") && Object.is(candidate.value, -0)) {
|
|
250
|
+
unsupportedCapability(language, "negative integer literal without semantic negation", location)
|
|
251
|
+
}
|
|
232
252
|
return
|
|
233
253
|
}
|
|
234
254
|
if (candidate.kind == "BooleanLiteral" || candidate.kind == "StringLiteral") return
|
|
@@ -248,7 +268,7 @@ function validateExpression(expression, language, ownerLocation, allowJavaNegate
|
|
|
248
268
|
unsupportedCapability(language, `unary operation ${String(candidate.operation)}`, location)
|
|
249
269
|
}
|
|
250
270
|
validateExpression(candidate.operand, language, location, candidate.operation == "IntegerNegate")
|
|
251
|
-
|
|
271
|
+
validateKnownTargetInteger(candidate, language, location)
|
|
252
272
|
return
|
|
253
273
|
}
|
|
254
274
|
if (candidate.kind == "BinaryExpression") {
|
|
@@ -257,7 +277,7 @@ function validateExpression(expression, language, ownerLocation, allowJavaNegate
|
|
|
257
277
|
}
|
|
258
278
|
validateExpression(candidate.left, language, location)
|
|
259
279
|
validateExpression(candidate.right, language, location)
|
|
260
|
-
|
|
280
|
+
validateKnownTargetInteger(candidate, language, location)
|
|
261
281
|
return
|
|
262
282
|
}
|
|
263
283
|
|
|
@@ -271,14 +291,16 @@ function validateExpression(expression, language, ownerLocation, allowJavaNegate
|
|
|
271
291
|
* @param {import("../semantic/types.js").SourceLocation | undefined} location - Operation location.
|
|
272
292
|
* @returns {void}
|
|
273
293
|
*/
|
|
274
|
-
function
|
|
275
|
-
if (language != "java") return
|
|
276
|
-
|
|
294
|
+
function validateKnownTargetInteger(expression, language, location) {
|
|
277
295
|
const value = knownIntegerValue(expression)
|
|
278
296
|
|
|
279
|
-
if (value !== undefined && (value < -2147483648n || value > 2147483647n)) {
|
|
297
|
+
if (language == "java" && value !== undefined && (value < -2147483648n || value > 2147483647n)) {
|
|
280
298
|
unsupportedCapability(language, "compile-time-known integer operation outside signed 32-bit int range", location)
|
|
281
299
|
}
|
|
300
|
+
if ((language == "csharp" || language == "go" || language == "c" || language == "cpp") && value !== undefined &&
|
|
301
|
+
(value < -9223372036854775808n || value > 9223372036854775807n)) {
|
|
302
|
+
unsupportedCapability(language, "compile-time-known integer operation outside signed 64-bit long range", location)
|
|
303
|
+
}
|
|
282
304
|
}
|
|
283
305
|
|
|
284
306
|
/**
|
|
@@ -321,11 +343,15 @@ export function emitExpression(writer, expression, path, language, emitIdentifie
|
|
|
321
343
|
return
|
|
322
344
|
}
|
|
323
345
|
if (expression.kind == "IntegerLiteral") {
|
|
324
|
-
|
|
346
|
+
const spelling = language == "csharp" ? `${expression.value}L` : String(expression.value)
|
|
347
|
+
|
|
348
|
+
writer.mapped(spelling, {mappingKind: "exact", node: expression, path, role: "literal"})
|
|
325
349
|
return
|
|
326
350
|
}
|
|
327
351
|
if (expression.kind == "BooleanLiteral") {
|
|
328
|
-
|
|
352
|
+
const spelling = language == "python" ? expression.value ? "True" : "False" : expression.value ? "true" : "false"
|
|
353
|
+
|
|
354
|
+
writer.mapped(spelling, {mappingKind: "exact", node: expression, path, role: "literal"})
|
|
329
355
|
return
|
|
330
356
|
}
|
|
331
357
|
if (expression.kind == "StringLiteral") {
|
|
@@ -344,8 +370,15 @@ export function emitExpression(writer, expression, path, language, emitIdentifie
|
|
|
344
370
|
}
|
|
345
371
|
|
|
346
372
|
if (expression.kind == "UnaryExpression") {
|
|
373
|
+
if (language == "csharp" && expression.operation == "IntegerNegate") {
|
|
374
|
+
writer.mapped("checked(", {mappingKind: "anchor", node: expression, path})
|
|
375
|
+
writer.mapped("-", {mappingKind: "exact", node: expression, path, role: "operator"})
|
|
376
|
+
emitExpression(writer, expression.operand, `${path}/operand`, language, emitIdentifier)
|
|
377
|
+
writer.mapped(")", {mappingKind: "anchor", node: expression, path})
|
|
378
|
+
return
|
|
379
|
+
}
|
|
347
380
|
writer.mapped("(", {mappingKind: "anchor", node: expression, path})
|
|
348
|
-
writer.mapped(unaryOperationSyntax[expression.operation], {
|
|
381
|
+
writer.mapped(language == "python" && expression.operation == "BooleanNot" ? "not " : unaryOperationSyntax[expression.operation], {
|
|
349
382
|
mappingKind: "exact", node: expression, path, role: "operator"
|
|
350
383
|
})
|
|
351
384
|
emitExpression(writer, expression.operand, `${path}/operand`, language, emitIdentifier)
|
|
@@ -353,6 +386,19 @@ export function emitExpression(writer, expression, path, language, emitIdentifie
|
|
|
353
386
|
return
|
|
354
387
|
}
|
|
355
388
|
|
|
389
|
+
if (language == "csharp" && ["IntegerAdd", "IntegerSubtract", "IntegerMultiply"].includes(expression.operation)) {
|
|
390
|
+
writer.mapped("checked(", {mappingKind: "anchor", node: expression, path})
|
|
391
|
+
emitExpression(writer, expression.left, `${path}/left`, language, emitIdentifier)
|
|
392
|
+
writer.synthetic(" ", "operator spacing", [expression], [path])
|
|
393
|
+
writer.mapped(binaryOperationSpelling(expression.operation, language), {
|
|
394
|
+
mappingKind: "exact", node: expression, path, role: "operator"
|
|
395
|
+
})
|
|
396
|
+
writer.synthetic(" ", "operator spacing", [expression], [path])
|
|
397
|
+
emitExpression(writer, expression.right, `${path}/right`, language, emitIdentifier)
|
|
398
|
+
writer.mapped(")", {mappingKind: "anchor", node: expression, path})
|
|
399
|
+
return
|
|
400
|
+
}
|
|
401
|
+
|
|
356
402
|
if (language == "java" && (expression.operation == "StringEqual" || expression.operation == "StringNotEqual")) {
|
|
357
403
|
const compositeOperator = expression.operation == "StringNotEqual" && writer.hasRange(expression, path, "equalityOperator")
|
|
358
404
|
|
|
@@ -450,6 +496,7 @@ function binaryOperationSpelling(operation, language) {
|
|
|
450
496
|
const syntax = binaryOperationSyntax[operation]
|
|
451
497
|
|
|
452
498
|
if (language == "php" && syntax.php) return syntax.php
|
|
499
|
+
if (language == "python" && syntax.python) return syntax.python
|
|
453
500
|
if ((language == "php" || language == "javascript" || language == "typescript") && syntax.strict) return syntax.strict
|
|
454
501
|
|
|
455
502
|
return syntax.default
|