tree-sitter 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (930) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +29 -8
  3. data/Rakefile +19 -4
  4. data/ext/tree-sitter/Makefile +24 -0
  5. data/ext/tree-sitter/document.c +149 -0
  6. data/ext/tree-sitter/document.h +17 -0
  7. data/ext/tree-sitter/extconf.rb +55 -15
  8. data/ext/tree-sitter/node.c +300 -0
  9. data/ext/tree-sitter/node.h +34 -0
  10. data/ext/tree-sitter/out/document.o +0 -0
  11. data/ext/tree-sitter/out/get_changed_ranges.o +0 -0
  12. data/ext/tree-sitter/out/language.o +0 -0
  13. data/ext/tree-sitter/out/lexer.o +0 -0
  14. data/ext/tree-sitter/out/libruntime.a +0 -0
  15. data/ext/tree-sitter/out/node.o +0 -0
  16. data/ext/tree-sitter/out/parser.o +0 -0
  17. data/ext/tree-sitter/out/python/parser.c +65600 -0
  18. data/ext/tree-sitter/out/python/parser.o +0 -0
  19. data/ext/tree-sitter/out/python/scanner.cc +164 -0
  20. data/ext/tree-sitter/out/python/scanner.o +0 -0
  21. data/ext/tree-sitter/out/stack.o +0 -0
  22. data/ext/tree-sitter/out/string_input.o +0 -0
  23. data/ext/tree-sitter/out/tree.o +0 -0
  24. data/ext/tree-sitter/out/utf16.o +0 -0
  25. data/ext/tree-sitter/out/utf8proc.o +0 -0
  26. data/ext/tree-sitter/tree-sitter.c +4 -109
  27. data/ext/tree-sitter/tree-sitter.h +4 -0
  28. data/ext/tree-sitter/tree-sitter/LICENSE +7 -0
  29. data/ext/tree-sitter/tree-sitter/README.md +13 -13
  30. data/ext/tree-sitter/tree-sitter/appveyor.yml +24 -0
  31. data/ext/tree-sitter/tree-sitter/docs/Gemfile +2 -0
  32. data/ext/tree-sitter/tree-sitter/docs/Gemfile.lock +239 -0
  33. data/ext/tree-sitter/tree-sitter/docs/_config.yml +1 -0
  34. data/ext/tree-sitter/tree-sitter/docs/_layouts/table-of-contents.html +74 -0
  35. data/ext/tree-sitter/tree-sitter/docs/creating-parsers.md +360 -0
  36. data/ext/tree-sitter/tree-sitter/docs/css/style.css +13 -0
  37. data/ext/tree-sitter/tree-sitter/docs/index.md +10 -0
  38. data/ext/tree-sitter/tree-sitter/externals/gyp/PRESUBMIT.py +10 -2
  39. data/ext/tree-sitter/tree-sitter/externals/gyp/buildbot/aosp_manifest.xml +466 -0
  40. data/ext/tree-sitter/tree-sitter/externals/gyp/buildbot/buildbot_run.py +91 -30
  41. data/ext/tree-sitter/tree-sitter/externals/gyp/gyp +1 -1
  42. data/ext/tree-sitter/tree-sitter/externals/gyp/gyptest.py +3 -3
  43. data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/MSVSNew.py +1 -1
  44. data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/MSVSSettings.py +11 -5
  45. data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/MSVSSettings_test.py +1 -1
  46. data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/MSVSUtil.py +18 -15
  47. data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/MSVSVersion.py +53 -20
  48. data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/__init__.py +4 -6
  49. data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/__init__.pyc +0 -0
  50. data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/common.py +69 -2
  51. data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/common.pyc +0 -0
  52. data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/flock_tool.py +6 -1
  53. data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/generator/__init__.pyc +0 -0
  54. data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/generator/analyzer.py +569 -0
  55. data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/generator/android.py +133 -111
  56. data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/generator/cmake.py +3 -3
  57. data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/generator/eclipse.py +112 -22
  58. data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/generator/gypd.py +3 -0
  59. data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/generator/make.py +45 -14
  60. data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/generator/make.pyc +0 -0
  61. data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/generator/msvs.py +170 -98
  62. data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/generator/ninja.py +300 -71
  63. data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/generator/ninja_test.py +12 -9
  64. data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/generator/xcode.py +46 -12
  65. data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/generator/xcode.pyc +0 -0
  66. data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/input.py +379 -335
  67. data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/input.pyc +0 -0
  68. data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/input_test.py +7 -7
  69. data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/mac_tool.py +94 -3
  70. data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/msvs_emulation.py +131 -40
  71. data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/simple_copy.py +46 -0
  72. data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/win_tool.py +28 -5
  73. data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/xcode_emulation.py +185 -88
  74. data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/xcode_emulation.pyc +0 -0
  75. data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/xcode_ninja.py +268 -0
  76. data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/xcodeproj_file.py +53 -46
  77. data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/xcodeproj_file.pyc +0 -0
  78. data/ext/tree-sitter/tree-sitter/externals/gyp/test/actions-bare/gyptest-bare.py +1 -0
  79. data/ext/tree-sitter/tree-sitter/externals/gyp/test/actions-depfile/depfile.gyp +25 -0
  80. data/ext/tree-sitter/tree-sitter/externals/gyp/test/actions-depfile/gyptest-all.py +20 -0
  81. data/ext/tree-sitter/tree-sitter/externals/gyp/test/actions-depfile/input.txt +1 -0
  82. data/ext/tree-sitter/tree-sitter/externals/gyp/test/actions-none/gyptest-none.py +1 -0
  83. data/ext/tree-sitter/tree-sitter/externals/gyp/test/actions/gyptest-all.py +1 -1
  84. data/ext/tree-sitter/tree-sitter/externals/gyp/test/actions/gyptest-default.py +1 -1
  85. data/ext/tree-sitter/tree-sitter/externals/gyp/test/actions/gyptest-generated-header.py +6 -0
  86. data/ext/tree-sitter/tree-sitter/externals/gyp/test/actions/src/subdir1/program.c +1 -1
  87. data/ext/tree-sitter/tree-sitter/externals/gyp/test/actions/src/subdir3/generate_main.py +1 -1
  88. data/ext/tree-sitter/tree-sitter/externals/gyp/test/additional-targets/gyptest-additional.py +8 -1
  89. data/ext/tree-sitter/tree-sitter/externals/gyp/test/analyzer/common.gypi +6 -0
  90. data/ext/tree-sitter/tree-sitter/externals/gyp/test/analyzer/gyptest-analyzer.py +356 -0
  91. data/ext/tree-sitter/tree-sitter/externals/gyp/test/analyzer/subdir/subdir.gyp +36 -0
  92. data/ext/tree-sitter/tree-sitter/externals/gyp/test/analyzer/subdir/subdir2/subdir2.gyp +15 -0
  93. data/ext/tree-sitter/tree-sitter/externals/gyp/test/analyzer/subdir2/subdir.gyp +18 -0
  94. data/ext/tree-sitter/tree-sitter/externals/gyp/test/analyzer/subdir2/subdir.includes.gypi +9 -0
  95. data/ext/tree-sitter/tree-sitter/externals/gyp/test/analyzer/test.gyp +113 -0
  96. data/ext/tree-sitter/tree-sitter/externals/gyp/test/analyzer/test2.gyp +25 -0
  97. data/ext/tree-sitter/tree-sitter/externals/gyp/test/analyzer/test2.includes.gypi +13 -0
  98. data/ext/tree-sitter/tree-sitter/externals/gyp/test/analyzer/test2.includes.includes.gypi +9 -0
  99. data/ext/tree-sitter/tree-sitter/externals/gyp/test/analyzer/test2.toplevel_includes.gypi +15 -0
  100. data/ext/tree-sitter/tree-sitter/externals/gyp/test/analyzer/test3.gyp +77 -0
  101. data/ext/tree-sitter/tree-sitter/externals/gyp/test/analyzer/test4.gyp +80 -0
  102. data/ext/tree-sitter/tree-sitter/externals/gyp/test/analyzer/test5.gyp +25 -0
  103. data/ext/tree-sitter/tree-sitter/externals/gyp/test/android/32or64.c +13 -0
  104. data/ext/tree-sitter/tree-sitter/externals/gyp/test/android/file.in +1 -0
  105. data/ext/tree-sitter/tree-sitter/externals/gyp/test/android/gyptest-host-multilib.py +32 -0
  106. data/ext/tree-sitter/tree-sitter/externals/gyp/test/android/gyptest-make-functions.py +24 -0
  107. data/ext/tree-sitter/tree-sitter/externals/gyp/test/android/gyptest-noalias.py +21 -0
  108. data/ext/tree-sitter/tree-sitter/externals/gyp/test/android/gyptest-settings-list.py +24 -0
  109. data/ext/tree-sitter/tree-sitter/externals/gyp/test/android/gyptest-settings.py +24 -0
  110. data/ext/tree-sitter/tree-sitter/externals/gyp/test/android/gyptest-space-filenames.py +19 -0
  111. data/ext/tree-sitter/tree-sitter/externals/gyp/test/android/hello.c +12 -0
  112. data/ext/tree-sitter/tree-sitter/externals/gyp/test/android/hello.gyp +15 -0
  113. data/ext/tree-sitter/tree-sitter/externals/gyp/test/android/host_32or64.gyp +38 -0
  114. data/ext/tree-sitter/tree-sitter/externals/gyp/test/android/make_functions.gyp +31 -0
  115. data/ext/tree-sitter/tree-sitter/externals/gyp/test/android/settings-list.gyp +18 -0
  116. data/ext/tree-sitter/tree-sitter/externals/gyp/test/android/settings.gyp +18 -0
  117. data/ext/tree-sitter/tree-sitter/externals/gyp/test/android/space_filenames.gyp +18 -0
  118. data/ext/tree-sitter/tree-sitter/externals/gyp/test/android/writefile.c +18 -0
  119. data/ext/tree-sitter/tree-sitter/externals/gyp/test/assembly/src/program.c +1 -1
  120. data/ext/tree-sitter/tree-sitter/externals/gyp/test/build-option/gyptest-build.py +11 -0
  121. data/ext/tree-sitter/tree-sitter/externals/gyp/test/build-option/hello.c +1 -1
  122. data/ext/tree-sitter/tree-sitter/externals/gyp/test/builddir/src/prog1.c +1 -1
  123. data/ext/tree-sitter/tree-sitter/externals/gyp/test/builddir/src/subdir2/prog2.c +1 -1
  124. data/ext/tree-sitter/tree-sitter/externals/gyp/test/builddir/src/subdir2/subdir3/prog3.c +1 -1
  125. data/ext/tree-sitter/tree-sitter/externals/gyp/test/builddir/src/subdir2/subdir3/subdir4/prog4.c +1 -1
  126. data/ext/tree-sitter/tree-sitter/externals/gyp/test/builddir/src/subdir2/subdir3/subdir4/subdir5/prog5.c +1 -1
  127. data/ext/tree-sitter/tree-sitter/externals/gyp/test/cflags/cflags.c +1 -1
  128. data/ext/tree-sitter/tree-sitter/externals/gyp/test/cflags/gyptest-cflags.py +15 -55
  129. data/ext/tree-sitter/tree-sitter/externals/gyp/test/compilable/src/program.cpp +1 -1
  130. data/ext/tree-sitter/tree-sitter/externals/gyp/test/compiler-override/{compiler.gyp → compiler-exe.gyp} +0 -0
  131. data/ext/tree-sitter/tree-sitter/externals/gyp/test/compiler-override/compiler-shared-lib.gyp +16 -0
  132. data/ext/tree-sitter/tree-sitter/externals/gyp/test/compiler-override/gyptest-compiler-env-toolchain.py +78 -0
  133. data/ext/tree-sitter/tree-sitter/externals/gyp/test/compiler-override/gyptest-compiler-env.py +9 -11
  134. data/ext/tree-sitter/tree-sitter/externals/gyp/test/compiler-override/gyptest-compiler-global-settings.py +5 -0
  135. data/ext/tree-sitter/tree-sitter/externals/gyp/test/compiler-override/my_nm.py +8 -0
  136. data/ext/tree-sitter/tree-sitter/externals/gyp/test/compiler-override/my_readelf.py +8 -0
  137. data/ext/tree-sitter/tree-sitter/externals/gyp/test/conditions/elseif/elseif.gyp +43 -0
  138. data/ext/tree-sitter/tree-sitter/externals/gyp/test/conditions/elseif/elseif_bad1.gyp +20 -0
  139. data/ext/tree-sitter/tree-sitter/externals/gyp/test/conditions/elseif/elseif_bad2.gyp +22 -0
  140. data/ext/tree-sitter/tree-sitter/externals/gyp/test/conditions/elseif/elseif_bad3.gyp +23 -0
  141. data/ext/tree-sitter/tree-sitter/externals/gyp/test/conditions/elseif/elseif_conditions.gypi +15 -0
  142. data/ext/tree-sitter/tree-sitter/externals/gyp/test/conditions/elseif/gyptest_elseif.py +33 -0
  143. data/ext/tree-sitter/tree-sitter/externals/gyp/test/conditions/elseif/program.cc +10 -0
  144. data/ext/tree-sitter/tree-sitter/externals/gyp/test/configurations/basics/configurations.c +1 -1
  145. data/ext/tree-sitter/tree-sitter/externals/gyp/test/configurations/basics/gyptest-configurations.py +6 -0
  146. data/ext/tree-sitter/tree-sitter/externals/gyp/test/configurations/inheritance/configurations.c +1 -1
  147. data/ext/tree-sitter/tree-sitter/externals/gyp/test/configurations/inheritance/duplicates.gyp +27 -0
  148. data/ext/tree-sitter/tree-sitter/externals/gyp/test/configurations/inheritance/duplicates.gypd.golden +12 -0
  149. data/ext/tree-sitter/tree-sitter/externals/gyp/test/configurations/inheritance/gyptest-duplicates.py +34 -0
  150. data/ext/tree-sitter/tree-sitter/externals/gyp/test/configurations/inheritance/gyptest-inheritance.py +6 -0
  151. data/ext/tree-sitter/tree-sitter/externals/gyp/test/configurations/target_platform/front.c +1 -1
  152. data/ext/tree-sitter/tree-sitter/externals/gyp/test/configurations/x64/configurations.c +1 -1
  153. data/ext/tree-sitter/tree-sitter/externals/gyp/test/copies/gyptest-all.py +3 -1
  154. data/ext/tree-sitter/tree-sitter/externals/gyp/test/copies/gyptest-default.py +3 -1
  155. data/ext/tree-sitter/tree-sitter/externals/gyp/test/copies/gyptest-samedir.py +1 -0
  156. data/ext/tree-sitter/tree-sitter/externals/gyp/test/copies/gyptest-slash.py +1 -0
  157. data/ext/tree-sitter/tree-sitter/externals/gyp/test/copies/gyptest-updir.py +1 -0
  158. data/ext/tree-sitter/tree-sitter/externals/gyp/test/cxxflags/cxxflags.cc +4 -4
  159. data/ext/tree-sitter/tree-sitter/externals/gyp/test/cxxflags/cxxflags.gyp +0 -1
  160. data/ext/tree-sitter/tree-sitter/externals/gyp/test/cxxflags/gyptest-cxxflags.py +13 -33
  161. data/ext/tree-sitter/tree-sitter/externals/gyp/test/defines-escaping/defines-escaping.c +1 -1
  162. data/ext/tree-sitter/tree-sitter/externals/gyp/test/defines/defines.c +1 -1
  163. data/ext/tree-sitter/tree-sitter/externals/gyp/test/dependencies/gyptest-extra-targets.py +2 -1
  164. data/ext/tree-sitter/tree-sitter/externals/gyp/test/dependencies/gyptest-lib-only.py +1 -1
  165. data/ext/tree-sitter/tree-sitter/externals/gyp/test/dependency-copy/src/file1.c +1 -1
  166. data/ext/tree-sitter/tree-sitter/externals/gyp/test/dependency-copy/src/file2.c +1 -1
  167. data/ext/tree-sitter/tree-sitter/externals/gyp/test/empty-target/empty-target.gyp +12 -0
  168. data/ext/tree-sitter/tree-sitter/externals/gyp/test/empty-target/gyptest-empty-target.py +18 -0
  169. data/ext/tree-sitter/tree-sitter/externals/gyp/test/errors/dependency_cycle.gyp +23 -0
  170. data/ext/tree-sitter/tree-sitter/externals/gyp/test/errors/file_cycle0.gyp +17 -0
  171. data/ext/tree-sitter/tree-sitter/externals/gyp/test/errors/file_cycle1.gyp +13 -0
  172. data/ext/tree-sitter/tree-sitter/externals/gyp/test/errors/gyptest-errors.py +10 -2
  173. data/ext/tree-sitter/tree-sitter/externals/gyp/test/exclusion/hello.c +1 -1
  174. data/ext/tree-sitter/tree-sitter/externals/gyp/test/external-cross-compile/src/program.cc +1 -1
  175. data/ext/tree-sitter/tree-sitter/externals/gyp/test/generator-output/actions/subdir1/program.c +1 -1
  176. data/ext/tree-sitter/tree-sitter/externals/gyp/test/generator-output/gyptest-copies.py +3 -2
  177. data/ext/tree-sitter/tree-sitter/externals/gyp/test/generator-output/rules/subdir1/program.c +1 -1
  178. data/ext/tree-sitter/tree-sitter/externals/gyp/test/generator-output/src/prog1.c +1 -1
  179. data/ext/tree-sitter/tree-sitter/externals/gyp/test/generator-output/src/subdir2/deeper/deeper.c +1 -1
  180. data/ext/tree-sitter/tree-sitter/externals/gyp/test/generator-output/src/subdir2/prog2.c +1 -1
  181. data/ext/tree-sitter/tree-sitter/externals/gyp/test/generator-output/src/subdir3/prog3.c +1 -1
  182. data/ext/tree-sitter/tree-sitter/externals/gyp/test/gyp-defines/gyptest-multiple-values.py +2 -0
  183. data/ext/tree-sitter/tree-sitter/externals/gyp/test/hello/hello.c +1 -1
  184. data/ext/tree-sitter/tree-sitter/externals/gyp/test/hello/hello2.c +1 -1
  185. data/ext/tree-sitter/tree-sitter/externals/gyp/test/home_dot_gyp/src/printfoo.c +1 -1
  186. data/ext/tree-sitter/tree-sitter/externals/gyp/test/include_dirs/src/includes.c +1 -1
  187. data/ext/tree-sitter/tree-sitter/externals/gyp/test/include_dirs/src/subdir/subdir_includes.c +1 -1
  188. data/ext/tree-sitter/tree-sitter/externals/gyp/test/intermediate_dir/gyptest-intermediate-dir.py +2 -0
  189. data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/app-bundle/TestApp/Images.xcassets/AppIcon.appiconset/Contents.json +58 -0
  190. data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/app-bundle/TestApp/Images.xcassets/image.imageset/Contents.json +23 -0
  191. data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/app-bundle/TestApp/Images.xcassets/image.imageset/super_sylvain.png +0 -0
  192. data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/app-bundle/TestApp/Images.xcassets/image.imageset/super_sylvain@2x.png +0 -0
  193. data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/app-bundle/TestApp/Images.xcassets/image.imageset/super_sylvain@3x.png +0 -0
  194. data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/app-bundle/test-assets-catalog.gyp +45 -0
  195. data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/app-bundle/test-crosscompile.gyp +47 -0
  196. data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/app-bundle/test.gyp +0 -1
  197. data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/app-bundle/tool_main.cc +7 -0
  198. data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/extension/ActionExtension/ActionViewController.h +9 -0
  199. data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/extension/ActionExtension/ActionViewController.m +31 -0
  200. data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/extension/ActionExtension/Info.plist +42 -0
  201. data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/extension/ActionExtension/MainInterface.storyboard +63 -0
  202. data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/extension/ExtensionContainer/AppDelegate.h +12 -0
  203. data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/extension/ExtensionContainer/AppDelegate.m +19 -0
  204. data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/extension/ExtensionContainer/Base.lproj/Main.storyboard +25 -0
  205. data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/extension/ExtensionContainer/Images.xcassets/AppIcon.appiconset/Contents.json +53 -0
  206. data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/extension/ExtensionContainer/Images.xcassets/LaunchImage.launchimage/Contents.json +51 -0
  207. data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/extension/ExtensionContainer/Info.plist +32 -0
  208. data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/extension/ExtensionContainer/ViewController.h +11 -0
  209. data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/extension/ExtensionContainer/ViewController.m +24 -0
  210. data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/extension/ExtensionContainer/main.m +13 -0
  211. data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/extension/extension.gyp +85 -0
  212. data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/gyptest-app-ios-assets-catalog.py +57 -0
  213. data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/gyptest-app-ios.py +7 -7
  214. data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/gyptest-archs.py +22 -70
  215. data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/gyptest-crosscompile.py +34 -0
  216. data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/gyptest-extension.py +28 -0
  217. data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/gyptest-watch.py +36 -0
  218. data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/gyptest-xcode-ninja.py +25 -0
  219. data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/watch/WatchApp/Images.xcassets/AppIcon.appiconset/Contents.json +62 -0
  220. data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/watch/WatchApp/Images.xcassets/LaunchImage.launchimage/Contents.json +24 -0
  221. data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/watch/WatchApp/Info.plist +35 -0
  222. data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/watch/WatchApp/Interface.storyboard +15 -0
  223. data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/watch/WatchContainer/AppDelegate.h +12 -0
  224. data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/watch/WatchContainer/AppDelegate.m +19 -0
  225. data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/watch/WatchContainer/Base.lproj/Main.storyboard +25 -0
  226. data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/watch/WatchContainer/Images.xcassets/AppIcon.appiconset/Contents.json +53 -0
  227. data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/watch/WatchContainer/Images.xcassets/LaunchImage.launchimage/Contents.json +51 -0
  228. data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/watch/WatchContainer/Info.plist +32 -0
  229. data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/watch/WatchContainer/ViewController.h +11 -0
  230. data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/watch/WatchContainer/ViewController.m +24 -0
  231. data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/watch/WatchContainer/main.m +13 -0
  232. data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/watch/WatchKitExtension/Images.xcassets/MyImage.imageset/Contents.json +20 -0
  233. data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/watch/WatchKitExtension/Info.plist +38 -0
  234. data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/watch/WatchKitExtension/InterfaceController.h +10 -0
  235. data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/watch/WatchKitExtension/InterfaceController.m +25 -0
  236. data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/watch/WatchKitExtension/MainInterface.storyboard +63 -0
  237. data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/watch/watch.gyp +105 -0
  238. data/ext/tree-sitter/tree-sitter/externals/gyp/test/lib/TestGyp.py +349 -46
  239. data/ext/tree-sitter/tree-sitter/externals/gyp/test/lib/TestMac.py +73 -0
  240. data/ext/tree-sitter/tree-sitter/externals/gyp/test/lib/TestWin.py +101 -0
  241. data/ext/tree-sitter/tree-sitter/externals/gyp/test/library/gyptest-shared.py +6 -0
  242. data/ext/tree-sitter/tree-sitter/externals/gyp/test/library/gyptest-static.py +6 -0
  243. data/ext/tree-sitter/tree-sitter/externals/gyp/test/library/src/program.c +1 -1
  244. data/ext/tree-sitter/tree-sitter/externals/gyp/test/link-dependency/gyptest-link-dependency.py +23 -0
  245. data/ext/tree-sitter/tree-sitter/externals/gyp/test/link-dependency/main.c +7 -0
  246. data/ext/tree-sitter/tree-sitter/externals/gyp/test/link-dependency/mymalloc.c +12 -0
  247. data/ext/tree-sitter/tree-sitter/externals/gyp/test/link-dependency/test.gyp +37 -0
  248. data/ext/tree-sitter/tree-sitter/externals/gyp/test/link-objects/base.c +1 -1
  249. data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/app-bundle/TestApp/Images.xcassets/AppIcon.appiconset/Contents.json +58 -0
  250. data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/app-bundle/TestApp/Images.xcassets/image.imageset/Contents.json +23 -0
  251. data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/app-bundle/TestApp/Images.xcassets/image.imageset/super_sylvain.png +0 -0
  252. data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/app-bundle/TestApp/Images.xcassets/image.imageset/super_sylvain@2x.png +0 -0
  253. data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/app-bundle/TestApp/Images.xcassets/image.imageset/super_sylvain@3x.png +0 -0
  254. data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/app-bundle/test-assets-catalog.gyp +43 -0
  255. data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/archs/file_a.cc +8 -0
  256. data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/archs/file_a.h +10 -0
  257. data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/archs/file_b.cc +8 -0
  258. data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/archs/file_b.h +10 -0
  259. data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/archs/file_c.cc +11 -0
  260. data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/archs/file_d.cc +11 -0
  261. data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/archs/test-archs-multiarch.gyp +20 -0
  262. data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/archs/test-dependencies.gyp +92 -0
  263. data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/archs/test-valid-archs.gyp +28 -0
  264. data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/clang-cxx-library/libc++.cc +2 -2
  265. data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/clang-cxx-library/libstdc++.cc +1 -1
  266. data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/gyptest-action-envvars.py +6 -0
  267. data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/gyptest-app-assets-catalog.py +120 -0
  268. data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/gyptest-app-error.py +2 -1
  269. data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/gyptest-app.py +8 -20
  270. data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/gyptest-archs.py +39 -33
  271. data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/gyptest-cflags.py +1 -0
  272. data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/gyptest-clang-cxx-library.py +3 -4
  273. data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/gyptest-global-settings.py +7 -0
  274. data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/gyptest-installname.py +1 -0
  275. data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/gyptest-ldflags-passed-to-libtool.py +1 -0
  276. data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/gyptest-ldflags.py +6 -0
  277. data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/gyptest-libraries.py +6 -0
  278. data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/gyptest-libtool-zero.py +26 -0
  279. data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/gyptest-loadable-module-bundle-product-extension.py +31 -0
  280. data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/gyptest-loadable-module.py +1 -0
  281. data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/gyptest-objc-gc.py +24 -18
  282. data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/gyptest-postbuild-copy-bundle.py +1 -1
  283. data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/gyptest-postbuild-fail.py +1 -0
  284. data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/gyptest-prefixheader.py +1 -0
  285. data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/gyptest-rpath.py +5 -4
  286. data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/gyptest-strip.py +13 -5
  287. data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/gyptest-swift-library.py +62 -0
  288. data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/gyptest-type-envvars.py +3 -1
  289. data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/gyptest-xcode-env-order.py +2 -6
  290. data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/gyptest-xcode-support-actions.py +25 -0
  291. data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/libtool-zero/mylib.c +7 -0
  292. data/ext/tree-sitter/tree-sitter/externals/gyp/test/{errors/duplicate_basenames.gyp → mac/libtool-zero/test.gyp} +6 -4
  293. data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/loadable-module-bundle-product-extension/src.cc +7 -0
  294. data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/loadable-module-bundle-product-extension/test.gyp +24 -0
  295. data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/swift-library/Info.plist +28 -0
  296. data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/swift-library/file.swift +9 -0
  297. data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/swift-library/test.gyp +21 -0
  298. data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/type_envvars/test_bundle_executable.sh +1 -2
  299. data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/type_envvars/test_bundle_loadable_module.sh +1 -2
  300. data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/type_envvars/test_bundle_shared_library.sh +1 -2
  301. data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/type_envvars/test_check_sdkroot.sh +47 -0
  302. data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/type_envvars/test_nonbundle_executable.sh +2 -2
  303. data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/type_envvars/test_nonbundle_loadable_module.sh +1 -2
  304. data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/type_envvars/test_nonbundle_none.sh +1 -2
  305. data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/type_envvars/test_nonbundle_shared_library.sh +1 -2
  306. data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/type_envvars/test_nonbundle_static_library.sh +1 -2
  307. data/ext/tree-sitter/tree-sitter/{out/Release/linker.lock → externals/gyp/test/mac/xcode-support-actions/source.c} +0 -0
  308. data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/xcode-support-actions/test.gyp +26 -0
  309. data/ext/tree-sitter/tree-sitter/externals/gyp/test/make/main.cc +1 -1
  310. data/ext/tree-sitter/tree-sitter/externals/gyp/test/make/noload/main.c +1 -1
  311. data/ext/tree-sitter/tree-sitter/externals/gyp/test/make_global_settings/ar/gyptest-make_global_settings_ar.py +123 -0
  312. data/ext/tree-sitter/tree-sitter/externals/gyp/test/make_global_settings/ar/make_global_settings_ar.gyp +29 -0
  313. data/ext/tree-sitter/tree-sitter/externals/gyp/test/make_global_settings/basics/gyptest-make_global_settings.py +2 -2
  314. data/ext/tree-sitter/tree-sitter/externals/gyp/test/make_global_settings/full-toolchain/bar.cc +1 -0
  315. data/ext/tree-sitter/tree-sitter/externals/gyp/test/make_global_settings/full-toolchain/foo.c +1 -0
  316. data/ext/tree-sitter/tree-sitter/externals/gyp/test/make_global_settings/full-toolchain/gyptest-make_global_settings.py +48 -0
  317. data/ext/tree-sitter/tree-sitter/externals/gyp/test/make_global_settings/full-toolchain/make_global_settings.gyp +22 -0
  318. data/ext/tree-sitter/tree-sitter/externals/gyp/test/make_global_settings/full-toolchain/my_nm.py +8 -0
  319. data/ext/tree-sitter/tree-sitter/externals/gyp/test/make_global_settings/full-toolchain/my_readelf.py +8 -0
  320. data/ext/tree-sitter/tree-sitter/externals/gyp/test/make_global_settings/ld/gyptest-make_global_settings_ld.py +130 -0
  321. data/ext/tree-sitter/tree-sitter/externals/gyp/test/make_global_settings/ld/make_global_settings_ld.gyp +29 -0
  322. data/ext/tree-sitter/tree-sitter/externals/gyp/test/many-actions/gyptest-many-actions-unsorted.py +1 -0
  323. data/ext/tree-sitter/tree-sitter/externals/gyp/test/msvs/buildevents/gyptest-ninja-warnings.py +2 -2
  324. data/ext/tree-sitter/tree-sitter/externals/gyp/test/msvs/config_attrs/hello.c +2 -2
  325. data/ext/tree-sitter/tree-sitter/externals/gyp/test/msvs/external_builder/hello.cpp +1 -1
  326. data/ext/tree-sitter/tree-sitter/externals/gyp/test/msvs/filters/gyptest-filters-2010.py +1 -1
  327. data/ext/tree-sitter/tree-sitter/externals/gyp/test/msvs/list_excluded/hello.cpp +1 -1
  328. data/ext/tree-sitter/tree-sitter/externals/gyp/test/msvs/multiple_actions_error_handling/action_fail.py +7 -0
  329. data/ext/tree-sitter/tree-sitter/externals/gyp/test/msvs/multiple_actions_error_handling/action_succeed.py +7 -0
  330. data/ext/tree-sitter/tree-sitter/externals/gyp/test/msvs/multiple_actions_error_handling/actions.gyp +40 -0
  331. data/ext/tree-sitter/tree-sitter/externals/gyp/test/msvs/multiple_actions_error_handling/gyptest.py +26 -0
  332. data/ext/tree-sitter/tree-sitter/externals/gyp/test/msvs/props/hello.c +1 -1
  333. data/ext/tree-sitter/tree-sitter/externals/gyp/test/msvs/shared_output/hello.c +1 -1
  334. data/ext/tree-sitter/tree-sitter/externals/gyp/test/msvs/shared_output/there/there.c +1 -1
  335. data/ext/tree-sitter/tree-sitter/externals/gyp/test/msvs/uldi2010/hello.c +1 -1
  336. data/ext/tree-sitter/tree-sitter/externals/gyp/test/multiple-targets/gyptest-all.py +0 -3
  337. data/ext/tree-sitter/tree-sitter/externals/gyp/test/multiple-targets/gyptest-default.py +0 -3
  338. data/ext/tree-sitter/tree-sitter/externals/gyp/test/multiple-targets/src/prog1.c +1 -1
  339. data/ext/tree-sitter/tree-sitter/externals/gyp/test/multiple-targets/src/prog2.c +1 -1
  340. data/ext/tree-sitter/tree-sitter/externals/gyp/test/ninja/action-rule-hash/gyptest-action-rule-hash.py +32 -0
  341. data/ext/tree-sitter/tree-sitter/externals/gyp/test/ninja/action-rule-hash/subdir/action-rule-hash.gyp +29 -0
  342. data/ext/tree-sitter/tree-sitter/externals/gyp/test/ninja/action-rule-hash/subdir/emit.py +13 -0
  343. data/ext/tree-sitter/tree-sitter/externals/gyp/test/ninja/action_dependencies/gyptest-action-dependencies.py +3 -0
  344. data/ext/tree-sitter/tree-sitter/externals/gyp/test/ninja/chained-dependency/chained.c +1 -1
  345. data/ext/tree-sitter/tree-sitter/externals/gyp/test/ninja/chained-dependency/gyptest-chained-dependency.py +4 -0
  346. data/ext/tree-sitter/tree-sitter/externals/gyp/test/ninja/empty-and-non-empty-duplicate-name/gyptest-empty-and-non-empty-duplicate-name.py +23 -0
  347. data/ext/tree-sitter/tree-sitter/externals/gyp/test/ninja/empty-and-non-empty-duplicate-name/subdir/included.gyp +19 -0
  348. data/ext/tree-sitter/tree-sitter/externals/gyp/test/ninja/empty-and-non-empty-duplicate-name/test.gyp +19 -0
  349. data/ext/tree-sitter/tree-sitter/externals/gyp/test/ninja/normalize-paths-win/gyptest-normalize-paths.py +4 -0
  350. data/ext/tree-sitter/tree-sitter/externals/gyp/test/ninja/normalize-paths-win/normalize-paths.gyp +12 -0
  351. data/ext/tree-sitter/tree-sitter/externals/gyp/test/ninja/solibs_avoid_relinking/gyptest-solibs-avoid-relinking.py +5 -0
  352. data/ext/tree-sitter/tree-sitter/externals/gyp/test/ninja/use-console/foo.bar +5 -0
  353. data/ext/tree-sitter/tree-sitter/externals/gyp/test/ninja/use-console/gyptest-use-console.py +29 -0
  354. data/ext/tree-sitter/tree-sitter/externals/gyp/test/ninja/use-console/use-console.gyp +60 -0
  355. data/ext/tree-sitter/tree-sitter/externals/gyp/test/no-cpp/gyptest-no-cpp.py +1 -0
  356. data/ext/tree-sitter/tree-sitter/externals/gyp/test/product/hello.c +1 -1
  357. data/ext/tree-sitter/tree-sitter/externals/gyp/test/prune_targets/gyptest-prune-targets.py +3 -0
  358. data/ext/tree-sitter/tree-sitter/externals/gyp/test/rules-dirname/gyptest-dirname.py +17 -3
  359. data/ext/tree-sitter/tree-sitter/externals/gyp/test/rules-dirname/src/subdir/a/b/c.gencc +2 -5
  360. data/ext/tree-sitter/tree-sitter/externals/gyp/test/rules-dirname/src/subdir/foo/bar/baz.gencc +2 -5
  361. data/ext/tree-sitter/tree-sitter/externals/gyp/test/rules-dirname/src/subdir/input-rule-dirname.gyp +62 -14
  362. data/ext/tree-sitter/tree-sitter/externals/gyp/test/rules-dirname/src/subdir/main.cc +2 -0
  363. data/ext/tree-sitter/tree-sitter/externals/gyp/test/rules-dirname/src/subdir/nodir.gencc +8 -0
  364. data/ext/tree-sitter/tree-sitter/externals/gyp/test/rules-rebuild/src/main.c +1 -1
  365. data/ext/tree-sitter/tree-sitter/externals/gyp/test/rules-use-built-dependencies/gyptest-use-built-dependencies.py +1 -0
  366. data/ext/tree-sitter/tree-sitter/externals/gyp/test/rules/gyptest-all.py +7 -1
  367. data/ext/tree-sitter/tree-sitter/externals/gyp/test/rules/gyptest-default.py +7 -1
  368. data/ext/tree-sitter/tree-sitter/externals/gyp/test/rules/src/actions.gyp +1 -0
  369. data/ext/tree-sitter/tree-sitter/externals/gyp/test/rules/src/special-variables.gyp +0 -1
  370. data/ext/tree-sitter/tree-sitter/externals/gyp/test/rules/src/subdir1/program.c +1 -1
  371. data/ext/tree-sitter/tree-sitter/externals/gyp/test/rules/src/subdir2/both_rule_and_action_input.gyp +50 -0
  372. data/ext/tree-sitter/tree-sitter/externals/gyp/test/rules/src/subdir2/program.c +12 -0
  373. data/ext/tree-sitter/tree-sitter/externals/gyp/test/rules/src/subdir3/program.c +1 -1
  374. data/ext/tree-sitter/tree-sitter/externals/gyp/test/rules/src/subdir4/build-asm.gyp +1 -1
  375. data/ext/tree-sitter/tree-sitter/externals/gyp/test/rules/src/subdir4/program.c +1 -1
  376. data/ext/tree-sitter/tree-sitter/externals/gyp/test/same-source-file-name/gyptest-shared.py +27 -0
  377. data/ext/tree-sitter/tree-sitter/externals/gyp/test/same-source-file-name/gyptest-static.py +29 -0
  378. data/ext/tree-sitter/tree-sitter/externals/gyp/test/same-source-file-name/src/double-shared.gyp +6 -0
  379. data/ext/tree-sitter/tree-sitter/externals/gyp/test/same-source-file-name/src/double-static.gyp +1 -0
  380. data/ext/tree-sitter/tree-sitter/externals/gyp/test/same-source-file-name/src/prog1.c +1 -1
  381. data/ext/tree-sitter/tree-sitter/externals/gyp/test/same-source-file-name/src/prog2.c +1 -1
  382. data/ext/tree-sitter/tree-sitter/externals/gyp/test/same-source-file-name/src/prog3.c +1 -1
  383. data/ext/tree-sitter/tree-sitter/externals/gyp/test/same-target-name-different-directory/gyptest-all.py +5 -0
  384. data/ext/tree-sitter/tree-sitter/externals/gyp/test/sibling/gyptest-all.py +6 -3
  385. data/ext/tree-sitter/tree-sitter/externals/gyp/test/sibling/gyptest-relocate.py +6 -3
  386. data/ext/tree-sitter/tree-sitter/externals/gyp/test/sibling/src/prog1/prog1.c +1 -1
  387. data/ext/tree-sitter/tree-sitter/externals/gyp/test/sibling/src/prog2/prog2.c +1 -1
  388. data/ext/tree-sitter/tree-sitter/externals/gyp/test/standalone-static-library/prog.c +1 -1
  389. data/ext/tree-sitter/tree-sitter/externals/gyp/test/subdirectory/gyptest-SYMROOT-all.py +1 -1
  390. data/ext/tree-sitter/tree-sitter/externals/gyp/test/subdirectory/gyptest-SYMROOT-default.py +1 -1
  391. data/ext/tree-sitter/tree-sitter/externals/gyp/test/subdirectory/src/prog1.c +1 -1
  392. data/ext/tree-sitter/tree-sitter/externals/gyp/test/subdirectory/src/subdir/prog2.c +1 -1
  393. data/ext/tree-sitter/tree-sitter/externals/gyp/test/subdirectory/src/subdir/subdir2/prog3.c +1 -1
  394. data/ext/tree-sitter/tree-sitter/externals/gyp/test/toolsets/main.cc +1 -1
  395. data/ext/tree-sitter/tree-sitter/externals/gyp/test/toplevel-dir/gyptest-toplevel-dir.py +1 -1
  396. data/ext/tree-sitter/tree-sitter/externals/gyp/test/toplevel-dir/src/sub1/prog1.c +1 -1
  397. data/ext/tree-sitter/tree-sitter/externals/gyp/test/toplevel-dir/src/sub2/prog2.c +1 -1
  398. data/ext/tree-sitter/tree-sitter/externals/gyp/test/variables/commands/gyptest-commands-repeated-multidir.py +23 -0
  399. data/ext/tree-sitter/tree-sitter/externals/gyp/test/variables/commands/repeated_multidir/dir_1/test_1.gyp +13 -0
  400. data/ext/tree-sitter/tree-sitter/externals/gyp/test/variables/commands/repeated_multidir/dir_2/test_2.gyp +13 -0
  401. data/ext/tree-sitter/tree-sitter/externals/gyp/test/variables/commands/repeated_multidir/main.gyp +16 -0
  402. data/ext/tree-sitter/tree-sitter/externals/gyp/test/variables/commands/repeated_multidir/print_cwd_basename.py +10 -0
  403. data/ext/tree-sitter/tree-sitter/externals/gyp/test/variables/commands/repeated_multidir/repeated_command_common.gypi +25 -0
  404. data/ext/tree-sitter/tree-sitter/externals/gyp/test/variables/latelate/src/program.cc +1 -1
  405. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/command-quote/command-quote.gyp +0 -5
  406. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/command-quote/subdir/and/another/in-subdir.gyp +0 -1
  407. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/compiler-flags/calling-convention-cdecl.def +6 -0
  408. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/compiler-flags/calling-convention-fastcall.def +6 -0
  409. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/compiler-flags/calling-convention-stdcall.def +6 -0
  410. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/compiler-flags/calling-convention-vectorcall.def +6 -0
  411. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/compiler-flags/calling-convention.cc +6 -0
  412. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/compiler-flags/calling-convention.gyp +66 -0
  413. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/compiler-flags/enable-enhanced-instruction-set.cc +28 -0
  414. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/compiler-flags/enable-enhanced-instruction-set.gyp +68 -0
  415. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/compiler-flags/floating-point-model-fast.cc +19 -0
  416. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/compiler-flags/floating-point-model-precise.cc +19 -0
  417. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/compiler-flags/floating-point-model-strict.cc +19 -0
  418. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/compiler-flags/floating-point-model.gyp +43 -0
  419. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/enable-winrt/dllmain.cc +30 -0
  420. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/enable-winrt/enable-winrt.gyp +39 -0
  421. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/generator-output-different-drive/prog.c +1 -1
  422. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/gyptest-cl-calling-convention.py +22 -0
  423. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/gyptest-cl-enable-enhanced-instruction-set.py +44 -0
  424. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/gyptest-cl-floating-point-model.py +22 -0
  425. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/gyptest-link-base-address.py +1 -1
  426. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/gyptest-link-enable-winrt.py +35 -0
  427. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/gyptest-link-pdb-no-output.py +25 -0
  428. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/gyptest-link-pdb-output.py +0 -1
  429. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/gyptest-link-profile.py +1 -1
  430. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/gyptest-link-restat-importlib.py +6 -0
  431. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/gyptest-link-safeseh.py +40 -0
  432. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/gyptest-link-shard.py +3 -0
  433. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/gyptest-macro-targetext.py +26 -0
  434. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/gyptest-macro-targetfilename.py +32 -0
  435. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/gyptest-macro-targetpath.py +30 -0
  436. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/gyptest-midl-excluded.py +22 -0
  437. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/gyptest-midl-includedirs.py +21 -0
  438. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/gyptest-midl-rules.py +4 -0
  439. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/gyptest-ml-safeseh.py +22 -0
  440. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/gyptest-system-include.py +21 -0
  441. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/idl-excluded/bad.idl +6 -0
  442. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/idl-excluded/copy-file.py +11 -0
  443. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/idl-excluded/idl-excluded.gyp +58 -0
  444. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/idl-excluded/program.cc +7 -0
  445. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/idl-includedirs/hello.cc +7 -0
  446. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/idl-includedirs/idl-includedirs.gyp +26 -0
  447. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/idl-includedirs/subdir/bar.idl +13 -0
  448. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/idl-includedirs/subdir/foo.idl +14 -0
  449. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/idl-rules/Window.idl +9 -0
  450. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/idl-rules/basic-idl.gyp +67 -42
  451. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/idl-rules/idl_compiler.py +17 -0
  452. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/large-pdb/main.cc +1 -1
  453. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/linker-flags/pdb-output.gyp +13 -0
  454. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/linker-flags/safeseh.gyp +47 -0
  455. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/linker-flags/safeseh_hello.cc +11 -0
  456. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/linker-flags/safeseh_zero.asm +10 -0
  457. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/linker-flags/update_pgd.py +3 -3
  458. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/ml-safeseh/a.asm +10 -0
  459. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/ml-safeseh/hello.cc +11 -0
  460. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/ml-safeseh/ml-safeseh.gyp +24 -0
  461. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/precompiled/hello.c +1 -1
  462. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/shard/hello.cc +7 -0
  463. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/shard/shard.gyp +11 -0
  464. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/shard/shard_ref.gyp +41 -0
  465. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/system-include/bar/header.h +0 -0
  466. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/system-include/common/commonheader.h +0 -0
  467. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/system-include/foo/header.h +0 -0
  468. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/system-include/main.cc +4 -0
  469. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/system-include/test.gyp +26 -0
  470. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/vs-macros/containing-gyp.gyp +0 -1
  471. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/vs-macros/input-output-macros.gyp +0 -1
  472. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/vs-macros/targetext.gyp +59 -0
  473. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/vs-macros/targetfilename.gyp +59 -0
  474. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/vs-macros/targetpath.gyp +59 -0
  475. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/win-tool/copies_readonly_files.gyp +29 -0
  476. data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/win-tool/gyptest-win-tool-handles-readonly-files.py +55 -0
  477. data/ext/tree-sitter/tree-sitter/externals/gyp/tools/emacs/gyp.el +36 -13
  478. data/ext/tree-sitter/tree-sitter/externals/gyp/tools/pretty_sln.py +4 -3
  479. data/ext/tree-sitter/tree-sitter/externals/utf8proc/CMakeLists.txt +4 -2
  480. data/ext/tree-sitter/tree-sitter/externals/utf8proc/MANIFEST +3 -3
  481. data/ext/tree-sitter/tree-sitter/externals/utf8proc/Makefile +11 -6
  482. data/ext/tree-sitter/tree-sitter/externals/utf8proc/NEWS.md +69 -0
  483. data/ext/tree-sitter/tree-sitter/externals/utf8proc/README.md +4 -2
  484. data/ext/tree-sitter/tree-sitter/externals/utf8proc/bench/bench.c +2 -2
  485. data/ext/tree-sitter/tree-sitter/externals/utf8proc/data/Makefile +12 -9
  486. data/ext/tree-sitter/tree-sitter/externals/utf8proc/data/data_generator.rb +125 -42
  487. data/ext/tree-sitter/tree-sitter/externals/utf8proc/test/custom.c +27 -0
  488. data/ext/tree-sitter/tree-sitter/externals/utf8proc/test/iterate.c +8 -2
  489. data/ext/tree-sitter/tree-sitter/externals/utf8proc/test/printproperty.c +5 -7
  490. data/ext/tree-sitter/tree-sitter/externals/utf8proc/utf8proc.c +209 -98
  491. data/ext/tree-sitter/tree-sitter/externals/utf8proc/utf8proc.h +126 -28
  492. data/ext/tree-sitter/tree-sitter/externals/utf8proc/utf8proc_data.c +12976 -15342
  493. data/ext/tree-sitter/tree-sitter/include/tree_sitter/compiler.h +2 -0
  494. data/ext/tree-sitter/tree-sitter/include/tree_sitter/parser.h +73 -74
  495. data/ext/tree-sitter/tree-sitter/include/tree_sitter/runtime.h +29 -20
  496. data/ext/tree-sitter/tree-sitter/project.gyp +13 -24
  497. data/ext/tree-sitter/tree-sitter/script/benchmark +76 -0
  498. data/ext/tree-sitter/tree-sitter/script/build-fuzzers +66 -0
  499. data/ext/tree-sitter/tree-sitter/script/ci +2 -1
  500. data/ext/tree-sitter/tree-sitter/script/configure.cmd +3 -0
  501. data/ext/tree-sitter/tree-sitter/script/fetch-fixtures +13 -9
  502. data/ext/tree-sitter/tree-sitter/script/fetch-fixtures.cmd +26 -0
  503. data/ext/tree-sitter/tree-sitter/script/reproduce +1 -0
  504. data/ext/tree-sitter/tree-sitter/script/run-fuzzer +57 -0
  505. data/ext/tree-sitter/tree-sitter/script/test +47 -8
  506. data/ext/tree-sitter/tree-sitter/script/test.cmd +2 -0
  507. data/ext/tree-sitter/tree-sitter/script/trim-whitespace +1 -1
  508. data/ext/tree-sitter/tree-sitter/script/util/scan-build.sh +24 -0
  509. data/ext/tree-sitter/tree-sitter/src/compiler/build_tables/lex_item.cc +60 -41
  510. data/ext/tree-sitter/tree-sitter/src/compiler/build_tables/lex_item.h +6 -7
  511. data/ext/tree-sitter/tree-sitter/src/compiler/build_tables/lex_item_transitions.cc +108 -101
  512. data/ext/tree-sitter/tree-sitter/src/compiler/build_tables/lex_item_transitions.h +1 -4
  513. data/ext/tree-sitter/tree-sitter/src/compiler/build_tables/lex_table_builder.cc +537 -0
  514. data/ext/tree-sitter/tree-sitter/src/compiler/build_tables/lex_table_builder.h +57 -0
  515. data/ext/tree-sitter/tree-sitter/src/compiler/build_tables/lookahead_set.cc +93 -19
  516. data/ext/tree-sitter/tree-sitter/src/compiler/build_tables/lookahead_set.h +90 -5
  517. data/ext/tree-sitter/tree-sitter/src/compiler/build_tables/parse_item.cc +77 -29
  518. data/ext/tree-sitter/tree-sitter/src/compiler/build_tables/parse_item.h +4 -9
  519. data/ext/tree-sitter/tree-sitter/src/compiler/build_tables/parse_item_set_builder.cc +229 -94
  520. data/ext/tree-sitter/tree-sitter/src/compiler/build_tables/parse_item_set_builder.h +9 -3
  521. data/ext/tree-sitter/tree-sitter/src/compiler/build_tables/parse_table_builder.cc +893 -0
  522. data/ext/tree-sitter/tree-sitter/src/compiler/build_tables/parse_table_builder.h +38 -0
  523. data/ext/tree-sitter/tree-sitter/src/compiler/build_tables/rule_can_be_blank.cc +34 -35
  524. data/ext/tree-sitter/tree-sitter/src/compiler/build_tables/rule_can_be_blank.h +1 -1
  525. data/ext/tree-sitter/tree-sitter/src/compiler/compile.cc +23 -40
  526. data/ext/tree-sitter/tree-sitter/src/compiler/compile_error.h +6 -0
  527. data/ext/tree-sitter/tree-sitter/src/compiler/generate_code/c_code.cc +301 -124
  528. data/ext/tree-sitter/tree-sitter/src/compiler/generate_code/c_code.h +12 -4
  529. data/ext/tree-sitter/tree-sitter/{doc → src/compiler}/grammar-schema.json +34 -42
  530. data/ext/tree-sitter/tree-sitter/src/compiler/grammar.h +24 -5
  531. data/ext/tree-sitter/tree-sitter/src/compiler/lex_table.cc +2 -31
  532. data/ext/tree-sitter/tree-sitter/src/compiler/lex_table.h +6 -30
  533. data/ext/tree-sitter/tree-sitter/src/compiler/lexical_grammar.h +15 -3
  534. data/ext/tree-sitter/tree-sitter/src/compiler/parse_grammar.cc +143 -105
  535. data/ext/tree-sitter/tree-sitter/src/compiler/parse_grammar.h +2 -1
  536. data/ext/tree-sitter/tree-sitter/src/compiler/parse_table.cc +71 -174
  537. data/ext/tree-sitter/tree-sitter/src/compiler/parse_table.h +23 -41
  538. data/ext/tree-sitter/tree-sitter/src/compiler/prepare_grammar/expand_repeats.cc +67 -34
  539. data/ext/tree-sitter/tree-sitter/src/compiler/prepare_grammar/expand_repeats.h +0 -2
  540. data/ext/tree-sitter/tree-sitter/src/compiler/prepare_grammar/expand_tokens.cc +53 -61
  541. data/ext/tree-sitter/tree-sitter/src/compiler/prepare_grammar/expand_tokens.h +9 -3
  542. data/ext/tree-sitter/tree-sitter/src/compiler/prepare_grammar/extract_choices.cc +37 -43
  543. data/ext/tree-sitter/tree-sitter/src/compiler/prepare_grammar/extract_choices.h +1 -1
  544. data/ext/tree-sitter/tree-sitter/src/compiler/prepare_grammar/extract_tokens.cc +248 -125
  545. data/ext/tree-sitter/tree-sitter/src/compiler/prepare_grammar/extract_tokens.h +3 -2
  546. data/ext/tree-sitter/tree-sitter/src/compiler/prepare_grammar/flatten_grammar.cc +114 -70
  547. data/ext/tree-sitter/tree-sitter/src/compiler/prepare_grammar/flatten_grammar.h +2 -2
  548. data/ext/tree-sitter/tree-sitter/src/compiler/prepare_grammar/initial_syntax_grammar.h +4 -3
  549. data/ext/tree-sitter/tree-sitter/src/compiler/prepare_grammar/intern_symbols.cc +113 -50
  550. data/ext/tree-sitter/tree-sitter/src/compiler/prepare_grammar/intern_symbols.h +2 -2
  551. data/ext/tree-sitter/tree-sitter/src/compiler/prepare_grammar/interned_grammar.h +7 -6
  552. data/ext/tree-sitter/tree-sitter/src/compiler/prepare_grammar/normalize_rules.cc +5 -3
  553. data/ext/tree-sitter/tree-sitter/src/compiler/prepare_grammar/parse_regex.cc +95 -76
  554. data/ext/tree-sitter/tree-sitter/src/compiler/prepare_grammar/parse_regex.h +1 -1
  555. data/ext/tree-sitter/tree-sitter/src/compiler/prepare_grammar/prepare_grammar.cc +9 -7
  556. data/ext/tree-sitter/tree-sitter/src/compiler/prepare_grammar/prepare_grammar.h +2 -5
  557. data/ext/tree-sitter/tree-sitter/src/compiler/prepare_grammar/token_description.cc +59 -45
  558. data/ext/tree-sitter/tree-sitter/src/compiler/prepare_grammar/token_description.h +1 -1
  559. data/ext/tree-sitter/tree-sitter/src/compiler/rule.cc +284 -6
  560. data/ext/tree-sitter/tree-sitter/src/compiler/rule.h +124 -25
  561. data/ext/tree-sitter/tree-sitter/src/compiler/rules/blank.h +5 -14
  562. data/ext/tree-sitter/tree-sitter/src/compiler/rules/character_set.cc +35 -84
  563. data/ext/tree-sitter/tree-sitter/src/compiler/rules/character_set.h +19 -26
  564. data/ext/tree-sitter/tree-sitter/src/compiler/rules/choice.cc +3 -69
  565. data/ext/tree-sitter/tree-sitter/src/compiler/rules/choice.h +6 -13
  566. data/ext/tree-sitter/tree-sitter/src/compiler/rules/metadata.cc +128 -71
  567. data/ext/tree-sitter/tree-sitter/src/compiler/rules/metadata.h +48 -17
  568. data/ext/tree-sitter/tree-sitter/src/compiler/rules/named_symbol.h +6 -12
  569. data/ext/tree-sitter/tree-sitter/src/compiler/rules/pattern.h +6 -12
  570. data/ext/tree-sitter/tree-sitter/src/compiler/rules/repeat.cc +5 -34
  571. data/ext/tree-sitter/tree-sitter/src/compiler/rules/repeat.h +7 -13
  572. data/ext/tree-sitter/tree-sitter/src/compiler/rules/seq.cc +6 -47
  573. data/ext/tree-sitter/tree-sitter/src/compiler/rules/seq.h +8 -14
  574. data/ext/tree-sitter/tree-sitter/src/compiler/rules/string.h +6 -12
  575. data/ext/tree-sitter/tree-sitter/src/compiler/rules/symbol.h +53 -32
  576. data/ext/tree-sitter/tree-sitter/src/compiler/syntax_grammar.cc +24 -22
  577. data/ext/tree-sitter/tree-sitter/src/compiler/syntax_grammar.h +36 -21
  578. data/ext/tree-sitter/tree-sitter/src/compiler/util/make_visitor.h +31 -0
  579. data/ext/tree-sitter/tree-sitter/src/runtime/alloc.h +1 -1
  580. data/ext/tree-sitter/tree-sitter/src/runtime/array.h +25 -36
  581. data/ext/tree-sitter/tree-sitter/src/runtime/document.c +61 -34
  582. data/ext/tree-sitter/tree-sitter/src/runtime/document.h +3 -0
  583. data/ext/tree-sitter/tree-sitter/src/runtime/error_costs.h +5 -19
  584. data/ext/tree-sitter/tree-sitter/src/runtime/get_changed_ranges.c +355 -0
  585. data/ext/tree-sitter/tree-sitter/src/runtime/get_changed_ranges.h +20 -0
  586. data/ext/tree-sitter/tree-sitter/src/runtime/language.c +33 -31
  587. data/ext/tree-sitter/tree-sitter/src/runtime/language.h +27 -3
  588. data/ext/tree-sitter/tree-sitter/src/runtime/length.h +5 -21
  589. data/ext/tree-sitter/tree-sitter/src/runtime/lexer.c +61 -17
  590. data/ext/tree-sitter/tree-sitter/src/runtime/lexer.h +4 -5
  591. data/ext/tree-sitter/tree-sitter/src/runtime/node.c +93 -89
  592. data/ext/tree-sitter/tree-sitter/src/runtime/node.h +1 -1
  593. data/ext/tree-sitter/tree-sitter/src/runtime/parser.c +850 -743
  594. data/ext/tree-sitter/tree-sitter/src/runtime/parser.h +13 -8
  595. data/ext/tree-sitter/tree-sitter/src/runtime/point.h +9 -4
  596. data/ext/tree-sitter/tree-sitter/src/runtime/reduce_action.h +2 -0
  597. data/ext/tree-sitter/tree-sitter/src/runtime/reusable_node.h +14 -18
  598. data/ext/tree-sitter/tree-sitter/src/runtime/stack.c +424 -302
  599. data/ext/tree-sitter/tree-sitter/src/runtime/stack.h +75 -72
  600. data/ext/tree-sitter/tree-sitter/src/runtime/string_input.c +4 -10
  601. data/ext/tree-sitter/tree-sitter/src/runtime/tree.c +401 -252
  602. data/ext/tree-sitter/tree-sitter/src/runtime/tree.h +71 -57
  603. data/ext/tree-sitter/tree-sitter/src/runtime/utf16.c +5 -0
  604. data/ext/tree-sitter/tree-sitter/test/benchmarks.cc +122 -0
  605. data/ext/tree-sitter/tree-sitter/{spec/compiler/build_tables/lex_item_spec.cc → test/compiler/build_tables/lex_item_test.cc} +141 -143
  606. data/ext/tree-sitter/tree-sitter/test/compiler/build_tables/parse_item_set_builder_test.cc +134 -0
  607. data/ext/tree-sitter/tree-sitter/{spec/compiler/build_tables/rule_can_be_blank_spec.cc → test/compiler/build_tables/rule_can_be_blank_test.cc} +16 -19
  608. data/ext/tree-sitter/tree-sitter/test/compiler/prepare_grammar/expand_repeats_test.cc +170 -0
  609. data/ext/tree-sitter/tree-sitter/test/compiler/prepare_grammar/expand_tokens_test.cc +89 -0
  610. data/ext/tree-sitter/tree-sitter/test/compiler/prepare_grammar/extract_choices_test.cc +77 -0
  611. data/ext/tree-sitter/tree-sitter/test/compiler/prepare_grammar/extract_tokens_test.cc +459 -0
  612. data/ext/tree-sitter/tree-sitter/test/compiler/prepare_grammar/flatten_grammar_test.cc +130 -0
  613. data/ext/tree-sitter/tree-sitter/test/compiler/prepare_grammar/intern_symbols_test.cc +101 -0
  614. data/ext/tree-sitter/tree-sitter/test/compiler/prepare_grammar/parse_regex_test.cc +334 -0
  615. data/ext/tree-sitter/tree-sitter/{spec/compiler/rules/character_set_spec.cc → test/compiler/rules/character_set_test.cc} +15 -27
  616. data/ext/tree-sitter/tree-sitter/test/compiler/rules/rule_test.cc +90 -0
  617. data/ext/tree-sitter/tree-sitter/{spec/compiler/util/string_helpers_spec.cc → test/compiler/util/string_helpers_test.cc} +1 -1
  618. data/ext/tree-sitter/tree-sitter/test/fixtures/error_corpus/c_errors.txt +166 -0
  619. data/ext/tree-sitter/tree-sitter/test/fixtures/error_corpus/javascript_errors.txt +179 -0
  620. data/ext/tree-sitter/tree-sitter/{spec → test}/fixtures/error_corpus/json_errors.txt +10 -7
  621. data/ext/tree-sitter/tree-sitter/{spec → test}/fixtures/error_corpus/python_errors.txt +0 -0
  622. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/aliased_inlined_rules/corpus.txt +13 -0
  623. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/aliased_inlined_rules/grammar.json +59 -0
  624. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/aliased_inlined_rules/readme.md +1 -0
  625. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/aliased_rules/corpus.txt +18 -0
  626. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/aliased_rules/grammar.json +71 -0
  627. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/aliased_unit_reductions/corpus.txt +12 -0
  628. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/aliased_unit_reductions/grammar.json +70 -0
  629. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/aliased_unit_reductions/readme.md +5 -0
  630. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/anonymous_tokens_with_escaped_chars/corpus.txt +32 -0
  631. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/anonymous_tokens_with_escaped_chars/grammar.json +14 -0
  632. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/anonymous_tokens_with_escaped_chars/readme.md +1 -0
  633. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/associativity_left/corpus.txt +8 -0
  634. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/associativity_left/grammar.json +31 -0
  635. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/associativity_missing/expected_error.txt +13 -0
  636. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/associativity_missing/grammar.json +27 -0
  637. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/associativity_right/corpus.txt +8 -0
  638. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/associativity_right/grammar.json +31 -0
  639. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/conflict_in_repeat_rule/expected_error.txt +14 -0
  640. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/conflict_in_repeat_rule/grammar.json +76 -0
  641. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/conflict_in_repeat_rule/readme.md +1 -0
  642. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/conflict_in_repeat_rule_after_external_token/expected_error.txt +14 -0
  643. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/conflict_in_repeat_rule_after_external_token/grammar.json +82 -0
  644. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/conflict_in_repeat_rule_after_external_token/readme.md +1 -0
  645. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/conflicting_precedence/expected_error.txt +15 -0
  646. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/conflicting_precedence/grammar.json +58 -0
  647. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/dynamic_precedence/corpus.txt +25 -0
  648. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/dynamic_precedence/grammar.json +73 -0
  649. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/dynamic_precedence/readme.md +1 -0
  650. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/epsilon_rules/expected_error.txt +4 -0
  651. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/epsilon_rules/grammar.json +15 -0
  652. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/external_and_internal_anonymous_tokens/corpus.txt +41 -0
  653. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/external_and_internal_anonymous_tokens/grammar.json +35 -0
  654. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/external_and_internal_anonymous_tokens/readme.md +1 -0
  655. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/external_and_internal_anonymous_tokens/scanner.c +36 -0
  656. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/external_and_internal_tokens/corpus.txt +41 -0
  657. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/external_and_internal_tokens/grammar.json +36 -0
  658. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/external_and_internal_tokens/readme.md +1 -0
  659. data/ext/tree-sitter/tree-sitter/{spec/fixtures/external_scanners/shared_external_tokens.c → test/fixtures/test_grammars/external_and_internal_tokens/scanner.c} +21 -14
  660. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/external_extra_tokens/corpus.txt +10 -0
  661. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/external_extra_tokens/grammar.json +25 -0
  662. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/external_extra_tokens/scanner.c +49 -0
  663. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/external_tokens/corpus.txt +22 -0
  664. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/external_tokens/grammar.json +57 -0
  665. data/ext/tree-sitter/tree-sitter/{spec/fixtures/external_scanners/percent_strings.c → test/fixtures/test_grammars/external_tokens/scanner.c} +19 -17
  666. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/inline_rules/corpus.txt +20 -0
  667. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/inline_rules/grammar.json +76 -0
  668. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/inlined_aliased_rules/corpus.txt +18 -0
  669. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/inlined_aliased_rules/grammar.json +75 -0
  670. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/inlined_aliased_rules/readme.md +1 -0
  671. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/inverted_external_token/corpus.txt +32 -0
  672. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/inverted_external_token/grammar.json +55 -0
  673. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/inverted_external_token/readme.md +1 -0
  674. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/inverted_external_token/scanner.c +48 -0
  675. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/invisible_start_rule/expected_error.txt +1 -0
  676. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/invisible_start_rule/grammar.json +23 -0
  677. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/lexical_conflicts_due_to_state_merging/corpus.txt +33 -0
  678. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/lexical_conflicts_due_to_state_merging/grammar.json +65 -0
  679. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/lexical_conflicts_due_to_state_merging/readme.md +20 -0
  680. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/nested_inlined_rules/corpus.txt +12 -0
  681. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/nested_inlined_rules/grammar.json +54 -0
  682. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/nested_inlined_rules/readme.md +1 -0
  683. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/partially_resolved_conflict/expected_error.txt +14 -0
  684. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/partially_resolved_conflict/grammar.json +58 -0
  685. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/partially_resolved_conflict/readme.txt +1 -0
  686. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/precedence_on_single_child_missing/expected_error.txt +15 -0
  687. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/precedence_on_single_child_missing/grammar.json +63 -0
  688. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/precedence_on_single_child_missing/readme.md +15 -0
  689. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/precedence_on_single_child_negative/corpus.txt +12 -0
  690. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/precedence_on_single_child_negative/grammar.json +63 -0
  691. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/precedence_on_single_child_negative/readme.md +1 -0
  692. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/precedence_on_single_child_positive/corpus.txt +13 -0
  693. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/precedence_on_single_child_positive/grammar.json +63 -0
  694. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/precedence_on_single_child_positive/readme.md +1 -0
  695. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/precedence_on_subsequence/corpus.txt +24 -0
  696. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/precedence_on_subsequence/grammar.json +135 -0
  697. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/readme.md +3 -0
  698. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/readme_grammar/corpus.txt +13 -0
  699. data/{test/tree-sitter/fixtures/arithmetic → ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/readme_grammar}/grammar.json +3 -3
  700. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/start_rule_is_blank/corpus.txt +7 -0
  701. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/start_rule_is_blank/grammar.json +6 -0
  702. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/start_rule_is_token/corpus.txt +6 -0
  703. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/start_rule_is_token/grammar.json +6 -0
  704. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/unused_rules/corpus.txt +9 -0
  705. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/unused_rules/grammar.json +73 -0
  706. data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/unused_rules/readme.md +1 -0
  707. data/ext/tree-sitter/tree-sitter/test/fuzz/README.md +43 -0
  708. data/ext/tree-sitter/tree-sitter/test/fuzz/fuzzer.cc +27 -0
  709. data/ext/tree-sitter/tree-sitter/test/fuzz/gen-dict.py +31 -0
  710. data/ext/tree-sitter/tree-sitter/{spec → test}/helpers/dedent.h +0 -0
  711. data/ext/tree-sitter/tree-sitter/{spec → test}/helpers/encoding_helpers.cc +9 -3
  712. data/ext/tree-sitter/tree-sitter/{spec → test}/helpers/encoding_helpers.h +0 -0
  713. data/ext/tree-sitter/tree-sitter/test/helpers/file_helpers.cc +100 -0
  714. data/ext/tree-sitter/tree-sitter/test/helpers/file_helpers.h +15 -0
  715. data/ext/tree-sitter/tree-sitter/test/helpers/load_language.cc +239 -0
  716. data/ext/tree-sitter/tree-sitter/test/helpers/load_language.h +14 -0
  717. data/ext/tree-sitter/tree-sitter/{spec → test}/helpers/point_helpers.cc +2 -5
  718. data/ext/tree-sitter/tree-sitter/{spec → test}/helpers/point_helpers.h +0 -0
  719. data/ext/tree-sitter/tree-sitter/test/helpers/random_helpers.cc +59 -0
  720. data/ext/tree-sitter/tree-sitter/test/helpers/random_helpers.h +14 -0
  721. data/ext/tree-sitter/tree-sitter/{spec → test}/helpers/read_test_entries.cc +38 -38
  722. data/ext/tree-sitter/tree-sitter/test/helpers/read_test_entries.h +22 -0
  723. data/ext/tree-sitter/tree-sitter/{spec → test}/helpers/record_alloc.cc +7 -13
  724. data/ext/tree-sitter/tree-sitter/{spec → test}/helpers/record_alloc.h +2 -2
  725. data/ext/tree-sitter/tree-sitter/{spec → test}/helpers/scope_sequence.cc +0 -0
  726. data/ext/tree-sitter/tree-sitter/{spec → test}/helpers/scope_sequence.h +0 -0
  727. data/ext/tree-sitter/tree-sitter/{spec → test}/helpers/spy_input.cc +39 -15
  728. data/ext/tree-sitter/tree-sitter/{spec → test}/helpers/spy_input.h +4 -4
  729. data/ext/tree-sitter/tree-sitter/{spec → test}/helpers/spy_logger.cc +0 -0
  730. data/ext/tree-sitter/tree-sitter/{spec → test}/helpers/spy_logger.h +0 -0
  731. data/ext/tree-sitter/tree-sitter/{spec → test}/helpers/stderr_logger.cc +0 -0
  732. data/ext/tree-sitter/tree-sitter/{spec → test}/helpers/stderr_logger.h +0 -0
  733. data/ext/tree-sitter/tree-sitter/test/helpers/stream_methods.cc +224 -0
  734. data/ext/tree-sitter/tree-sitter/{spec → test}/helpers/stream_methods.h +32 -15
  735. data/ext/tree-sitter/tree-sitter/test/helpers/tree_helpers.cc +99 -0
  736. data/ext/tree-sitter/tree-sitter/{spec → test}/helpers/tree_helpers.h +3 -1
  737. data/ext/tree-sitter/tree-sitter/test/integration/fuzzing-examples.cc +67 -0
  738. data/ext/tree-sitter/tree-sitter/test/integration/real_grammars.cc +142 -0
  739. data/ext/tree-sitter/tree-sitter/test/integration/test_grammars.cc +79 -0
  740. data/ext/tree-sitter/tree-sitter/{spec/runtime/document_spec.cc → test/runtime/document_test.cc} +150 -32
  741. data/ext/tree-sitter/tree-sitter/test/runtime/language_test.cc +55 -0
  742. data/ext/tree-sitter/tree-sitter/{spec/runtime/node_spec.cc → test/runtime/node_test.cc} +222 -127
  743. data/ext/tree-sitter/tree-sitter/{spec/runtime/parser_spec.cc → test/runtime/parser_test.cc} +126 -85
  744. data/ext/tree-sitter/tree-sitter/{spec/runtime/stack_spec.cc → test/runtime/stack_test.cc} +201 -164
  745. data/ext/tree-sitter/tree-sitter/test/runtime/tree_test.cc +475 -0
  746. data/ext/tree-sitter/tree-sitter/{spec/spec_helper.h → test/test_helper.h} +3 -3
  747. data/ext/tree-sitter/tree-sitter/{spec/specs.cc → test/tests.cc} +4 -3
  748. data/ext/tree-sitter/tree-sitter/tests.gyp +77 -23
  749. data/lib/tree-sitter.rb +4 -0
  750. data/lib/tree-sitter/node.rb +27 -0
  751. data/lib/tree-sitter/version.rb +3 -1
  752. data/test/test_helper.rb +4 -0
  753. data/test/tree-sitter/fixtures/parsers/python/parser.c +65600 -0
  754. data/test/tree-sitter/fixtures/parsers/python/scanner.cc +164 -0
  755. data/test/tree-sitter/test_basic.rb +2 -0
  756. data/test/tree-sitter/test_document.rb +101 -1
  757. data/test/tree-sitter/test_node.rb +73 -0
  758. data/tree-sitter.gemspec +4 -2
  759. metadata +445 -217
  760. data/ext/tree-sitter/tree-sitter/Makefile +0 -360
  761. data/ext/tree-sitter/tree-sitter/compiler.target.mk +0 -238
  762. data/ext/tree-sitter/tree-sitter/externals/gyp/pylintrc +0 -307
  763. data/ext/tree-sitter/tree-sitter/externals/gyp/test/same-source-file-name/gyptest-fail-shared.py +0 -18
  764. data/ext/tree-sitter/tree-sitter/externals/gyp/test/same-source-file-name/gyptest-fail-static.py +0 -18
  765. data/ext/tree-sitter/tree-sitter/gyp-mac-tool +0 -511
  766. data/ext/tree-sitter/tree-sitter/out/Release/libcompiler.a +0 -0
  767. data/ext/tree-sitter/tree-sitter/out/Release/libruntime.a +0 -0
  768. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/externals/json-parser/json.o +0 -0
  769. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/externals/utf8proc/utf8proc.o +0 -0
  770. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/build_tables/build_lex_table.o +0 -0
  771. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/build_tables/build_parse_table.o +0 -0
  772. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/build_tables/build_tables.o +0 -0
  773. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/build_tables/lex_conflict_manager.o +0 -0
  774. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/build_tables/lex_item.o +0 -0
  775. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/build_tables/lex_item_transitions.o +0 -0
  776. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/build_tables/lookahead_set.o +0 -0
  777. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/build_tables/parse_item.o +0 -0
  778. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/build_tables/parse_item_set_builder.o +0 -0
  779. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/build_tables/recovery_tokens.o +0 -0
  780. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/build_tables/rule_can_be_blank.o +0 -0
  781. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/compile.o +0 -0
  782. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/generate_code/c_code.o +0 -0
  783. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/lex_table.o +0 -0
  784. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/parse_grammar.o +0 -0
  785. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/parse_table.o +0 -0
  786. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/precedence_range.o +0 -0
  787. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/prepare_grammar/expand_repeats.o +0 -0
  788. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/prepare_grammar/expand_tokens.o +0 -0
  789. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/prepare_grammar/extract_choices.o +0 -0
  790. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/prepare_grammar/extract_tokens.o +0 -0
  791. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/prepare_grammar/flatten_grammar.o +0 -0
  792. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/prepare_grammar/intern_symbols.o +0 -0
  793. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/prepare_grammar/is_token.o +0 -0
  794. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/prepare_grammar/normalize_rules.o +0 -0
  795. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/prepare_grammar/parse_regex.o +0 -0
  796. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/prepare_grammar/prepare_grammar.o +0 -0
  797. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/prepare_grammar/token_description.o +0 -0
  798. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/rule.o +0 -0
  799. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/rules/blank.o +0 -0
  800. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/rules/built_in_symbols.o +0 -0
  801. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/rules/character_range.o +0 -0
  802. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/rules/character_set.o +0 -0
  803. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/rules/choice.o +0 -0
  804. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/rules/metadata.o +0 -0
  805. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/rules/named_symbol.o +0 -0
  806. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/rules/pattern.o +0 -0
  807. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/rules/repeat.o +0 -0
  808. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/rules/rules.o +0 -0
  809. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/rules/seq.o +0 -0
  810. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/rules/string.o +0 -0
  811. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/rules/symbol.o +0 -0
  812. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/rules/visitor.o +0 -0
  813. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/syntax_grammar.o +0 -0
  814. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/util/string_helpers.o +0 -0
  815. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/variable.o +0 -0
  816. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/runtime/externals/utf8proc/utf8proc.o +0 -0
  817. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/runtime/src/runtime/document.o +0 -0
  818. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/runtime/src/runtime/error_costs.o +0 -0
  819. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/runtime/src/runtime/language.o +0 -0
  820. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/runtime/src/runtime/lexer.o +0 -0
  821. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/runtime/src/runtime/node.o +0 -0
  822. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/runtime/src/runtime/parser.o +0 -0
  823. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/runtime/src/runtime/stack.o +0 -0
  824. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/runtime/src/runtime/string_input.o +0 -0
  825. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/runtime/src/runtime/tree.o +0 -0
  826. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/runtime/src/runtime/utf16.o +0 -0
  827. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/compiler/build_tables/distinctive_tokens_spec.o +0 -0
  828. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/compiler/build_tables/lex_conflict_manager_spec.o +0 -0
  829. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/compiler/build_tables/lex_item_spec.o +0 -0
  830. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/compiler/build_tables/parse_item_set_builder_spec.o +0 -0
  831. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/compiler/build_tables/rule_can_be_blank_spec.o +0 -0
  832. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/compiler/prepare_grammar/expand_repeats_spec.o +0 -0
  833. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/compiler/prepare_grammar/expand_tokens_spec.o +0 -0
  834. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/compiler/prepare_grammar/extract_choices_spec.o +0 -0
  835. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/compiler/prepare_grammar/extract_tokens_spec.o +0 -0
  836. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/compiler/prepare_grammar/flatten_grammar_spec.o +0 -0
  837. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/compiler/prepare_grammar/intern_symbols_spec.o +0 -0
  838. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/compiler/prepare_grammar/parse_regex_spec.o +0 -0
  839. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/compiler/rules/character_set_spec.o +0 -0
  840. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/compiler/rules/choice_spec.o +0 -0
  841. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/compiler/rules/repeat_spec.o +0 -0
  842. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/compiler/util/string_helpers_spec.o +0 -0
  843. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/helpers/encoding_helpers.o +0 -0
  844. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/helpers/load_language.o +0 -0
  845. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/helpers/point_helpers.o +0 -0
  846. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/helpers/random_helpers.o +0 -0
  847. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/helpers/read_test_entries.o +0 -0
  848. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/helpers/record_alloc.o +0 -0
  849. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/helpers/rule_helpers.o +0 -0
  850. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/helpers/scope_sequence.o +0 -0
  851. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/helpers/spy_input.o +0 -0
  852. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/helpers/spy_logger.o +0 -0
  853. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/helpers/stderr_logger.o +0 -0
  854. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/helpers/stream_methods.o +0 -0
  855. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/helpers/tree_helpers.o +0 -0
  856. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/integration/compile_grammar_spec.o +0 -0
  857. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/integration/corpus_specs.o +0 -0
  858. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/runtime/document_spec.o +0 -0
  859. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/runtime/node_spec.o +0 -0
  860. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/runtime/parser_spec.o +0 -0
  861. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/runtime/stack_spec.o +0 -0
  862. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/runtime/tree_spec.o +0 -0
  863. data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/specs.o +0 -0
  864. data/ext/tree-sitter/tree-sitter/out/Release/tests +0 -0
  865. data/ext/tree-sitter/tree-sitter/project.Makefile +0 -6
  866. data/ext/tree-sitter/tree-sitter/runtime.target.mk +0 -174
  867. data/ext/tree-sitter/tree-sitter/spec/compiler/build_tables/distinctive_tokens_spec.cc +0 -34
  868. data/ext/tree-sitter/tree-sitter/spec/compiler/build_tables/lex_conflict_manager_spec.cc +0 -88
  869. data/ext/tree-sitter/tree-sitter/spec/compiler/build_tables/parse_item_set_builder_spec.cc +0 -133
  870. data/ext/tree-sitter/tree-sitter/spec/compiler/prepare_grammar/expand_repeats_spec.cc +0 -152
  871. data/ext/tree-sitter/tree-sitter/spec/compiler/prepare_grammar/expand_tokens_spec.cc +0 -109
  872. data/ext/tree-sitter/tree-sitter/spec/compiler/prepare_grammar/extract_choices_spec.cc +0 -106
  873. data/ext/tree-sitter/tree-sitter/spec/compiler/prepare_grammar/extract_tokens_spec.cc +0 -251
  874. data/ext/tree-sitter/tree-sitter/spec/compiler/prepare_grammar/flatten_grammar_spec.cc +0 -89
  875. data/ext/tree-sitter/tree-sitter/spec/compiler/prepare_grammar/intern_symbols_spec.cc +0 -89
  876. data/ext/tree-sitter/tree-sitter/spec/compiler/prepare_grammar/parse_regex_spec.cc +0 -245
  877. data/ext/tree-sitter/tree-sitter/spec/compiler/rules/choice_spec.cc +0 -53
  878. data/ext/tree-sitter/tree-sitter/spec/compiler/rules/repeat_spec.cc +0 -22
  879. data/ext/tree-sitter/tree-sitter/spec/fixtures/error_corpus/c_errors.txt +0 -130
  880. data/ext/tree-sitter/tree-sitter/spec/fixtures/error_corpus/javascript_errors.txt +0 -157
  881. data/ext/tree-sitter/tree-sitter/spec/fixtures/external_scanners/extra_external_tokens.c +0 -42
  882. data/ext/tree-sitter/tree-sitter/spec/helpers/equals_pointer.h +0 -37
  883. data/ext/tree-sitter/tree-sitter/spec/helpers/load_language.cc +0 -206
  884. data/ext/tree-sitter/tree-sitter/spec/helpers/load_language.h +0 -12
  885. data/ext/tree-sitter/tree-sitter/spec/helpers/random_helpers.cc +0 -35
  886. data/ext/tree-sitter/tree-sitter/spec/helpers/random_helpers.h +0 -8
  887. data/ext/tree-sitter/tree-sitter/spec/helpers/read_test_entries.h +0 -15
  888. data/ext/tree-sitter/tree-sitter/spec/helpers/rule_helpers.cc +0 -55
  889. data/ext/tree-sitter/tree-sitter/spec/helpers/rule_helpers.h +0 -21
  890. data/ext/tree-sitter/tree-sitter/spec/helpers/stream_methods.cc +0 -140
  891. data/ext/tree-sitter/tree-sitter/spec/helpers/tree_helpers.cc +0 -50
  892. data/ext/tree-sitter/tree-sitter/spec/integration/compile_grammar_spec.cc +0 -847
  893. data/ext/tree-sitter/tree-sitter/spec/integration/corpus_specs.cc +0 -185
  894. data/ext/tree-sitter/tree-sitter/spec/runtime/tree_spec.cc +0 -439
  895. data/ext/tree-sitter/tree-sitter/src/compiler/build_tables/build_lex_table.cc +0 -195
  896. data/ext/tree-sitter/tree-sitter/src/compiler/build_tables/build_lex_table.h +0 -18
  897. data/ext/tree-sitter/tree-sitter/src/compiler/build_tables/build_parse_table.cc +0 -604
  898. data/ext/tree-sitter/tree-sitter/src/compiler/build_tables/build_parse_table.h +0 -22
  899. data/ext/tree-sitter/tree-sitter/src/compiler/build_tables/build_tables.cc +0 -27
  900. data/ext/tree-sitter/tree-sitter/src/compiler/build_tables/build_tables.h +0 -24
  901. data/ext/tree-sitter/tree-sitter/src/compiler/build_tables/conflict_type.h +0 -16
  902. data/ext/tree-sitter/tree-sitter/src/compiler/build_tables/lex_conflict_manager.cc +0 -55
  903. data/ext/tree-sitter/tree-sitter/src/compiler/build_tables/lex_conflict_manager.h +0 -31
  904. data/ext/tree-sitter/tree-sitter/src/compiler/build_tables/recovery_tokens.cc +0 -89
  905. data/ext/tree-sitter/tree-sitter/src/compiler/build_tables/recovery_tokens.h +0 -19
  906. data/ext/tree-sitter/tree-sitter/src/compiler/build_tables/remove_duplicate_states.h +0 -65
  907. data/ext/tree-sitter/tree-sitter/src/compiler/compile.h +0 -16
  908. data/ext/tree-sitter/tree-sitter/src/compiler/prepare_grammar/is_token.cc +0 -30
  909. data/ext/tree-sitter/tree-sitter/src/compiler/prepare_grammar/is_token.h +0 -14
  910. data/ext/tree-sitter/tree-sitter/src/compiler/rules.h +0 -28
  911. data/ext/tree-sitter/tree-sitter/src/compiler/rules/blank.cc +0 -36
  912. data/ext/tree-sitter/tree-sitter/src/compiler/rules/built_in_symbols.cc +0 -19
  913. data/ext/tree-sitter/tree-sitter/src/compiler/rules/built_in_symbols.h +0 -16
  914. data/ext/tree-sitter/tree-sitter/src/compiler/rules/character_range.cc +0 -36
  915. data/ext/tree-sitter/tree-sitter/src/compiler/rules/character_range.h +0 -25
  916. data/ext/tree-sitter/tree-sitter/src/compiler/rules/named_symbol.cc +0 -35
  917. data/ext/tree-sitter/tree-sitter/src/compiler/rules/pattern.cc +0 -36
  918. data/ext/tree-sitter/tree-sitter/src/compiler/rules/rules.cc +0 -108
  919. data/ext/tree-sitter/tree-sitter/src/compiler/rules/string.cc +0 -35
  920. data/ext/tree-sitter/tree-sitter/src/compiler/rules/symbol.cc +0 -82
  921. data/ext/tree-sitter/tree-sitter/src/compiler/rules/visitor.cc +0 -44
  922. data/ext/tree-sitter/tree-sitter/src/compiler/rules/visitor.h +0 -234
  923. data/ext/tree-sitter/tree-sitter/src/compiler/variable.cc +0 -11
  924. data/ext/tree-sitter/tree-sitter/src/compiler/variable.h +0 -27
  925. data/ext/tree-sitter/tree-sitter/src/runtime/error_costs.c +0 -28
  926. data/ext/tree-sitter/tree-sitter/src/runtime/tree_path.h +0 -217
  927. data/ext/tree-sitter/tree-sitter/tests.Makefile +0 -6
  928. data/ext/tree-sitter/tree-sitter/tests.target.mk +0 -176
  929. data/test/tree-sitter/fixtures/ruby/grammar.json +0 -4803
  930. data/test/tree-sitter/test_grammar.rb +0 -34
@@ -0,0 +1,893 @@
1
+ #include "compiler/build_tables/parse_table_builder.h"
2
+ #include <algorithm>
3
+ #include <map>
4
+ #include <set>
5
+ #include <deque>
6
+ #include <string>
7
+ #include <unordered_map>
8
+ #include <utility>
9
+ #include "compiler/parse_table.h"
10
+ #include "compiler/build_tables/parse_item.h"
11
+ #include "compiler/build_tables/parse_item_set_builder.h"
12
+ #include "compiler/lexical_grammar.h"
13
+ #include "compiler/syntax_grammar.h"
14
+ #include "compiler/rule.h"
15
+ #include "compiler/build_tables/lex_table_builder.h"
16
+
17
+ namespace tree_sitter {
18
+ namespace build_tables {
19
+
20
+ using std::deque;
21
+ using std::find;
22
+ using std::vector;
23
+ using std::set;
24
+ using std::tuple;
25
+ using std::make_tuple;
26
+ using std::map;
27
+ using std::move;
28
+ using std::string;
29
+ using std::to_string;
30
+ using std::unique_ptr;
31
+ using std::unordered_map;
32
+ using rules::Associativity;
33
+ using rules::Symbol;
34
+ using rules::END_OF_INPUT;
35
+
36
+ using SymbolSequence = vector<Symbol>;
37
+
38
+ struct ParseStateQueueEntry {
39
+ SymbolSequence preceding_symbols;
40
+ ParseItemSet item_set;
41
+ ParseStateId state_id;
42
+ };
43
+
44
+ class ParseTableBuilderImpl : public ParseTableBuilder {
45
+ const SyntaxGrammar grammar;
46
+ const LexicalGrammar lexical_grammar;
47
+ unordered_map<ParseItemSet, ParseStateId> state_ids_by_item_set;
48
+ vector<const ParseItemSet *> item_sets_by_state_id;
49
+ deque<ParseStateQueueEntry> parse_state_queue;
50
+ ParseTable parse_table;
51
+ ParseItemSetBuilder item_set_builder;
52
+ unique_ptr<LexTableBuilder> lex_table_builder;
53
+ unordered_map<Symbol, LookaheadSet> following_tokens_by_token;
54
+ vector<LookaheadSet> coincident_tokens_by_token;
55
+
56
+ public:
57
+ ParseTableBuilderImpl(const SyntaxGrammar &syntax_grammar, const LexicalGrammar &lexical_grammar)
58
+ : grammar(syntax_grammar),
59
+ lexical_grammar(lexical_grammar),
60
+ item_set_builder(syntax_grammar, lexical_grammar),
61
+ coincident_tokens_by_token(lexical_grammar.variables.size()) {
62
+
63
+ for (unsigned i = 0, n = lexical_grammar.variables.size(); i < n; i++) {
64
+ coincident_tokens_by_token[i].insert(rules::END_OF_INPUT());
65
+ if (lexical_grammar.variables[i].is_string) {
66
+ for (unsigned j = 0; j < i; j++) {
67
+ if (lexical_grammar.variables[j].is_string) {
68
+ coincident_tokens_by_token[i].insert(Symbol::terminal(j));
69
+ coincident_tokens_by_token[j].insert(Symbol::terminal(i));
70
+ }
71
+ }
72
+ }
73
+ }
74
+ }
75
+
76
+ BuildResult build() {
77
+ // Ensure that the empty rename sequence has index 0.
78
+ parse_table.alias_sequences.push_back({});
79
+
80
+ // Ensure that the error state has index 0.
81
+ ParseStateId error_state_id = add_parse_state({}, ParseItemSet{});
82
+
83
+ // Add the starting state.
84
+ Symbol start_symbol = Symbol::non_terminal(0);
85
+ Production start_production({{start_symbol, 0, rules::AssociativityNone, rules::Alias{}}}, 0);
86
+
87
+ add_parse_state({}, ParseItemSet{{
88
+ {
89
+ ParseItem(rules::START(), start_production, 0),
90
+ LookaheadSet({END_OF_INPUT()}),
91
+ },
92
+ }});
93
+
94
+ CompileError error = process_part_state_queue();
95
+ if (error) return {
96
+ parse_table,
97
+ LexTable(),
98
+ LexTable(),
99
+ rules::NONE(),
100
+ error,
101
+ };
102
+
103
+ lex_table_builder = LexTableBuilder::create(
104
+ grammar,
105
+ lexical_grammar,
106
+ following_tokens_by_token,
107
+ coincident_tokens_by_token
108
+ );
109
+
110
+ build_error_parse_state(error_state_id);
111
+ remove_precedence_values();
112
+ remove_duplicate_parse_states();
113
+ eliminate_unit_reductions();
114
+ populate_used_terminals();
115
+
116
+ auto lex_table_result = lex_table_builder->build(&parse_table);
117
+ return {
118
+ parse_table,
119
+ lex_table_result.main_table,
120
+ lex_table_result.keyword_table,
121
+ lex_table_result.keyword_capture_token,
122
+ CompileError::none()
123
+ };
124
+ }
125
+
126
+ private:
127
+ CompileError process_part_state_queue() {
128
+ while (!parse_state_queue.empty()) {
129
+ auto entry = parse_state_queue.front();
130
+ parse_state_queue.pop_front();
131
+
132
+ item_set_builder.apply_transitive_closure(&entry.item_set);
133
+ string conflict = add_actions(
134
+ move(entry.preceding_symbols),
135
+ move(entry.item_set),
136
+ entry.state_id
137
+ );
138
+
139
+ if (!conflict.empty()) {
140
+ return CompileError(TSCompileErrorTypeParseConflict, conflict);
141
+ }
142
+ }
143
+
144
+ return CompileError::none();
145
+ }
146
+
147
+ void build_error_parse_state(ParseStateId state_id) {
148
+ unsigned CannotMerge = (
149
+ MatchesShorterStringWithinSeparators |
150
+ MatchesLongerStringWithValidNextChar
151
+ );
152
+
153
+ parse_table.states[state_id].terminal_entries.clear();
154
+
155
+ // Add all the tokens that have no conflict with other tokens.
156
+ LookaheadSet non_conflicting_tokens;
157
+ for (unsigned i = 0; i < lexical_grammar.variables.size(); i++) {
158
+ Symbol token = Symbol::terminal(i);
159
+ bool conflicts_with_other_tokens = false;
160
+ for (unsigned j = 0; j < lexical_grammar.variables.size(); j++) {
161
+ Symbol other_token = Symbol::terminal(j);
162
+ if (j != i &&
163
+ !coincident_tokens_by_token[token.index].contains(other_token) &&
164
+ (lex_table_builder->get_conflict_status(other_token, token) & CannotMerge)) {
165
+ conflicts_with_other_tokens = true;
166
+ break;
167
+ }
168
+ }
169
+ if (!conflicts_with_other_tokens) non_conflicting_tokens.insert(token);
170
+ }
171
+
172
+ LookaheadSet tokens;
173
+ for (unsigned i = 0; i < lexical_grammar.variables.size(); i++) {
174
+ Symbol token = Symbol::terminal(i);
175
+ bool conflicts_with_other_tokens = false;
176
+ if (!non_conflicting_tokens.contains(token)) {
177
+ non_conflicting_tokens.for_each([&](Symbol other_token) {
178
+ if (!coincident_tokens_by_token[token.index].contains(other_token) &&
179
+ (lex_table_builder->get_conflict_status(other_token, token) & CannotMerge)) {
180
+ conflicts_with_other_tokens = true;
181
+ return false;
182
+ }
183
+ return true;
184
+ });
185
+ }
186
+ if (!conflicts_with_other_tokens) {
187
+ parse_table.add_terminal_action(state_id, token, ParseAction::Recover());
188
+ }
189
+ }
190
+
191
+ for (size_t i = 0; i < grammar.external_tokens.size(); i++) {
192
+ if (grammar.external_tokens[i].corresponding_internal_token == rules::NONE()) {
193
+ parse_table.states[state_id].terminal_entries[Symbol::external(i)].actions.push_back(ParseAction::Recover());
194
+ }
195
+ }
196
+
197
+ parse_table.add_terminal_action(state_id, END_OF_INPUT(), ParseAction::Recover());
198
+ }
199
+
200
+ ParseStateId add_parse_state(SymbolSequence &&preceding_symbols, const ParseItemSet &item_set) {
201
+ ParseStateId new_state_id = parse_table.states.size();
202
+ auto insertion = state_ids_by_item_set.insert({move(item_set), new_state_id});
203
+ if (insertion.second) {
204
+ item_sets_by_state_id.push_back(&insertion.first->first);
205
+ parse_table.states.push_back(ParseState());
206
+ parse_state_queue.push_back({
207
+ move(preceding_symbols),
208
+ insertion.first->first,
209
+ new_state_id
210
+ });
211
+ return new_state_id;
212
+ } else {
213
+ return insertion.first->second;
214
+ }
215
+ }
216
+
217
+ string add_actions(SymbolSequence &&sequence, ParseItemSet &&item_set, ParseStateId state_id) {
218
+ map<Symbol, ParseItemSet> terminal_successors;
219
+ map<Symbol::Index, ParseItemSet> nonterminal_successors;
220
+ set<Symbol> lookaheads_with_conflicts;
221
+
222
+ for (const auto &pair : item_set.entries) {
223
+ const ParseItem &item = pair.first;
224
+ const LookaheadSet &lookahead_symbols = pair.second;
225
+
226
+ // If the item is finished, immediately add a Reduce or Accept action to
227
+ // the parse table for each of its lookahead terminals.
228
+ if (item.is_done()) {
229
+ ParseAction action = item.lhs() == rules::START() ?
230
+ ParseAction::Accept() :
231
+ ParseAction::Reduce(
232
+ item.lhs(),
233
+ item.step_index,
234
+ item.precedence(),
235
+ item.production->dynamic_precedence,
236
+ item.associativity(),
237
+ get_alias_sequence_id(*item.production)
238
+ );
239
+
240
+ lookahead_symbols.for_each([&](Symbol lookahead) {
241
+ ParseTableEntry &entry = parse_table.states[state_id].terminal_entries[lookahead];
242
+
243
+ // Only add the highest-precedence Reduce actions to the parse table.
244
+ // If other lower-precedence actions are possible, ignore them.
245
+ if (entry.actions.empty()) {
246
+ entry.actions.push_back(action);
247
+ } else {
248
+ ParseAction &existing_action = entry.actions[0];
249
+ if (existing_action.type == ParseActionTypeAccept) {
250
+ entry.actions.push_back(action);
251
+ } else {
252
+ if (action.precedence > existing_action.precedence) {
253
+ entry.actions.assign({action});
254
+ lookaheads_with_conflicts.erase(lookahead);
255
+ } else if (action.precedence == existing_action.precedence) {
256
+ entry.actions.push_back(action);
257
+ lookaheads_with_conflicts.insert(lookahead);
258
+ }
259
+ }
260
+ }
261
+
262
+ return true;
263
+ });
264
+
265
+ // If the item is unfinished, create a new item by advancing one symbol.
266
+ // Add that new item to a successor item set.
267
+ } else {
268
+ Symbol symbol = item.production->at(item.step_index).symbol;
269
+ ParseItem new_item(item.lhs(), *item.production, item.step_index + 1);
270
+
271
+ if (symbol.is_non_terminal()) {
272
+ nonterminal_successors[symbol.index].entries[new_item] = lookahead_symbols;
273
+ } else {
274
+ terminal_successors[symbol].entries[new_item] = lookahead_symbols;
275
+ }
276
+ }
277
+ }
278
+
279
+ // Add a Shift action for each possible successor state. Shift actions for
280
+ // terminal lookaheads can conflict with Reduce actions added previously.
281
+ for (auto &pair : terminal_successors) {
282
+ Symbol lookahead = pair.first;
283
+ ParseItemSet &next_item_set = pair.second;
284
+ ParseStateId next_state_id = add_parse_state(append_symbol(sequence, lookahead), next_item_set);
285
+
286
+ if (!parse_table.states[state_id].terminal_entries[lookahead].actions.empty()) {
287
+ lookaheads_with_conflicts.insert(lookahead);
288
+ }
289
+
290
+ parse_table.add_terminal_action(state_id, lookahead, ParseAction::Shift(next_state_id));
291
+ }
292
+
293
+ // Add a Shift action for each non-terminal transition.
294
+ for (auto &pair : nonterminal_successors) {
295
+ Symbol lookahead = Symbol::non_terminal(pair.first);
296
+ ParseItemSet &next_item_set = pair.second;
297
+ ParseStateId next_state_id = add_parse_state(append_symbol(sequence, lookahead), next_item_set);
298
+ parse_table.set_nonterminal_action(state_id, lookahead.index, next_state_id);
299
+ }
300
+
301
+ for (Symbol lookahead : lookaheads_with_conflicts) {
302
+ string conflict = handle_conflict(lookahead, item_set, sequence, state_id);
303
+ if (!conflict.empty()) return conflict;
304
+ }
305
+
306
+ ParseAction shift_extra = ParseAction::ShiftExtra();
307
+ ParseState &state = parse_table.states[state_id];
308
+ for (const Symbol &extra_symbol : grammar.extra_tokens) {
309
+ if (!state.terminal_entries.count(extra_symbol) || state.has_shift_action()) {
310
+ parse_table.add_terminal_action(state_id, extra_symbol, shift_extra);
311
+ }
312
+ }
313
+
314
+ auto &terminals = state.terminal_entries;
315
+ for (auto iter = terminals.begin(), end = terminals.end(); iter != end; ++iter) {
316
+ if (iter->first.is_built_in() || iter->first.is_external()) continue;
317
+ for (auto other_iter = terminals.begin(); other_iter != iter; ++other_iter) {
318
+ if (other_iter->first.is_built_in() || other_iter->first.is_external()) continue;
319
+ coincident_tokens_by_token[iter->first.index].insert(other_iter->first);
320
+ coincident_tokens_by_token[other_iter->first.index].insert(iter->first);
321
+ }
322
+ }
323
+
324
+ return "";
325
+ }
326
+
327
+ void remove_precedence_values() {
328
+ for (ParseState &state : parse_table.states) {
329
+ for (auto &entry : state.terminal_entries) {
330
+ auto &actions = entry.second.actions;
331
+
332
+ for (ParseAction &action : actions) {
333
+ action.precedence = 0;
334
+ action.associativity = rules::AssociativityNone;
335
+ }
336
+
337
+ for (auto i = actions.begin(); i != actions.end();) {
338
+ bool erased = false;
339
+ for (auto j = actions.begin(); j != i; j++) {
340
+ if (*j == *i) {
341
+ actions.erase(i);
342
+ erased = true;
343
+ break;
344
+ }
345
+ }
346
+ if (!erased) {
347
+ ++i;
348
+ }
349
+ }
350
+ }
351
+ }
352
+ }
353
+
354
+ void remove_duplicate_parse_states() {
355
+ unordered_map<size_t, set<ParseStateId>> state_indices_by_signature;
356
+
357
+ for (auto &pair : state_ids_by_item_set) {
358
+ const ParseItemSet &item_set = pair.first;
359
+ ParseStateId state_id = pair.second;
360
+ state_indices_by_signature[item_set.unfinished_item_signature()].insert(state_id);
361
+ }
362
+
363
+ set<ParseStateId> deleted_states;
364
+
365
+ while (true) {
366
+ map<ParseStateId, ParseStateId> state_replacements;
367
+
368
+ for (auto &pair : state_indices_by_signature) {
369
+ auto &state_indices = pair.second;
370
+
371
+ for (auto i = state_indices.begin(), end = state_indices.end(); i != end;) {
372
+ for (ParseStateId j : state_indices) {
373
+ if (j == *i) {
374
+ ++i;
375
+ break;
376
+ }
377
+ if (!state_replacements.count(j) && merge_parse_state(j, *i)) {
378
+ state_replacements.insert({*i, j});
379
+ deleted_states.insert(*i);
380
+ i = state_indices.erase(i);
381
+ break;
382
+ }
383
+ }
384
+ }
385
+ }
386
+
387
+ if (state_replacements.empty()) break;
388
+
389
+ for (ParseStateId i = 0, n = parse_table.states.size(); i < n; i++) {
390
+ if (!state_replacements.count(i)) {
391
+ ParseState &state = parse_table.states[i];
392
+ state.each_referenced_state([&state_replacements](ParseStateId *state_index) {
393
+ auto replacement = state_replacements.find(*state_index);
394
+ if (replacement != state_replacements.end()) {
395
+ *state_index = replacement->second;
396
+ }
397
+ });
398
+ }
399
+ }
400
+ }
401
+
402
+ delete_parse_states(deleted_states);
403
+ }
404
+
405
+ void eliminate_unit_reductions() {
406
+ set<Symbol::Index> aliased_symbols;
407
+ for (auto &variable : grammar.variables) {
408
+ for (auto &production : variable.productions) {
409
+ for (auto &step : production) {
410
+ if (!step.alias.value.empty()) {
411
+ aliased_symbols.insert(step.symbol.index);
412
+ }
413
+ }
414
+ }
415
+ }
416
+
417
+ // Find all the "unit reduction states" - states whose only actions are unit reductions,
418
+ // all of which reduce by the same symbol. Store the symbols along with the state indices.
419
+ unordered_map<ParseStateId, Symbol::Index> unit_reduction_states;
420
+ for (ParseStateId i = 0, n = parse_table.states.size(); i < n; i++) {
421
+ ParseState &state = parse_table.states[i];
422
+ bool only_unit_reductions = true;
423
+ Symbol::Index unit_reduction_symbol = -1;
424
+
425
+ if (!state.nonterminal_entries.empty()) continue;
426
+
427
+ for (auto &entry : state.terminal_entries) {
428
+ for (ParseAction &action : entry.second.actions) {
429
+ if (action.extra) continue;
430
+ if (action.type == ParseActionTypeReduce &&
431
+ action.consumed_symbol_count == 1 &&
432
+ action.alias_sequence_id == 0 &&
433
+ !aliased_symbols.count(action.symbol.index) &&
434
+ grammar.variables[action.symbol.index].type != VariableTypeNamed &&
435
+ (unit_reduction_symbol == -1 || unit_reduction_symbol == action.symbol.index)
436
+ ) {
437
+ unit_reduction_symbol = action.symbol.index;
438
+ } else {
439
+ only_unit_reductions = false;
440
+ break;
441
+ }
442
+ }
443
+
444
+ if (!only_unit_reductions) break;
445
+ }
446
+
447
+ if (only_unit_reductions) unit_reduction_states[i] = unit_reduction_symbol;
448
+ }
449
+
450
+ // Update each parse state so that the parser never enters these "unit reduction states".
451
+ // If a shift action points to a unit reduction state, update it to point directly at
452
+ // the same state as the shift action that's associated with the unit reduction's
453
+ // non-terminal.
454
+ for (ParseState &state : parse_table.states) {
455
+ bool done = false;
456
+ while (!done) {
457
+ done = true;
458
+ state.each_referenced_state([&](ParseStateId *state_id) {
459
+ const auto &unit_reduction_entry = unit_reduction_states.find(*state_id);
460
+ if (unit_reduction_entry != unit_reduction_states.end()) {
461
+ auto entry_for_reduced_symbol = state.nonterminal_entries.find(unit_reduction_entry->second);
462
+ *state_id = entry_for_reduced_symbol->second;
463
+ done = false;
464
+ }
465
+ });
466
+ }
467
+ }
468
+
469
+ // Remove the unit reduction states from the parse table.
470
+ set<ParseStateId> states_to_delete;
471
+ for (auto &entry : unit_reduction_states) {
472
+ if (entry.first != 1) states_to_delete.insert(entry.first);
473
+ }
474
+ delete_parse_states(states_to_delete);
475
+ }
476
+
477
+ void populate_used_terminals() {
478
+ for (const ParseState &state : parse_table.states) {
479
+ for (auto &entry : state.terminal_entries) {
480
+ parse_table.symbols.insert(entry.first);
481
+ }
482
+ }
483
+ }
484
+
485
+ // Does this parse state already have the given set of actions, for some lookahead token?
486
+ static bool has_actions(const ParseState &state, const ParseTableEntry &entry) {
487
+ for (const auto &pair : state.terminal_entries)
488
+ if (pair.second.actions == entry.actions)
489
+ return true;
490
+ return false;
491
+ }
492
+
493
+ // Can we add the given entry into the given parse state without affecting
494
+ // the behavior of the parser for valid inputs?
495
+ bool can_add_entry_to_state(const ParseState &state, Symbol new_token, const ParseTableEntry &entry) {
496
+ // Only merge parse states by allowing existing reductions to happen
497
+ // with additional lookahead tokens. Do not alter parse states in ways
498
+ // that allow entirely new types of actions to happen.
499
+ if (entry.actions.back().type != ParseActionTypeReduce) return false;
500
+ if (!has_actions(state, entry)) return false;
501
+
502
+ // Do not add external tokens; they could conflict lexically with any of the state's
503
+ // existing lookahead tokens.
504
+ if (new_token.is_external()) return false;
505
+
506
+ // Do not add tokens which are both internal and external. Their validity could
507
+ // influence the behavior of the external scanner.
508
+ for (const ExternalToken &external_token : grammar.external_tokens) {
509
+ if (external_token.corresponding_internal_token == new_token) return false;
510
+ }
511
+
512
+ // Do not add a token if it conflicts with an existing token.
513
+ if (!new_token.is_built_in()) {
514
+ for (const auto &entry : state.terminal_entries) {
515
+ if (lex_table_builder->get_conflict_status(entry.first, new_token) & CannotDistinguish) {
516
+ return false;
517
+ }
518
+ }
519
+ }
520
+
521
+ return true;
522
+ }
523
+
524
+ // If the parse states at the given indices are mergeable, merge the second one
525
+ // into the first one.
526
+ bool merge_parse_state(size_t left_index, size_t right_index) {
527
+ ParseState &left_state = parse_table.states[left_index];
528
+ ParseState &right_state = parse_table.states[right_index];
529
+ if (left_state.nonterminal_entries != right_state.nonterminal_entries) return false;
530
+
531
+ for (auto &left_entry : left_state.terminal_entries) {
532
+ Symbol lookahead = left_entry.first;
533
+ const auto &right_entry = right_state.terminal_entries.find(lookahead);
534
+ if (right_entry == right_state.terminal_entries.end()) {
535
+ if (!can_add_entry_to_state(right_state, lookahead, left_entry.second)) return false;
536
+ } else {
537
+ if (right_entry->second.actions != left_entry.second.actions) return false;
538
+ }
539
+ }
540
+
541
+ set<Symbol> symbols_to_merge;
542
+ for (auto &right_entry : right_state.terminal_entries) {
543
+ Symbol lookahead = right_entry.first;
544
+ const auto &left_entry = left_state.terminal_entries.find(lookahead);
545
+ if (left_entry == left_state.terminal_entries.end()) {
546
+ if (!can_add_entry_to_state(left_state, lookahead, right_entry.second)) return false;
547
+ symbols_to_merge.insert(lookahead);
548
+ }
549
+ }
550
+
551
+ for (const Symbol &lookahead : symbols_to_merge) {
552
+ left_state.terminal_entries[lookahead] = right_state.terminal_entries[lookahead];
553
+ }
554
+
555
+ return true;
556
+ }
557
+
558
+ string handle_conflict(Symbol lookahead, const ParseItemSet &item_set,
559
+ const SymbolSequence &preceding_symbols, ParseStateId state_id) {
560
+ ParseTableEntry &entry = parse_table.states[state_id].terminal_entries[lookahead];
561
+ bool considered_associativity = false;
562
+ int reduction_precedence = entry.actions.front().precedence;
563
+
564
+ PrecedenceRange shift_precedence;
565
+ set<ParseItem> conflicting_items;
566
+ for (auto &pair : item_set.entries) {
567
+ const ParseItem &item = pair.first;
568
+ if (item.is_done()) {
569
+ if (pair.second.contains(lookahead)) {
570
+ conflicting_items.insert(item);
571
+ }
572
+ } else if (item.step_index > 0) {
573
+ LookaheadSet first_set = item_set_builder.get_first_set(item.next_symbol());
574
+ if (first_set.contains(lookahead)) {
575
+ shift_precedence.add(item.production->at(item.step_index - 1).precedence);
576
+ conflicting_items.insert(item);
577
+ }
578
+ }
579
+ }
580
+
581
+ if (entry.actions.back().type == ParseActionTypeShift) {
582
+ Symbol symbol = conflicting_items.begin()->lhs();
583
+ if (symbol.is_non_terminal() && grammar.variables[symbol.index].type == VariableTypeAuxiliary) {
584
+ bool all_symbols_match = true;
585
+ for (const ParseItem &conflicting_item : conflicting_items) {
586
+ if (conflicting_item.lhs() != symbol) {
587
+ all_symbols_match = false;
588
+ break;
589
+ }
590
+ }
591
+ if (all_symbols_match) {
592
+ entry.actions.back().repetition = true;
593
+ return "";
594
+ }
595
+ }
596
+
597
+ // If the shift action has higher precedence, prefer it over any of the
598
+ // reduce actions.
599
+ if (shift_precedence.min > reduction_precedence ||
600
+ (shift_precedence.min == reduction_precedence &&
601
+ shift_precedence.max > reduction_precedence)) {
602
+ entry.actions.assign({entry.actions.back()});
603
+ }
604
+
605
+ // If the shift action has lower precedence, prefer the reduce actions.
606
+ else if (shift_precedence.max < reduction_precedence ||
607
+ (shift_precedence.max == reduction_precedence &&
608
+ shift_precedence.min < reduction_precedence)) {
609
+ entry.actions.pop_back();
610
+ for (auto item_iter = conflicting_items.begin(); item_iter != conflicting_items.end();) {
611
+ if (item_iter->is_done()) {
612
+ ++item_iter;
613
+ } else {
614
+ item_iter = conflicting_items.erase(item_iter);
615
+ }
616
+ }
617
+ }
618
+
619
+ // If the shift action has the same precedence as the reduce actions,
620
+ // consider the reduce actions' associativity. If they are all left
621
+ // associative, prefer the reduce actions. If they are all right
622
+ // associative, prefer the shift.
623
+ else if (shift_precedence.min == reduction_precedence &&
624
+ shift_precedence.max == reduction_precedence) {
625
+ considered_associativity = true;
626
+ bool has_non_associative_reductions = false;
627
+ bool has_left_associative_reductions = false;
628
+ bool has_right_associative_reductions = false;
629
+ for (const ParseAction &action : entry.actions) {
630
+ if (action.type != ParseActionTypeReduce) break;
631
+ switch (action.associativity) {
632
+ case rules::AssociativityLeft:
633
+ has_left_associative_reductions = true;
634
+ break;
635
+ case rules::AssociativityRight:
636
+ has_right_associative_reductions = true;
637
+ break;
638
+ default:
639
+ has_non_associative_reductions = true;
640
+ break;
641
+ }
642
+ }
643
+
644
+ if (!has_non_associative_reductions) {
645
+ if (has_right_associative_reductions && !has_left_associative_reductions) {
646
+ entry.actions.assign({entry.actions.back()});
647
+ } else if (has_left_associative_reductions && !has_right_associative_reductions) {
648
+ entry.actions.pop_back();
649
+ }
650
+ }
651
+ }
652
+ }
653
+
654
+ if (entry.actions.size() == 1) return "";
655
+
656
+ set<Symbol> actual_conflict;
657
+ for (const ParseItem &item : conflicting_items) {
658
+ Symbol symbol = item.lhs();
659
+ if (grammar.variables[symbol.index].type == VariableTypeAuxiliary) {
660
+ ParseStateId preceding_state_id = 1;
661
+ for (auto &preceding_symbol : preceding_symbols) {
662
+ ParseState &preceding_state = parse_table.states[preceding_state_id];
663
+ if (preceding_state.nonterminal_entries.count(symbol.index)) break;
664
+ preceding_state_id = preceding_symbol.is_non_terminal() ?
665
+ preceding_state.nonterminal_entries[preceding_symbol.index] :
666
+ preceding_state.terminal_entries[preceding_symbol].actions.back().state_index;
667
+ }
668
+ const ParseItemSet &preceding_item_set = *item_sets_by_state_id[preceding_state_id];
669
+ for (auto &preceding_entry : preceding_item_set.entries) {
670
+ if (preceding_entry.first.next_symbol() == symbol) {
671
+ actual_conflict.insert(preceding_entry.first.lhs());
672
+ }
673
+ }
674
+ } else {
675
+ actual_conflict.insert(symbol);
676
+ }
677
+ }
678
+
679
+ for (const auto &expected_conflict : grammar.expected_conflicts) {
680
+ if (expected_conflict == actual_conflict) return "";
681
+ }
682
+
683
+ string description = "Unresolved conflict for symbol sequence:\n\n";
684
+ for (auto &symbol : preceding_symbols) {
685
+ description += " " + symbol_name(symbol);
686
+ }
687
+
688
+ const string dot = "\xE2\x80\xA2";
689
+ const string ellipsis = "\xE2\x80\xA6";
690
+
691
+ description += " " + dot + " " + symbol_name(lookahead) + " " + ellipsis;
692
+ description += "\n\n";
693
+ description += "Possible interpretations:\n\n";
694
+
695
+ size_t interpretation_count = 1;
696
+ for (const ParseItem &item : conflicting_items) {
697
+ description += " " + to_string(interpretation_count++) + ":";
698
+
699
+ for (size_t i = 0; i < preceding_symbols.size() - item.step_index; i++) {
700
+ description += " " + symbol_name(preceding_symbols[i]);
701
+ }
702
+
703
+ description += " (" + symbol_name(item.lhs());
704
+ for (size_t i = 0; i < item.production->size(); i++) {
705
+ if (i == item.step_index) {
706
+ description += " " + dot;
707
+ }
708
+ description += " " + symbol_name(item.production->at(i).symbol);
709
+ }
710
+ description += ")";
711
+
712
+ if (item.is_done()) {
713
+ description += " " + dot + " " + symbol_name(lookahead) + " " + ellipsis;
714
+ }
715
+
716
+ description += "\n";
717
+ }
718
+
719
+ description += "\nPossible resolutions:\n\n";
720
+
721
+ size_t resolution_count = 1;
722
+ if (actual_conflict.size() > 1) {
723
+ if (entry.actions.back().type == ParseActionTypeShift) {
724
+ description += " " + to_string(resolution_count++) + ": ";
725
+ description += "Specify a higher precedence in";
726
+ bool is_first = true;
727
+ for (Symbol conflict_symbol : actual_conflict) {
728
+ for (const ParseItem &parse_item : conflicting_items) {
729
+ if (parse_item.lhs() == conflict_symbol && !parse_item.is_done()) {
730
+ if (!is_first) description += " and";
731
+ description += " `" + symbol_name(conflict_symbol) + "`";
732
+ is_first = false;
733
+ break;
734
+ }
735
+ }
736
+ }
737
+ description += " than in the other rules.\n";
738
+ }
739
+
740
+ for (const ParseAction &action : entry.actions) {
741
+ if (action.type == ParseActionTypeReduce) {
742
+ description += " " + to_string(resolution_count++) + ": ";
743
+ description += "Specify a higher precedence in `";
744
+ description += symbol_name(action.symbol);
745
+ description += "` than in the other rules.\n";
746
+ }
747
+ }
748
+ }
749
+
750
+ if (considered_associativity) {
751
+ description += " " + to_string(resolution_count++) + ": ";
752
+ description += "Specify a left or right associativity in";
753
+ bool is_first = true;
754
+ for (const ParseAction &action : entry.actions) {
755
+ if (action.type == ParseActionTypeReduce) {
756
+ if (!is_first) description += " and";
757
+ description += " `" + symbol_name(action.symbol) + "`";
758
+ is_first = false;
759
+ }
760
+ }
761
+ description += "\n";
762
+ }
763
+
764
+ description += " " + to_string(resolution_count++) + ": ";
765
+ description += "Add a conflict for these rules:";
766
+ for (Symbol conflict_symbol : actual_conflict) {
767
+ description += " `" + symbol_name(conflict_symbol) + "`";
768
+ }
769
+ description += "\n";
770
+ return description;
771
+ }
772
+
773
+ void delete_parse_states(const set<ParseStateId> deleted_states) {
774
+ vector<ParseStateId> new_state_ids(parse_table.states.size());
775
+ size_t deleted_state_count = 0;
776
+ auto deleted_state_iter = deleted_states.begin();
777
+ for (ParseStateId i = 0; i < new_state_ids.size(); i++) {
778
+ while (deleted_state_iter != deleted_states.end() && *deleted_state_iter < i) {
779
+ deleted_state_count++;
780
+ deleted_state_iter++;
781
+ }
782
+ new_state_ids[i] = i - deleted_state_count;
783
+ }
784
+
785
+ ParseStateId original_state_index = 0;
786
+ auto iter = parse_table.states.begin();
787
+ while (iter != parse_table.states.end()) {
788
+ if (deleted_states.count(original_state_index)) {
789
+ iter = parse_table.states.erase(iter);
790
+ } else {
791
+ ParseState &state = *iter;
792
+ state.each_referenced_state([&new_state_ids](ParseStateId *state_index) {
793
+ *state_index = new_state_ids[*state_index];
794
+ });
795
+ ++iter;
796
+ }
797
+ original_state_index++;
798
+ }
799
+ }
800
+
801
+ string symbol_name(const rules::Symbol &symbol) const {
802
+ if (symbol.is_built_in()) {
803
+ if (symbol == END_OF_INPUT())
804
+ return "END_OF_INPUT";
805
+ else
806
+ return "";
807
+ }
808
+
809
+ switch (symbol.type) {
810
+ case Symbol::Terminal: {
811
+ const LexicalVariable &variable = lexical_grammar.variables[symbol.index];
812
+ if (variable.type == VariableTypeNamed)
813
+ return variable.name;
814
+ else
815
+ return "'" + variable.name + "'";
816
+ }
817
+ case Symbol::NonTerminal: {
818
+ return grammar.variables[symbol.index].name;
819
+ }
820
+ case Symbol::External:
821
+ default: {
822
+ return grammar.external_tokens[symbol.index].name;
823
+ }
824
+ }
825
+ }
826
+
827
+ unsigned get_alias_sequence_id(const Production &production) {
828
+ bool has_alias = false;
829
+ AliasSequence alias_sequence;
830
+ for (unsigned i = 0, n = production.size(); i < n; i++) {
831
+ auto &step = production.at(i);
832
+ if (!step.alias.value.empty()) {
833
+ has_alias = true;
834
+ alias_sequence.resize(i + 1);
835
+ alias_sequence[i] = step.alias;
836
+ }
837
+ }
838
+
839
+ if (has_alias && production.size() > parse_table.max_alias_sequence_length) {
840
+ parse_table.max_alias_sequence_length = production.size();
841
+ }
842
+
843
+ auto begin = parse_table.alias_sequences.begin();
844
+ auto end = parse_table.alias_sequences.end();
845
+ auto iter = find(begin, end, alias_sequence);
846
+ if (iter != end) {
847
+ return iter - begin;
848
+ } else {
849
+ parse_table.alias_sequences.push_back(move(alias_sequence));
850
+ return parse_table.alias_sequences.size() - 1;
851
+ }
852
+ }
853
+
854
+ SymbolSequence append_symbol(const SymbolSequence &sequence, const Symbol &symbol) {
855
+ if (!sequence.empty()) {
856
+ const LookaheadSet &left_tokens = item_set_builder.get_last_set(sequence.back());
857
+ const LookaheadSet &right_tokens = item_set_builder.get_first_set(symbol);
858
+
859
+ if (!left_tokens.empty() && !right_tokens.empty()) {
860
+ left_tokens.for_each([&](Symbol left_symbol) {
861
+ if (left_symbol.is_terminal() && !left_symbol.is_built_in()) {
862
+ right_tokens.for_each([&](Symbol right_symbol) {
863
+ if (right_symbol.is_terminal() && !right_symbol.is_built_in()) {
864
+ following_tokens_by_token[left_symbol].insert(right_symbol);
865
+ }
866
+ return true;
867
+ });
868
+ }
869
+ return true;
870
+ });
871
+ }
872
+ }
873
+
874
+ SymbolSequence result(sequence.size() + 1);
875
+ result.assign(sequence.begin(), sequence.end());
876
+ result.push_back(symbol);
877
+ return result;
878
+ }
879
+ };
880
+
881
+ unique_ptr<ParseTableBuilder> ParseTableBuilder::create(
882
+ const SyntaxGrammar &syntax_grammar,
883
+ const LexicalGrammar &lexical_grammar
884
+ ) {
885
+ return unique_ptr<ParseTableBuilder>(new ParseTableBuilderImpl(syntax_grammar, lexical_grammar));
886
+ }
887
+
888
+ ParseTableBuilder::BuildResult ParseTableBuilder::build() {
889
+ return static_cast<ParseTableBuilderImpl *>(this)->build();
890
+ }
891
+
892
+ } // namespace build_tables
893
+ } // namespace tree_sitter