@coana-tech/cli 14.12.76 → 14.12.77
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/cli.mjs +1 -1
- package/package.json +1 -1
- package/reachability-analyzers-cli.mjs +1 -1
- package/repos/coana-tech/alucard/alucard.jar +0 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/cli.mjs +24669 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/node-addon-api/LICENSE.md +9 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/node-addon-api/README.md +95 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/node-addon-api/common.gypi +21 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/node-addon-api/except.gypi +25 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/node-addon-api/index.js +14 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/node-addon-api/napi-inl.deprecated.h +186 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/node-addon-api/napi-inl.h +6941 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/node-addon-api/napi.h +3295 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/node-addon-api/node_addon_api.gyp +42 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/node-addon-api/node_api.gyp +9 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/node-addon-api/noexcept.gypi +26 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/node-addon-api/nothing.c +0 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/node-addon-api/package-support.json +21 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/node-addon-api/package.json +480 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/node-addon-api/tools/README.md +73 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/node-addon-api/tools/check-napi.js +99 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/node-addon-api/tools/clang-format.js +71 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/node-addon-api/tools/conversion.js +301 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/node-gyp-build/LICENSE +21 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/node-gyp-build/README.md +58 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/node-gyp-build/SECURITY.md +5 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/node-gyp-build/bin.js +84 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/node-gyp-build/build-test.js +19 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/node-gyp-build/index.js +6 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/node-gyp-build/node-gyp-build.js +207 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/node-gyp-build/optional.js +7 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/node-gyp-build/package.json +43 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/LICENSE +21 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/README.md +128 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/binding.gyp +80 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/index.js +919 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/node_modules/.bin/node-gyp-build +16 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/node_modules/.bin/node-gyp-build-optional +16 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/node_modules/.bin/node-gyp-build-test +16 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/package.json +76 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/prebuilds/darwin-arm64/tree-sitter.node +0 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/prebuilds/darwin-x64/tree-sitter.node +0 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/prebuilds/linux-arm64/tree-sitter.node +0 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/prebuilds/linux-x64/tree-sitter.node +0 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/prebuilds/win32-arm64/tree-sitter.node +0 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/prebuilds/win32-x64/tree-sitter.node +0 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/src/addon_data.h +47 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/src/binding.cc +35 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/src/conversions.cc +140 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/src/conversions.h +22 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/src/language.cc +106 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/src/language.h +17 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/src/logger.cc +70 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/src/logger.h +19 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/src/lookaheaditerator.cc +122 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/src/lookaheaditerator.h +33 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/src/node.cc +1088 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/src/node.h +30 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/src/parser.cc +306 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/src/parser.h +35 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/src/query.cc +397 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/src/query.h +40 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/src/tree.cc +316 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/src/tree.h +45 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/src/tree_cursor.cc +213 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/src/tree_cursor.h +52 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/tree-sitter.d.ts +1042 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/vendor/tree-sitter/lib/include/tree_sitter/api.h +1318 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/vendor/tree-sitter/lib/src/alloc.c +48 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/vendor/tree-sitter/lib/src/alloc.h +41 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/vendor/tree-sitter/lib/src/array.h +291 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/vendor/tree-sitter/lib/src/atomic.h +68 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/vendor/tree-sitter/lib/src/clock.h +146 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/vendor/tree-sitter/lib/src/error_costs.h +11 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/vendor/tree-sitter/lib/src/get_changed_ranges.c +501 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/vendor/tree-sitter/lib/src/get_changed_ranges.h +36 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/vendor/tree-sitter/lib/src/host.h +21 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/vendor/tree-sitter/lib/src/language.c +223 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/vendor/tree-sitter/lib/src/language.h +297 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/vendor/tree-sitter/lib/src/length.h +52 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/vendor/tree-sitter/lib/src/lexer.c +435 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/vendor/tree-sitter/lib/src/lexer.h +49 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/vendor/tree-sitter/lib/src/lib.c +12 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/vendor/tree-sitter/lib/src/node.c +920 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/vendor/tree-sitter/lib/src/parser.c +2165 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/vendor/tree-sitter/lib/src/parser.h +266 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/vendor/tree-sitter/lib/src/point.h +62 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/vendor/tree-sitter/lib/src/portable/endian.h +206 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/vendor/tree-sitter/lib/src/query.c +4187 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/vendor/tree-sitter/lib/src/reduce_action.h +34 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/vendor/tree-sitter/lib/src/reusable_node.h +95 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/vendor/tree-sitter/lib/src/stack.c +899 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/vendor/tree-sitter/lib/src/stack.h +130 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/vendor/tree-sitter/lib/src/subtree.c +1066 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/vendor/tree-sitter/lib/src/subtree.h +399 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/vendor/tree-sitter/lib/src/tree.c +170 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/vendor/tree-sitter/lib/src/tree.h +31 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/vendor/tree-sitter/lib/src/tree_cursor.c +712 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/vendor/tree-sitter/lib/src/tree_cursor.h +48 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/vendor/tree-sitter/lib/src/ts_assert.h +11 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/ICU_SHA +1 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/LICENSE +414 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/README.md +29 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/ptypes.h +1 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/umachine.h +448 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/urename.h +1 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/utf.h +1 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/utf16.h +733 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/utf8.h +881 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode.h +83 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/vendor/tree-sitter/lib/src/wasm/stdlib-symbols.txt +24 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/vendor/tree-sitter/lib/src/wasm/stdlib.c +109 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/vendor/tree-sitter/lib/src/wasm/wasm-stdlib.h +1302 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/vendor/tree-sitter/lib/src/wasm_store.c +1859 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter/vendor/tree-sitter/lib/src/wasm_store.h +31 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter-ruby/LICENSE +22 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter-ruby/README.md +21 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter-ruby/binding.gyp +30 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter-ruby/bindings/node/binding.cc +20 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter-ruby/bindings/node/binding_test.js +9 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter-ruby/bindings/node/index.d.ts +28 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter-ruby/bindings/node/index.js +11 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter-ruby/grammar.js +1281 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter-ruby/node_modules/.bin/node-gyp-build +16 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter-ruby/node_modules/.bin/node-gyp-build-optional +16 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter-ruby/node_modules/.bin/node-gyp-build-test +16 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter-ruby/package.json +77 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter-ruby/prebuilds/darwin-arm64/tree-sitter-ruby.node +0 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter-ruby/prebuilds/darwin-x64/tree-sitter-ruby.node +0 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter-ruby/prebuilds/linux-arm64/tree-sitter-ruby.node +0 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter-ruby/prebuilds/linux-x64/tree-sitter-ruby.node +0 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter-ruby/prebuilds/win32-arm64/tree-sitter-ruby.node +0 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter-ruby/prebuilds/win32-x64/tree-sitter-ruby.node +0 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter-ruby/queries/highlights.scm +154 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter-ruby/queries/locals.scm +27 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter-ruby/queries/tags.scm +64 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter-ruby/src/grammar.json +8364 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter-ruby/src/node-types.json +4108 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter-ruby/src/parser.c +471247 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter-ruby/src/scanner.c +1107 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter-ruby/src/tree_sitter/alloc.h +54 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter-ruby/src/tree_sitter/array.h +290 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter-ruby/src/tree_sitter/parser.h +266 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter-ruby/tree-sitter-ruby.wasm +0 -0
- package/repos/coana-tech/callgraph-reachability-analyzers/packages/cli/dist/bundle/node_modules/tree-sitter-ruby/tree-sitter.json +46 -0
- package/repos/coana-tech/goana/bin/goana-darwin-amd64.gz +0 -0
- package/repos/coana-tech/goana/bin/goana-darwin-arm64.gz +0 -0
- package/repos/coana-tech/goana/bin/goana-linux-amd64.gz +0 -0
- package/repos/coana-tech/goana/bin/goana-linux-arm64.gz +0 -0
|
@@ -0,0 +1,1066 @@
|
|
|
1
|
+
#include <ctype.h>
|
|
2
|
+
#include <stdint.h>
|
|
3
|
+
#include <stdbool.h>
|
|
4
|
+
#include <string.h>
|
|
5
|
+
#include <stdio.h>
|
|
6
|
+
#include "./alloc.h"
|
|
7
|
+
#include "./array.h"
|
|
8
|
+
#include "./atomic.h"
|
|
9
|
+
#include "./subtree.h"
|
|
10
|
+
#include "./length.h"
|
|
11
|
+
#include "./language.h"
|
|
12
|
+
#include "./error_costs.h"
|
|
13
|
+
#include "./ts_assert.h"
|
|
14
|
+
#include <stddef.h>
|
|
15
|
+
|
|
16
|
+
typedef struct {
|
|
17
|
+
Length start;
|
|
18
|
+
Length old_end;
|
|
19
|
+
Length new_end;
|
|
20
|
+
} Edit;
|
|
21
|
+
|
|
22
|
+
#define TS_MAX_INLINE_TREE_LENGTH UINT8_MAX
|
|
23
|
+
#define TS_MAX_TREE_POOL_SIZE 32
|
|
24
|
+
|
|
25
|
+
// ExternalScannerState
|
|
26
|
+
|
|
27
|
+
void ts_external_scanner_state_init(ExternalScannerState *self, const char *data, unsigned length) {
|
|
28
|
+
self->length = length;
|
|
29
|
+
if (length > sizeof(self->short_data)) {
|
|
30
|
+
self->long_data = ts_malloc(length);
|
|
31
|
+
memcpy(self->long_data, data, length);
|
|
32
|
+
} else {
|
|
33
|
+
memcpy(self->short_data, data, length);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
ExternalScannerState ts_external_scanner_state_copy(const ExternalScannerState *self) {
|
|
38
|
+
ExternalScannerState result = *self;
|
|
39
|
+
if (self->length > sizeof(self->short_data)) {
|
|
40
|
+
result.long_data = ts_malloc(self->length);
|
|
41
|
+
memcpy(result.long_data, self->long_data, self->length);
|
|
42
|
+
}
|
|
43
|
+
return result;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
void ts_external_scanner_state_delete(ExternalScannerState *self) {
|
|
47
|
+
if (self->length > sizeof(self->short_data)) {
|
|
48
|
+
ts_free(self->long_data);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const char *ts_external_scanner_state_data(const ExternalScannerState *self) {
|
|
53
|
+
if (self->length > sizeof(self->short_data)) {
|
|
54
|
+
return self->long_data;
|
|
55
|
+
} else {
|
|
56
|
+
return self->short_data;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
bool ts_external_scanner_state_eq(const ExternalScannerState *self, const char *buffer, unsigned length) {
|
|
61
|
+
return
|
|
62
|
+
self->length == length &&
|
|
63
|
+
memcmp(ts_external_scanner_state_data(self), buffer, length) == 0;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// SubtreeArray
|
|
67
|
+
|
|
68
|
+
void ts_subtree_array_copy(SubtreeArray self, SubtreeArray *dest) {
|
|
69
|
+
dest->size = self.size;
|
|
70
|
+
dest->capacity = self.capacity;
|
|
71
|
+
dest->contents = self.contents;
|
|
72
|
+
if (self.capacity > 0) {
|
|
73
|
+
dest->contents = ts_calloc(self.capacity, sizeof(Subtree));
|
|
74
|
+
memcpy(dest->contents, self.contents, self.size * sizeof(Subtree));
|
|
75
|
+
for (uint32_t i = 0; i < self.size; i++) {
|
|
76
|
+
ts_subtree_retain(dest->contents[i]);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
void ts_subtree_array_clear(SubtreePool *pool, SubtreeArray *self) {
|
|
82
|
+
for (uint32_t i = 0; i < self->size; i++) {
|
|
83
|
+
ts_subtree_release(pool, self->contents[i]);
|
|
84
|
+
}
|
|
85
|
+
array_clear(self);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
void ts_subtree_array_delete(SubtreePool *pool, SubtreeArray *self) {
|
|
89
|
+
ts_subtree_array_clear(pool, self);
|
|
90
|
+
array_delete(self);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
void ts_subtree_array_remove_trailing_extras(
|
|
94
|
+
SubtreeArray *self,
|
|
95
|
+
SubtreeArray *destination
|
|
96
|
+
) {
|
|
97
|
+
array_clear(destination);
|
|
98
|
+
while (self->size > 0) {
|
|
99
|
+
Subtree last = self->contents[self->size - 1];
|
|
100
|
+
if (ts_subtree_extra(last)) {
|
|
101
|
+
self->size--;
|
|
102
|
+
array_push(destination, last);
|
|
103
|
+
} else {
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
ts_subtree_array_reverse(destination);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
void ts_subtree_array_reverse(SubtreeArray *self) {
|
|
111
|
+
for (uint32_t i = 0, limit = self->size / 2; i < limit; i++) {
|
|
112
|
+
size_t reverse_index = self->size - 1 - i;
|
|
113
|
+
Subtree swap = self->contents[i];
|
|
114
|
+
self->contents[i] = self->contents[reverse_index];
|
|
115
|
+
self->contents[reverse_index] = swap;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// SubtreePool
|
|
120
|
+
|
|
121
|
+
SubtreePool ts_subtree_pool_new(uint32_t capacity) {
|
|
122
|
+
SubtreePool self = {array_new(), array_new()};
|
|
123
|
+
array_reserve(&self.free_trees, capacity);
|
|
124
|
+
return self;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
void ts_subtree_pool_delete(SubtreePool *self) {
|
|
128
|
+
if (self->free_trees.contents) {
|
|
129
|
+
for (unsigned i = 0; i < self->free_trees.size; i++) {
|
|
130
|
+
ts_free(self->free_trees.contents[i].ptr);
|
|
131
|
+
}
|
|
132
|
+
array_delete(&self->free_trees);
|
|
133
|
+
}
|
|
134
|
+
if (self->tree_stack.contents) array_delete(&self->tree_stack);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
static SubtreeHeapData *ts_subtree_pool_allocate(SubtreePool *self) {
|
|
138
|
+
if (self->free_trees.size > 0) {
|
|
139
|
+
return array_pop(&self->free_trees).ptr;
|
|
140
|
+
} else {
|
|
141
|
+
return ts_malloc(sizeof(SubtreeHeapData));
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
static void ts_subtree_pool_free(SubtreePool *self, SubtreeHeapData *tree) {
|
|
146
|
+
if (self->free_trees.capacity > 0 && self->free_trees.size + 1 <= TS_MAX_TREE_POOL_SIZE) {
|
|
147
|
+
array_push(&self->free_trees, (MutableSubtree) {.ptr = tree});
|
|
148
|
+
} else {
|
|
149
|
+
ts_free(tree);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// Subtree
|
|
154
|
+
|
|
155
|
+
static inline bool ts_subtree_can_inline(Length padding, Length size, uint32_t lookahead_bytes) {
|
|
156
|
+
return
|
|
157
|
+
padding.bytes < TS_MAX_INLINE_TREE_LENGTH &&
|
|
158
|
+
padding.extent.row < 16 &&
|
|
159
|
+
padding.extent.column < TS_MAX_INLINE_TREE_LENGTH &&
|
|
160
|
+
size.extent.row == 0 &&
|
|
161
|
+
size.extent.column < TS_MAX_INLINE_TREE_LENGTH &&
|
|
162
|
+
lookahead_bytes < 16;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
Subtree ts_subtree_new_leaf(
|
|
166
|
+
SubtreePool *pool, TSSymbol symbol, Length padding, Length size,
|
|
167
|
+
uint32_t lookahead_bytes, TSStateId parse_state,
|
|
168
|
+
bool has_external_tokens, bool depends_on_column,
|
|
169
|
+
bool is_keyword, const TSLanguage *language
|
|
170
|
+
) {
|
|
171
|
+
TSSymbolMetadata metadata = ts_language_symbol_metadata(language, symbol);
|
|
172
|
+
bool extra = symbol == ts_builtin_sym_end;
|
|
173
|
+
|
|
174
|
+
bool is_inline = (
|
|
175
|
+
symbol <= UINT8_MAX &&
|
|
176
|
+
!has_external_tokens &&
|
|
177
|
+
ts_subtree_can_inline(padding, size, lookahead_bytes)
|
|
178
|
+
);
|
|
179
|
+
|
|
180
|
+
if (is_inline) {
|
|
181
|
+
return (Subtree) {{
|
|
182
|
+
.parse_state = parse_state,
|
|
183
|
+
.symbol = symbol,
|
|
184
|
+
.padding_bytes = padding.bytes,
|
|
185
|
+
.padding_rows = padding.extent.row,
|
|
186
|
+
.padding_columns = padding.extent.column,
|
|
187
|
+
.size_bytes = size.bytes,
|
|
188
|
+
.lookahead_bytes = lookahead_bytes,
|
|
189
|
+
.visible = metadata.visible,
|
|
190
|
+
.named = metadata.named,
|
|
191
|
+
.extra = extra,
|
|
192
|
+
.has_changes = false,
|
|
193
|
+
.is_missing = false,
|
|
194
|
+
.is_keyword = is_keyword,
|
|
195
|
+
.is_inline = true,
|
|
196
|
+
}};
|
|
197
|
+
} else {
|
|
198
|
+
SubtreeHeapData *data = ts_subtree_pool_allocate(pool);
|
|
199
|
+
*data = (SubtreeHeapData) {
|
|
200
|
+
.ref_count = 1,
|
|
201
|
+
.padding = padding,
|
|
202
|
+
.size = size,
|
|
203
|
+
.lookahead_bytes = lookahead_bytes,
|
|
204
|
+
.error_cost = 0,
|
|
205
|
+
.child_count = 0,
|
|
206
|
+
.symbol = symbol,
|
|
207
|
+
.parse_state = parse_state,
|
|
208
|
+
.visible = metadata.visible,
|
|
209
|
+
.named = metadata.named,
|
|
210
|
+
.extra = extra,
|
|
211
|
+
.fragile_left = false,
|
|
212
|
+
.fragile_right = false,
|
|
213
|
+
.has_changes = false,
|
|
214
|
+
.has_external_tokens = has_external_tokens,
|
|
215
|
+
.has_external_scanner_state_change = false,
|
|
216
|
+
.depends_on_column = depends_on_column,
|
|
217
|
+
.is_missing = false,
|
|
218
|
+
.is_keyword = is_keyword,
|
|
219
|
+
{{.first_leaf = {.symbol = 0, .parse_state = 0}}}
|
|
220
|
+
};
|
|
221
|
+
return (Subtree) {.ptr = data};
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
void ts_subtree_set_symbol(
|
|
226
|
+
MutableSubtree *self,
|
|
227
|
+
TSSymbol symbol,
|
|
228
|
+
const TSLanguage *language
|
|
229
|
+
) {
|
|
230
|
+
TSSymbolMetadata metadata = ts_language_symbol_metadata(language, symbol);
|
|
231
|
+
if (self->data.is_inline) {
|
|
232
|
+
ts_assert(symbol < UINT8_MAX);
|
|
233
|
+
self->data.symbol = symbol;
|
|
234
|
+
self->data.named = metadata.named;
|
|
235
|
+
self->data.visible = metadata.visible;
|
|
236
|
+
} else {
|
|
237
|
+
self->ptr->symbol = symbol;
|
|
238
|
+
self->ptr->named = metadata.named;
|
|
239
|
+
self->ptr->visible = metadata.visible;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
Subtree ts_subtree_new_error(
|
|
244
|
+
SubtreePool *pool, int32_t lookahead_char, Length padding, Length size,
|
|
245
|
+
uint32_t bytes_scanned, TSStateId parse_state, const TSLanguage *language
|
|
246
|
+
) {
|
|
247
|
+
Subtree result = ts_subtree_new_leaf(
|
|
248
|
+
pool, ts_builtin_sym_error, padding, size, bytes_scanned,
|
|
249
|
+
parse_state, false, false, false, language
|
|
250
|
+
);
|
|
251
|
+
SubtreeHeapData *data = (SubtreeHeapData *)result.ptr;
|
|
252
|
+
data->fragile_left = true;
|
|
253
|
+
data->fragile_right = true;
|
|
254
|
+
data->lookahead_char = lookahead_char;
|
|
255
|
+
return result;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// Clone a subtree.
|
|
259
|
+
MutableSubtree ts_subtree_clone(Subtree self) {
|
|
260
|
+
size_t alloc_size = ts_subtree_alloc_size(self.ptr->child_count);
|
|
261
|
+
Subtree *new_children = ts_malloc(alloc_size);
|
|
262
|
+
Subtree *old_children = ts_subtree_children(self);
|
|
263
|
+
memcpy(new_children, old_children, alloc_size);
|
|
264
|
+
SubtreeHeapData *result = (SubtreeHeapData *)&new_children[self.ptr->child_count];
|
|
265
|
+
if (self.ptr->child_count > 0) {
|
|
266
|
+
for (uint32_t i = 0; i < self.ptr->child_count; i++) {
|
|
267
|
+
ts_subtree_retain(new_children[i]);
|
|
268
|
+
}
|
|
269
|
+
} else if (self.ptr->has_external_tokens) {
|
|
270
|
+
result->external_scanner_state = ts_external_scanner_state_copy(
|
|
271
|
+
&self.ptr->external_scanner_state
|
|
272
|
+
);
|
|
273
|
+
}
|
|
274
|
+
result->ref_count = 1;
|
|
275
|
+
return (MutableSubtree) {.ptr = result};
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// Get mutable version of a subtree.
|
|
279
|
+
//
|
|
280
|
+
// This takes ownership of the subtree. If the subtree has only one owner,
|
|
281
|
+
// this will directly convert it into a mutable version. Otherwise, it will
|
|
282
|
+
// perform a copy.
|
|
283
|
+
MutableSubtree ts_subtree_make_mut(SubtreePool *pool, Subtree self) {
|
|
284
|
+
if (self.data.is_inline) return (MutableSubtree) {self.data};
|
|
285
|
+
if (self.ptr->ref_count == 1) return ts_subtree_to_mut_unsafe(self);
|
|
286
|
+
MutableSubtree result = ts_subtree_clone(self);
|
|
287
|
+
ts_subtree_release(pool, self);
|
|
288
|
+
return result;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
static void ts_subtree__compress(
|
|
292
|
+
MutableSubtree self,
|
|
293
|
+
unsigned count,
|
|
294
|
+
const TSLanguage *language,
|
|
295
|
+
MutableSubtreeArray *stack
|
|
296
|
+
) {
|
|
297
|
+
unsigned initial_stack_size = stack->size;
|
|
298
|
+
|
|
299
|
+
MutableSubtree tree = self;
|
|
300
|
+
TSSymbol symbol = tree.ptr->symbol;
|
|
301
|
+
for (unsigned i = 0; i < count; i++) {
|
|
302
|
+
if (tree.ptr->ref_count > 1 || tree.ptr->child_count < 2) break;
|
|
303
|
+
|
|
304
|
+
MutableSubtree child = ts_subtree_to_mut_unsafe(ts_subtree_children(tree)[0]);
|
|
305
|
+
if (
|
|
306
|
+
child.data.is_inline ||
|
|
307
|
+
child.ptr->child_count < 2 ||
|
|
308
|
+
child.ptr->ref_count > 1 ||
|
|
309
|
+
child.ptr->symbol != symbol
|
|
310
|
+
) break;
|
|
311
|
+
|
|
312
|
+
MutableSubtree grandchild = ts_subtree_to_mut_unsafe(ts_subtree_children(child)[0]);
|
|
313
|
+
if (
|
|
314
|
+
grandchild.data.is_inline ||
|
|
315
|
+
grandchild.ptr->child_count < 2 ||
|
|
316
|
+
grandchild.ptr->ref_count > 1 ||
|
|
317
|
+
grandchild.ptr->symbol != symbol
|
|
318
|
+
) break;
|
|
319
|
+
|
|
320
|
+
ts_subtree_children(tree)[0] = ts_subtree_from_mut(grandchild);
|
|
321
|
+
ts_subtree_children(child)[0] = ts_subtree_children(grandchild)[grandchild.ptr->child_count - 1];
|
|
322
|
+
ts_subtree_children(grandchild)[grandchild.ptr->child_count - 1] = ts_subtree_from_mut(child);
|
|
323
|
+
array_push(stack, tree);
|
|
324
|
+
tree = grandchild;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
while (stack->size > initial_stack_size) {
|
|
328
|
+
tree = array_pop(stack);
|
|
329
|
+
MutableSubtree child = ts_subtree_to_mut_unsafe(ts_subtree_children(tree)[0]);
|
|
330
|
+
MutableSubtree grandchild = ts_subtree_to_mut_unsafe(ts_subtree_children(child)[child.ptr->child_count - 1]);
|
|
331
|
+
ts_subtree_summarize_children(grandchild, language);
|
|
332
|
+
ts_subtree_summarize_children(child, language);
|
|
333
|
+
ts_subtree_summarize_children(tree, language);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
void ts_subtree_balance(Subtree self, SubtreePool *pool, const TSLanguage *language) {
|
|
338
|
+
array_clear(&pool->tree_stack);
|
|
339
|
+
|
|
340
|
+
if (ts_subtree_child_count(self) > 0 && self.ptr->ref_count == 1) {
|
|
341
|
+
array_push(&pool->tree_stack, ts_subtree_to_mut_unsafe(self));
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
while (pool->tree_stack.size > 0) {
|
|
345
|
+
MutableSubtree tree = array_pop(&pool->tree_stack);
|
|
346
|
+
|
|
347
|
+
if (tree.ptr->repeat_depth > 0) {
|
|
348
|
+
Subtree child1 = ts_subtree_children(tree)[0];
|
|
349
|
+
Subtree child2 = ts_subtree_children(tree)[tree.ptr->child_count - 1];
|
|
350
|
+
long repeat_delta = (long)ts_subtree_repeat_depth(child1) - (long)ts_subtree_repeat_depth(child2);
|
|
351
|
+
if (repeat_delta > 0) {
|
|
352
|
+
unsigned n = (unsigned)repeat_delta;
|
|
353
|
+
for (unsigned i = n / 2; i > 0; i /= 2) {
|
|
354
|
+
ts_subtree__compress(tree, i, language, &pool->tree_stack);
|
|
355
|
+
n -= i;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
for (uint32_t i = 0; i < tree.ptr->child_count; i++) {
|
|
361
|
+
Subtree child = ts_subtree_children(tree)[i];
|
|
362
|
+
if (ts_subtree_child_count(child) > 0 && child.ptr->ref_count == 1) {
|
|
363
|
+
array_push(&pool->tree_stack, ts_subtree_to_mut_unsafe(child));
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
// Assign all of the node's properties that depend on its children.
|
|
370
|
+
void ts_subtree_summarize_children(
|
|
371
|
+
MutableSubtree self,
|
|
372
|
+
const TSLanguage *language
|
|
373
|
+
) {
|
|
374
|
+
ts_assert(!self.data.is_inline);
|
|
375
|
+
|
|
376
|
+
self.ptr->named_child_count = 0;
|
|
377
|
+
self.ptr->visible_child_count = 0;
|
|
378
|
+
self.ptr->error_cost = 0;
|
|
379
|
+
self.ptr->repeat_depth = 0;
|
|
380
|
+
self.ptr->visible_descendant_count = 0;
|
|
381
|
+
self.ptr->has_external_tokens = false;
|
|
382
|
+
self.ptr->depends_on_column = false;
|
|
383
|
+
self.ptr->has_external_scanner_state_change = false;
|
|
384
|
+
self.ptr->dynamic_precedence = 0;
|
|
385
|
+
|
|
386
|
+
uint32_t structural_index = 0;
|
|
387
|
+
const TSSymbol *alias_sequence = ts_language_alias_sequence(language, self.ptr->production_id);
|
|
388
|
+
uint32_t lookahead_end_byte = 0;
|
|
389
|
+
|
|
390
|
+
const Subtree *children = ts_subtree_children(self);
|
|
391
|
+
for (uint32_t i = 0; i < self.ptr->child_count; i++) {
|
|
392
|
+
Subtree child = children[i];
|
|
393
|
+
|
|
394
|
+
if (
|
|
395
|
+
self.ptr->size.extent.row == 0 &&
|
|
396
|
+
ts_subtree_depends_on_column(child)
|
|
397
|
+
) {
|
|
398
|
+
self.ptr->depends_on_column = true;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
if (ts_subtree_has_external_scanner_state_change(child)) {
|
|
402
|
+
self.ptr->has_external_scanner_state_change = true;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
if (i == 0) {
|
|
406
|
+
self.ptr->padding = ts_subtree_padding(child);
|
|
407
|
+
self.ptr->size = ts_subtree_size(child);
|
|
408
|
+
} else {
|
|
409
|
+
self.ptr->size = length_add(self.ptr->size, ts_subtree_total_size(child));
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
uint32_t child_lookahead_end_byte =
|
|
413
|
+
self.ptr->padding.bytes +
|
|
414
|
+
self.ptr->size.bytes +
|
|
415
|
+
ts_subtree_lookahead_bytes(child);
|
|
416
|
+
if (child_lookahead_end_byte > lookahead_end_byte) {
|
|
417
|
+
lookahead_end_byte = child_lookahead_end_byte;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
if (ts_subtree_symbol(child) != ts_builtin_sym_error_repeat) {
|
|
421
|
+
self.ptr->error_cost += ts_subtree_error_cost(child);
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
uint32_t grandchild_count = ts_subtree_child_count(child);
|
|
425
|
+
if (
|
|
426
|
+
self.ptr->symbol == ts_builtin_sym_error ||
|
|
427
|
+
self.ptr->symbol == ts_builtin_sym_error_repeat
|
|
428
|
+
) {
|
|
429
|
+
if (!ts_subtree_extra(child) && !(ts_subtree_is_error(child) && grandchild_count == 0)) {
|
|
430
|
+
if (ts_subtree_visible(child)) {
|
|
431
|
+
self.ptr->error_cost += ERROR_COST_PER_SKIPPED_TREE;
|
|
432
|
+
} else if (grandchild_count > 0) {
|
|
433
|
+
self.ptr->error_cost += ERROR_COST_PER_SKIPPED_TREE * child.ptr->visible_child_count;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
self.ptr->dynamic_precedence += ts_subtree_dynamic_precedence(child);
|
|
439
|
+
self.ptr->visible_descendant_count += ts_subtree_visible_descendant_count(child);
|
|
440
|
+
|
|
441
|
+
if (alias_sequence && alias_sequence[structural_index] != 0 && !ts_subtree_extra(child)) {
|
|
442
|
+
self.ptr->visible_descendant_count++;
|
|
443
|
+
self.ptr->visible_child_count++;
|
|
444
|
+
if (ts_language_symbol_metadata(language, alias_sequence[structural_index]).named) {
|
|
445
|
+
self.ptr->named_child_count++;
|
|
446
|
+
}
|
|
447
|
+
} else if (ts_subtree_visible(child)) {
|
|
448
|
+
self.ptr->visible_descendant_count++;
|
|
449
|
+
self.ptr->visible_child_count++;
|
|
450
|
+
if (ts_subtree_named(child)) self.ptr->named_child_count++;
|
|
451
|
+
} else if (grandchild_count > 0) {
|
|
452
|
+
self.ptr->visible_child_count += child.ptr->visible_child_count;
|
|
453
|
+
self.ptr->named_child_count += child.ptr->named_child_count;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
if (ts_subtree_has_external_tokens(child)) self.ptr->has_external_tokens = true;
|
|
457
|
+
|
|
458
|
+
if (ts_subtree_is_error(child)) {
|
|
459
|
+
self.ptr->fragile_left = self.ptr->fragile_right = true;
|
|
460
|
+
self.ptr->parse_state = TS_TREE_STATE_NONE;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
if (!ts_subtree_extra(child)) structural_index++;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
self.ptr->lookahead_bytes = lookahead_end_byte - self.ptr->size.bytes - self.ptr->padding.bytes;
|
|
467
|
+
|
|
468
|
+
if (
|
|
469
|
+
self.ptr->symbol == ts_builtin_sym_error ||
|
|
470
|
+
self.ptr->symbol == ts_builtin_sym_error_repeat
|
|
471
|
+
) {
|
|
472
|
+
self.ptr->error_cost +=
|
|
473
|
+
ERROR_COST_PER_RECOVERY +
|
|
474
|
+
ERROR_COST_PER_SKIPPED_CHAR * self.ptr->size.bytes +
|
|
475
|
+
ERROR_COST_PER_SKIPPED_LINE * self.ptr->size.extent.row;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
if (self.ptr->child_count > 0) {
|
|
479
|
+
Subtree first_child = children[0];
|
|
480
|
+
Subtree last_child = children[self.ptr->child_count - 1];
|
|
481
|
+
|
|
482
|
+
self.ptr->first_leaf.symbol = ts_subtree_leaf_symbol(first_child);
|
|
483
|
+
self.ptr->first_leaf.parse_state = ts_subtree_leaf_parse_state(first_child);
|
|
484
|
+
|
|
485
|
+
if (ts_subtree_fragile_left(first_child)) self.ptr->fragile_left = true;
|
|
486
|
+
if (ts_subtree_fragile_right(last_child)) self.ptr->fragile_right = true;
|
|
487
|
+
|
|
488
|
+
if (
|
|
489
|
+
self.ptr->child_count >= 2 &&
|
|
490
|
+
!self.ptr->visible &&
|
|
491
|
+
!self.ptr->named &&
|
|
492
|
+
ts_subtree_symbol(first_child) == self.ptr->symbol
|
|
493
|
+
) {
|
|
494
|
+
if (ts_subtree_repeat_depth(first_child) > ts_subtree_repeat_depth(last_child)) {
|
|
495
|
+
self.ptr->repeat_depth = ts_subtree_repeat_depth(first_child) + 1;
|
|
496
|
+
} else {
|
|
497
|
+
self.ptr->repeat_depth = ts_subtree_repeat_depth(last_child) + 1;
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
// Create a new parent node with the given children.
|
|
504
|
+
//
|
|
505
|
+
// This takes ownership of the children array.
|
|
506
|
+
MutableSubtree ts_subtree_new_node(
|
|
507
|
+
TSSymbol symbol,
|
|
508
|
+
SubtreeArray *children,
|
|
509
|
+
unsigned production_id,
|
|
510
|
+
const TSLanguage *language
|
|
511
|
+
) {
|
|
512
|
+
TSSymbolMetadata metadata = ts_language_symbol_metadata(language, symbol);
|
|
513
|
+
bool fragile = symbol == ts_builtin_sym_error || symbol == ts_builtin_sym_error_repeat;
|
|
514
|
+
|
|
515
|
+
// Allocate the node's data at the end of the array of children.
|
|
516
|
+
size_t new_byte_size = ts_subtree_alloc_size(children->size);
|
|
517
|
+
if (children->capacity * sizeof(Subtree) < new_byte_size) {
|
|
518
|
+
children->contents = ts_realloc(children->contents, new_byte_size);
|
|
519
|
+
children->capacity = (uint32_t)(new_byte_size / sizeof(Subtree));
|
|
520
|
+
}
|
|
521
|
+
SubtreeHeapData *data = (SubtreeHeapData *)&children->contents[children->size];
|
|
522
|
+
|
|
523
|
+
*data = (SubtreeHeapData) {
|
|
524
|
+
.ref_count = 1,
|
|
525
|
+
.symbol = symbol,
|
|
526
|
+
.child_count = children->size,
|
|
527
|
+
.visible = metadata.visible,
|
|
528
|
+
.named = metadata.named,
|
|
529
|
+
.has_changes = false,
|
|
530
|
+
.has_external_scanner_state_change = false,
|
|
531
|
+
.fragile_left = fragile,
|
|
532
|
+
.fragile_right = fragile,
|
|
533
|
+
.is_keyword = false,
|
|
534
|
+
{{
|
|
535
|
+
.visible_descendant_count = 0,
|
|
536
|
+
.production_id = production_id,
|
|
537
|
+
.first_leaf = {.symbol = 0, .parse_state = 0},
|
|
538
|
+
}}
|
|
539
|
+
};
|
|
540
|
+
MutableSubtree result = {.ptr = data};
|
|
541
|
+
ts_subtree_summarize_children(result, language);
|
|
542
|
+
return result;
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
// Create a new error node containing the given children.
|
|
546
|
+
//
|
|
547
|
+
// This node is treated as 'extra'. Its children are prevented from having
|
|
548
|
+
// having any effect on the parse state.
|
|
549
|
+
Subtree ts_subtree_new_error_node(
|
|
550
|
+
SubtreeArray *children,
|
|
551
|
+
bool extra,
|
|
552
|
+
const TSLanguage *language
|
|
553
|
+
) {
|
|
554
|
+
MutableSubtree result = ts_subtree_new_node(
|
|
555
|
+
ts_builtin_sym_error, children, 0, language
|
|
556
|
+
);
|
|
557
|
+
result.ptr->extra = extra;
|
|
558
|
+
return ts_subtree_from_mut(result);
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
// Create a new 'missing leaf' node.
|
|
562
|
+
//
|
|
563
|
+
// This node is treated as 'extra'. Its children are prevented from having
|
|
564
|
+
// having any effect on the parse state.
|
|
565
|
+
Subtree ts_subtree_new_missing_leaf(
|
|
566
|
+
SubtreePool *pool,
|
|
567
|
+
TSSymbol symbol,
|
|
568
|
+
Length padding,
|
|
569
|
+
uint32_t lookahead_bytes,
|
|
570
|
+
const TSLanguage *language
|
|
571
|
+
) {
|
|
572
|
+
Subtree result = ts_subtree_new_leaf(
|
|
573
|
+
pool, symbol, padding, length_zero(), lookahead_bytes,
|
|
574
|
+
0, false, false, false, language
|
|
575
|
+
);
|
|
576
|
+
if (result.data.is_inline) {
|
|
577
|
+
result.data.is_missing = true;
|
|
578
|
+
} else {
|
|
579
|
+
((SubtreeHeapData *)result.ptr)->is_missing = true;
|
|
580
|
+
}
|
|
581
|
+
return result;
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
void ts_subtree_retain(Subtree self) {
|
|
585
|
+
if (self.data.is_inline) return;
|
|
586
|
+
ts_assert(self.ptr->ref_count > 0);
|
|
587
|
+
atomic_inc((volatile uint32_t *)&self.ptr->ref_count);
|
|
588
|
+
ts_assert(self.ptr->ref_count != 0);
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
void ts_subtree_release(SubtreePool *pool, Subtree self) {
|
|
592
|
+
if (self.data.is_inline) return;
|
|
593
|
+
array_clear(&pool->tree_stack);
|
|
594
|
+
|
|
595
|
+
ts_assert(self.ptr->ref_count > 0);
|
|
596
|
+
if (atomic_dec((volatile uint32_t *)&self.ptr->ref_count) == 0) {
|
|
597
|
+
array_push(&pool->tree_stack, ts_subtree_to_mut_unsafe(self));
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
while (pool->tree_stack.size > 0) {
|
|
601
|
+
MutableSubtree tree = array_pop(&pool->tree_stack);
|
|
602
|
+
if (tree.ptr->child_count > 0) {
|
|
603
|
+
Subtree *children = ts_subtree_children(tree);
|
|
604
|
+
for (uint32_t i = 0; i < tree.ptr->child_count; i++) {
|
|
605
|
+
Subtree child = children[i];
|
|
606
|
+
if (child.data.is_inline) continue;
|
|
607
|
+
ts_assert(child.ptr->ref_count > 0);
|
|
608
|
+
if (atomic_dec((volatile uint32_t *)&child.ptr->ref_count) == 0) {
|
|
609
|
+
array_push(&pool->tree_stack, ts_subtree_to_mut_unsafe(child));
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
ts_free(children);
|
|
613
|
+
} else {
|
|
614
|
+
if (tree.ptr->has_external_tokens) {
|
|
615
|
+
ts_external_scanner_state_delete(&tree.ptr->external_scanner_state);
|
|
616
|
+
}
|
|
617
|
+
ts_subtree_pool_free(pool, tree.ptr);
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
int ts_subtree_compare(Subtree left, Subtree right, SubtreePool *pool) {
|
|
623
|
+
array_push(&pool->tree_stack, ts_subtree_to_mut_unsafe(left));
|
|
624
|
+
array_push(&pool->tree_stack, ts_subtree_to_mut_unsafe(right));
|
|
625
|
+
|
|
626
|
+
while (pool->tree_stack.size > 0) {
|
|
627
|
+
right = ts_subtree_from_mut(array_pop(&pool->tree_stack));
|
|
628
|
+
left = ts_subtree_from_mut(array_pop(&pool->tree_stack));
|
|
629
|
+
|
|
630
|
+
int result = 0;
|
|
631
|
+
if (ts_subtree_symbol(left) < ts_subtree_symbol(right)) result = -1;
|
|
632
|
+
else if (ts_subtree_symbol(right) < ts_subtree_symbol(left)) result = 1;
|
|
633
|
+
else if (ts_subtree_child_count(left) < ts_subtree_child_count(right)) result = -1;
|
|
634
|
+
else if (ts_subtree_child_count(right) < ts_subtree_child_count(left)) result = 1;
|
|
635
|
+
if (result != 0) {
|
|
636
|
+
array_clear(&pool->tree_stack);
|
|
637
|
+
return result;
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
for (uint32_t i = ts_subtree_child_count(left); i > 0; i--) {
|
|
641
|
+
Subtree left_child = ts_subtree_children(left)[i - 1];
|
|
642
|
+
Subtree right_child = ts_subtree_children(right)[i - 1];
|
|
643
|
+
array_push(&pool->tree_stack, ts_subtree_to_mut_unsafe(left_child));
|
|
644
|
+
array_push(&pool->tree_stack, ts_subtree_to_mut_unsafe(right_child));
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
return 0;
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
static inline void ts_subtree_set_has_changes(MutableSubtree *self) {
|
|
652
|
+
if (self->data.is_inline) {
|
|
653
|
+
self->data.has_changes = true;
|
|
654
|
+
} else {
|
|
655
|
+
self->ptr->has_changes = true;
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
Subtree ts_subtree_edit(Subtree self, const TSInputEdit *input_edit, SubtreePool *pool) {
|
|
660
|
+
typedef struct {
|
|
661
|
+
Subtree *tree;
|
|
662
|
+
Edit edit;
|
|
663
|
+
} EditEntry;
|
|
664
|
+
|
|
665
|
+
Array(EditEntry) stack = array_new();
|
|
666
|
+
array_push(&stack, ((EditEntry) {
|
|
667
|
+
.tree = &self,
|
|
668
|
+
.edit = (Edit) {
|
|
669
|
+
.start = {input_edit->start_byte, input_edit->start_point},
|
|
670
|
+
.old_end = {input_edit->old_end_byte, input_edit->old_end_point},
|
|
671
|
+
.new_end = {input_edit->new_end_byte, input_edit->new_end_point},
|
|
672
|
+
},
|
|
673
|
+
}));
|
|
674
|
+
|
|
675
|
+
while (stack.size) {
|
|
676
|
+
EditEntry entry = array_pop(&stack);
|
|
677
|
+
Edit edit = entry.edit;
|
|
678
|
+
bool is_noop = edit.old_end.bytes == edit.start.bytes && edit.new_end.bytes == edit.start.bytes;
|
|
679
|
+
bool is_pure_insertion = edit.old_end.bytes == edit.start.bytes;
|
|
680
|
+
bool parent_depends_on_column = ts_subtree_depends_on_column(*entry.tree);
|
|
681
|
+
bool column_shifted = edit.new_end.extent.column != edit.old_end.extent.column;
|
|
682
|
+
|
|
683
|
+
Length size = ts_subtree_size(*entry.tree);
|
|
684
|
+
Length padding = ts_subtree_padding(*entry.tree);
|
|
685
|
+
Length total_size = length_add(padding, size);
|
|
686
|
+
uint32_t lookahead_bytes = ts_subtree_lookahead_bytes(*entry.tree);
|
|
687
|
+
uint32_t end_byte = total_size.bytes + lookahead_bytes;
|
|
688
|
+
if (edit.start.bytes > end_byte || (is_noop && edit.start.bytes == end_byte)) continue;
|
|
689
|
+
|
|
690
|
+
// If the edit is entirely within the space before this subtree, then shift this
|
|
691
|
+
// subtree over according to the edit without changing its size.
|
|
692
|
+
if (edit.old_end.bytes <= padding.bytes) {
|
|
693
|
+
padding = length_add(edit.new_end, length_sub(padding, edit.old_end));
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
// If the edit starts in the space before this subtree and extends into this subtree,
|
|
697
|
+
// shrink the subtree's content to compensate for the change in the space before it.
|
|
698
|
+
else if (edit.start.bytes < padding.bytes) {
|
|
699
|
+
size = length_saturating_sub(size, length_sub(edit.old_end, padding));
|
|
700
|
+
padding = edit.new_end;
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
// If the edit is a pure insertion right at the start of the subtree,
|
|
704
|
+
// shift the subtree over according to the insertion.
|
|
705
|
+
else if (edit.start.bytes == padding.bytes && is_pure_insertion) {
|
|
706
|
+
padding = edit.new_end;
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
// If the edit is within this subtree, resize the subtree to reflect the edit.
|
|
710
|
+
else if (
|
|
711
|
+
edit.start.bytes < total_size.bytes ||
|
|
712
|
+
(edit.start.bytes == total_size.bytes && is_pure_insertion)
|
|
713
|
+
) {
|
|
714
|
+
size = length_add(
|
|
715
|
+
length_sub(edit.new_end, padding),
|
|
716
|
+
length_saturating_sub(total_size, edit.old_end)
|
|
717
|
+
);
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
MutableSubtree result = ts_subtree_make_mut(pool, *entry.tree);
|
|
721
|
+
|
|
722
|
+
if (result.data.is_inline) {
|
|
723
|
+
if (ts_subtree_can_inline(padding, size, lookahead_bytes)) {
|
|
724
|
+
result.data.padding_bytes = padding.bytes;
|
|
725
|
+
result.data.padding_rows = padding.extent.row;
|
|
726
|
+
result.data.padding_columns = padding.extent.column;
|
|
727
|
+
result.data.size_bytes = size.bytes;
|
|
728
|
+
} else {
|
|
729
|
+
SubtreeHeapData *data = ts_subtree_pool_allocate(pool);
|
|
730
|
+
data->ref_count = 1;
|
|
731
|
+
data->padding = padding;
|
|
732
|
+
data->size = size;
|
|
733
|
+
data->lookahead_bytes = lookahead_bytes;
|
|
734
|
+
data->error_cost = 0;
|
|
735
|
+
data->child_count = 0;
|
|
736
|
+
data->symbol = result.data.symbol;
|
|
737
|
+
data->parse_state = result.data.parse_state;
|
|
738
|
+
data->visible = result.data.visible;
|
|
739
|
+
data->named = result.data.named;
|
|
740
|
+
data->extra = result.data.extra;
|
|
741
|
+
data->fragile_left = false;
|
|
742
|
+
data->fragile_right = false;
|
|
743
|
+
data->has_changes = false;
|
|
744
|
+
data->has_external_tokens = false;
|
|
745
|
+
data->depends_on_column = false;
|
|
746
|
+
data->is_missing = result.data.is_missing;
|
|
747
|
+
data->is_keyword = result.data.is_keyword;
|
|
748
|
+
result.ptr = data;
|
|
749
|
+
}
|
|
750
|
+
} else {
|
|
751
|
+
result.ptr->padding = padding;
|
|
752
|
+
result.ptr->size = size;
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
ts_subtree_set_has_changes(&result);
|
|
756
|
+
*entry.tree = ts_subtree_from_mut(result);
|
|
757
|
+
|
|
758
|
+
Length child_left, child_right = length_zero();
|
|
759
|
+
for (uint32_t i = 0, n = ts_subtree_child_count(*entry.tree); i < n; i++) {
|
|
760
|
+
Subtree *child = &ts_subtree_children(*entry.tree)[i];
|
|
761
|
+
Length child_size = ts_subtree_total_size(*child);
|
|
762
|
+
child_left = child_right;
|
|
763
|
+
child_right = length_add(child_left, child_size);
|
|
764
|
+
|
|
765
|
+
// If this child ends before the edit, it is not affected.
|
|
766
|
+
if (child_right.bytes + ts_subtree_lookahead_bytes(*child) < edit.start.bytes) continue;
|
|
767
|
+
|
|
768
|
+
// Keep editing child nodes until a node is reached that starts after the edit.
|
|
769
|
+
// Also, if this node's validity depends on its column position, then continue
|
|
770
|
+
// invaliditing child nodes until reaching a line break.
|
|
771
|
+
if ((
|
|
772
|
+
(child_left.bytes > edit.old_end.bytes) ||
|
|
773
|
+
(child_left.bytes == edit.old_end.bytes && child_size.bytes > 0 && i > 0)
|
|
774
|
+
) && (
|
|
775
|
+
!parent_depends_on_column ||
|
|
776
|
+
child_left.extent.row > padding.extent.row
|
|
777
|
+
) && (
|
|
778
|
+
!ts_subtree_depends_on_column(*child) ||
|
|
779
|
+
!column_shifted ||
|
|
780
|
+
child_left.extent.row > edit.old_end.extent.row
|
|
781
|
+
)) {
|
|
782
|
+
break;
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
// Transform edit into the child's coordinate space.
|
|
786
|
+
Edit child_edit = {
|
|
787
|
+
.start = length_saturating_sub(edit.start, child_left),
|
|
788
|
+
.old_end = length_saturating_sub(edit.old_end, child_left),
|
|
789
|
+
.new_end = length_saturating_sub(edit.new_end, child_left),
|
|
790
|
+
};
|
|
791
|
+
|
|
792
|
+
// Interpret all inserted text as applying to the *first* child that touches the edit.
|
|
793
|
+
// Subsequent children are only never have any text inserted into them; they are only
|
|
794
|
+
// shrunk to compensate for the edit.
|
|
795
|
+
if (
|
|
796
|
+
child_right.bytes > edit.start.bytes ||
|
|
797
|
+
(child_right.bytes == edit.start.bytes && is_pure_insertion)
|
|
798
|
+
) {
|
|
799
|
+
edit.new_end = edit.start;
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
// Children that occur before the edit are not reshaped by the edit.
|
|
803
|
+
else {
|
|
804
|
+
child_edit.old_end = child_edit.start;
|
|
805
|
+
child_edit.new_end = child_edit.start;
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
// Queue processing of this child's subtree.
|
|
809
|
+
array_push(&stack, ((EditEntry) {
|
|
810
|
+
.tree = child,
|
|
811
|
+
.edit = child_edit,
|
|
812
|
+
}));
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
array_delete(&stack);
|
|
817
|
+
return self;
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
Subtree ts_subtree_last_external_token(Subtree tree) {
|
|
821
|
+
if (!ts_subtree_has_external_tokens(tree)) return NULL_SUBTREE;
|
|
822
|
+
while (tree.ptr->child_count > 0) {
|
|
823
|
+
for (uint32_t i = tree.ptr->child_count - 1; i + 1 > 0; i--) {
|
|
824
|
+
Subtree child = ts_subtree_children(tree)[i];
|
|
825
|
+
if (ts_subtree_has_external_tokens(child)) {
|
|
826
|
+
tree = child;
|
|
827
|
+
break;
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
return tree;
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
static size_t ts_subtree__write_char_to_string(char *str, size_t n, int32_t chr) {
|
|
835
|
+
if (chr == -1)
|
|
836
|
+
return snprintf(str, n, "INVALID");
|
|
837
|
+
else if (chr == '\0')
|
|
838
|
+
return snprintf(str, n, "'\\0'");
|
|
839
|
+
else if (chr == '\n')
|
|
840
|
+
return snprintf(str, n, "'\\n'");
|
|
841
|
+
else if (chr == '\t')
|
|
842
|
+
return snprintf(str, n, "'\\t'");
|
|
843
|
+
else if (chr == '\r')
|
|
844
|
+
return snprintf(str, n, "'\\r'");
|
|
845
|
+
else if (0 < chr && chr < 128 && isprint(chr))
|
|
846
|
+
return snprintf(str, n, "'%c'", chr);
|
|
847
|
+
else
|
|
848
|
+
return snprintf(str, n, "%d", chr);
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
static const char *const ROOT_FIELD = "__ROOT__";
|
|
852
|
+
|
|
853
|
+
static size_t ts_subtree__write_to_string(
|
|
854
|
+
Subtree self, char *string, size_t limit,
|
|
855
|
+
const TSLanguage *language, bool include_all,
|
|
856
|
+
TSSymbol alias_symbol, bool alias_is_named, const char *field_name
|
|
857
|
+
) {
|
|
858
|
+
if (!self.ptr) return snprintf(string, limit, "(NULL)");
|
|
859
|
+
|
|
860
|
+
char *cursor = string;
|
|
861
|
+
char **writer = (limit > 1) ? &cursor : &string;
|
|
862
|
+
bool is_root = field_name == ROOT_FIELD;
|
|
863
|
+
bool is_visible =
|
|
864
|
+
include_all ||
|
|
865
|
+
ts_subtree_missing(self) ||
|
|
866
|
+
(
|
|
867
|
+
alias_symbol
|
|
868
|
+
? alias_is_named
|
|
869
|
+
: ts_subtree_visible(self) && ts_subtree_named(self)
|
|
870
|
+
);
|
|
871
|
+
|
|
872
|
+
if (is_visible) {
|
|
873
|
+
if (!is_root) {
|
|
874
|
+
cursor += snprintf(*writer, limit, " ");
|
|
875
|
+
if (field_name) {
|
|
876
|
+
cursor += snprintf(*writer, limit, "%s: ", field_name);
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
if (ts_subtree_is_error(self) && ts_subtree_child_count(self) == 0 && self.ptr->size.bytes > 0) {
|
|
881
|
+
cursor += snprintf(*writer, limit, "(UNEXPECTED ");
|
|
882
|
+
cursor += ts_subtree__write_char_to_string(*writer, limit, self.ptr->lookahead_char);
|
|
883
|
+
} else {
|
|
884
|
+
TSSymbol symbol = alias_symbol ? alias_symbol : ts_subtree_symbol(self);
|
|
885
|
+
const char *symbol_name = ts_language_symbol_name(language, symbol);
|
|
886
|
+
if (ts_subtree_missing(self)) {
|
|
887
|
+
cursor += snprintf(*writer, limit, "(MISSING ");
|
|
888
|
+
if (alias_is_named || ts_subtree_named(self)) {
|
|
889
|
+
cursor += snprintf(*writer, limit, "%s", symbol_name);
|
|
890
|
+
} else {
|
|
891
|
+
cursor += snprintf(*writer, limit, "\"%s\"", symbol_name);
|
|
892
|
+
}
|
|
893
|
+
} else {
|
|
894
|
+
cursor += snprintf(*writer, limit, "(%s", symbol_name);
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
} else if (is_root) {
|
|
898
|
+
TSSymbol symbol = alias_symbol ? alias_symbol : ts_subtree_symbol(self);
|
|
899
|
+
const char *symbol_name = ts_language_symbol_name(language, symbol);
|
|
900
|
+
if (ts_subtree_child_count(self) > 0) {
|
|
901
|
+
cursor += snprintf(*writer, limit, "(%s", symbol_name);
|
|
902
|
+
} else if (ts_subtree_named(self)) {
|
|
903
|
+
cursor += snprintf(*writer, limit, "(%s)", symbol_name);
|
|
904
|
+
} else {
|
|
905
|
+
cursor += snprintf(*writer, limit, "(\"%s\")", symbol_name);
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
if (ts_subtree_child_count(self)) {
|
|
910
|
+
const TSSymbol *alias_sequence = ts_language_alias_sequence(language, self.ptr->production_id);
|
|
911
|
+
const TSFieldMapEntry *field_map, *field_map_end;
|
|
912
|
+
ts_language_field_map(
|
|
913
|
+
language,
|
|
914
|
+
self.ptr->production_id,
|
|
915
|
+
&field_map,
|
|
916
|
+
&field_map_end
|
|
917
|
+
);
|
|
918
|
+
|
|
919
|
+
uint32_t structural_child_index = 0;
|
|
920
|
+
for (uint32_t i = 0; i < self.ptr->child_count; i++) {
|
|
921
|
+
Subtree child = ts_subtree_children(self)[i];
|
|
922
|
+
if (ts_subtree_extra(child)) {
|
|
923
|
+
cursor += ts_subtree__write_to_string(
|
|
924
|
+
child, *writer, limit,
|
|
925
|
+
language, include_all,
|
|
926
|
+
0, false, NULL
|
|
927
|
+
);
|
|
928
|
+
} else {
|
|
929
|
+
TSSymbol subtree_alias_symbol = alias_sequence
|
|
930
|
+
? alias_sequence[structural_child_index]
|
|
931
|
+
: 0;
|
|
932
|
+
bool subtree_alias_is_named = subtree_alias_symbol
|
|
933
|
+
? ts_language_symbol_metadata(language, subtree_alias_symbol).named
|
|
934
|
+
: false;
|
|
935
|
+
|
|
936
|
+
const char *child_field_name = is_visible ? NULL : field_name;
|
|
937
|
+
for (const TSFieldMapEntry *map = field_map; map < field_map_end; map++) {
|
|
938
|
+
if (!map->inherited && map->child_index == structural_child_index) {
|
|
939
|
+
child_field_name = language->field_names[map->field_id];
|
|
940
|
+
break;
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
cursor += ts_subtree__write_to_string(
|
|
945
|
+
child, *writer, limit,
|
|
946
|
+
language, include_all,
|
|
947
|
+
subtree_alias_symbol, subtree_alias_is_named, child_field_name
|
|
948
|
+
);
|
|
949
|
+
structural_child_index++;
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
if (is_visible) cursor += snprintf(*writer, limit, ")");
|
|
955
|
+
|
|
956
|
+
return cursor - string;
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
char *ts_subtree_string(
|
|
960
|
+
Subtree self,
|
|
961
|
+
TSSymbol alias_symbol,
|
|
962
|
+
bool alias_is_named,
|
|
963
|
+
const TSLanguage *language,
|
|
964
|
+
bool include_all
|
|
965
|
+
) {
|
|
966
|
+
char scratch_string[1];
|
|
967
|
+
size_t size = ts_subtree__write_to_string(
|
|
968
|
+
self, scratch_string, 1,
|
|
969
|
+
language, include_all,
|
|
970
|
+
alias_symbol, alias_is_named, ROOT_FIELD
|
|
971
|
+
) + 1;
|
|
972
|
+
char *result = ts_malloc(size * sizeof(char));
|
|
973
|
+
ts_subtree__write_to_string(
|
|
974
|
+
self, result, size,
|
|
975
|
+
language, include_all,
|
|
976
|
+
alias_symbol, alias_is_named, ROOT_FIELD
|
|
977
|
+
);
|
|
978
|
+
return result;
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
void ts_subtree__print_dot_graph(const Subtree *self, uint32_t start_offset,
|
|
982
|
+
const TSLanguage *language, TSSymbol alias_symbol,
|
|
983
|
+
FILE *f) {
|
|
984
|
+
TSSymbol subtree_symbol = ts_subtree_symbol(*self);
|
|
985
|
+
TSSymbol symbol = alias_symbol ? alias_symbol : subtree_symbol;
|
|
986
|
+
uint32_t end_offset = start_offset + ts_subtree_total_bytes(*self);
|
|
987
|
+
fprintf(f, "tree_%p [label=\"", (void *)self);
|
|
988
|
+
ts_language_write_symbol_as_dot_string(language, f, symbol);
|
|
989
|
+
fprintf(f, "\"");
|
|
990
|
+
|
|
991
|
+
if (ts_subtree_child_count(*self) == 0) fprintf(f, ", shape=plaintext");
|
|
992
|
+
if (ts_subtree_extra(*self)) fprintf(f, ", fontcolor=gray");
|
|
993
|
+
if (ts_subtree_has_changes(*self)) fprintf(f, ", color=green, penwidth=2");
|
|
994
|
+
|
|
995
|
+
fprintf(f, ", tooltip=\""
|
|
996
|
+
"range: %u - %u\n"
|
|
997
|
+
"state: %d\n"
|
|
998
|
+
"error-cost: %u\n"
|
|
999
|
+
"has-changes: %u\n"
|
|
1000
|
+
"depends-on-column: %u\n"
|
|
1001
|
+
"descendant-count: %u\n"
|
|
1002
|
+
"repeat-depth: %u\n"
|
|
1003
|
+
"lookahead-bytes: %u",
|
|
1004
|
+
start_offset, end_offset,
|
|
1005
|
+
ts_subtree_parse_state(*self),
|
|
1006
|
+
ts_subtree_error_cost(*self),
|
|
1007
|
+
ts_subtree_has_changes(*self),
|
|
1008
|
+
ts_subtree_depends_on_column(*self),
|
|
1009
|
+
ts_subtree_visible_descendant_count(*self),
|
|
1010
|
+
ts_subtree_repeat_depth(*self),
|
|
1011
|
+
ts_subtree_lookahead_bytes(*self)
|
|
1012
|
+
);
|
|
1013
|
+
|
|
1014
|
+
if (ts_subtree_is_error(*self) && ts_subtree_child_count(*self) == 0 && self->ptr->lookahead_char != 0) {
|
|
1015
|
+
fprintf(f, "\ncharacter: '%c'", self->ptr->lookahead_char);
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
fprintf(f, "\"]\n");
|
|
1019
|
+
|
|
1020
|
+
uint32_t child_start_offset = start_offset;
|
|
1021
|
+
uint32_t child_info_offset =
|
|
1022
|
+
language->max_alias_sequence_length *
|
|
1023
|
+
ts_subtree_production_id(*self);
|
|
1024
|
+
for (uint32_t i = 0, n = ts_subtree_child_count(*self); i < n; i++) {
|
|
1025
|
+
const Subtree *child = &ts_subtree_children(*self)[i];
|
|
1026
|
+
TSSymbol subtree_alias_symbol = 0;
|
|
1027
|
+
if (!ts_subtree_extra(*child) && child_info_offset) {
|
|
1028
|
+
subtree_alias_symbol = language->alias_sequences[child_info_offset];
|
|
1029
|
+
child_info_offset++;
|
|
1030
|
+
}
|
|
1031
|
+
ts_subtree__print_dot_graph(child, child_start_offset, language, subtree_alias_symbol, f);
|
|
1032
|
+
fprintf(f, "tree_%p -> tree_%p [tooltip=%u]\n", (void *)self, (void *)child, i);
|
|
1033
|
+
child_start_offset += ts_subtree_total_bytes(*child);
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
void ts_subtree_print_dot_graph(Subtree self, const TSLanguage *language, FILE *f) {
|
|
1038
|
+
fprintf(f, "digraph tree {\n");
|
|
1039
|
+
fprintf(f, "edge [arrowhead=none]\n");
|
|
1040
|
+
ts_subtree__print_dot_graph(&self, 0, language, 0, f);
|
|
1041
|
+
fprintf(f, "}\n");
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
const ExternalScannerState *ts_subtree_external_scanner_state(Subtree self) {
|
|
1045
|
+
static const ExternalScannerState empty_state = {{.short_data = {0}}, .length = 0};
|
|
1046
|
+
if (
|
|
1047
|
+
self.ptr &&
|
|
1048
|
+
!self.data.is_inline &&
|
|
1049
|
+
self.ptr->has_external_tokens &&
|
|
1050
|
+
self.ptr->child_count == 0
|
|
1051
|
+
) {
|
|
1052
|
+
return &self.ptr->external_scanner_state;
|
|
1053
|
+
} else {
|
|
1054
|
+
return &empty_state;
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
bool ts_subtree_external_scanner_state_eq(Subtree self, Subtree other) {
|
|
1059
|
+
const ExternalScannerState *state_self = ts_subtree_external_scanner_state(self);
|
|
1060
|
+
const ExternalScannerState *state_other = ts_subtree_external_scanner_state(other);
|
|
1061
|
+
return ts_external_scanner_state_eq(
|
|
1062
|
+
state_self,
|
|
1063
|
+
ts_external_scanner_state_data(state_other),
|
|
1064
|
+
state_other->length
|
|
1065
|
+
);
|
|
1066
|
+
}
|