0sec-cli 0.21.4 → 0.22.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (251) hide show
  1. package/0.js +56 -56
  2. package/README.md +48 -63
  3. package/chunks/{adapt-loop-IGBRQAXO.js → adapt-loop-J6QCZZTB.js} +4 -4
  4. package/chunks/{artifact-scraper-LNQJUORS.js → artifact-scraper-MFKT6OI4.js} +2 -2
  5. package/chunks/{assumption-mining-4MJTP6H5.js → assumption-mining-646LYSJY.js} +16 -16
  6. package/chunks/{chunk-Z3IKZX3X.js → chunk-23DG5YKS.js} +1 -1
  7. package/chunks/{chunk-2WSXFFJZ.js → chunk-3E2KALZ5.js} +2 -2
  8. package/chunks/{chunk-TF46UWFU.js → chunk-4G7OVYJX.js} +1 -1
  9. package/chunks/{chunk-E2UOY5PJ.js → chunk-5BTJMINS.js} +12 -70
  10. package/chunks/{chunk-QZVG3BG4.js → chunk-5IBCBQEH.js} +1 -2
  11. package/chunks/{chunk-YA4PUM4H.js → chunk-7XCKYNLO.js} +1 -1
  12. package/chunks/{chunk-BACXRTQ4.js → chunk-AV2LG2L7.js} +87 -767
  13. package/chunks/{chunk-IMGWPNQM.js → chunk-BCSRRQG5.js} +76 -593
  14. package/chunks/{chunk-NOPBXZUV.js → chunk-BOUGKEKA.js} +1 -1
  15. package/chunks/{chunk-RF5QGKLR.js → chunk-CPWA6RWE.js} +3 -3
  16. package/chunks/{chunk-P6YG6TEZ.js → chunk-DKSCN2AB.js} +1 -1
  17. package/chunks/{chunk-YPOA3W4O.js → chunk-GOEA3NW6.js} +877 -110
  18. package/chunks/{chunk-ANDKY54G.js → chunk-HHPWRY2M.js} +4019 -7299
  19. package/chunks/{chunk-NDJU5ZZ7.js → chunk-IFME676H.js} +3 -3
  20. package/chunks/{chunk-HBKCGJAV.js → chunk-IVQV574Y.js} +1 -1
  21. package/chunks/{chunk-W4JOXE4N.js → chunk-IXT64DV5.js} +709 -1929
  22. package/chunks/{chunk-PC6RCKQV.js → chunk-KAU6NLGP.js} +59 -26
  23. package/chunks/{chunk-FAH6V4QM.js → chunk-LGCASF2C.js} +1117 -2291
  24. package/chunks/{chunk-CAJJRUTV.js → chunk-NLH4LMWH.js} +1 -1
  25. package/chunks/chunk-OHHCGDJ2.js +5523 -0
  26. package/chunks/{chunk-YHWWF4QY.js → chunk-OSBPGWTE.js} +3 -3
  27. package/chunks/{chunk-G34QP2XW.js → chunk-TM74SSHC.js} +1 -1
  28. package/chunks/{chunk-VOAXLO4A.js → chunk-TO35Y326.js} +5 -721
  29. package/chunks/{chunk-FWAYJ2IV.js → chunk-TV27OWIW.js} +8 -8
  30. package/chunks/chunk-UELXHK2Y.js +1950 -0
  31. package/chunks/{chunk-CL5KAUM6.js → chunk-V6GHX34G.js} +274 -8
  32. package/chunks/{chunk-WZISK5VC.js → chunk-VWITLWXB.js} +53 -7
  33. package/chunks/{chunk-ER3SUMYJ.js → chunk-W6UWZFKL.js} +0 -195
  34. package/chunks/chunk-WSDDGFA6.js +114 -0
  35. package/chunks/{chunk-5T6D5BVY.js → chunk-WZRVS7SB.js} +1 -1
  36. package/chunks/chunk-X7LAEEUW.js +2143 -0
  37. package/chunks/chunk-XA2O4WXA.js +1228 -0
  38. package/chunks/{chunk-Y5H6E24H.js → chunk-XCISCI4T.js} +1 -1
  39. package/chunks/{chunk-WPQLBN4S.js → chunk-XDKB2P5X.js} +1 -1
  40. package/chunks/{chunk-SBMB4OL3.js → chunk-YL6YAGLL.js} +62 -8
  41. package/chunks/{chunk-O6SD4A36.js → chunk-ZKQ2I3S2.js} +1 -1
  42. package/chunks/{codex-models-TYYV4JNN.js → codex-models-NHQW45SO.js} +5 -3
  43. package/chunks/{commands-WF5RG4I2.js → commands-N6GN5SBF.js} +2152 -3643
  44. package/chunks/{db-U3WQZVAO.js → db-5IWEJUYV.js} +3 -3
  45. package/chunks/{disclose-67GZCDBO.js → disclose-LDNKAVRH.js} +10 -8
  46. package/chunks/{dist-ACC3DZUZ.js → dist-BS4CY4RG.js} +3 -1
  47. package/chunks/{dist-EVTN3UTT.js → dist-FSS7MBDF.js} +2 -2
  48. package/chunks/{dist-F6X62TQK.js → dist-L3XJWWZ6.js} +225 -192
  49. package/chunks/{eval-runner-SA6OUGHZ.js → eval-runner-EMEGF24P.js} +11 -11
  50. package/chunks/{exploit-agent-36Q7XQFP.js → exploit-agent-KW4EB7BE.js} +1 -1
  51. package/chunks/{exploit-autoclimb-J4OTSTZ6.js → exploit-autoclimb-CXJ2ERRO.js} +1 -1
  52. package/chunks/{exploit-climb-PYEJDIC4.js → exploit-climb-TJWLY4XC.js} +2 -2
  53. package/chunks/fix-UUKPXCFB.js +26 -0
  54. package/chunks/{harness-GDUMKGSE.js → harness-C5HOKIEV.js} +3 -3
  55. package/chunks/{hunt-scan-UDJSCISU.js → hunt-scan-KZZ444V2.js} +14 -14
  56. package/chunks/{identity-JTIVJSV7.js → identity-62SVRW4H.js} +1 -1
  57. package/chunks/{kernel-primitive-F2IXUFAX.js → kernel-primitive-Z77IR7YS.js} +2 -2
  58. package/chunks/{kernel-vm-runner-276LHIOV.js → kernel-vm-runner-JW77P276.js} +2 -2
  59. package/chunks/{memsafety-scan-NHUOGTEX.js → memsafety-scan-FCPAXIZE.js} +2 -2
  60. package/chunks/{native-loop-3BSYVDUI.js → native-loop-P6P5GYVJ.js} +10 -10
  61. package/chunks/{npm-detectors-VIYJXKFQ.js → npm-detectors-Z2ZIQCN4.js} +2 -2
  62. package/chunks/orchestrate-DWWUT5RC.js +58 -0
  63. package/chunks/{process-PNMC36JI.js → process-N245QIQG.js} +1 -4
  64. package/chunks/{run-CBGE6DRQ.js → run-GAFKBCTN.js} +14935 -17598
  65. package/chunks/{runtime-PXO5G6UV.js → runtime-H7YBR5IZ.js} +4 -5
  66. package/chunks/{scope-NJHIDDTN.js → scope-QWY4VQZ7.js} +4 -1
  67. package/chunks/{session-store-46WBZM22.js → session-store-XIDFGG7K.js} +2 -2
  68. package/chunks/{variant-candidates-UH2WC2HA.js → variant-candidates-7D4F5E4H.js} +3 -3
  69. package/chunks/{web-recon-prepass-SFXU44SS.js → web-recon-prepass-VXXBPDAV.js} +3 -3
  70. package/cli-path-traversal-fixture.js +352 -0
  71. package/dashboard/assets/bot-Bg1Tp9_d.js +1 -0
  72. package/dashboard/assets/dist-B_dDCPbu.js +1 -0
  73. package/dashboard/assets/findings-page-mayGhNx6.js +5 -0
  74. package/dashboard/assets/format--susmHX7.js +1 -0
  75. package/dashboard/assets/input-TuVPR3Zl.js +1 -0
  76. package/dashboard/assets/jsx-runtime-MGseXjj5.js +3 -0
  77. package/dashboard/assets/live-page-HWWHX99U.js +1 -0
  78. package/dashboard/assets/meta-tile-ckHo-w7k.js +1 -0
  79. package/dashboard/assets/operations-BxZ0OoXO.js +10 -0
  80. package/dashboard/assets/operations-app-D3d35rgo.js +46 -0
  81. package/dashboard/assets/overview-page-W_4IteEr.js +1 -0
  82. package/dashboard/assets/page-header-Bw9AJgBV.js +1 -0
  83. package/dashboard/assets/scans-page-CgzVXHnn.js +1 -0
  84. package/dashboard/assets/siren-KQj8QAnJ.js +1 -0
  85. package/dashboard/assets/table-8EDklulN.js +1 -0
  86. package/dashboard/assets/tabs-CFHPOwg8.js +1 -0
  87. package/dashboard/index.html +2 -3
  88. package/node_modules/node-addon-api/LICENSE.md +9 -0
  89. package/node_modules/node-addon-api/README.md +95 -0
  90. package/node_modules/node-addon-api/common.gypi +21 -0
  91. package/node_modules/node-addon-api/except.gypi +25 -0
  92. package/node_modules/node-addon-api/index.js +14 -0
  93. package/node_modules/node-addon-api/napi-inl.deprecated.h +186 -0
  94. package/node_modules/node-addon-api/napi-inl.h +7250 -0
  95. package/node_modules/node-addon-api/napi.h +3463 -0
  96. package/node_modules/node-addon-api/node_addon_api.gyp +42 -0
  97. package/node_modules/node-addon-api/node_api.gyp +9 -0
  98. package/node_modules/node-addon-api/noexcept.gypi +26 -0
  99. package/node_modules/node-addon-api/nothing.c +0 -0
  100. package/node_modules/node-addon-api/package-support.json +21 -0
  101. package/node_modules/node-addon-api/package.json +481 -0
  102. package/node_modules/node-addon-api/tools/README.md +73 -0
  103. package/node_modules/node-addon-api/tools/check-napi.js +99 -0
  104. package/node_modules/node-addon-api/tools/clang-format.js +71 -0
  105. package/node_modules/node-addon-api/tools/conversion.js +301 -0
  106. package/node_modules/node-gyp-build/LICENSE +21 -0
  107. package/node_modules/node-gyp-build/README.md +58 -0
  108. package/node_modules/node-gyp-build/SECURITY.md +5 -0
  109. package/node_modules/node-gyp-build/bin.js +84 -0
  110. package/node_modules/node-gyp-build/build-test.js +19 -0
  111. package/node_modules/node-gyp-build/index.js +6 -0
  112. package/node_modules/node-gyp-build/node-gyp-build.js +207 -0
  113. package/node_modules/node-gyp-build/optional.js +7 -0
  114. package/node_modules/node-gyp-build/package.json +43 -0
  115. package/node_modules/tree-sitter/LICENSE +21 -0
  116. package/node_modules/tree-sitter/README.md +90 -0
  117. package/node_modules/tree-sitter/binding.gyp +76 -0
  118. package/node_modules/tree-sitter/index.js +895 -0
  119. package/node_modules/tree-sitter/package.json +62 -0
  120. package/node_modules/tree-sitter/prebuilds/darwin-arm64/tree-sitter.node +0 -0
  121. package/node_modules/tree-sitter/prebuilds/darwin-x64/tree-sitter.node +0 -0
  122. package/node_modules/tree-sitter/prebuilds/linux-x64/tree-sitter.node +0 -0
  123. package/node_modules/tree-sitter/prebuilds/win32-x64/tree-sitter.node +0 -0
  124. package/node_modules/tree-sitter/src/addon_data.h +47 -0
  125. package/node_modules/tree-sitter/src/binding.cc +35 -0
  126. package/node_modules/tree-sitter/src/conversions.cc +140 -0
  127. package/node_modules/tree-sitter/src/conversions.h +22 -0
  128. package/node_modules/tree-sitter/src/language.cc +106 -0
  129. package/node_modules/tree-sitter/src/language.h +17 -0
  130. package/node_modules/tree-sitter/src/logger.cc +70 -0
  131. package/node_modules/tree-sitter/src/logger.h +19 -0
  132. package/node_modules/tree-sitter/src/lookaheaditerator.cc +122 -0
  133. package/node_modules/tree-sitter/src/lookaheaditerator.h +33 -0
  134. package/node_modules/tree-sitter/src/node.cc +1056 -0
  135. package/node_modules/tree-sitter/src/node.h +30 -0
  136. package/node_modules/tree-sitter/src/parser.cc +298 -0
  137. package/node_modules/tree-sitter/src/parser.h +35 -0
  138. package/node_modules/tree-sitter/src/query.cc +383 -0
  139. package/node_modules/tree-sitter/src/query.h +39 -0
  140. package/node_modules/tree-sitter/src/tree.cc +307 -0
  141. package/node_modules/tree-sitter/src/tree.h +45 -0
  142. package/node_modules/tree-sitter/src/tree_cursor.cc +213 -0
  143. package/node_modules/tree-sitter/src/tree_cursor.h +52 -0
  144. package/node_modules/tree-sitter/tree-sitter.d.ts +211 -0
  145. package/node_modules/tree-sitter/vendor/tree-sitter/LICENSE +21 -0
  146. package/node_modules/tree-sitter/vendor/tree-sitter/README.md +21 -0
  147. package/node_modules/tree-sitter/vendor/tree-sitter/lib/README.md +6 -0
  148. package/node_modules/tree-sitter/vendor/tree-sitter/lib/include/tree_sitter/api.h +1266 -0
  149. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/alloc.c +48 -0
  150. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/alloc.h +41 -0
  151. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/array.h +290 -0
  152. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/atomic.h +68 -0
  153. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/clock.h +146 -0
  154. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/error_costs.h +11 -0
  155. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/get_changed_ranges.c +501 -0
  156. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/get_changed_ranges.h +36 -0
  157. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/host.h +21 -0
  158. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/language.c +221 -0
  159. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/language.h +299 -0
  160. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/length.h +52 -0
  161. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/lexer.c +419 -0
  162. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/lexer.h +49 -0
  163. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/lib.c +14 -0
  164. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/node.c +774 -0
  165. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/parser.c +2151 -0
  166. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/parser.h +230 -0
  167. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/point.h +62 -0
  168. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/query.c +4134 -0
  169. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/reduce_action.h +34 -0
  170. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/reusable_node.h +95 -0
  171. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/stack.c +899 -0
  172. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/stack.h +133 -0
  173. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/subtree.c +1060 -0
  174. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/subtree.h +382 -0
  175. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/tree.c +165 -0
  176. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/tree.h +31 -0
  177. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/tree_cursor.c +714 -0
  178. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/tree_cursor.h +48 -0
  179. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/ICU_SHA +1 -0
  180. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/LICENSE +414 -0
  181. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/README.md +29 -0
  182. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/ptypes.h +1 -0
  183. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/umachine.h +448 -0
  184. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/urename.h +1 -0
  185. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/utf.h +1 -0
  186. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/utf16.h +733 -0
  187. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/utf8.h +881 -0
  188. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode.h +50 -0
  189. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/wasm/stdlib-symbols.txt +23 -0
  190. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/wasm/stdlib.c +109 -0
  191. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/wasm/wasm-stdlib.h +1294 -0
  192. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/wasm_store.c +1823 -0
  193. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/wasm_store.h +31 -0
  194. package/node_modules/tree-sitter/vendor/tree-sitter/test/fixtures/grammars/.gitkeep +0 -0
  195. package/node_modules/tree-sitter-c/LICENSE +21 -0
  196. package/node_modules/tree-sitter-c/README.md +18 -0
  197. package/node_modules/tree-sitter-c/binding.gyp +20 -0
  198. package/node_modules/tree-sitter-c/bindings/node/binding.cc +20 -0
  199. package/node_modules/tree-sitter-c/bindings/node/index.d.ts +28 -0
  200. package/node_modules/tree-sitter-c/bindings/node/index.js +7 -0
  201. package/node_modules/tree-sitter-c/grammar.js +1463 -0
  202. package/node_modules/tree-sitter-c/package.json +108 -0
  203. package/node_modules/tree-sitter-c/prebuilds/darwin-arm64/tree-sitter-c.node +0 -0
  204. package/node_modules/tree-sitter-c/prebuilds/darwin-x64/tree-sitter-c.node +0 -0
  205. package/node_modules/tree-sitter-c/prebuilds/linux-x64/tree-sitter-c.node +0 -0
  206. package/node_modules/tree-sitter-c/prebuilds/win32-x64/tree-sitter-c.node +0 -0
  207. package/node_modules/tree-sitter-c/queries/highlights.scm +81 -0
  208. package/node_modules/tree-sitter-c/queries/tags.scm +9 -0
  209. package/node_modules/tree-sitter-c/src/grammar.json +9682 -0
  210. package/node_modules/tree-sitter-c/src/node-types.json +4556 -0
  211. package/node_modules/tree-sitter-c/src/parser.c +113852 -0
  212. package/node_modules/tree-sitter-c/src/tree_sitter/alloc.h +54 -0
  213. package/node_modules/tree-sitter-c/src/tree_sitter/array.h +290 -0
  214. package/node_modules/tree-sitter-c/src/tree_sitter/parser.h +265 -0
  215. package/package.json +10 -3
  216. package/vendor/tree-sitter-0.21.1-node24.json +16 -0
  217. package/vendor/tree-sitter-0.21.1-node24.tgz +0 -0
  218. package/chunks/chunk-CGHCEN7W.js +0 -169
  219. package/chunks/chunk-CXKDWFNO.js +0 -102
  220. package/chunks/chunk-GIQKESMN.js +0 -687
  221. package/chunks/chunk-HPQZHOIU.js +0 -67
  222. package/chunks/chunk-PD2BBBKT.js +0 -245
  223. package/chunks/chunk-WF5W75WY.js +0 -1070
  224. package/chunks/fix-J2KBRJDV.js +0 -12
  225. package/chunks/orchestrate-DHBFRTSI.js +0 -59
  226. package/chunks/replay-runner-LK2XFIVG.js +0 -39
  227. package/dashboard/assets/bot-yILPnRgD.js +0 -1
  228. package/dashboard/assets/chevron-down-BeDJ-Vka.js +0 -1
  229. package/dashboard/assets/circle-alert-BEnMBMT-.js +0 -1
  230. package/dashboard/assets/client-DRYsuOGl.js +0 -9
  231. package/dashboard/assets/copy-Bi5vzoF9.js +0 -1
  232. package/dashboard/assets/desktop-BT7RkC4q.js +0 -32
  233. package/dashboard/assets/desktop-OaBI0E0e.css +0 -1
  234. package/dashboard/assets/dist-CmX-h7a4.js +0 -1
  235. package/dashboard/assets/dist-DAwYQmf_.js +0 -45
  236. package/dashboard/assets/findings-page-B4rwF6fZ.js +0 -5
  237. package/dashboard/assets/format-LNQSSpn6.js +0 -1
  238. package/dashboard/assets/jsx-runtime-C7oxC63R.js +0 -1
  239. package/dashboard/assets/live-page-DoNwpPAO.js +0 -1
  240. package/dashboard/assets/meta-tile-BMtBC-Qq.js +0 -1
  241. package/dashboard/assets/operations-app-ER0gg7GN.js +0 -2
  242. package/dashboard/assets/operations-e2CGYKB1.js +0 -4
  243. package/dashboard/assets/overview-page-CmeWH17A.js +0 -1
  244. package/dashboard/assets/page-header-CIJyycfz.js +0 -1
  245. package/dashboard/assets/play-Dwo-9xt6.js +0 -1
  246. package/dashboard/assets/scans-page-CuhzWhHx.js +0 -1
  247. package/dashboard/assets/search-CiooTLck.js +0 -1
  248. package/dashboard/assets/siren-CCBwTSuk.js +0 -1
  249. package/dashboard/assets/table-BgsSBdke.js +0 -1
  250. package/dashboard/assets/tabs-vn6v7Bk6.js +0 -1
  251. package/dashboard/desktop.html +0 -21
@@ -0,0 +1,221 @@
1
+ #include "./language.h"
2
+ #include "./wasm_store.h"
3
+ #include "tree_sitter/api.h"
4
+ #include <string.h>
5
+
6
+ const TSLanguage *ts_language_copy(const TSLanguage *self) {
7
+ if (self && ts_language_is_wasm(self)) {
8
+ ts_wasm_language_retain(self);
9
+ }
10
+ return self;
11
+ }
12
+
13
+ void ts_language_delete(const TSLanguage *self) {
14
+ if (self && ts_language_is_wasm(self)) {
15
+ ts_wasm_language_release(self);
16
+ }
17
+ }
18
+
19
+ uint32_t ts_language_symbol_count(const TSLanguage *self) {
20
+ return self->symbol_count + self->alias_count;
21
+ }
22
+
23
+ uint32_t ts_language_state_count(const TSLanguage *self) {
24
+ return self->state_count;
25
+ }
26
+
27
+ uint32_t ts_language_version(const TSLanguage *self) {
28
+ return self->version;
29
+ }
30
+
31
+ uint32_t ts_language_field_count(const TSLanguage *self) {
32
+ return self->field_count;
33
+ }
34
+
35
+ void ts_language_table_entry(
36
+ const TSLanguage *self,
37
+ TSStateId state,
38
+ TSSymbol symbol,
39
+ TableEntry *result
40
+ ) {
41
+ if (symbol == ts_builtin_sym_error || symbol == ts_builtin_sym_error_repeat) {
42
+ result->action_count = 0;
43
+ result->is_reusable = false;
44
+ result->actions = NULL;
45
+ } else {
46
+ assert(symbol < self->token_count);
47
+ uint32_t action_index = ts_language_lookup(self, state, symbol);
48
+ const TSParseActionEntry *entry = &self->parse_actions[action_index];
49
+ result->action_count = entry->entry.count;
50
+ result->is_reusable = entry->entry.reusable;
51
+ result->actions = (const TSParseAction *)(entry + 1);
52
+ }
53
+ }
54
+
55
+ TSSymbolMetadata ts_language_symbol_metadata(
56
+ const TSLanguage *self,
57
+ TSSymbol symbol
58
+ ) {
59
+ if (symbol == ts_builtin_sym_error) {
60
+ return (TSSymbolMetadata) {.visible = true, .named = true};
61
+ } else if (symbol == ts_builtin_sym_error_repeat) {
62
+ return (TSSymbolMetadata) {.visible = false, .named = false};
63
+ } else {
64
+ return self->symbol_metadata[symbol];
65
+ }
66
+ }
67
+
68
+ TSSymbol ts_language_public_symbol(
69
+ const TSLanguage *self,
70
+ TSSymbol symbol
71
+ ) {
72
+ if (symbol == ts_builtin_sym_error) return symbol;
73
+ return self->public_symbol_map[symbol];
74
+ }
75
+
76
+ TSStateId ts_language_next_state(
77
+ const TSLanguage *self,
78
+ TSStateId state,
79
+ TSSymbol symbol
80
+ ) {
81
+ if (symbol == ts_builtin_sym_error || symbol == ts_builtin_sym_error_repeat) {
82
+ return 0;
83
+ } else if (symbol < self->token_count) {
84
+ uint32_t count;
85
+ const TSParseAction *actions = ts_language_actions(self, state, symbol, &count);
86
+ if (count > 0) {
87
+ TSParseAction action = actions[count - 1];
88
+ if (action.type == TSParseActionTypeShift) {
89
+ return action.shift.extra ? state : action.shift.state;
90
+ }
91
+ }
92
+ return 0;
93
+ } else {
94
+ return ts_language_lookup(self, state, symbol);
95
+ }
96
+ }
97
+
98
+ const char *ts_language_symbol_name(
99
+ const TSLanguage *self,
100
+ TSSymbol symbol
101
+ ) {
102
+ if (symbol == ts_builtin_sym_error) {
103
+ return "ERROR";
104
+ } else if (symbol == ts_builtin_sym_error_repeat) {
105
+ return "_ERROR";
106
+ } else if (symbol < ts_language_symbol_count(self)) {
107
+ return self->symbol_names[symbol];
108
+ } else {
109
+ return NULL;
110
+ }
111
+ }
112
+
113
+ TSSymbol ts_language_symbol_for_name(
114
+ const TSLanguage *self,
115
+ const char *string,
116
+ uint32_t length,
117
+ bool is_named
118
+ ) {
119
+ if (!strncmp(string, "ERROR", length)) return ts_builtin_sym_error;
120
+ uint16_t count = (uint16_t)ts_language_symbol_count(self);
121
+ for (TSSymbol i = 0; i < count; i++) {
122
+ TSSymbolMetadata metadata = ts_language_symbol_metadata(self, i);
123
+ if ((!metadata.visible && !metadata.supertype) || metadata.named != is_named) continue;
124
+ const char *symbol_name = self->symbol_names[i];
125
+ if (!strncmp(symbol_name, string, length) && !symbol_name[length]) {
126
+ return self->public_symbol_map[i];
127
+ }
128
+ }
129
+ return 0;
130
+ }
131
+
132
+ TSSymbolType ts_language_symbol_type(
133
+ const TSLanguage *self,
134
+ TSSymbol symbol
135
+ ) {
136
+ TSSymbolMetadata metadata = ts_language_symbol_metadata(self, symbol);
137
+ if (metadata.named && metadata.visible) {
138
+ return TSSymbolTypeRegular;
139
+ } else if (metadata.visible) {
140
+ return TSSymbolTypeAnonymous;
141
+ } else {
142
+ return TSSymbolTypeAuxiliary;
143
+ }
144
+ }
145
+
146
+ const char *ts_language_field_name_for_id(
147
+ const TSLanguage *self,
148
+ TSFieldId id
149
+ ) {
150
+ uint32_t count = ts_language_field_count(self);
151
+ if (count && id <= count) {
152
+ return self->field_names[id];
153
+ } else {
154
+ return NULL;
155
+ }
156
+ }
157
+
158
+ TSFieldId ts_language_field_id_for_name(
159
+ const TSLanguage *self,
160
+ const char *name,
161
+ uint32_t name_length
162
+ ) {
163
+ uint16_t count = (uint16_t)ts_language_field_count(self);
164
+ for (TSSymbol i = 1; i < count + 1; i++) {
165
+ switch (strncmp(name, self->field_names[i], name_length)) {
166
+ case 0:
167
+ if (self->field_names[i][name_length] == 0) return i;
168
+ break;
169
+ case -1:
170
+ return 0;
171
+ default:
172
+ break;
173
+ }
174
+ }
175
+ return 0;
176
+ }
177
+
178
+ TSLookaheadIterator *ts_lookahead_iterator_new(const TSLanguage *self, TSStateId state) {
179
+ if (state >= self->state_count) return NULL;
180
+ LookaheadIterator *iterator = ts_malloc(sizeof(LookaheadIterator));
181
+ *iterator = ts_language_lookaheads(self, state);
182
+ return (TSLookaheadIterator *)iterator;
183
+ }
184
+
185
+ void ts_lookahead_iterator_delete(TSLookaheadIterator *self) {
186
+ ts_free(self);
187
+ }
188
+
189
+ bool ts_lookahead_iterator_reset_state(TSLookaheadIterator * self, TSStateId state) {
190
+ LookaheadIterator *iterator = (LookaheadIterator *)self;
191
+ if (state >= iterator->language->state_count) return false;
192
+ *iterator = ts_language_lookaheads(iterator->language, state);
193
+ return true;
194
+ }
195
+
196
+ const TSLanguage *ts_lookahead_iterator_language(const TSLookaheadIterator *self) {
197
+ const LookaheadIterator *iterator = (const LookaheadIterator *)self;
198
+ return iterator->language;
199
+ }
200
+
201
+ bool ts_lookahead_iterator_reset(TSLookaheadIterator *self, const TSLanguage *language, TSStateId state) {
202
+ if (state >= language->state_count) return false;
203
+ LookaheadIterator *iterator = (LookaheadIterator *)self;
204
+ *iterator = ts_language_lookaheads(language, state);
205
+ return true;
206
+ }
207
+
208
+ bool ts_lookahead_iterator_next(TSLookaheadIterator *self) {
209
+ LookaheadIterator *iterator = (LookaheadIterator *)self;
210
+ return ts_lookahead_iterator__next(iterator);
211
+ }
212
+
213
+ TSSymbol ts_lookahead_iterator_current_symbol(const TSLookaheadIterator *self) {
214
+ const LookaheadIterator *iterator = (const LookaheadIterator *)self;
215
+ return iterator->symbol;
216
+ }
217
+
218
+ const char *ts_lookahead_iterator_current_symbol_name(const TSLookaheadIterator *self) {
219
+ const LookaheadIterator *iterator = (const LookaheadIterator *)self;
220
+ return ts_language_symbol_name(iterator->language, iterator->symbol);
221
+ }
@@ -0,0 +1,299 @@
1
+ #ifndef TREE_SITTER_LANGUAGE_H_
2
+ #define TREE_SITTER_LANGUAGE_H_
3
+
4
+ #ifdef __cplusplus
5
+ extern "C" {
6
+ #endif
7
+
8
+ #include "./subtree.h"
9
+ #include "./parser.h"
10
+
11
+ #define ts_builtin_sym_error_repeat (ts_builtin_sym_error - 1)
12
+
13
+ #define LANGUAGE_VERSION_WITH_PRIMARY_STATES 14
14
+ #define LANGUAGE_VERSION_USABLE_VIA_WASM 13
15
+
16
+ typedef struct {
17
+ const TSParseAction *actions;
18
+ uint32_t action_count;
19
+ bool is_reusable;
20
+ } TableEntry;
21
+
22
+ typedef struct {
23
+ const TSLanguage *language;
24
+ const uint16_t *data;
25
+ const uint16_t *group_end;
26
+ TSStateId state;
27
+ uint16_t table_value;
28
+ uint16_t section_index;
29
+ uint16_t group_count;
30
+ bool is_small_state;
31
+
32
+ const TSParseAction *actions;
33
+ TSSymbol symbol;
34
+ TSStateId next_state;
35
+ uint16_t action_count;
36
+ } LookaheadIterator;
37
+
38
+ void ts_language_table_entry(const TSLanguage *, TSStateId, TSSymbol, TableEntry *);
39
+
40
+ TSSymbolMetadata ts_language_symbol_metadata(const TSLanguage *, TSSymbol);
41
+
42
+ TSSymbol ts_language_public_symbol(const TSLanguage *, TSSymbol);
43
+
44
+ TSStateId ts_language_next_state(const TSLanguage *self, TSStateId state, TSSymbol symbol);
45
+
46
+ static inline bool ts_language_is_symbol_external(const TSLanguage *self, TSSymbol symbol) {
47
+ return 0 < symbol && symbol < self->external_token_count + 1;
48
+ }
49
+
50
+ static inline const TSParseAction *ts_language_actions(
51
+ const TSLanguage *self,
52
+ TSStateId state,
53
+ TSSymbol symbol,
54
+ uint32_t *count
55
+ ) {
56
+ TableEntry entry;
57
+ ts_language_table_entry(self, state, symbol, &entry);
58
+ *count = entry.action_count;
59
+ return entry.actions;
60
+ }
61
+
62
+ static inline bool ts_language_has_reduce_action(
63
+ const TSLanguage *self,
64
+ TSStateId state,
65
+ TSSymbol symbol
66
+ ) {
67
+ TableEntry entry;
68
+ ts_language_table_entry(self, state, symbol, &entry);
69
+ return entry.action_count > 0 && entry.actions[0].type == TSParseActionTypeReduce;
70
+ }
71
+
72
+ // Lookup the table value for a given symbol and state.
73
+ //
74
+ // For non-terminal symbols, the table value represents a successor state.
75
+ // For terminal symbols, it represents an index in the actions table.
76
+ // For 'large' parse states, this is a direct lookup. For 'small' parse
77
+ // states, this requires searching through the symbol groups to find
78
+ // the given symbol.
79
+ static inline uint16_t ts_language_lookup(
80
+ const TSLanguage *self,
81
+ TSStateId state,
82
+ TSSymbol symbol
83
+ ) {
84
+ if (state >= self->large_state_count) {
85
+ uint32_t index = self->small_parse_table_map[state - self->large_state_count];
86
+ const uint16_t *data = &self->small_parse_table[index];
87
+ uint16_t group_count = *(data++);
88
+ for (unsigned i = 0; i < group_count; i++) {
89
+ uint16_t section_value = *(data++);
90
+ uint16_t symbol_count = *(data++);
91
+ for (unsigned j = 0; j < symbol_count; j++) {
92
+ if (*(data++) == symbol) return section_value;
93
+ }
94
+ }
95
+ return 0;
96
+ } else {
97
+ return self->parse_table[state * self->symbol_count + symbol];
98
+ }
99
+ }
100
+
101
+ static inline bool ts_language_has_actions(
102
+ const TSLanguage *self,
103
+ TSStateId state,
104
+ TSSymbol symbol
105
+ ) {
106
+ return ts_language_lookup(self, state, symbol) != 0;
107
+ }
108
+
109
+ // Iterate over all of the symbols that are valid in the given state.
110
+ //
111
+ // For 'large' parse states, this just requires iterating through
112
+ // all possible symbols and checking the parse table for each one.
113
+ // For 'small' parse states, this exploits the structure of the
114
+ // table to only visit the valid symbols.
115
+ static inline LookaheadIterator ts_language_lookaheads(
116
+ const TSLanguage *self,
117
+ TSStateId state
118
+ ) {
119
+ bool is_small_state = state >= self->large_state_count;
120
+ const uint16_t *data;
121
+ const uint16_t *group_end = NULL;
122
+ uint16_t group_count = 0;
123
+ if (is_small_state) {
124
+ uint32_t index = self->small_parse_table_map[state - self->large_state_count];
125
+ data = &self->small_parse_table[index];
126
+ group_end = data + 1;
127
+ group_count = *data;
128
+ } else {
129
+ data = &self->parse_table[state * self->symbol_count] - 1;
130
+ }
131
+ return (LookaheadIterator) {
132
+ .language = self,
133
+ .data = data,
134
+ .group_end = group_end,
135
+ .group_count = group_count,
136
+ .is_small_state = is_small_state,
137
+ .symbol = UINT16_MAX,
138
+ .next_state = 0,
139
+ };
140
+ }
141
+
142
+ static inline bool ts_lookahead_iterator__next(LookaheadIterator *self) {
143
+ // For small parse states, valid symbols are listed explicitly,
144
+ // grouped by their value. There's no need to look up the actions
145
+ // again until moving to the next group.
146
+ if (self->is_small_state) {
147
+ self->data++;
148
+ if (self->data == self->group_end) {
149
+ if (self->group_count == 0) return false;
150
+ self->group_count--;
151
+ self->table_value = *(self->data++);
152
+ unsigned symbol_count = *(self->data++);
153
+ self->group_end = self->data + symbol_count;
154
+ self->symbol = *self->data;
155
+ } else {
156
+ self->symbol = *self->data;
157
+ return true;
158
+ }
159
+ }
160
+
161
+ // For large parse states, iterate through every symbol until one
162
+ // is found that has valid actions.
163
+ else {
164
+ do {
165
+ self->data++;
166
+ self->symbol++;
167
+ if (self->symbol >= self->language->symbol_count) return false;
168
+ self->table_value = *self->data;
169
+ } while (!self->table_value);
170
+ }
171
+
172
+ // Depending on if the symbols is terminal or non-terminal, the table value either
173
+ // represents a list of actions or a successor state.
174
+ if (self->symbol < self->language->token_count) {
175
+ const TSParseActionEntry *entry = &self->language->parse_actions[self->table_value];
176
+ self->action_count = entry->entry.count;
177
+ self->actions = (const TSParseAction *)(entry + 1);
178
+ self->next_state = 0;
179
+ } else {
180
+ self->action_count = 0;
181
+ self->next_state = self->table_value;
182
+ }
183
+ return true;
184
+ }
185
+
186
+ // Whether the state is a "primary state". If this returns false, it indicates that there exists
187
+ // another state that behaves identically to this one with respect to query analysis.
188
+ static inline bool ts_language_state_is_primary(
189
+ const TSLanguage *self,
190
+ TSStateId state
191
+ ) {
192
+ if (self->version >= LANGUAGE_VERSION_WITH_PRIMARY_STATES) {
193
+ return state == self->primary_state_ids[state];
194
+ } else {
195
+ return true;
196
+ }
197
+ }
198
+
199
+ static inline const bool *ts_language_enabled_external_tokens(
200
+ const TSLanguage *self,
201
+ unsigned external_scanner_state
202
+ ) {
203
+ if (external_scanner_state == 0) {
204
+ return NULL;
205
+ } else {
206
+ return self->external_scanner.states + self->external_token_count * external_scanner_state;
207
+ }
208
+ }
209
+
210
+ static inline const TSSymbol *ts_language_alias_sequence(
211
+ const TSLanguage *self,
212
+ uint32_t production_id
213
+ ) {
214
+ return production_id ?
215
+ &self->alias_sequences[production_id * self->max_alias_sequence_length] :
216
+ NULL;
217
+ }
218
+
219
+ static inline TSSymbol ts_language_alias_at(
220
+ const TSLanguage *self,
221
+ uint32_t production_id,
222
+ uint32_t child_index
223
+ ) {
224
+ return production_id ?
225
+ self->alias_sequences[production_id * self->max_alias_sequence_length + child_index] :
226
+ 0;
227
+ }
228
+
229
+ static inline void ts_language_field_map(
230
+ const TSLanguage *self,
231
+ uint32_t production_id,
232
+ const TSFieldMapEntry **start,
233
+ const TSFieldMapEntry **end
234
+ ) {
235
+ if (self->field_count == 0) {
236
+ *start = NULL;
237
+ *end = NULL;
238
+ return;
239
+ }
240
+
241
+ TSFieldMapSlice slice = self->field_map_slices[production_id];
242
+ *start = &self->field_map_entries[slice.index];
243
+ *end = &self->field_map_entries[slice.index] + slice.length;
244
+ }
245
+
246
+ static inline void ts_language_aliases_for_symbol(
247
+ const TSLanguage *self,
248
+ TSSymbol original_symbol,
249
+ const TSSymbol **start,
250
+ const TSSymbol **end
251
+ ) {
252
+ *start = &self->public_symbol_map[original_symbol];
253
+ *end = *start + 1;
254
+
255
+ unsigned idx = 0;
256
+ for (;;) {
257
+ TSSymbol symbol = self->alias_map[idx++];
258
+ if (symbol == 0 || symbol > original_symbol) break;
259
+ uint16_t count = self->alias_map[idx++];
260
+ if (symbol == original_symbol) {
261
+ *start = &self->alias_map[idx];
262
+ *end = &self->alias_map[idx + count];
263
+ break;
264
+ }
265
+ idx += count;
266
+ }
267
+ }
268
+
269
+ static inline void ts_language_write_symbol_as_dot_string(
270
+ const TSLanguage *self,
271
+ FILE *f,
272
+ TSSymbol symbol
273
+ ) {
274
+ const char *name = ts_language_symbol_name(self, symbol);
275
+ for (const char *chr = name; *chr; chr++) {
276
+ switch (*chr) {
277
+ case '"':
278
+ case '\\':
279
+ fputc('\\', f);
280
+ fputc(*chr, f);
281
+ break;
282
+ case '\n':
283
+ fputs("\\n", f);
284
+ break;
285
+ case '\t':
286
+ fputs("\\t", f);
287
+ break;
288
+ default:
289
+ fputc(*chr, f);
290
+ break;
291
+ }
292
+ }
293
+ }
294
+
295
+ #ifdef __cplusplus
296
+ }
297
+ #endif
298
+
299
+ #endif // TREE_SITTER_LANGUAGE_H_
@@ -0,0 +1,52 @@
1
+ #ifndef TREE_SITTER_LENGTH_H_
2
+ #define TREE_SITTER_LENGTH_H_
3
+
4
+ #include <stdlib.h>
5
+ #include <stdbool.h>
6
+ #include "./point.h"
7
+ #include "tree_sitter/api.h"
8
+
9
+ typedef struct {
10
+ uint32_t bytes;
11
+ TSPoint extent;
12
+ } Length;
13
+
14
+ static const Length LENGTH_UNDEFINED = {0, {0, 1}};
15
+ static const Length LENGTH_MAX = {UINT32_MAX, {UINT32_MAX, UINT32_MAX}};
16
+
17
+ static inline bool length_is_undefined(Length length) {
18
+ return length.bytes == 0 && length.extent.column != 0;
19
+ }
20
+
21
+ static inline Length length_min(Length len1, Length len2) {
22
+ return (len1.bytes < len2.bytes) ? len1 : len2;
23
+ }
24
+
25
+ static inline Length length_add(Length len1, Length len2) {
26
+ Length result;
27
+ result.bytes = len1.bytes + len2.bytes;
28
+ result.extent = point_add(len1.extent, len2.extent);
29
+ return result;
30
+ }
31
+
32
+ static inline Length length_sub(Length len1, Length len2) {
33
+ Length result;
34
+ result.bytes = len1.bytes - len2.bytes;
35
+ result.extent = point_sub(len1.extent, len2.extent);
36
+ return result;
37
+ }
38
+
39
+ static inline Length length_zero(void) {
40
+ Length result = {0, {0, 0}};
41
+ return result;
42
+ }
43
+
44
+ static inline Length length_saturating_sub(Length len1, Length len2) {
45
+ if (len1.bytes > len2.bytes) {
46
+ return length_sub(len1, len2);
47
+ } else {
48
+ return length_zero();
49
+ }
50
+ }
51
+
52
+ #endif