@apple/tree-sitter-pkl 0.16.0 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (704) hide show
  1. package/.editorconfig +46 -0
  2. package/.gitattributes +50 -0
  3. package/CHANGELOG.adoc +88 -0
  4. package/CMakeLists.txt +66 -0
  5. package/Cargo.lock +21 -21
  6. package/Cargo.toml +1 -1
  7. package/Makefile +97 -0
  8. package/Package.swift +24 -0
  9. package/README.md +40 -0
  10. package/bindings/c/tree-sitter-pkl.h +16 -0
  11. package/bindings/c/tree-sitter-pkl.pc.in +10 -0
  12. package/bindings/c/tree_sitter/tree-sitter-pkl.h +16 -0
  13. package/bindings/go/binding.go +15 -0
  14. package/bindings/go/binding_test.go +15 -0
  15. package/bindings/node/binding_test.js +9 -0
  16. package/bindings/node/index.d.ts +27 -0
  17. package/bindings/python/tests/test_binding.py +12 -0
  18. package/bindings/python/tree_sitter_pkl/__init__.py +42 -0
  19. package/bindings/python/tree_sitter_pkl/__init__.pyi +10 -0
  20. package/bindings/python/tree_sitter_pkl/binding.c +35 -0
  21. package/bindings/python/tree_sitter_pkl/py.typed +0 -0
  22. package/bindings/swift/TreeSitterPkl/pkl.h +16 -0
  23. package/bindings/swift/TreeSitterPklTests/TreeSitterPklTests.swift +12 -0
  24. package/go.mod +5 -0
  25. package/gradle.properties +5 -0
  26. package/gradlew +251 -0
  27. package/gradlew.bat +94 -0
  28. package/grammar.js +322 -208
  29. package/licenserc.toml +23 -0
  30. package/package.json +4 -4
  31. package/pyproject.toml +29 -0
  32. package/queries/highlights.scm +14 -24
  33. package/queries/injections.scm +4 -4
  34. package/queries/locals.scm +2 -2
  35. package/scripts/license-header.txt +13 -0
  36. package/setup.py +77 -0
  37. package/src/grammar.json +1495 -1041
  38. package/src/node-types.json +4261 -1172
  39. package/src/parser.c +41920 -50720
  40. package/src/scanner.c +97 -29
  41. package/src/tree_sitter/alloc.h +54 -0
  42. package/src/tree_sitter/array.h +291 -0
  43. package/src/tree_sitter/parser.h +80 -17
  44. package/test/corpus/basic/annotation.txt +241 -0
  45. package/test/corpus/basic/comments.txt +41 -0
  46. package/test/corpus/basic/shebangComment.txt +15 -0
  47. package/test/corpus/basic/types.txt +187 -0
  48. package/test/corpus/class/constModifier.txt +23 -0
  49. package/test/corpus/class/fixedModifier.txt +23 -0
  50. package/test/corpus/expr/binary.txt +107 -0
  51. package/test/corpus/expr/binary2.txt +18 -0
  52. package/test/corpus/expr/functionLiteral.txt +22 -0
  53. package/test/corpus/expr/if.txt +15 -0
  54. package/test/corpus/expr/import.txt +20 -0
  55. package/test/corpus/expr/let.txt +17 -0
  56. package/test/corpus/expr/new.txt +34 -0
  57. package/test/corpus/expr/qualifiedAccess.txt +102 -0
  58. package/test/corpus/expr/read.txt +26 -0
  59. package/test/corpus/expr/subscript.txt +48 -0
  60. package/test/corpus/expr/super.txt +27 -0
  61. package/test/corpus/expr/throw.txt +13 -0
  62. package/test/corpus/expr/trace.txt +13 -0
  63. package/test/corpus/expr/typeTest.txt +29 -0
  64. package/test/corpus/expr/unaryMinus.txt +22 -0
  65. package/test/corpus/module/moduleHeader1.txt +23 -0
  66. package/test/corpus/module/moduleHeader2.txt +29 -0
  67. package/test/corpus/module/moduleHeader3.error.txt +23 -0
  68. package/test/corpus/module/moduleHeader4.txt +34 -0
  69. package/test/corpus/module/moduleHeader5.txt +16 -0
  70. package/test/corpus/module/moduleHeader6.txt +17 -0
  71. package/test/corpus/number/underscores.txt +99 -0
  72. package/test/corpus/object/mixedEntriesAndElements.txt +52 -0
  73. package/test/corpus/object/objectAmendChain.txt +38 -0
  74. package/test/corpus/object/objectBodyParams.txt +21 -0
  75. package/test/corpus/object/objectElementWithTypeConstraint +30 -0
  76. package/test/corpus/object/objectElementsWithParens.txt +51 -0
  77. package/test/corpus/object/objectElementsWithTypeParams +65 -0
  78. package/test/corpus/object/objectGenerator.txt +53 -0
  79. package/test/corpus/object/objectMember.txt +129 -0
  80. package/test/corpus/object/objectMemberPredicate.txt +41 -0
  81. package/test/corpus/object/objectSpread.txt +51 -0
  82. package/test/corpus/object/objectWhenGenerator.txt +71 -0
  83. package/test/corpus/snippetTests/annotation/annotation1.txt +284 -0
  84. package/test/corpus/snippetTests/annotation/annotation2.txt +20 -0
  85. package/test/corpus/snippetTests/annotation/annotation3.txt +24 -0
  86. package/test/corpus/snippetTests/annotation/annotation4.txt +32 -0
  87. package/test/corpus/snippetTests/annotation/annotation5.txt +28 -0
  88. package/test/corpus/snippetTests/annotation/annotation6.txt +19 -0
  89. package/test/corpus/snippetTests/annotation/annotationIsNotExpression.txt +29 -0
  90. package/test/corpus/snippetTests/annotation/deprecated1.txt +385 -0
  91. package/test/corpus/snippetTests/annotation/deprecated2.txt +99 -0
  92. package/test/corpus/snippetTests/annotation/deprecated3.txt +155 -0
  93. package/test/corpus/snippetTests/annotation/deprecatedNoRepeatedWarnings.txt +58 -0
  94. package/test/corpus/snippetTests/annotation/deprecatedWithMessage1.txt +405 -0
  95. package/test/corpus/snippetTests/annotation/deprecatedWithMessage2.txt +104 -0
  96. package/test/corpus/snippetTests/annotation/deprecatedWithMessage3.txt +155 -0
  97. package/test/corpus/snippetTests/annotation/deprecationSuperMethod.txt +144 -0
  98. package/test/corpus/snippetTests/api/Resource.txt +128 -0
  99. package/test/corpus/snippetTests/api/analyze1.txt +176 -0
  100. package/test/corpus/snippetTests/api/any.txt +523 -0
  101. package/test/corpus/snippetTests/api/anyConverter.txt +161 -0
  102. package/test/corpus/snippetTests/api/baseModule.txt +170 -0
  103. package/test/corpus/snippetTests/api/dataSize.txt +1165 -0
  104. package/test/corpus/snippetTests/api/duration.txt +800 -0
  105. package/test/corpus/snippetTests/api/float.txt +1334 -0
  106. package/test/corpus/snippetTests/api/int.txt +1142 -0
  107. package/test/corpus/snippetTests/api/intseq.txt +1021 -0
  108. package/test/corpus/snippetTests/api/jsonParser1.txt +279 -0
  109. package/test/corpus/snippetTests/api/jsonParser2.txt +294 -0
  110. package/test/corpus/snippetTests/api/jsonParser3.txt +143 -0
  111. package/test/corpus/snippetTests/api/jsonParser4.txt +112 -0
  112. package/test/corpus/snippetTests/api/jsonParser5.txt +171 -0
  113. package/test/corpus/snippetTests/api/jsonRenderer1.json.txt +41 -0
  114. package/test/corpus/snippetTests/api/jsonRenderer2b.txt +300 -0
  115. package/test/corpus/snippetTests/api/jsonRenderer3.json.txt +334 -0
  116. package/test/corpus/snippetTests/api/jsonRenderer4.txt +388 -0
  117. package/test/corpus/snippetTests/api/jsonRenderer5.txt +388 -0
  118. package/test/corpus/snippetTests/api/jsonRenderer6.json.txt +163 -0
  119. package/test/corpus/snippetTests/api/jsonRenderer7.txt +53 -0
  120. package/test/corpus/snippetTests/api/jsonRenderer8.txt +30 -0
  121. package/test/corpus/snippetTests/api/jsonRendererEmptyComposites.txt +114 -0
  122. package/test/corpus/snippetTests/api/jsonnetRenderer3.jsonnet.txt +356 -0
  123. package/test/corpus/snippetTests/api/jsonnetRenderer4.txt +393 -0
  124. package/test/corpus/snippetTests/api/jsonnetRenderer5.txt +393 -0
  125. package/test/corpus/snippetTests/api/jsonnetRenderer6.jsonnet.txt +169 -0
  126. package/test/corpus/snippetTests/api/jsonnetRenderer7.txt +36 -0
  127. package/test/corpus/snippetTests/api/list.txt +4432 -0
  128. package/test/corpus/snippetTests/api/listNullable.txt +1513 -0
  129. package/test/corpus/snippetTests/api/map.txt +1144 -0
  130. package/test/corpus/snippetTests/api/mapping.txt +948 -0
  131. package/test/corpus/snippetTests/api/mathModule.txt +1426 -0
  132. package/test/corpus/snippetTests/api/module.txt +77 -0
  133. package/test/corpus/snippetTests/api/moduleOutput.txt +24 -0
  134. package/test/corpus/snippetTests/api/moduleOutput2.txt +25 -0
  135. package/test/corpus/snippetTests/api/pListRenderer1.plist.txt +41 -0
  136. package/test/corpus/snippetTests/api/pListRenderer3.plist.txt +348 -0
  137. package/test/corpus/snippetTests/api/pListRenderer4.txt +375 -0
  138. package/test/corpus/snippetTests/api/pListRenderer5.txt +424 -0
  139. package/test/corpus/snippetTests/api/pListRenderer6.plist.txt +163 -0
  140. package/test/corpus/snippetTests/api/pListRenderer7.txt +30 -0
  141. package/test/corpus/snippetTests/api/pair.txt +170 -0
  142. package/test/corpus/snippetTests/api/pcfRenderer1.txt +95 -0
  143. package/test/corpus/snippetTests/api/pcfRenderer2b.txt +301 -0
  144. package/test/corpus/snippetTests/api/pcfRenderer3.txt +350 -0
  145. package/test/corpus/snippetTests/api/pcfRenderer4.txt +391 -0
  146. package/test/corpus/snippetTests/api/pcfRenderer5.txt +460 -0
  147. package/test/corpus/snippetTests/api/pcfRenderer6.txt +118 -0
  148. package/test/corpus/snippetTests/api/pcfRenderer8.txt +16 -0
  149. package/test/corpus/snippetTests/api/platformModule.txt +147 -0
  150. package/test/corpus/snippetTests/api/plistRenderer2b.txt +300 -0
  151. package/test/corpus/snippetTests/api/propertiesRenderer1.properties.txt +41 -0
  152. package/test/corpus/snippetTests/api/propertiesRenderer10.properties.txt +24 -0
  153. package/test/corpus/snippetTests/api/propertiesRenderer11.txt +30 -0
  154. package/test/corpus/snippetTests/api/propertiesRenderer2b.txt +303 -0
  155. package/test/corpus/snippetTests/api/propertiesRenderer4.txt +484 -0
  156. package/test/corpus/snippetTests/api/propertiesRenderer5.txt +491 -0
  157. package/test/corpus/snippetTests/api/propertiesRenderer8.properties.txt +628 -0
  158. package/test/corpus/snippetTests/api/propertiesRenderer9.properties.txt +292 -0
  159. package/test/corpus/snippetTests/api/propertiesRendererBug66849708.properties.txt +106 -0
  160. package/test/corpus/snippetTests/api/protobuf2.txt +408 -0
  161. package/test/corpus/snippetTests/api/reflect1.txt +1686 -0
  162. package/test/corpus/snippetTests/api/reflect2.txt +480 -0
  163. package/test/corpus/snippetTests/api/reflect3.txt +193 -0
  164. package/test/corpus/snippetTests/api/reflectedDeclaration.txt +64 -0
  165. package/test/corpus/snippetTests/api/regex.txt +320 -0
  166. package/test/corpus/snippetTests/api/releaseModule.txt +262 -0
  167. package/test/corpus/snippetTests/api/renderDirective2.txt +374 -0
  168. package/test/corpus/snippetTests/api/semverModule.txt +2224 -0
  169. package/test/corpus/snippetTests/api/set.txt +3891 -0
  170. package/test/corpus/snippetTests/api/setNullable.txt +1113 -0
  171. package/test/corpus/snippetTests/api/typeAliases.txt +449 -0
  172. package/test/corpus/snippetTests/api/typeConverters.txt +211 -0
  173. package/test/corpus/snippetTests/api/xmlRenderer1.xml.txt +174 -0
  174. package/test/corpus/snippetTests/api/xmlRenderer2b.txt +306 -0
  175. package/test/corpus/snippetTests/api/xmlRenderer3.xml.txt +320 -0
  176. package/test/corpus/snippetTests/api/xmlRenderer4.txt +401 -0
  177. package/test/corpus/snippetTests/api/xmlRenderer5.txt +402 -0
  178. package/test/corpus/snippetTests/api/xmlRenderer6.xml.txt +169 -0
  179. package/test/corpus/snippetTests/api/xmlRenderer8.txt +36 -0
  180. package/test/corpus/snippetTests/api/xmlRendererCData.xml.txt +48 -0
  181. package/test/corpus/snippetTests/api/xmlRendererElement.xml.txt +103 -0
  182. package/test/corpus/snippetTests/api/xmlRendererHtml.xml.txt +212 -0
  183. package/test/corpus/snippetTests/api/xmlRendererInline.xml.txt +175 -0
  184. package/test/corpus/snippetTests/api/xmlRendererInline3.xml.txt +152 -0
  185. package/test/corpus/snippetTests/api/yamlParser1Yaml11.txt +22 -0
  186. package/test/corpus/snippetTests/api/yamlParser1Yaml12.txt +22 -0
  187. package/test/corpus/snippetTests/api/yamlParser2.txt +253 -0
  188. package/test/corpus/snippetTests/api/yamlParser3.txt +194 -0
  189. package/test/corpus/snippetTests/api/yamlParser4.txt +198 -0
  190. package/test/corpus/snippetTests/api/yamlParser5.txt +86 -0
  191. package/test/corpus/snippetTests/api/yamlParser6.txt +92 -0
  192. package/test/corpus/snippetTests/api/yamlRenderer1.yml.txt +41 -0
  193. package/test/corpus/snippetTests/api/yamlRenderer2b.txt +300 -0
  194. package/test/corpus/snippetTests/api/yamlRenderer3.yml.txt +342 -0
  195. package/test/corpus/snippetTests/api/yamlRenderer4.txt +441 -0
  196. package/test/corpus/snippetTests/api/yamlRenderer5.txt +441 -0
  197. package/test/corpus/snippetTests/api/yamlRenderer6.yml.txt +163 -0
  198. package/test/corpus/snippetTests/api/yamlRenderer7.txt +30 -0
  199. package/test/corpus/snippetTests/api/yamlRenderer8.yml.txt +142 -0
  200. package/test/corpus/snippetTests/api/yamlRendererBug66849708.yml.txt +106 -0
  201. package/test/corpus/snippetTests/api/yamlRendererEmpty.yml.txt +326 -0
  202. package/test/corpus/snippetTests/api/yamlRendererIndentationWidth2.yml.txt +227 -0
  203. package/test/corpus/snippetTests/api/yamlRendererIndentationWidth4.yml.txt +32 -0
  204. package/test/corpus/snippetTests/api/yamlRendererIndentationWidth5.yml.txt +32 -0
  205. package/test/corpus/snippetTests/api/yamlRendererStream1.txt +140 -0
  206. package/test/corpus/snippetTests/api/yamlRendererStringsYaml11.txt +22 -0
  207. package/test/corpus/snippetTests/api/yamlRendererStringsYaml12.txt +22 -0
  208. package/test/corpus/snippetTests/basic/amendsChains.txt +275 -0
  209. package/test/corpus/snippetTests/basic/as.txt +1468 -0
  210. package/test/corpus/snippetTests/basic/as2.txt +1077 -0
  211. package/test/corpus/snippetTests/basic/as3.txt +297 -0
  212. package/test/corpus/snippetTests/basic/baseModule.txt +11 -0
  213. package/test/corpus/snippetTests/basic/boolean.txt +430 -0
  214. package/test/corpus/snippetTests/basic/constModifier.txt +324 -0
  215. package/test/corpus/snippetTests/basic/constModifier2.txt +227 -0
  216. package/test/corpus/snippetTests/basic/constModifier3.txt +136 -0
  217. package/test/corpus/snippetTests/basic/constModifier4.txt +64 -0
  218. package/test/corpus/snippetTests/basic/constModifier5.txt +68 -0
  219. package/test/corpus/snippetTests/basic/dataSize.txt +658 -0
  220. package/test/corpus/snippetTests/basic/duration.txt +618 -0
  221. package/test/corpus/snippetTests/basic/exceptions.txt +18 -0
  222. package/test/corpus/snippetTests/basic/fixedProperty1.txt +62 -0
  223. package/test/corpus/snippetTests/basic/fixedProperty2.txt +33 -0
  224. package/test/corpus/snippetTests/basic/fixedProperty3.txt +31 -0
  225. package/test/corpus/snippetTests/basic/fixedProperty4.txt +15 -0
  226. package/test/corpus/snippetTests/basic/fixedProperty5.txt +20 -0
  227. package/test/corpus/snippetTests/basic/fixedProperty6.txt +15 -0
  228. package/test/corpus/snippetTests/basic/if.txt +83 -0
  229. package/test/corpus/snippetTests/basic/import1.txt +51 -0
  230. package/test/corpus/snippetTests/basic/import1b.txt +51 -0
  231. package/test/corpus/snippetTests/basic/import2.txt +34 -0
  232. package/test/corpus/snippetTests/basic/import3.txt +34 -0
  233. package/test/corpus/snippetTests/basic/imported.txt +19 -0
  234. package/test/corpus/snippetTests/basic/indexExpressions.txt +53 -0
  235. package/test/corpus/snippetTests/basic/intseq.txt +365 -0
  236. package/test/corpus/snippetTests/basic/is.txt +1504 -0
  237. package/test/corpus/snippetTests/basic/is2.txt +677 -0
  238. package/test/corpus/snippetTests/basic/let.txt +515 -0
  239. package/test/corpus/snippetTests/basic/letTyped.txt +293 -0
  240. package/test/corpus/snippetTests/basic/list.txt +252 -0
  241. package/test/corpus/snippetTests/basic/localMethodDynamicBinding.txt +187 -0
  242. package/test/corpus/snippetTests/basic/localMethodInAmendingModule.txt +216 -0
  243. package/test/corpus/snippetTests/basic/localMethodOverride1.txt +152 -0
  244. package/test/corpus/snippetTests/basic/localMethodOverride2.txt +173 -0
  245. package/test/corpus/snippetTests/basic/localMethodTyped.txt +564 -0
  246. package/test/corpus/snippetTests/basic/localMethodTyped2.txt +580 -0
  247. package/test/corpus/snippetTests/basic/localMethodTyped3.txt +218 -0
  248. package/test/corpus/snippetTests/basic/localMethodTyped4.txt +232 -0
  249. package/test/corpus/snippetTests/basic/localMethodTyped5.txt +211 -0
  250. package/test/corpus/snippetTests/basic/localMethodTyped6.txt +225 -0
  251. package/test/corpus/snippetTests/basic/localMethodUntyped.txt +488 -0
  252. package/test/corpus/snippetTests/basic/localModuleMemberOverride1.txt +227 -0
  253. package/test/corpus/snippetTests/basic/localModuleMemberOverride2.txt +202 -0
  254. package/test/corpus/snippetTests/basic/localProperty1.txt +33 -0
  255. package/test/corpus/snippetTests/basic/localProperty2.txt +77 -0
  256. package/test/corpus/snippetTests/basic/localPropertyAmendInAmendingModule.txt +25 -0
  257. package/test/corpus/snippetTests/basic/localPropertyInAmendingModule.txt +205 -0
  258. package/test/corpus/snippetTests/basic/localPropertyOverride1.txt +131 -0
  259. package/test/corpus/snippetTests/basic/localPropertyOverride2.txt +152 -0
  260. package/test/corpus/snippetTests/basic/localPropertyOverride3.txt +52 -0
  261. package/test/corpus/snippetTests/basic/localTypedClassMember.txt +277 -0
  262. package/test/corpus/snippetTests/basic/localTypedModuleMember.txt +265 -0
  263. package/test/corpus/snippetTests/basic/localTypedObjectMember.txt +268 -0
  264. package/test/corpus/snippetTests/basic/map.txt +398 -0
  265. package/test/corpus/snippetTests/basic/minPklVersion.txt +40 -0
  266. package/test/corpus/snippetTests/basic/moduleRef1.txt +108 -0
  267. package/test/corpus/snippetTests/basic/moduleRef2.txt +80 -0
  268. package/test/corpus/snippetTests/basic/moduleRef3.txt +112 -0
  269. package/test/corpus/snippetTests/basic/moduleRefLibrary.txt +33 -0
  270. package/test/corpus/snippetTests/basic/new.txt +1028 -0
  271. package/test/corpus/snippetTests/basic/newInAmendingModuleMethod.txt +116 -0
  272. package/test/corpus/snippetTests/basic/newInsideIf.txt +841 -0
  273. package/test/corpus/snippetTests/basic/newInsideLet.txt +869 -0
  274. package/test/corpus/snippetTests/basic/newType.txt +686 -0
  275. package/test/corpus/snippetTests/basic/nonNull.txt +131 -0
  276. package/test/corpus/snippetTests/basic/nullable.txt +239 -0
  277. package/test/corpus/snippetTests/basic/objectMember.txt +129 -0
  278. package/test/corpus/snippetTests/basic/objectMemberInvalid.txt +18 -0
  279. package/test/corpus/snippetTests/basic/objectMemberInvalid2.txt +18 -0
  280. package/test/corpus/snippetTests/basic/objectMemberInvalid3.txt +22 -0
  281. package/test/corpus/snippetTests/basic/parens.txt +59 -0
  282. package/test/corpus/snippetTests/basic/propertyDefaults.txt +126 -0
  283. package/test/corpus/snippetTests/basic/read.txt +250 -0
  284. package/test/corpus/snippetTests/basic/readGlob.txt +209 -0
  285. package/test/corpus/snippetTests/basic/semicolon.txt +18 -0
  286. package/test/corpus/snippetTests/basic/set.txt +340 -0
  287. package/test/corpus/snippetTests/basic/trace.txt +130 -0
  288. package/test/corpus/snippetTests/basic/typeResolution1.txt +31 -0
  289. package/test/corpus/snippetTests/basic/typeResolution2.txt +37 -0
  290. package/test/corpus/snippetTests/basic/typeResolution3.txt +63 -0
  291. package/test/corpus/snippetTests/basic/typeResolution4.txt +61 -0
  292. package/test/corpus/snippetTests/basic/underscore.txt +419 -0
  293. package/test/corpus/snippetTests/classes/class1.txt +54 -0
  294. package/test/corpus/snippetTests/classes/class2.txt +123 -0
  295. package/test/corpus/snippetTests/classes/class2a.txt +110 -0
  296. package/test/corpus/snippetTests/classes/class3.txt +65 -0
  297. package/test/corpus/snippetTests/classes/class4.txt +58 -0
  298. package/test/corpus/snippetTests/classes/constraints1.txt +141 -0
  299. package/test/corpus/snippetTests/classes/constraints11.txt +201 -0
  300. package/test/corpus/snippetTests/classes/constraints12.txt +204 -0
  301. package/test/corpus/snippetTests/classes/constraints13.txt +86 -0
  302. package/test/corpus/snippetTests/classes/constraints14.txt +39 -0
  303. package/test/corpus/snippetTests/classes/constraints2.txt +69 -0
  304. package/test/corpus/snippetTests/classes/constraints3.txt +97 -0
  305. package/test/corpus/snippetTests/classes/constraints4.txt +86 -0
  306. package/test/corpus/snippetTests/classes/constraints5.txt +71 -0
  307. package/test/corpus/snippetTests/classes/constraints6.txt +85 -0
  308. package/test/corpus/snippetTests/classes/constraints7.txt +148 -0
  309. package/test/corpus/snippetTests/classes/constraints8.txt +103 -0
  310. package/test/corpus/snippetTests/classes/constraints9.txt +92 -0
  311. package/test/corpus/snippetTests/classes/constraintsLambdaThis.txt +216 -0
  312. package/test/corpus/snippetTests/classes/equality.txt +123 -0
  313. package/test/corpus/snippetTests/classes/externalClass.txt +12 -0
  314. package/test/corpus/snippetTests/classes/externalFunction.txt +18 -0
  315. package/test/corpus/snippetTests/classes/externalProperty.txt +20 -0
  316. package/test/corpus/snippetTests/classes/functions1.txt +77 -0
  317. package/test/corpus/snippetTests/classes/functions2.txt +56 -0
  318. package/test/corpus/snippetTests/classes/functions3.txt +81 -0
  319. package/test/corpus/snippetTests/classes/functions4.txt +125 -0
  320. package/test/corpus/snippetTests/classes/inheritance1.txt +98 -0
  321. package/test/corpus/snippetTests/classes/inheritance2.txt +91 -0
  322. package/test/corpus/snippetTests/classes/invalidInstantiation1.txt +16 -0
  323. package/test/corpus/snippetTests/classes/invalidInstantiation2.txt +21 -0
  324. package/test/corpus/snippetTests/classes/lambdaConstraints1.txt +190 -0
  325. package/test/corpus/snippetTests/classes/listConstraints1.txt +312 -0
  326. package/test/corpus/snippetTests/classes/mapConstraints1.txt +495 -0
  327. package/test/corpus/snippetTests/classes/nullableTypes.txt +187 -0
  328. package/test/corpus/snippetTests/classes/setConstraints1.txt +312 -0
  329. package/test/corpus/snippetTests/classes/supercalls.txt +317 -0
  330. package/test/corpus/snippetTests/classes/unionTypes.txt +543 -0
  331. package/test/corpus/snippetTests/classes/unionTypesErrorAlias.txt +93 -0
  332. package/test/corpus/snippetTests/classes/unionTypesErrorDifferent1.txt +47 -0
  333. package/test/corpus/snippetTests/classes/unionTypesErrorDifferent2.txt +52 -0
  334. package/test/corpus/snippetTests/classes/unionTypesErrorMultipleAliases.txt +36 -0
  335. package/test/corpus/snippetTests/classes/unionTypesErrorNested.txt +99 -0
  336. package/test/corpus/snippetTests/classes/unionTypesErrorSimple.txt +42 -0
  337. package/test/corpus/snippetTests/classes/unionTypesErrorString1.txt +43 -0
  338. package/test/corpus/snippetTests/classes/unionTypesErrorString2.txt +85 -0
  339. package/test/corpus/snippetTests/classes/wrongType1.txt +34 -0
  340. package/test/corpus/snippetTests/classes/wrongType2.txt +47 -0
  341. package/test/corpus/snippetTests/classes/wrongType3.txt +71 -0
  342. package/test/corpus/snippetTests/classes/wrongType4.txt +77 -0
  343. package/test/corpus/snippetTests/classes/wrongType6.txt +43 -0
  344. package/test/corpus/snippetTests/errors/abstractOpenMember.txt +13 -0
  345. package/test/corpus/snippetTests/errors/analyzeImportsCannotFindModule.txt +41 -0
  346. package/test/corpus/snippetTests/errors/analyzeImportsInvalidGlob.txt +41 -0
  347. package/test/corpus/snippetTests/errors/analyzeInvalidHttpModule.txt +26 -0
  348. package/test/corpus/snippetTests/errors/analyzeInvalidModuleUri.txt +26 -0
  349. package/test/corpus/snippetTests/errors/analyzeRelativeModuleUri.txt +26 -0
  350. package/test/corpus/snippetTests/errors/anyConverterError.txt +56 -0
  351. package/test/corpus/snippetTests/errors/baseModule.txt +24 -0
  352. package/test/corpus/snippetTests/errors/cannotAmendFixedProperty1.txt +62 -0
  353. package/test/corpus/snippetTests/errors/cannotAmendFixedProperty2.txt +24 -0
  354. package/test/corpus/snippetTests/errors/cannotAssignFixedProperty1.txt +45 -0
  355. package/test/corpus/snippetTests/errors/cannotAssignFixedProperty2.txt +19 -0
  356. package/test/corpus/snippetTests/errors/cannotAssignFixedProperty3.txt +31 -0
  357. package/test/corpus/snippetTests/errors/cannotAssignToNothing.txt +15 -0
  358. package/test/corpus/snippetTests/errors/cannotChangeFixed1.txt +35 -0
  359. package/test/corpus/snippetTests/errors/cannotChangeFixed2.txt +35 -0
  360. package/test/corpus/snippetTests/errors/cannotFindMapKey.txt +39 -0
  361. package/test/corpus/snippetTests/errors/cannotFindStdLibModule.txt +20 -0
  362. package/test/corpus/snippetTests/errors/cannotInferParent2.txt +14 -0
  363. package/test/corpus/snippetTests/errors/cannotInferParent3.txt +48 -0
  364. package/test/corpus/snippetTests/errors/cannotInstantiateAbstractModule.txt +21 -0
  365. package/test/corpus/snippetTests/errors/cannotRenderMixin.txt +41 -0
  366. package/test/corpus/snippetTests/errors/classExtendsSelf.txt +27 -0
  367. package/test/corpus/snippetTests/errors/constraintDetails1.txt +80 -0
  368. package/test/corpus/snippetTests/errors/constraintDetails2.txt +77 -0
  369. package/test/corpus/snippetTests/errors/constraintDetails3.txt +87 -0
  370. package/test/corpus/snippetTests/errors/duplicateTypeParameter.txt +22 -0
  371. package/test/corpus/snippetTests/errors/extendExternalClass.txt +12 -0
  372. package/test/corpus/snippetTests/errors/extendTypeAlias.txt +33 -0
  373. package/test/corpus/snippetTests/errors/forGeneratorCannotGenerateMethods.txt +30 -0
  374. package/test/corpus/snippetTests/errors/forGeneratorCannotGenerateProperties.txt +28 -0
  375. package/test/corpus/snippetTests/errors/forGeneratorCannotIterateOverThisValue.txt +21 -0
  376. package/test/corpus/snippetTests/errors/forGeneratorCannotIterateOverTyped.txt +27 -0
  377. package/test/corpus/snippetTests/errors/forGeneratorDuplicateParams1.txt +38 -0
  378. package/test/corpus/snippetTests/errors/fullStackTraces.txt +64 -0
  379. package/test/corpus/snippetTests/errors/fullStackTraces2.txt +56 -0
  380. package/test/corpus/snippetTests/errors/functionNotFoundInClass.txt +35 -0
  381. package/test/corpus/snippetTests/errors/functionNotFoundInModule.txt +25 -0
  382. package/test/corpus/snippetTests/errors/functionNotFoundInScope.txt +38 -0
  383. package/test/corpus/snippetTests/errors/functionNotFoundMaybeLambda.txt +24 -0
  384. package/test/corpus/snippetTests/errors/functionNotFoundMaybeProperty.txt +18 -0
  385. package/test/corpus/snippetTests/errors/intrinsifiedTypeAlias1.txt +16 -0
  386. package/test/corpus/snippetTests/errors/intrinsifiedTypeAlias2.txt +16 -0
  387. package/test/corpus/snippetTests/errors/intrinsifiedTypeAlias3.txt +15 -0
  388. package/test/corpus/snippetTests/errors/intrinsifiedTypeAlias4.txt +15 -0
  389. package/test/corpus/snippetTests/errors/invalidClassMethodModifier.txt +29 -0
  390. package/test/corpus/snippetTests/errors/invalidClassModifier.txt +11 -0
  391. package/test/corpus/snippetTests/errors/invalidClassModifier2.txt +12 -0
  392. package/test/corpus/snippetTests/errors/invalidClassPropertyModifier.txt +31 -0
  393. package/test/corpus/snippetTests/errors/invalidGlobImport1.txt +19 -0
  394. package/test/corpus/snippetTests/errors/invalidGlobImport4.txt +19 -0
  395. package/test/corpus/snippetTests/errors/invalidGlobImport5.txt +20 -0
  396. package/test/corpus/snippetTests/errors/invalidGlobImport6.txt +14 -0
  397. package/test/corpus/snippetTests/errors/invalidGlobImport7.txt +21 -0
  398. package/test/corpus/snippetTests/errors/invalidGlobImport8.txt +22 -0
  399. package/test/corpus/snippetTests/errors/invalidGlobRead1.txt +14 -0
  400. package/test/corpus/snippetTests/errors/invalidGlobRead2.txt +14 -0
  401. package/test/corpus/snippetTests/errors/invalidGlobRead3.txt +14 -0
  402. package/test/corpus/snippetTests/errors/invalidImportBackslashSep.txt +14 -0
  403. package/test/corpus/snippetTests/errors/invalidImportUri.txt +19 -0
  404. package/test/corpus/snippetTests/errors/invalidMethodModifier.txt +14 -0
  405. package/test/corpus/snippetTests/errors/invalidModuleModifier.txt +20 -0
  406. package/test/corpus/snippetTests/errors/invalidObjectPropertyModifier.txt +17 -0
  407. package/test/corpus/snippetTests/errors/invalidOutput1.txt +17 -0
  408. package/test/corpus/snippetTests/errors/invalidOutput2.txt +22 -0
  409. package/test/corpus/snippetTests/errors/invalidOutput3.txt +12 -0
  410. package/test/corpus/snippetTests/errors/invalidPropertyModifier.txt +16 -0
  411. package/test/corpus/snippetTests/errors/invalidTripleDotSyntax1.txt +11 -0
  412. package/test/corpus/snippetTests/errors/invalidTripleDotSyntax2.txt +11 -0
  413. package/test/corpus/snippetTests/errors/invalidTypeAliasModifier.txt +14 -0
  414. package/test/corpus/snippetTests/errors/invalidTypeName1.txt +24 -0
  415. package/test/corpus/snippetTests/errors/invalidTypeName2.txt +31 -0
  416. package/test/corpus/snippetTests/errors/invalidTypeName3.txt +19 -0
  417. package/test/corpus/snippetTests/errors/invalidTypeName4.txt +24 -0
  418. package/test/corpus/snippetTests/errors/letExpressionError1.txt +24 -0
  419. package/test/corpus/snippetTests/errors/letExpressionError2.txt +27 -0
  420. package/test/corpus/snippetTests/errors/letExpressionErrorTyped.txt +27 -0
  421. package/test/corpus/snippetTests/errors/listingTypeCheckError1.txt +24 -0
  422. package/test/corpus/snippetTests/errors/listingTypeCheckError2.txt +30 -0
  423. package/test/corpus/snippetTests/errors/listingTypeCheckError3.txt +36 -0
  424. package/test/corpus/snippetTests/errors/listingTypeCheckError4.txt +43 -0
  425. package/test/corpus/snippetTests/errors/listingTypeCheckError5.txt +40 -0
  426. package/test/corpus/snippetTests/errors/listingTypeCheckError6.txt +58 -0
  427. package/test/corpus/snippetTests/errors/listingTypeCheckError7.txt +42 -0
  428. package/test/corpus/snippetTests/errors/listingTypeCheckError8.txt +84 -0
  429. package/test/corpus/snippetTests/errors/listingTypeCheckError9.txt +97 -0
  430. package/test/corpus/snippetTests/errors/localFixedMember.txt +19 -0
  431. package/test/corpus/snippetTests/errors/localFunctionWithTypeParameter.txt +18 -0
  432. package/test/corpus/snippetTests/errors/localHiddenMember.txt +17 -0
  433. package/test/corpus/snippetTests/errors/mappingTypeCheckError1.txt +29 -0
  434. package/test/corpus/snippetTests/errors/mappingTypeCheckError10.txt +49 -0
  435. package/test/corpus/snippetTests/errors/mappingTypeCheckError11.txt +106 -0
  436. package/test/corpus/snippetTests/errors/mappingTypeCheckError2.txt +30 -0
  437. package/test/corpus/snippetTests/errors/mappingTypeCheckError3.txt +30 -0
  438. package/test/corpus/snippetTests/errors/mappingTypeCheckError4.txt +36 -0
  439. package/test/corpus/snippetTests/errors/mappingTypeCheckError5.txt +41 -0
  440. package/test/corpus/snippetTests/errors/mappingTypeCheckError6.txt +75 -0
  441. package/test/corpus/snippetTests/errors/mappingTypeCheckError7.txt +45 -0
  442. package/test/corpus/snippetTests/errors/mappingTypeCheckError8.txt +33 -0
  443. package/test/corpus/snippetTests/errors/mappingTypeCheckError9.txt +69 -0
  444. package/test/corpus/snippetTests/errors/missingLocalPropertyValue1.txt +15 -0
  445. package/test/corpus/snippetTests/errors/missingLocalPropertyValue2.txt +22 -0
  446. package/test/corpus/snippetTests/errors/moduleAmendsSelf.txt +13 -0
  447. package/test/corpus/snippetTests/errors/moduleAmendsVersionCheck.txt +13 -0
  448. package/test/corpus/snippetTests/errors/moduleAmendsVersionCheck2.txt +22 -0
  449. package/test/corpus/snippetTests/errors/moduleExpected.txt +43 -0
  450. package/test/corpus/snippetTests/errors/moduleExtendsSelf.txt +20 -0
  451. package/test/corpus/snippetTests/errors/moduleExtendsVersionCheck.txt +13 -0
  452. package/test/corpus/snippetTests/errors/moduleExtendsVersionCheck2.txt +22 -0
  453. package/test/corpus/snippetTests/errors/moduleImportVersionCheck.txt +20 -0
  454. package/test/corpus/snippetTests/errors/moduleWithHighMinPklVersion.txt +29 -0
  455. package/test/corpus/snippetTests/errors/noDefault.txt +23 -0
  456. package/test/corpus/snippetTests/errors/noDefault2.txt +31 -0
  457. package/test/corpus/snippetTests/errors/objectCannotHaveElement.txt +72 -0
  458. package/test/corpus/snippetTests/errors/objectCannotHaveElement2.txt +98 -0
  459. package/test/corpus/snippetTests/errors/objectCannotHavePredicateMember.txt +25 -0
  460. package/test/corpus/snippetTests/errors/outOfRange1.txt +14 -0
  461. package/test/corpus/snippetTests/errors/outOfRange2.txt +17 -0
  462. package/test/corpus/snippetTests/errors/outOfRange3.txt +21 -0
  463. package/test/corpus/snippetTests/errors/propertyNotFound1.txt +32 -0
  464. package/test/corpus/snippetTests/errors/propertyNotFound2.txt +18 -0
  465. package/test/corpus/snippetTests/errors/refusingToLoadModule.txt +18 -0
  466. package/test/corpus/snippetTests/errors/spreadSyntaxCannotHaveElement.txt +38 -0
  467. package/test/corpus/snippetTests/errors/spreadSyntaxCannotHaveEntry.txt +34 -0
  468. package/test/corpus/snippetTests/errors/spreadSyntaxCannotHaveProperty.txt +34 -0
  469. package/test/corpus/snippetTests/errors/spreadSyntaxCannotIterateOverTyped.txt +44 -0
  470. package/test/corpus/snippetTests/errors/spreadSyntaxCannotSpreadListIntoMapping.txt +37 -0
  471. package/test/corpus/snippetTests/errors/spreadSyntaxDuplicateEntry1.txt +39 -0
  472. package/test/corpus/snippetTests/errors/spreadSyntaxDuplicateEntry2.txt +39 -0
  473. package/test/corpus/snippetTests/errors/spreadSyntaxDuplicateProperty1.txt +32 -0
  474. package/test/corpus/snippetTests/errors/spreadSyntaxDuplicateProperty2.txt +32 -0
  475. package/test/corpus/snippetTests/errors/spreadSyntaxNullValue.txt +20 -0
  476. package/test/corpus/snippetTests/errors/spreadSyntaxUnknownTypedProperty.txt +47 -0
  477. package/test/corpus/snippetTests/errors/stackTraceWithQuotedMemberName.txt +23 -0
  478. package/test/corpus/snippetTests/errors/supercalls.txt +18 -0
  479. package/test/corpus/snippetTests/errors/typeMismatchHelper.txt +19 -0
  480. package/test/corpus/snippetTests/errors/typeMismatchWithSameQualifiedClassName.txt +38 -0
  481. package/test/corpus/snippetTests/errors/typeMismatchWithSameQualifiedModuleName.txt +28 -0
  482. package/test/corpus/snippetTests/errors/undefinedOp1.txt +12 -0
  483. package/test/corpus/snippetTests/errors/undefinedOp2.txt +14 -0
  484. package/test/corpus/snippetTests/errors/undefinedOp3.txt +24 -0
  485. package/test/corpus/snippetTests/errors/undefinedProperty1.txt +28 -0
  486. package/test/corpus/snippetTests/errors/undefinedProperty2.txt +15 -0
  487. package/test/corpus/snippetTests/errors/undefinedProperty3.txt +95 -0
  488. package/test/corpus/snippetTests/errors/undefinedProperty4.txt +141 -0
  489. package/test/corpus/snippetTests/errors/undefinedProperty5.txt +160 -0
  490. package/test/corpus/snippetTests/errors/undefinedProperty6.txt +40 -0
  491. package/test/corpus/snippetTests/errors/undefinedProperty7.txt +35 -0
  492. package/test/corpus/snippetTests/errors/undefinedProperty8.txt +34 -0
  493. package/test/corpus/snippetTests/errors/underscoreLambda.txt +37 -0
  494. package/test/corpus/snippetTests/errors/underscoreLet.txt +17 -0
  495. package/test/corpus/snippetTests/errors/userDefinedTypeParameter1.txt +22 -0
  496. package/test/corpus/snippetTests/errors/userDefinedTypeParameter2.txt +32 -0
  497. package/test/corpus/snippetTests/errors/wrongForGeneratorType1.txt +35 -0
  498. package/test/corpus/snippetTests/errors/wrongForGeneratorType2.txt +37 -0
  499. package/test/corpus/snippetTests/errors/wrongNumberOfMapArguments.txt +16 -0
  500. package/test/corpus/snippetTests/generators/duplicateDefinition1.txt +23 -0
  501. package/test/corpus/snippetTests/generators/duplicateDefinition2.txt +30 -0
  502. package/test/corpus/snippetTests/generators/duplicateDefinition3.txt +26 -0
  503. package/test/corpus/snippetTests/generators/elementGenerators.txt +2628 -0
  504. package/test/corpus/snippetTests/generators/elementGeneratorsTyped.txt +1593 -0
  505. package/test/corpus/snippetTests/generators/entryGenerators.txt +3013 -0
  506. package/test/corpus/snippetTests/generators/entryGeneratorsTyped.txt +1858 -0
  507. package/test/corpus/snippetTests/generators/forGeneratorInMixins.txt +301 -0
  508. package/test/corpus/snippetTests/generators/forGeneratorLexicalScope.txt +199 -0
  509. package/test/corpus/snippetTests/generators/forGeneratorNestedReference.txt +277 -0
  510. package/test/corpus/snippetTests/generators/forGeneratorNestedReference2.txt +98 -0
  511. package/test/corpus/snippetTests/generators/forGeneratorVariableShadowing.txt +177 -0
  512. package/test/corpus/snippetTests/generators/generatorNoMembers.txt +157 -0
  513. package/test/corpus/snippetTests/generators/predicateMembersDynamicListing.txt +461 -0
  514. package/test/corpus/snippetTests/generators/predicateMembersDynamicMapping.txt +473 -0
  515. package/test/corpus/snippetTests/generators/predicateMembersListing.txt +463 -0
  516. package/test/corpus/snippetTests/generators/predicateMembersMapping.txt +474 -0
  517. package/test/corpus/snippetTests/generators/predicateMembersThis.txt +82 -0
  518. package/test/corpus/snippetTests/generators/propertyGenerators.txt +104 -0
  519. package/test/corpus/snippetTests/generators/spreadSyntaxDynamic.txt +411 -0
  520. package/test/corpus/snippetTests/generators/spreadSyntaxListing.txt +496 -0
  521. package/test/corpus/snippetTests/generators/spreadSyntaxMapping.txt +655 -0
  522. package/test/corpus/snippetTests/generators/spreadSyntaxNoSpace.txt +32 -0
  523. package/test/corpus/snippetTests/generators/spreadSyntaxNullable.txt +37 -0
  524. package/test/corpus/snippetTests/generators/spreadSyntaxTyped.txt +59 -0
  525. package/test/corpus/snippetTests/implementation/equality.txt +198 -0
  526. package/test/corpus/snippetTests/implementation/inequality.txt +198 -0
  527. package/test/corpus/snippetTests/internal/polymorphicCallSite.txt +499 -0
  528. package/test/corpus/snippetTests/lambdas/amendLambdaDef.txt +310 -0
  529. package/test/corpus/snippetTests/lambdas/amendLambdaExpr.txt +325 -0
  530. package/test/corpus/snippetTests/lambdas/amendLambdaExternalClassError.txt +45 -0
  531. package/test/corpus/snippetTests/lambdas/amendLambdaParameters.txt +155 -0
  532. package/test/corpus/snippetTests/lambdas/amendLambdaParametersTyped.txt +420 -0
  533. package/test/corpus/snippetTests/lambdas/amendLambdaThatReturnsAnotherLambda.txt +380 -0
  534. package/test/corpus/snippetTests/lambdas/amendLambdaTooFewArgsError.txt +60 -0
  535. package/test/corpus/snippetTests/lambdas/amendLambdaTooManyArgsError.txt +62 -0
  536. package/test/corpus/snippetTests/lambdas/equality.txt +62 -0
  537. package/test/corpus/snippetTests/lambdas/inequality.txt +62 -0
  538. package/test/corpus/snippetTests/lambdas/lambda1.txt +85 -0
  539. package/test/corpus/snippetTests/lambdas/lambda2.txt +78 -0
  540. package/test/corpus/snippetTests/lambdas/lambda3.txt +381 -0
  541. package/test/corpus/snippetTests/lambdas/lambda4.txt +147 -0
  542. package/test/corpus/snippetTests/lambdas/lambda5.txt +307 -0
  543. package/test/corpus/snippetTests/lambdas/lambdaStackTrace1.txt +35 -0
  544. package/test/corpus/snippetTests/lambdas/lambdaStackTrace2.txt +37 -0
  545. package/test/corpus/snippetTests/lambdas/lambdaStackTrace3.txt +33 -0
  546. package/test/corpus/snippetTests/lambdas/pipeOperator.txt +189 -0
  547. package/test/corpus/snippetTests/lambdas/tooManyLambdaParams.txt +27 -0
  548. package/test/corpus/snippetTests/lambdas/typedLambdas.txt +278 -0
  549. package/test/corpus/snippetTests/lambdas/wrongArgumentListLength.txt +37 -0
  550. package/test/corpus/snippetTests/listings/cacheStealing.txt +56 -0
  551. package/test/corpus/snippetTests/listings/cacheStealingTypeCheck.txt +27 -0
  552. package/test/corpus/snippetTests/listings/default.txt +133 -0
  553. package/test/corpus/snippetTests/listings/equality.txt +341 -0
  554. package/test/corpus/snippetTests/listings/hashCode.txt +438 -0
  555. package/test/corpus/snippetTests/listings/inequality.txt +173 -0
  556. package/test/corpus/snippetTests/listings/listing1.txt +360 -0
  557. package/test/corpus/snippetTests/listings/listing2.txt +755 -0
  558. package/test/corpus/snippetTests/listings/listing3.txt +490 -0
  559. package/test/corpus/snippetTests/listings/listing4.txt +156 -0
  560. package/test/corpus/snippetTests/listings/listing6.txt +208 -0
  561. package/test/corpus/snippetTests/listings/listing7.txt +71 -0
  562. package/test/corpus/snippetTests/listings/typeCheck.txt +2506 -0
  563. package/test/corpus/snippetTests/listings/wrongIndex.txt +121 -0
  564. package/test/corpus/snippetTests/listings/wrongParent.txt +253 -0
  565. package/test/corpus/snippetTests/listings2/default.txt +157 -0
  566. package/test/corpus/snippetTests/listings2/equality.txt +358 -0
  567. package/test/corpus/snippetTests/listings2/inequality.txt +227 -0
  568. package/test/corpus/snippetTests/listings2/listing1.txt +372 -0
  569. package/test/corpus/snippetTests/listings2/listing2.txt +904 -0
  570. package/test/corpus/snippetTests/listings2/listing3.txt +568 -0
  571. package/test/corpus/snippetTests/listings2/typeCheck.txt +336 -0
  572. package/test/corpus/snippetTests/listings2/wrongIndex.txt +151 -0
  573. package/test/corpus/snippetTests/listings2/wrongParent.txt +313 -0
  574. package/test/corpus/snippetTests/mappings/default.txt +174 -0
  575. package/test/corpus/snippetTests/mappings/duplicateComputedKey.txt +85 -0
  576. package/test/corpus/snippetTests/mappings/duplicateConstantKey.txt +32 -0
  577. package/test/corpus/snippetTests/mappings/equality.txt +383 -0
  578. package/test/corpus/snippetTests/mappings/hashCode.txt +461 -0
  579. package/test/corpus/snippetTests/mappings/inequality.txt +198 -0
  580. package/test/corpus/snippetTests/mappings/mapping1.txt +590 -0
  581. package/test/corpus/snippetTests/mappings/mapping2.txt +491 -0
  582. package/test/corpus/snippetTests/mappings/stringKeyNotFound.txt +50 -0
  583. package/test/corpus/snippetTests/mappings/typeCheck.txt +2877 -0
  584. package/test/corpus/snippetTests/mappings/wrongParent.txt +262 -0
  585. package/test/corpus/snippetTests/mappings2/default.txt +195 -0
  586. package/test/corpus/snippetTests/mappings2/duplicateComputedKey.txt +99 -0
  587. package/test/corpus/snippetTests/mappings2/duplicateConstantKey.txt +39 -0
  588. package/test/corpus/snippetTests/mappings2/equality.txt +416 -0
  589. package/test/corpus/snippetTests/mappings2/inequality.txt +268 -0
  590. package/test/corpus/snippetTests/mappings2/mapping1.txt +604 -0
  591. package/test/corpus/snippetTests/mappings2/mapping2.txt +595 -0
  592. package/test/corpus/snippetTests/mappings2/stringKeyNotFound.txt +57 -0
  593. package/test/corpus/snippetTests/mappings2/typeCheck.txt +582 -0
  594. package/test/corpus/snippetTests/mappings2/wrongParent.txt +334 -0
  595. package/test/corpus/snippetTests/methods/methodParameterConstraints1.txt +220 -0
  596. package/test/corpus/snippetTests/methods/methodParameterConstraints2.txt +382 -0
  597. package/test/corpus/snippetTests/methods/methodParameterTypes2.txt +734 -0
  598. package/test/corpus/snippetTests/methods/methodParameterTypes3.txt +196 -0
  599. package/test/corpus/snippetTests/modules/amendModule1.txt +36 -0
  600. package/test/corpus/snippetTests/modules/amendModule2.txt +28 -0
  601. package/test/corpus/snippetTests/modules/amendModule3.txt +24 -0
  602. package/test/corpus/snippetTests/modules/amendModule4.txt +35 -0
  603. package/test/corpus/snippetTests/modules/amendModule5.txt +68 -0
  604. package/test/corpus/snippetTests/modules/amendModule6.txt +13 -0
  605. package/test/corpus/snippetTests/modules/equality.txt +91 -0
  606. package/test/corpus/snippetTests/modules/extendModule1.txt +80 -0
  607. package/test/corpus/snippetTests/modules/externalFunction.txt +14 -0
  608. package/test/corpus/snippetTests/modules/externalProperty.txt +16 -0
  609. package/test/corpus/snippetTests/modules/filename with spaces 2.txt +14 -0
  610. package/test/corpus/snippetTests/modules/filename with spaces.txt +13 -0
  611. package/test/corpus/snippetTests/modules/functions.txt +264 -0
  612. package/test/corpus/snippetTests/modules/invalidAmend1.txt +18 -0
  613. package/test/corpus/snippetTests/modules/invalidAmend2.txt +19 -0
  614. package/test/corpus/snippetTests/modules/invalidAmend3.txt +23 -0
  615. package/test/corpus/snippetTests/modules/invalidAmend4.txt +21 -0
  616. package/test/corpus/snippetTests/modules/invalidAmend5.txt +17 -0
  617. package/test/corpus/snippetTests/modules/invalidAmend6.txt +22 -0
  618. package/test/corpus/snippetTests/modules/invalidExtend1.txt +18 -0
  619. package/test/corpus/snippetTests/modules/invalidExtend2.txt +13 -0
  620. package/test/corpus/snippetTests/modules/invalidExtend3.txt +13 -0
  621. package/test/corpus/snippetTests/modules/library.txt +77 -0
  622. package/test/corpus/snippetTests/modules/lists.txt +26 -0
  623. package/test/corpus/snippetTests/modules/objects.txt +22 -0
  624. package/test/corpus/snippetTests/modules/recursiveModule1.txt +51 -0
  625. package/test/corpus/snippetTests/modules/recursiveModule2.txt +26 -0
  626. package/test/corpus/snippetTests/modules/supercalls1.txt +43 -0
  627. package/test/corpus/snippetTests/modules/supercalls2.txt +76 -0
  628. package/test/corpus/snippetTests/modules/supercalls3.txt +142 -0
  629. package/test/corpus/snippetTests/modules/typedModuleMethods1.txt +229 -0
  630. package/test/corpus/snippetTests/modules/typedModuleProperties1.txt +106 -0
  631. package/test/corpus/snippetTests/modules/typedModuleProperties2.txt +16 -0
  632. package/test/corpus/snippetTests/modules/typedModuleProperties3.txt +20 -0
  633. package/test/corpus/snippetTests/modules//346/227/245/346/234/254/350/252/236.txt +45 -0
  634. package/test/corpus/snippetTests/modules//346/227/245/346/234/254/350/252/236_error.txt +14 -0
  635. package/test/corpus/snippetTests/objects/closure.txt +143 -0
  636. package/test/corpus/snippetTests/objects/configureObjectAssign.txt +78 -0
  637. package/test/corpus/snippetTests/objects/equality.txt +989 -0
  638. package/test/corpus/snippetTests/objects/hashCode.txt +566 -0
  639. package/test/corpus/snippetTests/objects/implicitReceiver1.txt +37 -0
  640. package/test/corpus/snippetTests/objects/implicitReceiver2.txt +33 -0
  641. package/test/corpus/snippetTests/objects/implicitReceiver3.txt +29 -0
  642. package/test/corpus/snippetTests/objects/implicitReceiver4.txt +25 -0
  643. package/test/corpus/snippetTests/objects/inequality.txt +777 -0
  644. package/test/corpus/snippetTests/objects/lateBinding1.txt +60 -0
  645. package/test/corpus/snippetTests/objects/lateBinding2.txt +60 -0
  646. package/test/corpus/snippetTests/objects/lateBinding3.txt +81 -0
  647. package/test/corpus/snippetTests/objects/lateBinding4.txt +77 -0
  648. package/test/corpus/snippetTests/objects/outer.txt +91 -0
  649. package/test/corpus/snippetTests/objects/outer2.txt +28 -0
  650. package/test/corpus/snippetTests/objects/super1.txt +67 -0
  651. package/test/corpus/snippetTests/objects/super2.txt +59 -0
  652. package/test/corpus/snippetTests/objects/super3.txt +59 -0
  653. package/test/corpus/snippetTests/objects/super4.txt +66 -0
  654. package/test/corpus/snippetTests/objects/super5.txt +69 -0
  655. package/test/corpus/snippetTests/objects/this1.txt +24 -0
  656. package/test/corpus/snippetTests/objects/this2.txt +71 -0
  657. package/test/corpus/snippetTests/packages/badImport1.error.txt +14 -0
  658. package/test/corpus/snippetTests/packages/badImport10.error.txt +14 -0
  659. package/test/corpus/snippetTests/packages/badImport11.error.txt +14 -0
  660. package/test/corpus/snippetTests/packages/badImport2.error.txt +14 -0
  661. package/test/corpus/snippetTests/packages/badImport3.error.txt +14 -0
  662. package/test/corpus/snippetTests/packages/badImport4.error.txt +14 -0
  663. package/test/corpus/snippetTests/packages/badImport6.error.txt +20 -0
  664. package/test/corpus/snippetTests/packages/badImport7.error.txt +14 -0
  665. package/test/corpus/snippetTests/packages/badImport8.error.txt +14 -0
  666. package/test/corpus/snippetTests/packages/badImport9.error.txt +14 -0
  667. package/test/corpus/snippetTests/packages/badRead1.error.txt +14 -0
  668. package/test/corpus/snippetTests/packages/badRead2.error.txt +14 -0
  669. package/test/corpus/snippetTests/packages/badRead3.error.txt +14 -0
  670. package/test/corpus/snippetTests/packages/badRead4.error.txt +14 -0
  671. package/test/corpus/snippetTests/packages/badRead8.error.txt +14 -0
  672. package/test/corpus/snippetTests/packages/badRead9.error.txt +14 -0
  673. package/test/corpus/snippetTests/packages/packages1.txt +103 -0
  674. package/test/corpus/snippetTests/packages/packages2.txt +104 -0
  675. package/test/corpus/snippetTests/packages/redirects.txt +54 -0
  676. package/test/corpus/snippetTests/types/ThisInTypeConstraint.txt +342 -0
  677. package/test/corpus/snippetTests/types/currentModuleType1.txt +343 -0
  678. package/test/corpus/snippetTests/types/currentModuleType2.txt +351 -0
  679. package/test/corpus/snippetTests/types/currentModuleType3.txt +18 -0
  680. package/test/corpus/snippetTests/types/cyclicTypeAlias1.txt +17 -0
  681. package/test/corpus/snippetTests/types/cyclicTypeAlias2.txt +42 -0
  682. package/test/corpus/snippetTests/types/modifiersForTypes.txt +68 -0
  683. package/test/corpus/snippetTests/types/moduleType.txt +58 -0
  684. package/test/corpus/snippetTests/types/nothingType.txt +29 -0
  685. package/test/corpus/snippetTests/types/nothingWithUnions.txt +31 -0
  686. package/test/corpus/snippetTests/types/typeAlias1.txt +925 -0
  687. package/test/corpus/snippetTests/types/typeAlias2.txt +361 -0
  688. package/test/corpus/snippetTests/types/typeAliasConstraint1.txt +79 -0
  689. package/test/corpus/snippetTests/types/typeAliasConstraint2.txt +77 -0
  690. package/test/corpus/snippetTests/types/typeAliasContext.txt +26 -0
  691. package/test/corpus/snippetTests/types/typeAliasUnion.txt +169 -0
  692. package/test/corpus/string/customStringDelimiters.txt +397 -0
  693. package/test/corpus/string/multiline.txt +39 -0
  694. package/test/corpus/string/multilineInterpolation.txt +102 -0
  695. package/test/corpus/string/multilineInterpolation2.txt +15 -0
  696. package/test/corpus/string/simple.txt +13 -0
  697. package/test/corpus/string/singleLineEscapes.txt +64 -0
  698. package/test/corpus/string/singleLineInterpolation.txt +94 -0
  699. package/test/corpus/string/stringWithTwoSlashes.txt +20 -0
  700. package/test/corpus/type/unionType.txt +34 -0
  701. package/test/corpus/type/unionTypeDefaults.txt +46 -0
  702. package/tree-sitter.json +41 -0
  703. package/README.adoc +0 -61
  704. package/src/synctests.ts +0 -44
package/src/scanner.c CHANGED
@@ -1,7 +1,25 @@
1
+ /*
2
+ * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * https://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
1
17
  #include <tree_sitter/parser.h>
2
18
  #include <stdio.h>
3
19
 
4
20
  enum TokenType {
21
+ // sequence of "normal" characters in a single line string without a pound sign
22
+ SL_STRING_CHARS,
5
23
  // sequence of "normal" characters in single line string with one pound sign
6
24
  SL1_STRING_CHARS,
7
25
  // sequence of "normal" characters in single line string with two pound signs
@@ -28,10 +46,12 @@ enum TokenType {
28
46
  ML5_STRING_CHARS,
29
47
  // sequence of "normal" characters in multiline string with six pound signs
30
48
  ML6_STRING_CHARS,
31
- // `[` as used in subscript expressions
32
- OPEN_SQUARE_BRACKET,
33
- // `[` as used in object entries
34
- OPEN_ENTRY_BRACKET,
49
+ // '[' at the start of a subscript
50
+ OPEN_SUBSCRIPT_BRACKET,
51
+ // '(' at the start of a method call, or a type constraint
52
+ OPEN_ARGUMENT_PAREN,
53
+ // binary minus ('-') operator
54
+ BINARY_MINUS
35
55
  };
36
56
 
37
57
  void *tree_sitter_pkl_external_scanner_create() { return NULL; }
@@ -41,6 +61,25 @@ unsigned tree_sitter_pkl_external_scanner_serialize(void *p, char *buffer) { ret
41
61
  void tree_sitter_pkl_external_scanner_deserialize(void *p, const char *b, unsigned n) {}
42
62
 
43
63
  static void advance(TSLexer *lexer) { lexer->advance(lexer, false); }
64
+ static void skip(TSLexer *lexer) { lexer->advance(lexer, true); }
65
+
66
+ static bool parse_sl_string_chars(TSLexer *lexer) {
67
+ bool has_content = false;
68
+ while (true) {
69
+ switch (lexer->lookahead) {
70
+ case '"':
71
+ case '\\':
72
+ return has_content;
73
+ case '\n':
74
+ case '\r':
75
+ case 0:
76
+ return has_content;
77
+ default:
78
+ has_content = true;
79
+ advance(lexer);
80
+ }
81
+ }
82
+ }
44
83
 
45
84
  static bool parse_slx_string_chars(TSLexer *lexer, int num_pounds) {
46
85
  bool has_content = false;
@@ -193,30 +232,55 @@ static bool parse_mlx_string_chars(TSLexer *lexer, int num_pounds) {
193
232
  }
194
233
  }
195
234
 
196
- bool parse_square_bracket_variant(TSLexer *lexer, bool open_square_bracket, bool open_entry_bracket) {
197
- while (
198
- lexer->lookahead == ' ' ||
199
- lexer->lookahead == '\t' ||
200
- (open_entry_bracket && (
201
- lexer->lookahead == ';' ||
202
- lexer->lookahead == '\n'
203
- ))
204
- ) {
205
- open_square_bracket = open_square_bracket && (lexer->lookahead != '\n' && lexer->lookahead != ';');
206
- lexer->advance(lexer, true);
235
+ static bool parse_symbol_no_preceding_newline_or_semicolon(TSLexer *lexer, bool open_subscript_bracket, bool open_argument_paren, bool binary_minus) {
236
+ if (lexer->eof(lexer)) {
237
+ return false;
207
238
  }
208
- if (lexer->lookahead == '[') {
209
- lexer->result_symbol = open_square_bracket ? OPEN_SQUARE_BRACKET : OPEN_ENTRY_BRACKET;
210
- lexer->advance(lexer, false);
211
- if (lexer->lookahead != '[') {
212
- lexer->mark_end(lexer);
213
- return true;
239
+ while (true) {
240
+ switch (lexer->lookahead) {
241
+ case ' ':
242
+ case '\t':
243
+ case '\r':
244
+ case '\f':
245
+ skip(lexer);
246
+ break;
247
+ case '[':
248
+ if (open_subscript_bracket) {
249
+ advance(lexer);
250
+ lexer->result_symbol = OPEN_SUBSCRIPT_BRACKET;
251
+ return true;
252
+ } else {
253
+ return false;
254
+ }
255
+ case '(':
256
+ if (open_argument_paren) {
257
+ advance(lexer);
258
+ lexer->result_symbol = OPEN_ARGUMENT_PAREN;
259
+ return true;
260
+ } else {
261
+ return false;
262
+ }
263
+ case '-':
264
+ if (binary_minus) {
265
+ advance(lexer);
266
+ lexer->mark_end(lexer);
267
+ // avoid parsing `->` as binary minus
268
+ if (lexer->lookahead == '>') {
269
+ return false;
270
+ }
271
+ lexer->result_symbol = BINARY_MINUS;
272
+ return true;
273
+ } else {
274
+ return false;
275
+ }
276
+ default:
277
+ return false;
214
278
  }
215
279
  }
216
- return false;
217
280
  }
218
281
 
219
282
  bool tree_sitter_pkl_external_scanner_scan(void *payload, TSLexer *lexer, const bool *valid_symbols) {
283
+ bool sl = valid_symbols[SL_STRING_CHARS];
220
284
  bool sl1 = valid_symbols[SL1_STRING_CHARS];
221
285
  bool sl2 = valid_symbols[SL2_STRING_CHARS];
222
286
  bool sl3 = valid_symbols[SL3_STRING_CHARS];
@@ -230,14 +294,18 @@ bool tree_sitter_pkl_external_scanner_scan(void *payload, TSLexer *lexer, const
230
294
  bool ml4 = valid_symbols[ML4_STRING_CHARS];
231
295
  bool ml5 = valid_symbols[ML5_STRING_CHARS];
232
296
  bool ml6 = valid_symbols[ML6_STRING_CHARS];
233
- bool osb = valid_symbols[OPEN_SQUARE_BRACKET];
234
- bool oeb = valid_symbols[OPEN_ENTRY_BRACKET];
235
-
236
- if (sl1 && sl2 && sl3 && sl4 && sl5 && sl6 && ml && ml1 && ml2 && ml3 && ml4 && ml5 && ml6 && osb && oeb) {
297
+ bool osb = valid_symbols[OPEN_SUBSCRIPT_BRACKET];
298
+ bool oap = valid_symbols[OPEN_ARGUMENT_PAREN];
299
+ bool bminus = valid_symbols[BINARY_MINUS];
300
+
301
+ if (sl && sl1 && sl2 && sl3 && sl4 && sl5 && sl6 && ml && ml1 && ml2 && ml3 && ml4 && ml5 && ml6 && osb && oap && bminus) {
237
302
  // error recovery mode -> don't match any string chars
238
303
  return false;
239
304
  }
240
305
 
306
+ if (sl) {
307
+ return parse_sl_string_chars(lexer);
308
+ }
241
309
  if (ml) {
242
310
  return parse_ml_string_chars(lexer);
243
311
  }
@@ -277,9 +345,9 @@ bool tree_sitter_pkl_external_scanner_scan(void *payload, TSLexer *lexer, const
277
345
  if (ml6) {
278
346
  return parse_mlx_string_chars(lexer, 6);
279
347
  }
280
- if (osb || oeb) {
281
- return parse_square_bracket_variant(lexer, osb, oeb);
348
+ // either possibly be true
349
+ if (osb || oap || bminus) {
350
+ return parse_symbol_no_preceding_newline_or_semicolon(lexer, osb, oap, bminus);
282
351
  }
283
352
  return false;
284
353
  }
285
-
@@ -0,0 +1,54 @@
1
+ #ifndef TREE_SITTER_ALLOC_H_
2
+ #define TREE_SITTER_ALLOC_H_
3
+
4
+ #ifdef __cplusplus
5
+ extern "C" {
6
+ #endif
7
+
8
+ #include <stdbool.h>
9
+ #include <stdio.h>
10
+ #include <stdlib.h>
11
+
12
+ // Allow clients to override allocation functions
13
+ #ifdef TREE_SITTER_REUSE_ALLOCATOR
14
+
15
+ extern void *(*ts_current_malloc)(size_t size);
16
+ extern void *(*ts_current_calloc)(size_t count, size_t size);
17
+ extern void *(*ts_current_realloc)(void *ptr, size_t size);
18
+ extern void (*ts_current_free)(void *ptr);
19
+
20
+ #ifndef ts_malloc
21
+ #define ts_malloc ts_current_malloc
22
+ #endif
23
+ #ifndef ts_calloc
24
+ #define ts_calloc ts_current_calloc
25
+ #endif
26
+ #ifndef ts_realloc
27
+ #define ts_realloc ts_current_realloc
28
+ #endif
29
+ #ifndef ts_free
30
+ #define ts_free ts_current_free
31
+ #endif
32
+
33
+ #else
34
+
35
+ #ifndef ts_malloc
36
+ #define ts_malloc malloc
37
+ #endif
38
+ #ifndef ts_calloc
39
+ #define ts_calloc calloc
40
+ #endif
41
+ #ifndef ts_realloc
42
+ #define ts_realloc realloc
43
+ #endif
44
+ #ifndef ts_free
45
+ #define ts_free free
46
+ #endif
47
+
48
+ #endif
49
+
50
+ #ifdef __cplusplus
51
+ }
52
+ #endif
53
+
54
+ #endif // TREE_SITTER_ALLOC_H_
@@ -0,0 +1,291 @@
1
+ #ifndef TREE_SITTER_ARRAY_H_
2
+ #define TREE_SITTER_ARRAY_H_
3
+
4
+ #ifdef __cplusplus
5
+ extern "C" {
6
+ #endif
7
+
8
+ #include "./alloc.h"
9
+
10
+ #include <assert.h>
11
+ #include <stdbool.h>
12
+ #include <stdint.h>
13
+ #include <stdlib.h>
14
+ #include <string.h>
15
+
16
+ #ifdef _MSC_VER
17
+ #pragma warning(push)
18
+ #pragma warning(disable : 4101)
19
+ #elif defined(__GNUC__) || defined(__clang__)
20
+ #pragma GCC diagnostic push
21
+ #pragma GCC diagnostic ignored "-Wunused-variable"
22
+ #endif
23
+
24
+ #define Array(T) \
25
+ struct { \
26
+ T *contents; \
27
+ uint32_t size; \
28
+ uint32_t capacity; \
29
+ }
30
+
31
+ /// Initialize an array.
32
+ #define array_init(self) \
33
+ ((self)->size = 0, (self)->capacity = 0, (self)->contents = NULL)
34
+
35
+ /// Create an empty array.
36
+ #define array_new() \
37
+ { NULL, 0, 0 }
38
+
39
+ /// Get a pointer to the element at a given `index` in the array.
40
+ #define array_get(self, _index) \
41
+ (assert((uint32_t)(_index) < (self)->size), &(self)->contents[_index])
42
+
43
+ /// Get a pointer to the first element in the array.
44
+ #define array_front(self) array_get(self, 0)
45
+
46
+ /// Get a pointer to the last element in the array.
47
+ #define array_back(self) array_get(self, (self)->size - 1)
48
+
49
+ /// Clear the array, setting its size to zero. Note that this does not free any
50
+ /// memory allocated for the array's contents.
51
+ #define array_clear(self) ((self)->size = 0)
52
+
53
+ /// Reserve `new_capacity` elements of space in the array. If `new_capacity` is
54
+ /// less than the array's current capacity, this function has no effect.
55
+ #define array_reserve(self, new_capacity) \
56
+ _array__reserve((Array *)(self), array_elem_size(self), new_capacity)
57
+
58
+ /// Free any memory allocated for this array. Note that this does not free any
59
+ /// memory allocated for the array's contents.
60
+ #define array_delete(self) _array__delete((Array *)(self))
61
+
62
+ /// Push a new `element` onto the end of the array.
63
+ #define array_push(self, element) \
64
+ (_array__grow((Array *)(self), 1, array_elem_size(self)), \
65
+ (self)->contents[(self)->size++] = (element))
66
+
67
+ /// Increase the array's size by `count` elements.
68
+ /// New elements are zero-initialized.
69
+ #define array_grow_by(self, count) \
70
+ do { \
71
+ if ((count) == 0) break; \
72
+ _array__grow((Array *)(self), count, array_elem_size(self)); \
73
+ memset((self)->contents + (self)->size, 0, (count) * array_elem_size(self)); \
74
+ (self)->size += (count); \
75
+ } while (0)
76
+
77
+ /// Append all elements from one array to the end of another.
78
+ #define array_push_all(self, other) \
79
+ array_extend((self), (other)->size, (other)->contents)
80
+
81
+ /// Append `count` elements to the end of the array, reading their values from the
82
+ /// `contents` pointer.
83
+ #define array_extend(self, count, contents) \
84
+ _array__splice( \
85
+ (Array *)(self), array_elem_size(self), (self)->size, \
86
+ 0, count, contents \
87
+ )
88
+
89
+ /// Remove `old_count` elements from the array starting at the given `index`. At
90
+ /// the same index, insert `new_count` new elements, reading their values from the
91
+ /// `new_contents` pointer.
92
+ #define array_splice(self, _index, old_count, new_count, new_contents) \
93
+ _array__splice( \
94
+ (Array *)(self), array_elem_size(self), _index, \
95
+ old_count, new_count, new_contents \
96
+ )
97
+
98
+ /// Insert one `element` into the array at the given `index`.
99
+ #define array_insert(self, _index, element) \
100
+ _array__splice((Array *)(self), array_elem_size(self), _index, 0, 1, &(element))
101
+
102
+ /// Remove one element from the array at the given `index`.
103
+ #define array_erase(self, _index) \
104
+ _array__erase((Array *)(self), array_elem_size(self), _index)
105
+
106
+ /// Pop the last element off the array, returning the element by value.
107
+ #define array_pop(self) ((self)->contents[--(self)->size])
108
+
109
+ /// Assign the contents of one array to another, reallocating if necessary.
110
+ #define array_assign(self, other) \
111
+ _array__assign((Array *)(self), (const Array *)(other), array_elem_size(self))
112
+
113
+ /// Swap one array with another
114
+ #define array_swap(self, other) \
115
+ _array__swap((Array *)(self), (Array *)(other))
116
+
117
+ /// Get the size of the array contents
118
+ #define array_elem_size(self) (sizeof *(self)->contents)
119
+
120
+ /// Search a sorted array for a given `needle` value, using the given `compare`
121
+ /// callback to determine the order.
122
+ ///
123
+ /// If an existing element is found to be equal to `needle`, then the `index`
124
+ /// out-parameter is set to the existing value's index, and the `exists`
125
+ /// out-parameter is set to true. Otherwise, `index` is set to an index where
126
+ /// `needle` should be inserted in order to preserve the sorting, and `exists`
127
+ /// is set to false.
128
+ #define array_search_sorted_with(self, compare, needle, _index, _exists) \
129
+ _array__search_sorted(self, 0, compare, , needle, _index, _exists)
130
+
131
+ /// Search a sorted array for a given `needle` value, using integer comparisons
132
+ /// of a given struct field (specified with a leading dot) to determine the order.
133
+ ///
134
+ /// See also `array_search_sorted_with`.
135
+ #define array_search_sorted_by(self, field, needle, _index, _exists) \
136
+ _array__search_sorted(self, 0, _compare_int, field, needle, _index, _exists)
137
+
138
+ /// Insert a given `value` into a sorted array, using the given `compare`
139
+ /// callback to determine the order.
140
+ #define array_insert_sorted_with(self, compare, value) \
141
+ do { \
142
+ unsigned _index, _exists; \
143
+ array_search_sorted_with(self, compare, &(value), &_index, &_exists); \
144
+ if (!_exists) array_insert(self, _index, value); \
145
+ } while (0)
146
+
147
+ /// Insert a given `value` into a sorted array, using integer comparisons of
148
+ /// a given struct field (specified with a leading dot) to determine the order.
149
+ ///
150
+ /// See also `array_search_sorted_by`.
151
+ #define array_insert_sorted_by(self, field, value) \
152
+ do { \
153
+ unsigned _index, _exists; \
154
+ array_search_sorted_by(self, field, (value) field, &_index, &_exists); \
155
+ if (!_exists) array_insert(self, _index, value); \
156
+ } while (0)
157
+
158
+ // Private
159
+
160
+ typedef Array(void) Array;
161
+
162
+ /// This is not what you're looking for, see `array_delete`.
163
+ static inline void _array__delete(Array *self) {
164
+ if (self->contents) {
165
+ ts_free(self->contents);
166
+ self->contents = NULL;
167
+ self->size = 0;
168
+ self->capacity = 0;
169
+ }
170
+ }
171
+
172
+ /// This is not what you're looking for, see `array_erase`.
173
+ static inline void _array__erase(Array *self, size_t element_size,
174
+ uint32_t index) {
175
+ assert(index < self->size);
176
+ char *contents = (char *)self->contents;
177
+ memmove(contents + index * element_size, contents + (index + 1) * element_size,
178
+ (self->size - index - 1) * element_size);
179
+ self->size--;
180
+ }
181
+
182
+ /// This is not what you're looking for, see `array_reserve`.
183
+ static inline void _array__reserve(Array *self, size_t element_size, uint32_t new_capacity) {
184
+ if (new_capacity > self->capacity) {
185
+ if (self->contents) {
186
+ self->contents = ts_realloc(self->contents, new_capacity * element_size);
187
+ } else {
188
+ self->contents = ts_malloc(new_capacity * element_size);
189
+ }
190
+ self->capacity = new_capacity;
191
+ }
192
+ }
193
+
194
+ /// This is not what you're looking for, see `array_assign`.
195
+ static inline void _array__assign(Array *self, const Array *other, size_t element_size) {
196
+ _array__reserve(self, element_size, other->size);
197
+ self->size = other->size;
198
+ memcpy(self->contents, other->contents, self->size * element_size);
199
+ }
200
+
201
+ /// This is not what you're looking for, see `array_swap`.
202
+ static inline void _array__swap(Array *self, Array *other) {
203
+ Array swap = *other;
204
+ *other = *self;
205
+ *self = swap;
206
+ }
207
+
208
+ /// This is not what you're looking for, see `array_push` or `array_grow_by`.
209
+ static inline void _array__grow(Array *self, uint32_t count, size_t element_size) {
210
+ uint32_t new_size = self->size + count;
211
+ if (new_size > self->capacity) {
212
+ uint32_t new_capacity = self->capacity * 2;
213
+ if (new_capacity < 8) new_capacity = 8;
214
+ if (new_capacity < new_size) new_capacity = new_size;
215
+ _array__reserve(self, element_size, new_capacity);
216
+ }
217
+ }
218
+
219
+ /// This is not what you're looking for, see `array_splice`.
220
+ static inline void _array__splice(Array *self, size_t element_size,
221
+ uint32_t index, uint32_t old_count,
222
+ uint32_t new_count, const void *elements) {
223
+ uint32_t new_size = self->size + new_count - old_count;
224
+ uint32_t old_end = index + old_count;
225
+ uint32_t new_end = index + new_count;
226
+ assert(old_end <= self->size);
227
+
228
+ _array__reserve(self, element_size, new_size);
229
+
230
+ char *contents = (char *)self->contents;
231
+ if (self->size > old_end) {
232
+ memmove(
233
+ contents + new_end * element_size,
234
+ contents + old_end * element_size,
235
+ (self->size - old_end) * element_size
236
+ );
237
+ }
238
+ if (new_count > 0) {
239
+ if (elements) {
240
+ memcpy(
241
+ (contents + index * element_size),
242
+ elements,
243
+ new_count * element_size
244
+ );
245
+ } else {
246
+ memset(
247
+ (contents + index * element_size),
248
+ 0,
249
+ new_count * element_size
250
+ );
251
+ }
252
+ }
253
+ self->size += new_count - old_count;
254
+ }
255
+
256
+ /// A binary search routine, based on Rust's `std::slice::binary_search_by`.
257
+ /// This is not what you're looking for, see `array_search_sorted_with` or `array_search_sorted_by`.
258
+ #define _array__search_sorted(self, start, compare, suffix, needle, _index, _exists) \
259
+ do { \
260
+ *(_index) = start; \
261
+ *(_exists) = false; \
262
+ uint32_t size = (self)->size - *(_index); \
263
+ if (size == 0) break; \
264
+ int comparison; \
265
+ while (size > 1) { \
266
+ uint32_t half_size = size / 2; \
267
+ uint32_t mid_index = *(_index) + half_size; \
268
+ comparison = compare(&((self)->contents[mid_index] suffix), (needle)); \
269
+ if (comparison <= 0) *(_index) = mid_index; \
270
+ size -= half_size; \
271
+ } \
272
+ comparison = compare(&((self)->contents[*(_index)] suffix), (needle)); \
273
+ if (comparison == 0) *(_exists) = true; \
274
+ else if (comparison < 0) *(_index) += 1; \
275
+ } while (0)
276
+
277
+ /// Helper macro for the `_sorted_by` routines below. This takes the left (existing)
278
+ /// parameter by reference in order to work with the generic sorting function above.
279
+ #define _compare_int(a, b) ((int)*(a) - (int)(b))
280
+
281
+ #ifdef _MSC_VER
282
+ #pragma warning(pop)
283
+ #elif defined(__GNUC__) || defined(__clang__)
284
+ #pragma GCC diagnostic pop
285
+ #endif
286
+
287
+ #ifdef __cplusplus
288
+ }
289
+ #endif
290
+
291
+ #endif // TREE_SITTER_ARRAY_H_