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.
- checksums.yaml +4 -4
- data/README.md +29 -8
- data/Rakefile +19 -4
- data/ext/tree-sitter/Makefile +24 -0
- data/ext/tree-sitter/document.c +149 -0
- data/ext/tree-sitter/document.h +17 -0
- data/ext/tree-sitter/extconf.rb +55 -15
- data/ext/tree-sitter/node.c +300 -0
- data/ext/tree-sitter/node.h +34 -0
- data/ext/tree-sitter/out/document.o +0 -0
- data/ext/tree-sitter/out/get_changed_ranges.o +0 -0
- data/ext/tree-sitter/out/language.o +0 -0
- data/ext/tree-sitter/out/lexer.o +0 -0
- data/ext/tree-sitter/out/libruntime.a +0 -0
- data/ext/tree-sitter/out/node.o +0 -0
- data/ext/tree-sitter/out/parser.o +0 -0
- data/ext/tree-sitter/out/python/parser.c +65600 -0
- data/ext/tree-sitter/out/python/parser.o +0 -0
- data/ext/tree-sitter/out/python/scanner.cc +164 -0
- data/ext/tree-sitter/out/python/scanner.o +0 -0
- data/ext/tree-sitter/out/stack.o +0 -0
- data/ext/tree-sitter/out/string_input.o +0 -0
- data/ext/tree-sitter/out/tree.o +0 -0
- data/ext/tree-sitter/out/utf16.o +0 -0
- data/ext/tree-sitter/out/utf8proc.o +0 -0
- data/ext/tree-sitter/tree-sitter.c +4 -109
- data/ext/tree-sitter/tree-sitter.h +4 -0
- data/ext/tree-sitter/tree-sitter/LICENSE +7 -0
- data/ext/tree-sitter/tree-sitter/README.md +13 -13
- data/ext/tree-sitter/tree-sitter/appveyor.yml +24 -0
- data/ext/tree-sitter/tree-sitter/docs/Gemfile +2 -0
- data/ext/tree-sitter/tree-sitter/docs/Gemfile.lock +239 -0
- data/ext/tree-sitter/tree-sitter/docs/_config.yml +1 -0
- data/ext/tree-sitter/tree-sitter/docs/_layouts/table-of-contents.html +74 -0
- data/ext/tree-sitter/tree-sitter/docs/creating-parsers.md +360 -0
- data/ext/tree-sitter/tree-sitter/docs/css/style.css +13 -0
- data/ext/tree-sitter/tree-sitter/docs/index.md +10 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/PRESUBMIT.py +10 -2
- data/ext/tree-sitter/tree-sitter/externals/gyp/buildbot/aosp_manifest.xml +466 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/buildbot/buildbot_run.py +91 -30
- data/ext/tree-sitter/tree-sitter/externals/gyp/gyp +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/gyptest.py +3 -3
- data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/MSVSNew.py +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/MSVSSettings.py +11 -5
- data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/MSVSSettings_test.py +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/MSVSUtil.py +18 -15
- data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/MSVSVersion.py +53 -20
- data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/__init__.py +4 -6
- data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/__init__.pyc +0 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/common.py +69 -2
- data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/common.pyc +0 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/flock_tool.py +6 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/generator/__init__.pyc +0 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/generator/analyzer.py +569 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/generator/android.py +133 -111
- data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/generator/cmake.py +3 -3
- data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/generator/eclipse.py +112 -22
- data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/generator/gypd.py +3 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/generator/make.py +45 -14
- data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/generator/make.pyc +0 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/generator/msvs.py +170 -98
- data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/generator/ninja.py +300 -71
- data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/generator/ninja_test.py +12 -9
- data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/generator/xcode.py +46 -12
- data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/generator/xcode.pyc +0 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/input.py +379 -335
- data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/input.pyc +0 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/input_test.py +7 -7
- data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/mac_tool.py +94 -3
- data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/msvs_emulation.py +131 -40
- data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/simple_copy.py +46 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/win_tool.py +28 -5
- data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/xcode_emulation.py +185 -88
- data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/xcode_emulation.pyc +0 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/xcode_ninja.py +268 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/xcodeproj_file.py +53 -46
- data/ext/tree-sitter/tree-sitter/externals/gyp/pylib/gyp/xcodeproj_file.pyc +0 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/actions-bare/gyptest-bare.py +1 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/actions-depfile/depfile.gyp +25 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/actions-depfile/gyptest-all.py +20 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/actions-depfile/input.txt +1 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/actions-none/gyptest-none.py +1 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/actions/gyptest-all.py +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/actions/gyptest-default.py +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/actions/gyptest-generated-header.py +6 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/actions/src/subdir1/program.c +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/actions/src/subdir3/generate_main.py +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/additional-targets/gyptest-additional.py +8 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/analyzer/common.gypi +6 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/analyzer/gyptest-analyzer.py +356 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/analyzer/subdir/subdir.gyp +36 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/analyzer/subdir/subdir2/subdir2.gyp +15 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/analyzer/subdir2/subdir.gyp +18 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/analyzer/subdir2/subdir.includes.gypi +9 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/analyzer/test.gyp +113 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/analyzer/test2.gyp +25 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/analyzer/test2.includes.gypi +13 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/analyzer/test2.includes.includes.gypi +9 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/analyzer/test2.toplevel_includes.gypi +15 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/analyzer/test3.gyp +77 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/analyzer/test4.gyp +80 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/analyzer/test5.gyp +25 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/android/32or64.c +13 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/android/file.in +1 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/android/gyptest-host-multilib.py +32 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/android/gyptest-make-functions.py +24 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/android/gyptest-noalias.py +21 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/android/gyptest-settings-list.py +24 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/android/gyptest-settings.py +24 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/android/gyptest-space-filenames.py +19 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/android/hello.c +12 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/android/hello.gyp +15 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/android/host_32or64.gyp +38 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/android/make_functions.gyp +31 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/android/settings-list.gyp +18 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/android/settings.gyp +18 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/android/space_filenames.gyp +18 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/android/writefile.c +18 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/assembly/src/program.c +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/build-option/gyptest-build.py +11 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/build-option/hello.c +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/builddir/src/prog1.c +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/builddir/src/subdir2/prog2.c +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/builddir/src/subdir2/subdir3/prog3.c +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/builddir/src/subdir2/subdir3/subdir4/prog4.c +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/builddir/src/subdir2/subdir3/subdir4/subdir5/prog5.c +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/cflags/cflags.c +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/cflags/gyptest-cflags.py +15 -55
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/compilable/src/program.cpp +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/compiler-override/{compiler.gyp → compiler-exe.gyp} +0 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/compiler-override/compiler-shared-lib.gyp +16 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/compiler-override/gyptest-compiler-env-toolchain.py +78 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/compiler-override/gyptest-compiler-env.py +9 -11
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/compiler-override/gyptest-compiler-global-settings.py +5 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/compiler-override/my_nm.py +8 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/compiler-override/my_readelf.py +8 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/conditions/elseif/elseif.gyp +43 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/conditions/elseif/elseif_bad1.gyp +20 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/conditions/elseif/elseif_bad2.gyp +22 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/conditions/elseif/elseif_bad3.gyp +23 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/conditions/elseif/elseif_conditions.gypi +15 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/conditions/elseif/gyptest_elseif.py +33 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/conditions/elseif/program.cc +10 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/configurations/basics/configurations.c +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/configurations/basics/gyptest-configurations.py +6 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/configurations/inheritance/configurations.c +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/configurations/inheritance/duplicates.gyp +27 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/configurations/inheritance/duplicates.gypd.golden +12 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/configurations/inheritance/gyptest-duplicates.py +34 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/configurations/inheritance/gyptest-inheritance.py +6 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/configurations/target_platform/front.c +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/configurations/x64/configurations.c +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/copies/gyptest-all.py +3 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/copies/gyptest-default.py +3 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/copies/gyptest-samedir.py +1 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/copies/gyptest-slash.py +1 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/copies/gyptest-updir.py +1 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/cxxflags/cxxflags.cc +4 -4
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/cxxflags/cxxflags.gyp +0 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/cxxflags/gyptest-cxxflags.py +13 -33
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/defines-escaping/defines-escaping.c +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/defines/defines.c +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/dependencies/gyptest-extra-targets.py +2 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/dependencies/gyptest-lib-only.py +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/dependency-copy/src/file1.c +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/dependency-copy/src/file2.c +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/empty-target/empty-target.gyp +12 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/empty-target/gyptest-empty-target.py +18 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/errors/dependency_cycle.gyp +23 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/errors/file_cycle0.gyp +17 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/errors/file_cycle1.gyp +13 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/errors/gyptest-errors.py +10 -2
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/exclusion/hello.c +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/external-cross-compile/src/program.cc +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/generator-output/actions/subdir1/program.c +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/generator-output/gyptest-copies.py +3 -2
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/generator-output/rules/subdir1/program.c +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/generator-output/src/prog1.c +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/generator-output/src/subdir2/deeper/deeper.c +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/generator-output/src/subdir2/prog2.c +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/generator-output/src/subdir3/prog3.c +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/gyp-defines/gyptest-multiple-values.py +2 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/hello/hello.c +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/hello/hello2.c +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/home_dot_gyp/src/printfoo.c +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/include_dirs/src/includes.c +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/include_dirs/src/subdir/subdir_includes.c +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/intermediate_dir/gyptest-intermediate-dir.py +2 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/app-bundle/TestApp/Images.xcassets/AppIcon.appiconset/Contents.json +58 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/app-bundle/TestApp/Images.xcassets/image.imageset/Contents.json +23 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/app-bundle/TestApp/Images.xcassets/image.imageset/super_sylvain.png +0 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/app-bundle/TestApp/Images.xcassets/image.imageset/super_sylvain@2x.png +0 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/app-bundle/TestApp/Images.xcassets/image.imageset/super_sylvain@3x.png +0 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/app-bundle/test-assets-catalog.gyp +45 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/app-bundle/test-crosscompile.gyp +47 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/app-bundle/test.gyp +0 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/app-bundle/tool_main.cc +7 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/extension/ActionExtension/ActionViewController.h +9 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/extension/ActionExtension/ActionViewController.m +31 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/extension/ActionExtension/Info.plist +42 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/extension/ActionExtension/MainInterface.storyboard +63 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/extension/ExtensionContainer/AppDelegate.h +12 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/extension/ExtensionContainer/AppDelegate.m +19 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/extension/ExtensionContainer/Base.lproj/Main.storyboard +25 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/extension/ExtensionContainer/Images.xcassets/AppIcon.appiconset/Contents.json +53 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/extension/ExtensionContainer/Images.xcassets/LaunchImage.launchimage/Contents.json +51 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/extension/ExtensionContainer/Info.plist +32 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/extension/ExtensionContainer/ViewController.h +11 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/extension/ExtensionContainer/ViewController.m +24 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/extension/ExtensionContainer/main.m +13 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/extension/extension.gyp +85 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/gyptest-app-ios-assets-catalog.py +57 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/gyptest-app-ios.py +7 -7
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/gyptest-archs.py +22 -70
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/gyptest-crosscompile.py +34 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/gyptest-extension.py +28 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/gyptest-watch.py +36 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/gyptest-xcode-ninja.py +25 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/watch/WatchApp/Images.xcassets/AppIcon.appiconset/Contents.json +62 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/watch/WatchApp/Images.xcassets/LaunchImage.launchimage/Contents.json +24 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/watch/WatchApp/Info.plist +35 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/watch/WatchApp/Interface.storyboard +15 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/watch/WatchContainer/AppDelegate.h +12 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/watch/WatchContainer/AppDelegate.m +19 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/watch/WatchContainer/Base.lproj/Main.storyboard +25 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/watch/WatchContainer/Images.xcassets/AppIcon.appiconset/Contents.json +53 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/watch/WatchContainer/Images.xcassets/LaunchImage.launchimage/Contents.json +51 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/watch/WatchContainer/Info.plist +32 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/watch/WatchContainer/ViewController.h +11 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/watch/WatchContainer/ViewController.m +24 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/watch/WatchContainer/main.m +13 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/watch/WatchKitExtension/Images.xcassets/MyImage.imageset/Contents.json +20 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/watch/WatchKitExtension/Info.plist +38 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/watch/WatchKitExtension/InterfaceController.h +10 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/watch/WatchKitExtension/InterfaceController.m +25 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/watch/WatchKitExtension/MainInterface.storyboard +63 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/ios/watch/watch.gyp +105 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/lib/TestGyp.py +349 -46
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/lib/TestMac.py +73 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/lib/TestWin.py +101 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/library/gyptest-shared.py +6 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/library/gyptest-static.py +6 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/library/src/program.c +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/link-dependency/gyptest-link-dependency.py +23 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/link-dependency/main.c +7 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/link-dependency/mymalloc.c +12 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/link-dependency/test.gyp +37 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/link-objects/base.c +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/app-bundle/TestApp/Images.xcassets/AppIcon.appiconset/Contents.json +58 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/app-bundle/TestApp/Images.xcassets/image.imageset/Contents.json +23 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/app-bundle/TestApp/Images.xcassets/image.imageset/super_sylvain.png +0 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/app-bundle/TestApp/Images.xcassets/image.imageset/super_sylvain@2x.png +0 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/app-bundle/TestApp/Images.xcassets/image.imageset/super_sylvain@3x.png +0 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/app-bundle/test-assets-catalog.gyp +43 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/archs/file_a.cc +8 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/archs/file_a.h +10 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/archs/file_b.cc +8 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/archs/file_b.h +10 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/archs/file_c.cc +11 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/archs/file_d.cc +11 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/archs/test-archs-multiarch.gyp +20 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/archs/test-dependencies.gyp +92 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/archs/test-valid-archs.gyp +28 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/clang-cxx-library/libc++.cc +2 -2
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/clang-cxx-library/libstdc++.cc +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/gyptest-action-envvars.py +6 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/gyptest-app-assets-catalog.py +120 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/gyptest-app-error.py +2 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/gyptest-app.py +8 -20
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/gyptest-archs.py +39 -33
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/gyptest-cflags.py +1 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/gyptest-clang-cxx-library.py +3 -4
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/gyptest-global-settings.py +7 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/gyptest-installname.py +1 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/gyptest-ldflags-passed-to-libtool.py +1 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/gyptest-ldflags.py +6 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/gyptest-libraries.py +6 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/gyptest-libtool-zero.py +26 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/gyptest-loadable-module-bundle-product-extension.py +31 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/gyptest-loadable-module.py +1 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/gyptest-objc-gc.py +24 -18
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/gyptest-postbuild-copy-bundle.py +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/gyptest-postbuild-fail.py +1 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/gyptest-prefixheader.py +1 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/gyptest-rpath.py +5 -4
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/gyptest-strip.py +13 -5
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/gyptest-swift-library.py +62 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/gyptest-type-envvars.py +3 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/gyptest-xcode-env-order.py +2 -6
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/gyptest-xcode-support-actions.py +25 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/libtool-zero/mylib.c +7 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/{errors/duplicate_basenames.gyp → mac/libtool-zero/test.gyp} +6 -4
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/loadable-module-bundle-product-extension/src.cc +7 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/loadable-module-bundle-product-extension/test.gyp +24 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/swift-library/Info.plist +28 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/swift-library/file.swift +9 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/swift-library/test.gyp +21 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/type_envvars/test_bundle_executable.sh +1 -2
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/type_envvars/test_bundle_loadable_module.sh +1 -2
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/type_envvars/test_bundle_shared_library.sh +1 -2
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/type_envvars/test_check_sdkroot.sh +47 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/type_envvars/test_nonbundle_executable.sh +2 -2
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/type_envvars/test_nonbundle_loadable_module.sh +1 -2
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/type_envvars/test_nonbundle_none.sh +1 -2
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/type_envvars/test_nonbundle_shared_library.sh +1 -2
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/type_envvars/test_nonbundle_static_library.sh +1 -2
- data/ext/tree-sitter/tree-sitter/{out/Release/linker.lock → externals/gyp/test/mac/xcode-support-actions/source.c} +0 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/mac/xcode-support-actions/test.gyp +26 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/make/main.cc +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/make/noload/main.c +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/make_global_settings/ar/gyptest-make_global_settings_ar.py +123 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/make_global_settings/ar/make_global_settings_ar.gyp +29 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/make_global_settings/basics/gyptest-make_global_settings.py +2 -2
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/make_global_settings/full-toolchain/bar.cc +1 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/make_global_settings/full-toolchain/foo.c +1 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/make_global_settings/full-toolchain/gyptest-make_global_settings.py +48 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/make_global_settings/full-toolchain/make_global_settings.gyp +22 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/make_global_settings/full-toolchain/my_nm.py +8 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/make_global_settings/full-toolchain/my_readelf.py +8 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/make_global_settings/ld/gyptest-make_global_settings_ld.py +130 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/make_global_settings/ld/make_global_settings_ld.gyp +29 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/many-actions/gyptest-many-actions-unsorted.py +1 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/msvs/buildevents/gyptest-ninja-warnings.py +2 -2
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/msvs/config_attrs/hello.c +2 -2
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/msvs/external_builder/hello.cpp +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/msvs/filters/gyptest-filters-2010.py +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/msvs/list_excluded/hello.cpp +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/msvs/multiple_actions_error_handling/action_fail.py +7 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/msvs/multiple_actions_error_handling/action_succeed.py +7 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/msvs/multiple_actions_error_handling/actions.gyp +40 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/msvs/multiple_actions_error_handling/gyptest.py +26 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/msvs/props/hello.c +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/msvs/shared_output/hello.c +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/msvs/shared_output/there/there.c +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/msvs/uldi2010/hello.c +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/multiple-targets/gyptest-all.py +0 -3
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/multiple-targets/gyptest-default.py +0 -3
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/multiple-targets/src/prog1.c +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/multiple-targets/src/prog2.c +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/ninja/action-rule-hash/gyptest-action-rule-hash.py +32 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/ninja/action-rule-hash/subdir/action-rule-hash.gyp +29 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/ninja/action-rule-hash/subdir/emit.py +13 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/ninja/action_dependencies/gyptest-action-dependencies.py +3 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/ninja/chained-dependency/chained.c +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/ninja/chained-dependency/gyptest-chained-dependency.py +4 -0
- 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
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/ninja/empty-and-non-empty-duplicate-name/subdir/included.gyp +19 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/ninja/empty-and-non-empty-duplicate-name/test.gyp +19 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/ninja/normalize-paths-win/gyptest-normalize-paths.py +4 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/ninja/normalize-paths-win/normalize-paths.gyp +12 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/ninja/solibs_avoid_relinking/gyptest-solibs-avoid-relinking.py +5 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/ninja/use-console/foo.bar +5 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/ninja/use-console/gyptest-use-console.py +29 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/ninja/use-console/use-console.gyp +60 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/no-cpp/gyptest-no-cpp.py +1 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/product/hello.c +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/prune_targets/gyptest-prune-targets.py +3 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/rules-dirname/gyptest-dirname.py +17 -3
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/rules-dirname/src/subdir/a/b/c.gencc +2 -5
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/rules-dirname/src/subdir/foo/bar/baz.gencc +2 -5
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/rules-dirname/src/subdir/input-rule-dirname.gyp +62 -14
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/rules-dirname/src/subdir/main.cc +2 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/rules-dirname/src/subdir/nodir.gencc +8 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/rules-rebuild/src/main.c +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/rules-use-built-dependencies/gyptest-use-built-dependencies.py +1 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/rules/gyptest-all.py +7 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/rules/gyptest-default.py +7 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/rules/src/actions.gyp +1 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/rules/src/special-variables.gyp +0 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/rules/src/subdir1/program.c +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/rules/src/subdir2/both_rule_and_action_input.gyp +50 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/rules/src/subdir2/program.c +12 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/rules/src/subdir3/program.c +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/rules/src/subdir4/build-asm.gyp +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/rules/src/subdir4/program.c +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/same-source-file-name/gyptest-shared.py +27 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/same-source-file-name/gyptest-static.py +29 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/same-source-file-name/src/double-shared.gyp +6 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/same-source-file-name/src/double-static.gyp +1 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/same-source-file-name/src/prog1.c +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/same-source-file-name/src/prog2.c +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/same-source-file-name/src/prog3.c +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/same-target-name-different-directory/gyptest-all.py +5 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/sibling/gyptest-all.py +6 -3
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/sibling/gyptest-relocate.py +6 -3
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/sibling/src/prog1/prog1.c +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/sibling/src/prog2/prog2.c +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/standalone-static-library/prog.c +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/subdirectory/gyptest-SYMROOT-all.py +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/subdirectory/gyptest-SYMROOT-default.py +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/subdirectory/src/prog1.c +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/subdirectory/src/subdir/prog2.c +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/subdirectory/src/subdir/subdir2/prog3.c +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/toolsets/main.cc +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/toplevel-dir/gyptest-toplevel-dir.py +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/toplevel-dir/src/sub1/prog1.c +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/toplevel-dir/src/sub2/prog2.c +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/variables/commands/gyptest-commands-repeated-multidir.py +23 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/variables/commands/repeated_multidir/dir_1/test_1.gyp +13 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/variables/commands/repeated_multidir/dir_2/test_2.gyp +13 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/variables/commands/repeated_multidir/main.gyp +16 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/variables/commands/repeated_multidir/print_cwd_basename.py +10 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/variables/commands/repeated_multidir/repeated_command_common.gypi +25 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/variables/latelate/src/program.cc +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/command-quote/command-quote.gyp +0 -5
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/command-quote/subdir/and/another/in-subdir.gyp +0 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/compiler-flags/calling-convention-cdecl.def +6 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/compiler-flags/calling-convention-fastcall.def +6 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/compiler-flags/calling-convention-stdcall.def +6 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/compiler-flags/calling-convention-vectorcall.def +6 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/compiler-flags/calling-convention.cc +6 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/compiler-flags/calling-convention.gyp +66 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/compiler-flags/enable-enhanced-instruction-set.cc +28 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/compiler-flags/enable-enhanced-instruction-set.gyp +68 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/compiler-flags/floating-point-model-fast.cc +19 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/compiler-flags/floating-point-model-precise.cc +19 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/compiler-flags/floating-point-model-strict.cc +19 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/compiler-flags/floating-point-model.gyp +43 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/enable-winrt/dllmain.cc +30 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/enable-winrt/enable-winrt.gyp +39 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/generator-output-different-drive/prog.c +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/gyptest-cl-calling-convention.py +22 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/gyptest-cl-enable-enhanced-instruction-set.py +44 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/gyptest-cl-floating-point-model.py +22 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/gyptest-link-base-address.py +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/gyptest-link-enable-winrt.py +35 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/gyptest-link-pdb-no-output.py +25 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/gyptest-link-pdb-output.py +0 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/gyptest-link-profile.py +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/gyptest-link-restat-importlib.py +6 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/gyptest-link-safeseh.py +40 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/gyptest-link-shard.py +3 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/gyptest-macro-targetext.py +26 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/gyptest-macro-targetfilename.py +32 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/gyptest-macro-targetpath.py +30 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/gyptest-midl-excluded.py +22 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/gyptest-midl-includedirs.py +21 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/gyptest-midl-rules.py +4 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/gyptest-ml-safeseh.py +22 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/gyptest-system-include.py +21 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/idl-excluded/bad.idl +6 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/idl-excluded/copy-file.py +11 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/idl-excluded/idl-excluded.gyp +58 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/idl-excluded/program.cc +7 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/idl-includedirs/hello.cc +7 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/idl-includedirs/idl-includedirs.gyp +26 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/idl-includedirs/subdir/bar.idl +13 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/idl-includedirs/subdir/foo.idl +14 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/idl-rules/Window.idl +9 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/idl-rules/basic-idl.gyp +67 -42
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/idl-rules/idl_compiler.py +17 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/large-pdb/main.cc +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/linker-flags/pdb-output.gyp +13 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/linker-flags/safeseh.gyp +47 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/linker-flags/safeseh_hello.cc +11 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/linker-flags/safeseh_zero.asm +10 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/linker-flags/update_pgd.py +3 -3
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/ml-safeseh/a.asm +10 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/ml-safeseh/hello.cc +11 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/ml-safeseh/ml-safeseh.gyp +24 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/precompiled/hello.c +1 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/shard/hello.cc +7 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/shard/shard.gyp +11 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/shard/shard_ref.gyp +41 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/system-include/bar/header.h +0 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/system-include/common/commonheader.h +0 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/system-include/foo/header.h +0 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/system-include/main.cc +4 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/system-include/test.gyp +26 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/vs-macros/containing-gyp.gyp +0 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/vs-macros/input-output-macros.gyp +0 -1
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/vs-macros/targetext.gyp +59 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/vs-macros/targetfilename.gyp +59 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/vs-macros/targetpath.gyp +59 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/win-tool/copies_readonly_files.gyp +29 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/win/win-tool/gyptest-win-tool-handles-readonly-files.py +55 -0
- data/ext/tree-sitter/tree-sitter/externals/gyp/tools/emacs/gyp.el +36 -13
- data/ext/tree-sitter/tree-sitter/externals/gyp/tools/pretty_sln.py +4 -3
- data/ext/tree-sitter/tree-sitter/externals/utf8proc/CMakeLists.txt +4 -2
- data/ext/tree-sitter/tree-sitter/externals/utf8proc/MANIFEST +3 -3
- data/ext/tree-sitter/tree-sitter/externals/utf8proc/Makefile +11 -6
- data/ext/tree-sitter/tree-sitter/externals/utf8proc/NEWS.md +69 -0
- data/ext/tree-sitter/tree-sitter/externals/utf8proc/README.md +4 -2
- data/ext/tree-sitter/tree-sitter/externals/utf8proc/bench/bench.c +2 -2
- data/ext/tree-sitter/tree-sitter/externals/utf8proc/data/Makefile +12 -9
- data/ext/tree-sitter/tree-sitter/externals/utf8proc/data/data_generator.rb +125 -42
- data/ext/tree-sitter/tree-sitter/externals/utf8proc/test/custom.c +27 -0
- data/ext/tree-sitter/tree-sitter/externals/utf8proc/test/iterate.c +8 -2
- data/ext/tree-sitter/tree-sitter/externals/utf8proc/test/printproperty.c +5 -7
- data/ext/tree-sitter/tree-sitter/externals/utf8proc/utf8proc.c +209 -98
- data/ext/tree-sitter/tree-sitter/externals/utf8proc/utf8proc.h +126 -28
- data/ext/tree-sitter/tree-sitter/externals/utf8proc/utf8proc_data.c +12976 -15342
- data/ext/tree-sitter/tree-sitter/include/tree_sitter/compiler.h +2 -0
- data/ext/tree-sitter/tree-sitter/include/tree_sitter/parser.h +73 -74
- data/ext/tree-sitter/tree-sitter/include/tree_sitter/runtime.h +29 -20
- data/ext/tree-sitter/tree-sitter/project.gyp +13 -24
- data/ext/tree-sitter/tree-sitter/script/benchmark +76 -0
- data/ext/tree-sitter/tree-sitter/script/build-fuzzers +66 -0
- data/ext/tree-sitter/tree-sitter/script/ci +2 -1
- data/ext/tree-sitter/tree-sitter/script/configure.cmd +3 -0
- data/ext/tree-sitter/tree-sitter/script/fetch-fixtures +13 -9
- data/ext/tree-sitter/tree-sitter/script/fetch-fixtures.cmd +26 -0
- data/ext/tree-sitter/tree-sitter/script/reproduce +1 -0
- data/ext/tree-sitter/tree-sitter/script/run-fuzzer +57 -0
- data/ext/tree-sitter/tree-sitter/script/test +47 -8
- data/ext/tree-sitter/tree-sitter/script/test.cmd +2 -0
- data/ext/tree-sitter/tree-sitter/script/trim-whitespace +1 -1
- data/ext/tree-sitter/tree-sitter/script/util/scan-build.sh +24 -0
- data/ext/tree-sitter/tree-sitter/src/compiler/build_tables/lex_item.cc +60 -41
- data/ext/tree-sitter/tree-sitter/src/compiler/build_tables/lex_item.h +6 -7
- data/ext/tree-sitter/tree-sitter/src/compiler/build_tables/lex_item_transitions.cc +108 -101
- data/ext/tree-sitter/tree-sitter/src/compiler/build_tables/lex_item_transitions.h +1 -4
- data/ext/tree-sitter/tree-sitter/src/compiler/build_tables/lex_table_builder.cc +537 -0
- data/ext/tree-sitter/tree-sitter/src/compiler/build_tables/lex_table_builder.h +57 -0
- data/ext/tree-sitter/tree-sitter/src/compiler/build_tables/lookahead_set.cc +93 -19
- data/ext/tree-sitter/tree-sitter/src/compiler/build_tables/lookahead_set.h +90 -5
- data/ext/tree-sitter/tree-sitter/src/compiler/build_tables/parse_item.cc +77 -29
- data/ext/tree-sitter/tree-sitter/src/compiler/build_tables/parse_item.h +4 -9
- data/ext/tree-sitter/tree-sitter/src/compiler/build_tables/parse_item_set_builder.cc +229 -94
- data/ext/tree-sitter/tree-sitter/src/compiler/build_tables/parse_item_set_builder.h +9 -3
- data/ext/tree-sitter/tree-sitter/src/compiler/build_tables/parse_table_builder.cc +893 -0
- data/ext/tree-sitter/tree-sitter/src/compiler/build_tables/parse_table_builder.h +38 -0
- data/ext/tree-sitter/tree-sitter/src/compiler/build_tables/rule_can_be_blank.cc +34 -35
- data/ext/tree-sitter/tree-sitter/src/compiler/build_tables/rule_can_be_blank.h +1 -1
- data/ext/tree-sitter/tree-sitter/src/compiler/compile.cc +23 -40
- data/ext/tree-sitter/tree-sitter/src/compiler/compile_error.h +6 -0
- data/ext/tree-sitter/tree-sitter/src/compiler/generate_code/c_code.cc +301 -124
- data/ext/tree-sitter/tree-sitter/src/compiler/generate_code/c_code.h +12 -4
- data/ext/tree-sitter/tree-sitter/{doc → src/compiler}/grammar-schema.json +34 -42
- data/ext/tree-sitter/tree-sitter/src/compiler/grammar.h +24 -5
- data/ext/tree-sitter/tree-sitter/src/compiler/lex_table.cc +2 -31
- data/ext/tree-sitter/tree-sitter/src/compiler/lex_table.h +6 -30
- data/ext/tree-sitter/tree-sitter/src/compiler/lexical_grammar.h +15 -3
- data/ext/tree-sitter/tree-sitter/src/compiler/parse_grammar.cc +143 -105
- data/ext/tree-sitter/tree-sitter/src/compiler/parse_grammar.h +2 -1
- data/ext/tree-sitter/tree-sitter/src/compiler/parse_table.cc +71 -174
- data/ext/tree-sitter/tree-sitter/src/compiler/parse_table.h +23 -41
- data/ext/tree-sitter/tree-sitter/src/compiler/prepare_grammar/expand_repeats.cc +67 -34
- data/ext/tree-sitter/tree-sitter/src/compiler/prepare_grammar/expand_repeats.h +0 -2
- data/ext/tree-sitter/tree-sitter/src/compiler/prepare_grammar/expand_tokens.cc +53 -61
- data/ext/tree-sitter/tree-sitter/src/compiler/prepare_grammar/expand_tokens.h +9 -3
- data/ext/tree-sitter/tree-sitter/src/compiler/prepare_grammar/extract_choices.cc +37 -43
- data/ext/tree-sitter/tree-sitter/src/compiler/prepare_grammar/extract_choices.h +1 -1
- data/ext/tree-sitter/tree-sitter/src/compiler/prepare_grammar/extract_tokens.cc +248 -125
- data/ext/tree-sitter/tree-sitter/src/compiler/prepare_grammar/extract_tokens.h +3 -2
- data/ext/tree-sitter/tree-sitter/src/compiler/prepare_grammar/flatten_grammar.cc +114 -70
- data/ext/tree-sitter/tree-sitter/src/compiler/prepare_grammar/flatten_grammar.h +2 -2
- data/ext/tree-sitter/tree-sitter/src/compiler/prepare_grammar/initial_syntax_grammar.h +4 -3
- data/ext/tree-sitter/tree-sitter/src/compiler/prepare_grammar/intern_symbols.cc +113 -50
- data/ext/tree-sitter/tree-sitter/src/compiler/prepare_grammar/intern_symbols.h +2 -2
- data/ext/tree-sitter/tree-sitter/src/compiler/prepare_grammar/interned_grammar.h +7 -6
- data/ext/tree-sitter/tree-sitter/src/compiler/prepare_grammar/normalize_rules.cc +5 -3
- data/ext/tree-sitter/tree-sitter/src/compiler/prepare_grammar/parse_regex.cc +95 -76
- data/ext/tree-sitter/tree-sitter/src/compiler/prepare_grammar/parse_regex.h +1 -1
- data/ext/tree-sitter/tree-sitter/src/compiler/prepare_grammar/prepare_grammar.cc +9 -7
- data/ext/tree-sitter/tree-sitter/src/compiler/prepare_grammar/prepare_grammar.h +2 -5
- data/ext/tree-sitter/tree-sitter/src/compiler/prepare_grammar/token_description.cc +59 -45
- data/ext/tree-sitter/tree-sitter/src/compiler/prepare_grammar/token_description.h +1 -1
- data/ext/tree-sitter/tree-sitter/src/compiler/rule.cc +284 -6
- data/ext/tree-sitter/tree-sitter/src/compiler/rule.h +124 -25
- data/ext/tree-sitter/tree-sitter/src/compiler/rules/blank.h +5 -14
- data/ext/tree-sitter/tree-sitter/src/compiler/rules/character_set.cc +35 -84
- data/ext/tree-sitter/tree-sitter/src/compiler/rules/character_set.h +19 -26
- data/ext/tree-sitter/tree-sitter/src/compiler/rules/choice.cc +3 -69
- data/ext/tree-sitter/tree-sitter/src/compiler/rules/choice.h +6 -13
- data/ext/tree-sitter/tree-sitter/src/compiler/rules/metadata.cc +128 -71
- data/ext/tree-sitter/tree-sitter/src/compiler/rules/metadata.h +48 -17
- data/ext/tree-sitter/tree-sitter/src/compiler/rules/named_symbol.h +6 -12
- data/ext/tree-sitter/tree-sitter/src/compiler/rules/pattern.h +6 -12
- data/ext/tree-sitter/tree-sitter/src/compiler/rules/repeat.cc +5 -34
- data/ext/tree-sitter/tree-sitter/src/compiler/rules/repeat.h +7 -13
- data/ext/tree-sitter/tree-sitter/src/compiler/rules/seq.cc +6 -47
- data/ext/tree-sitter/tree-sitter/src/compiler/rules/seq.h +8 -14
- data/ext/tree-sitter/tree-sitter/src/compiler/rules/string.h +6 -12
- data/ext/tree-sitter/tree-sitter/src/compiler/rules/symbol.h +53 -32
- data/ext/tree-sitter/tree-sitter/src/compiler/syntax_grammar.cc +24 -22
- data/ext/tree-sitter/tree-sitter/src/compiler/syntax_grammar.h +36 -21
- data/ext/tree-sitter/tree-sitter/src/compiler/util/make_visitor.h +31 -0
- data/ext/tree-sitter/tree-sitter/src/runtime/alloc.h +1 -1
- data/ext/tree-sitter/tree-sitter/src/runtime/array.h +25 -36
- data/ext/tree-sitter/tree-sitter/src/runtime/document.c +61 -34
- data/ext/tree-sitter/tree-sitter/src/runtime/document.h +3 -0
- data/ext/tree-sitter/tree-sitter/src/runtime/error_costs.h +5 -19
- data/ext/tree-sitter/tree-sitter/src/runtime/get_changed_ranges.c +355 -0
- data/ext/tree-sitter/tree-sitter/src/runtime/get_changed_ranges.h +20 -0
- data/ext/tree-sitter/tree-sitter/src/runtime/language.c +33 -31
- data/ext/tree-sitter/tree-sitter/src/runtime/language.h +27 -3
- data/ext/tree-sitter/tree-sitter/src/runtime/length.h +5 -21
- data/ext/tree-sitter/tree-sitter/src/runtime/lexer.c +61 -17
- data/ext/tree-sitter/tree-sitter/src/runtime/lexer.h +4 -5
- data/ext/tree-sitter/tree-sitter/src/runtime/node.c +93 -89
- data/ext/tree-sitter/tree-sitter/src/runtime/node.h +1 -1
- data/ext/tree-sitter/tree-sitter/src/runtime/parser.c +850 -743
- data/ext/tree-sitter/tree-sitter/src/runtime/parser.h +13 -8
- data/ext/tree-sitter/tree-sitter/src/runtime/point.h +9 -4
- data/ext/tree-sitter/tree-sitter/src/runtime/reduce_action.h +2 -0
- data/ext/tree-sitter/tree-sitter/src/runtime/reusable_node.h +14 -18
- data/ext/tree-sitter/tree-sitter/src/runtime/stack.c +424 -302
- data/ext/tree-sitter/tree-sitter/src/runtime/stack.h +75 -72
- data/ext/tree-sitter/tree-sitter/src/runtime/string_input.c +4 -10
- data/ext/tree-sitter/tree-sitter/src/runtime/tree.c +401 -252
- data/ext/tree-sitter/tree-sitter/src/runtime/tree.h +71 -57
- data/ext/tree-sitter/tree-sitter/src/runtime/utf16.c +5 -0
- data/ext/tree-sitter/tree-sitter/test/benchmarks.cc +122 -0
- data/ext/tree-sitter/tree-sitter/{spec/compiler/build_tables/lex_item_spec.cc → test/compiler/build_tables/lex_item_test.cc} +141 -143
- data/ext/tree-sitter/tree-sitter/test/compiler/build_tables/parse_item_set_builder_test.cc +134 -0
- 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
- data/ext/tree-sitter/tree-sitter/test/compiler/prepare_grammar/expand_repeats_test.cc +170 -0
- data/ext/tree-sitter/tree-sitter/test/compiler/prepare_grammar/expand_tokens_test.cc +89 -0
- data/ext/tree-sitter/tree-sitter/test/compiler/prepare_grammar/extract_choices_test.cc +77 -0
- data/ext/tree-sitter/tree-sitter/test/compiler/prepare_grammar/extract_tokens_test.cc +459 -0
- data/ext/tree-sitter/tree-sitter/test/compiler/prepare_grammar/flatten_grammar_test.cc +130 -0
- data/ext/tree-sitter/tree-sitter/test/compiler/prepare_grammar/intern_symbols_test.cc +101 -0
- data/ext/tree-sitter/tree-sitter/test/compiler/prepare_grammar/parse_regex_test.cc +334 -0
- data/ext/tree-sitter/tree-sitter/{spec/compiler/rules/character_set_spec.cc → test/compiler/rules/character_set_test.cc} +15 -27
- data/ext/tree-sitter/tree-sitter/test/compiler/rules/rule_test.cc +90 -0
- data/ext/tree-sitter/tree-sitter/{spec/compiler/util/string_helpers_spec.cc → test/compiler/util/string_helpers_test.cc} +1 -1
- data/ext/tree-sitter/tree-sitter/test/fixtures/error_corpus/c_errors.txt +166 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/error_corpus/javascript_errors.txt +179 -0
- data/ext/tree-sitter/tree-sitter/{spec → test}/fixtures/error_corpus/json_errors.txt +10 -7
- data/ext/tree-sitter/tree-sitter/{spec → test}/fixtures/error_corpus/python_errors.txt +0 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/aliased_inlined_rules/corpus.txt +13 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/aliased_inlined_rules/grammar.json +59 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/aliased_inlined_rules/readme.md +1 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/aliased_rules/corpus.txt +18 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/aliased_rules/grammar.json +71 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/aliased_unit_reductions/corpus.txt +12 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/aliased_unit_reductions/grammar.json +70 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/aliased_unit_reductions/readme.md +5 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/anonymous_tokens_with_escaped_chars/corpus.txt +32 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/anonymous_tokens_with_escaped_chars/grammar.json +14 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/anonymous_tokens_with_escaped_chars/readme.md +1 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/associativity_left/corpus.txt +8 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/associativity_left/grammar.json +31 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/associativity_missing/expected_error.txt +13 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/associativity_missing/grammar.json +27 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/associativity_right/corpus.txt +8 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/associativity_right/grammar.json +31 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/conflict_in_repeat_rule/expected_error.txt +14 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/conflict_in_repeat_rule/grammar.json +76 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/conflict_in_repeat_rule/readme.md +1 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/conflict_in_repeat_rule_after_external_token/expected_error.txt +14 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/conflict_in_repeat_rule_after_external_token/grammar.json +82 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/conflict_in_repeat_rule_after_external_token/readme.md +1 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/conflicting_precedence/expected_error.txt +15 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/conflicting_precedence/grammar.json +58 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/dynamic_precedence/corpus.txt +25 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/dynamic_precedence/grammar.json +73 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/dynamic_precedence/readme.md +1 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/epsilon_rules/expected_error.txt +4 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/epsilon_rules/grammar.json +15 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/external_and_internal_anonymous_tokens/corpus.txt +41 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/external_and_internal_anonymous_tokens/grammar.json +35 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/external_and_internal_anonymous_tokens/readme.md +1 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/external_and_internal_anonymous_tokens/scanner.c +36 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/external_and_internal_tokens/corpus.txt +41 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/external_and_internal_tokens/grammar.json +36 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/external_and_internal_tokens/readme.md +1 -0
- 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
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/external_extra_tokens/corpus.txt +10 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/external_extra_tokens/grammar.json +25 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/external_extra_tokens/scanner.c +49 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/external_tokens/corpus.txt +22 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/external_tokens/grammar.json +57 -0
- data/ext/tree-sitter/tree-sitter/{spec/fixtures/external_scanners/percent_strings.c → test/fixtures/test_grammars/external_tokens/scanner.c} +19 -17
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/inline_rules/corpus.txt +20 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/inline_rules/grammar.json +76 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/inlined_aliased_rules/corpus.txt +18 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/inlined_aliased_rules/grammar.json +75 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/inlined_aliased_rules/readme.md +1 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/inverted_external_token/corpus.txt +32 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/inverted_external_token/grammar.json +55 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/inverted_external_token/readme.md +1 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/inverted_external_token/scanner.c +48 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/invisible_start_rule/expected_error.txt +1 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/invisible_start_rule/grammar.json +23 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/lexical_conflicts_due_to_state_merging/corpus.txt +33 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/lexical_conflicts_due_to_state_merging/grammar.json +65 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/lexical_conflicts_due_to_state_merging/readme.md +20 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/nested_inlined_rules/corpus.txt +12 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/nested_inlined_rules/grammar.json +54 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/nested_inlined_rules/readme.md +1 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/partially_resolved_conflict/expected_error.txt +14 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/partially_resolved_conflict/grammar.json +58 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/partially_resolved_conflict/readme.txt +1 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/precedence_on_single_child_missing/expected_error.txt +15 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/precedence_on_single_child_missing/grammar.json +63 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/precedence_on_single_child_missing/readme.md +15 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/precedence_on_single_child_negative/corpus.txt +12 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/precedence_on_single_child_negative/grammar.json +63 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/precedence_on_single_child_negative/readme.md +1 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/precedence_on_single_child_positive/corpus.txt +13 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/precedence_on_single_child_positive/grammar.json +63 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/precedence_on_single_child_positive/readme.md +1 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/precedence_on_subsequence/corpus.txt +24 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/precedence_on_subsequence/grammar.json +135 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/readme.md +3 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/readme_grammar/corpus.txt +13 -0
- data/{test/tree-sitter/fixtures/arithmetic → ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/readme_grammar}/grammar.json +3 -3
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/start_rule_is_blank/corpus.txt +7 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/start_rule_is_blank/grammar.json +6 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/start_rule_is_token/corpus.txt +6 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/start_rule_is_token/grammar.json +6 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/unused_rules/corpus.txt +9 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/unused_rules/grammar.json +73 -0
- data/ext/tree-sitter/tree-sitter/test/fixtures/test_grammars/unused_rules/readme.md +1 -0
- data/ext/tree-sitter/tree-sitter/test/fuzz/README.md +43 -0
- data/ext/tree-sitter/tree-sitter/test/fuzz/fuzzer.cc +27 -0
- data/ext/tree-sitter/tree-sitter/test/fuzz/gen-dict.py +31 -0
- data/ext/tree-sitter/tree-sitter/{spec → test}/helpers/dedent.h +0 -0
- data/ext/tree-sitter/tree-sitter/{spec → test}/helpers/encoding_helpers.cc +9 -3
- data/ext/tree-sitter/tree-sitter/{spec → test}/helpers/encoding_helpers.h +0 -0
- data/ext/tree-sitter/tree-sitter/test/helpers/file_helpers.cc +100 -0
- data/ext/tree-sitter/tree-sitter/test/helpers/file_helpers.h +15 -0
- data/ext/tree-sitter/tree-sitter/test/helpers/load_language.cc +239 -0
- data/ext/tree-sitter/tree-sitter/test/helpers/load_language.h +14 -0
- data/ext/tree-sitter/tree-sitter/{spec → test}/helpers/point_helpers.cc +2 -5
- data/ext/tree-sitter/tree-sitter/{spec → test}/helpers/point_helpers.h +0 -0
- data/ext/tree-sitter/tree-sitter/test/helpers/random_helpers.cc +59 -0
- data/ext/tree-sitter/tree-sitter/test/helpers/random_helpers.h +14 -0
- data/ext/tree-sitter/tree-sitter/{spec → test}/helpers/read_test_entries.cc +38 -38
- data/ext/tree-sitter/tree-sitter/test/helpers/read_test_entries.h +22 -0
- data/ext/tree-sitter/tree-sitter/{spec → test}/helpers/record_alloc.cc +7 -13
- data/ext/tree-sitter/tree-sitter/{spec → test}/helpers/record_alloc.h +2 -2
- data/ext/tree-sitter/tree-sitter/{spec → test}/helpers/scope_sequence.cc +0 -0
- data/ext/tree-sitter/tree-sitter/{spec → test}/helpers/scope_sequence.h +0 -0
- data/ext/tree-sitter/tree-sitter/{spec → test}/helpers/spy_input.cc +39 -15
- data/ext/tree-sitter/tree-sitter/{spec → test}/helpers/spy_input.h +4 -4
- data/ext/tree-sitter/tree-sitter/{spec → test}/helpers/spy_logger.cc +0 -0
- data/ext/tree-sitter/tree-sitter/{spec → test}/helpers/spy_logger.h +0 -0
- data/ext/tree-sitter/tree-sitter/{spec → test}/helpers/stderr_logger.cc +0 -0
- data/ext/tree-sitter/tree-sitter/{spec → test}/helpers/stderr_logger.h +0 -0
- data/ext/tree-sitter/tree-sitter/test/helpers/stream_methods.cc +224 -0
- data/ext/tree-sitter/tree-sitter/{spec → test}/helpers/stream_methods.h +32 -15
- data/ext/tree-sitter/tree-sitter/test/helpers/tree_helpers.cc +99 -0
- data/ext/tree-sitter/tree-sitter/{spec → test}/helpers/tree_helpers.h +3 -1
- data/ext/tree-sitter/tree-sitter/test/integration/fuzzing-examples.cc +67 -0
- data/ext/tree-sitter/tree-sitter/test/integration/real_grammars.cc +142 -0
- data/ext/tree-sitter/tree-sitter/test/integration/test_grammars.cc +79 -0
- data/ext/tree-sitter/tree-sitter/{spec/runtime/document_spec.cc → test/runtime/document_test.cc} +150 -32
- data/ext/tree-sitter/tree-sitter/test/runtime/language_test.cc +55 -0
- data/ext/tree-sitter/tree-sitter/{spec/runtime/node_spec.cc → test/runtime/node_test.cc} +222 -127
- data/ext/tree-sitter/tree-sitter/{spec/runtime/parser_spec.cc → test/runtime/parser_test.cc} +126 -85
- data/ext/tree-sitter/tree-sitter/{spec/runtime/stack_spec.cc → test/runtime/stack_test.cc} +201 -164
- data/ext/tree-sitter/tree-sitter/test/runtime/tree_test.cc +475 -0
- data/ext/tree-sitter/tree-sitter/{spec/spec_helper.h → test/test_helper.h} +3 -3
- data/ext/tree-sitter/tree-sitter/{spec/specs.cc → test/tests.cc} +4 -3
- data/ext/tree-sitter/tree-sitter/tests.gyp +77 -23
- data/lib/tree-sitter.rb +4 -0
- data/lib/tree-sitter/node.rb +27 -0
- data/lib/tree-sitter/version.rb +3 -1
- data/test/test_helper.rb +4 -0
- data/test/tree-sitter/fixtures/parsers/python/parser.c +65600 -0
- data/test/tree-sitter/fixtures/parsers/python/scanner.cc +164 -0
- data/test/tree-sitter/test_basic.rb +2 -0
- data/test/tree-sitter/test_document.rb +101 -1
- data/test/tree-sitter/test_node.rb +73 -0
- data/tree-sitter.gemspec +4 -2
- metadata +445 -217
- data/ext/tree-sitter/tree-sitter/Makefile +0 -360
- data/ext/tree-sitter/tree-sitter/compiler.target.mk +0 -238
- data/ext/tree-sitter/tree-sitter/externals/gyp/pylintrc +0 -307
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/same-source-file-name/gyptest-fail-shared.py +0 -18
- data/ext/tree-sitter/tree-sitter/externals/gyp/test/same-source-file-name/gyptest-fail-static.py +0 -18
- data/ext/tree-sitter/tree-sitter/gyp-mac-tool +0 -511
- data/ext/tree-sitter/tree-sitter/out/Release/libcompiler.a +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/libruntime.a +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/externals/json-parser/json.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/externals/utf8proc/utf8proc.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/build_tables/build_lex_table.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/build_tables/build_parse_table.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/build_tables/build_tables.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/build_tables/lex_conflict_manager.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/build_tables/lex_item.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/build_tables/lex_item_transitions.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/build_tables/lookahead_set.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/build_tables/parse_item.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/build_tables/parse_item_set_builder.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/build_tables/recovery_tokens.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/build_tables/rule_can_be_blank.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/compile.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/generate_code/c_code.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/lex_table.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/parse_grammar.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/parse_table.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/precedence_range.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/prepare_grammar/expand_repeats.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/prepare_grammar/expand_tokens.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/prepare_grammar/extract_choices.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/prepare_grammar/extract_tokens.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/prepare_grammar/flatten_grammar.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/prepare_grammar/intern_symbols.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/prepare_grammar/is_token.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/prepare_grammar/normalize_rules.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/prepare_grammar/parse_regex.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/prepare_grammar/prepare_grammar.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/prepare_grammar/token_description.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/rule.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/rules/blank.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/rules/built_in_symbols.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/rules/character_range.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/rules/character_set.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/rules/choice.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/rules/metadata.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/rules/named_symbol.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/rules/pattern.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/rules/repeat.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/rules/rules.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/rules/seq.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/rules/string.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/rules/symbol.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/rules/visitor.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/syntax_grammar.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/util/string_helpers.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/compiler/src/compiler/variable.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/runtime/externals/utf8proc/utf8proc.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/runtime/src/runtime/document.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/runtime/src/runtime/error_costs.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/runtime/src/runtime/language.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/runtime/src/runtime/lexer.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/runtime/src/runtime/node.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/runtime/src/runtime/parser.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/runtime/src/runtime/stack.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/runtime/src/runtime/string_input.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/runtime/src/runtime/tree.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/runtime/src/runtime/utf16.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/compiler/build_tables/distinctive_tokens_spec.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/compiler/build_tables/lex_conflict_manager_spec.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/compiler/build_tables/lex_item_spec.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/compiler/build_tables/parse_item_set_builder_spec.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/compiler/build_tables/rule_can_be_blank_spec.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/compiler/prepare_grammar/expand_repeats_spec.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/compiler/prepare_grammar/expand_tokens_spec.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/compiler/prepare_grammar/extract_choices_spec.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/compiler/prepare_grammar/extract_tokens_spec.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/compiler/prepare_grammar/flatten_grammar_spec.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/compiler/prepare_grammar/intern_symbols_spec.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/compiler/prepare_grammar/parse_regex_spec.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/compiler/rules/character_set_spec.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/compiler/rules/choice_spec.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/compiler/rules/repeat_spec.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/compiler/util/string_helpers_spec.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/helpers/encoding_helpers.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/helpers/load_language.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/helpers/point_helpers.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/helpers/random_helpers.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/helpers/read_test_entries.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/helpers/record_alloc.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/helpers/rule_helpers.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/helpers/scope_sequence.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/helpers/spy_input.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/helpers/spy_logger.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/helpers/stderr_logger.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/helpers/stream_methods.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/helpers/tree_helpers.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/integration/compile_grammar_spec.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/integration/corpus_specs.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/runtime/document_spec.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/runtime/node_spec.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/runtime/parser_spec.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/runtime/stack_spec.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/runtime/tree_spec.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/obj.target/tests/spec/specs.o +0 -0
- data/ext/tree-sitter/tree-sitter/out/Release/tests +0 -0
- data/ext/tree-sitter/tree-sitter/project.Makefile +0 -6
- data/ext/tree-sitter/tree-sitter/runtime.target.mk +0 -174
- data/ext/tree-sitter/tree-sitter/spec/compiler/build_tables/distinctive_tokens_spec.cc +0 -34
- data/ext/tree-sitter/tree-sitter/spec/compiler/build_tables/lex_conflict_manager_spec.cc +0 -88
- data/ext/tree-sitter/tree-sitter/spec/compiler/build_tables/parse_item_set_builder_spec.cc +0 -133
- data/ext/tree-sitter/tree-sitter/spec/compiler/prepare_grammar/expand_repeats_spec.cc +0 -152
- data/ext/tree-sitter/tree-sitter/spec/compiler/prepare_grammar/expand_tokens_spec.cc +0 -109
- data/ext/tree-sitter/tree-sitter/spec/compiler/prepare_grammar/extract_choices_spec.cc +0 -106
- data/ext/tree-sitter/tree-sitter/spec/compiler/prepare_grammar/extract_tokens_spec.cc +0 -251
- data/ext/tree-sitter/tree-sitter/spec/compiler/prepare_grammar/flatten_grammar_spec.cc +0 -89
- data/ext/tree-sitter/tree-sitter/spec/compiler/prepare_grammar/intern_symbols_spec.cc +0 -89
- data/ext/tree-sitter/tree-sitter/spec/compiler/prepare_grammar/parse_regex_spec.cc +0 -245
- data/ext/tree-sitter/tree-sitter/spec/compiler/rules/choice_spec.cc +0 -53
- data/ext/tree-sitter/tree-sitter/spec/compiler/rules/repeat_spec.cc +0 -22
- data/ext/tree-sitter/tree-sitter/spec/fixtures/error_corpus/c_errors.txt +0 -130
- data/ext/tree-sitter/tree-sitter/spec/fixtures/error_corpus/javascript_errors.txt +0 -157
- data/ext/tree-sitter/tree-sitter/spec/fixtures/external_scanners/extra_external_tokens.c +0 -42
- data/ext/tree-sitter/tree-sitter/spec/helpers/equals_pointer.h +0 -37
- data/ext/tree-sitter/tree-sitter/spec/helpers/load_language.cc +0 -206
- data/ext/tree-sitter/tree-sitter/spec/helpers/load_language.h +0 -12
- data/ext/tree-sitter/tree-sitter/spec/helpers/random_helpers.cc +0 -35
- data/ext/tree-sitter/tree-sitter/spec/helpers/random_helpers.h +0 -8
- data/ext/tree-sitter/tree-sitter/spec/helpers/read_test_entries.h +0 -15
- data/ext/tree-sitter/tree-sitter/spec/helpers/rule_helpers.cc +0 -55
- data/ext/tree-sitter/tree-sitter/spec/helpers/rule_helpers.h +0 -21
- data/ext/tree-sitter/tree-sitter/spec/helpers/stream_methods.cc +0 -140
- data/ext/tree-sitter/tree-sitter/spec/helpers/tree_helpers.cc +0 -50
- data/ext/tree-sitter/tree-sitter/spec/integration/compile_grammar_spec.cc +0 -847
- data/ext/tree-sitter/tree-sitter/spec/integration/corpus_specs.cc +0 -185
- data/ext/tree-sitter/tree-sitter/spec/runtime/tree_spec.cc +0 -439
- data/ext/tree-sitter/tree-sitter/src/compiler/build_tables/build_lex_table.cc +0 -195
- data/ext/tree-sitter/tree-sitter/src/compiler/build_tables/build_lex_table.h +0 -18
- data/ext/tree-sitter/tree-sitter/src/compiler/build_tables/build_parse_table.cc +0 -604
- data/ext/tree-sitter/tree-sitter/src/compiler/build_tables/build_parse_table.h +0 -22
- data/ext/tree-sitter/tree-sitter/src/compiler/build_tables/build_tables.cc +0 -27
- data/ext/tree-sitter/tree-sitter/src/compiler/build_tables/build_tables.h +0 -24
- data/ext/tree-sitter/tree-sitter/src/compiler/build_tables/conflict_type.h +0 -16
- data/ext/tree-sitter/tree-sitter/src/compiler/build_tables/lex_conflict_manager.cc +0 -55
- data/ext/tree-sitter/tree-sitter/src/compiler/build_tables/lex_conflict_manager.h +0 -31
- data/ext/tree-sitter/tree-sitter/src/compiler/build_tables/recovery_tokens.cc +0 -89
- data/ext/tree-sitter/tree-sitter/src/compiler/build_tables/recovery_tokens.h +0 -19
- data/ext/tree-sitter/tree-sitter/src/compiler/build_tables/remove_duplicate_states.h +0 -65
- data/ext/tree-sitter/tree-sitter/src/compiler/compile.h +0 -16
- data/ext/tree-sitter/tree-sitter/src/compiler/prepare_grammar/is_token.cc +0 -30
- data/ext/tree-sitter/tree-sitter/src/compiler/prepare_grammar/is_token.h +0 -14
- data/ext/tree-sitter/tree-sitter/src/compiler/rules.h +0 -28
- data/ext/tree-sitter/tree-sitter/src/compiler/rules/blank.cc +0 -36
- data/ext/tree-sitter/tree-sitter/src/compiler/rules/built_in_symbols.cc +0 -19
- data/ext/tree-sitter/tree-sitter/src/compiler/rules/built_in_symbols.h +0 -16
- data/ext/tree-sitter/tree-sitter/src/compiler/rules/character_range.cc +0 -36
- data/ext/tree-sitter/tree-sitter/src/compiler/rules/character_range.h +0 -25
- data/ext/tree-sitter/tree-sitter/src/compiler/rules/named_symbol.cc +0 -35
- data/ext/tree-sitter/tree-sitter/src/compiler/rules/pattern.cc +0 -36
- data/ext/tree-sitter/tree-sitter/src/compiler/rules/rules.cc +0 -108
- data/ext/tree-sitter/tree-sitter/src/compiler/rules/string.cc +0 -35
- data/ext/tree-sitter/tree-sitter/src/compiler/rules/symbol.cc +0 -82
- data/ext/tree-sitter/tree-sitter/src/compiler/rules/visitor.cc +0 -44
- data/ext/tree-sitter/tree-sitter/src/compiler/rules/visitor.h +0 -234
- data/ext/tree-sitter/tree-sitter/src/compiler/variable.cc +0 -11
- data/ext/tree-sitter/tree-sitter/src/compiler/variable.h +0 -27
- data/ext/tree-sitter/tree-sitter/src/runtime/error_costs.c +0 -28
- data/ext/tree-sitter/tree-sitter/src/runtime/tree_path.h +0 -217
- data/ext/tree-sitter/tree-sitter/tests.Makefile +0 -6
- data/ext/tree-sitter/tree-sitter/tests.target.mk +0 -176
- data/test/tree-sitter/fixtures/ruby/grammar.json +0 -4803
- data/test/tree-sitter/test_grammar.rb +0 -34
@@ -13,23 +13,16 @@
|
|
13
13
|
#include "runtime/reduce_action.h"
|
14
14
|
#include "runtime/error_costs.h"
|
15
15
|
|
16
|
-
#define LOG(...)
|
17
|
-
if (self->lexer.logger.log) {
|
18
|
-
snprintf(self->lexer.debug_buffer,
|
19
|
-
|
20
|
-
self->lexer.debug_buffer); \
|
21
|
-
} \
|
22
|
-
if (self->print_debugging_graphs) { \
|
23
|
-
fprintf(stderr, "graph {\nlabel=\""); \
|
24
|
-
fprintf(stderr, __VA_ARGS__); \
|
25
|
-
fprintf(stderr, "\"\n}\n\n"); \
|
16
|
+
#define LOG(...) \
|
17
|
+
if (self->lexer.logger.log || self->print_debugging_graphs) { \
|
18
|
+
snprintf(self->lexer.debug_buffer, TREE_SITTER_SERIALIZATION_BUFFER_SIZE, __VA_ARGS__); \
|
19
|
+
parser__log(self); \
|
26
20
|
}
|
27
21
|
|
28
|
-
#define LOG_STACK()
|
29
|
-
if (self->print_debugging_graphs) {
|
30
|
-
ts_stack_print_dot_graph(self->stack, self->language
|
31
|
-
|
32
|
-
fputs("\n\n", stderr); \
|
22
|
+
#define LOG_STACK() \
|
23
|
+
if (self->print_debugging_graphs) { \
|
24
|
+
ts_stack_print_dot_graph(self->stack, self->language, stderr); \
|
25
|
+
fputs("\n\n", stderr); \
|
33
26
|
}
|
34
27
|
|
35
28
|
#define LOG_TREE() \
|
@@ -40,26 +33,42 @@
|
|
40
33
|
|
41
34
|
#define SYM_NAME(symbol) ts_language_symbol_name(self->language, symbol)
|
42
35
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
TreeArray *trees_above_error;
|
47
|
-
uint32_t tree_count_above_error;
|
48
|
-
bool found_repair;
|
49
|
-
ReduceAction best_repair;
|
50
|
-
TSStateId best_repair_next_state;
|
51
|
-
uint32_t best_repair_skip_count;
|
52
|
-
} ErrorRepairSession;
|
36
|
+
static const unsigned MAX_VERSION_COUNT = 6;
|
37
|
+
static const unsigned MAX_SUMMARY_DEPTH = 16;
|
38
|
+
static const unsigned MAX_COST_DIFFERENCE = 16 * ERROR_COST_PER_SKIPPED_TREE;
|
53
39
|
|
54
40
|
typedef struct {
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
41
|
+
unsigned cost;
|
42
|
+
unsigned node_count;
|
43
|
+
int dynamic_precedence;
|
44
|
+
bool is_in_error;
|
45
|
+
} ErrorStatus;
|
46
|
+
|
47
|
+
typedef enum {
|
48
|
+
ErrorComparisonTakeLeft,
|
49
|
+
ErrorComparisonPreferLeft,
|
50
|
+
ErrorComparisonNone,
|
51
|
+
ErrorComparisonPreferRight,
|
52
|
+
ErrorComparisonTakeRight,
|
53
|
+
} ErrorComparison;
|
54
|
+
|
55
|
+
static void parser__log(Parser *self) {
|
56
|
+
if (self->lexer.logger.log) {
|
57
|
+
self->lexer.logger.log(
|
58
|
+
self->lexer.logger.payload,
|
59
|
+
TSLogTypeParse,
|
60
|
+
self->lexer.debug_buffer
|
61
|
+
);
|
62
|
+
}
|
63
|
+
|
64
|
+
if (self->print_debugging_graphs) {
|
65
|
+
fprintf(stderr, "graph {\nlabel=\"");
|
66
|
+
for (char *c = &self->lexer.debug_buffer[0]; *c != 0; c++) {
|
67
|
+
if (*c == '"') fputc('\\', stderr);
|
68
|
+
fputc(*c, stderr);
|
69
|
+
}
|
70
|
+
fprintf(stderr, "\"\n}\n\n");
|
71
|
+
}
|
63
72
|
}
|
64
73
|
|
65
74
|
static bool parser__breakdown_top_of_stack(Parser *self, StackVersion version) {
|
@@ -67,20 +76,19 @@ static bool parser__breakdown_top_of_stack(Parser *self, StackVersion version) {
|
|
67
76
|
bool pending = false;
|
68
77
|
|
69
78
|
do {
|
70
|
-
|
71
|
-
if (!pop.
|
72
|
-
break;
|
79
|
+
StackSliceArray pop = ts_stack_pop_pending(self->stack, version);
|
80
|
+
if (!pop.size) break;
|
73
81
|
|
74
82
|
did_break_down = true;
|
75
83
|
pending = false;
|
76
|
-
for (uint32_t i = 0; i < pop.
|
77
|
-
StackSlice slice = pop.
|
78
|
-
TSStateId state =
|
84
|
+
for (uint32_t i = 0; i < pop.size; i++) {
|
85
|
+
StackSlice slice = pop.contents[i];
|
86
|
+
TSStateId state = ts_stack_state(self->stack, slice.version);
|
79
87
|
Tree *parent = *array_front(&slice.trees);
|
80
88
|
|
81
|
-
for (uint32_t j = 0; j < parent->
|
82
|
-
Tree *child = parent->children[j];
|
83
|
-
pending = child->
|
89
|
+
for (uint32_t j = 0; j < parent->children.size; j++) {
|
90
|
+
Tree *child = parent->children.contents[j];
|
91
|
+
pending = child->children.size > 0;
|
84
92
|
|
85
93
|
if (child->symbol == ts_builtin_sym_error) {
|
86
94
|
state = ERROR_STATE;
|
@@ -88,126 +96,137 @@ static bool parser__breakdown_top_of_stack(Parser *self, StackVersion version) {
|
|
88
96
|
state = ts_language_next_state(self->language, state, child->symbol);
|
89
97
|
}
|
90
98
|
|
99
|
+
ts_tree_retain(child);
|
91
100
|
ts_stack_push(self->stack, slice.version, child, pending, state);
|
92
101
|
}
|
93
102
|
|
94
103
|
for (uint32_t j = 1; j < slice.trees.size; j++) {
|
95
104
|
Tree *tree = slice.trees.contents[j];
|
96
|
-
|
105
|
+
ts_stack_push(self->stack, slice.version, tree, false, state);
|
97
106
|
}
|
98
107
|
|
108
|
+
ts_tree_release(&self->tree_pool, parent);
|
109
|
+
array_delete(&slice.trees);
|
110
|
+
|
99
111
|
LOG("breakdown_top_of_stack tree:%s", SYM_NAME(parent->symbol));
|
100
112
|
LOG_STACK();
|
101
|
-
|
102
|
-
ts_stack_decrease_push_count(self->stack, slice.version,
|
103
|
-
parent->child_count + 1);
|
104
|
-
ts_tree_release(parent);
|
105
|
-
array_delete(&slice.trees);
|
106
113
|
}
|
107
114
|
} while (pending);
|
108
115
|
|
109
116
|
return did_break_down;
|
110
117
|
}
|
111
118
|
|
112
|
-
static
|
119
|
+
static void parser__breakdown_lookahead(Parser *self, Tree **lookahead,
|
113
120
|
TSStateId state,
|
114
121
|
ReusableNode *reusable_node) {
|
115
|
-
bool
|
116
|
-
while (reusable_node->tree->
|
117
|
-
(self->is_split || reusable_node->tree->parse_state != state ||
|
118
|
-
reusable_node->tree->fragile_left ||
|
119
|
-
reusable_node->tree->fragile_right)) {
|
122
|
+
bool did_break_down = false;
|
123
|
+
while (reusable_node->tree->children.size > 0 && reusable_node->tree->parse_state != state) {
|
120
124
|
LOG("state_mismatch sym:%s", SYM_NAME(reusable_node->tree->symbol));
|
121
125
|
reusable_node_breakdown(reusable_node);
|
122
|
-
|
126
|
+
did_break_down = true;
|
123
127
|
}
|
124
128
|
|
125
|
-
if (
|
126
|
-
ts_tree_release(*lookahead);
|
129
|
+
if (did_break_down) {
|
130
|
+
ts_tree_release(&self->tree_pool, *lookahead);
|
127
131
|
ts_tree_retain(*lookahead = reusable_node->tree);
|
128
132
|
}
|
129
|
-
|
130
|
-
return result;
|
131
133
|
}
|
132
134
|
|
133
|
-
static
|
134
|
-
|
135
|
-
|
136
|
-
|
135
|
+
static ErrorComparison parser__compare_versions(Parser *self, ErrorStatus a, ErrorStatus b) {
|
136
|
+
if (!a.is_in_error && b.is_in_error) {
|
137
|
+
if (a.cost < b.cost) {
|
138
|
+
return ErrorComparisonTakeLeft;
|
139
|
+
} else {
|
140
|
+
return ErrorComparisonPreferLeft;
|
141
|
+
}
|
142
|
+
}
|
137
143
|
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
if (tree->size.bytes == 0)
|
146
|
-
return false;
|
147
|
-
if (!table_entry->is_reusable)
|
148
|
-
return false;
|
149
|
-
if (!table_entry->depends_on_lookahead)
|
150
|
-
return true;
|
151
|
-
return tree->child_count > 1 && tree->error_cost == 0;
|
152
|
-
}
|
144
|
+
if (a.is_in_error && !b.is_in_error) {
|
145
|
+
if (b.cost < a.cost) {
|
146
|
+
return ErrorComparisonTakeRight;
|
147
|
+
} else {
|
148
|
+
return ErrorComparisonPreferRight;
|
149
|
+
}
|
150
|
+
}
|
153
151
|
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
result = true;
|
160
|
-
i--;
|
161
|
-
continue;
|
152
|
+
if (a.cost < b.cost) {
|
153
|
+
if ((b.cost - a.cost) * (1 + a.node_count) > MAX_COST_DIFFERENCE) {
|
154
|
+
return ErrorComparisonTakeLeft;
|
155
|
+
} else {
|
156
|
+
return ErrorComparisonPreferLeft;
|
162
157
|
}
|
158
|
+
}
|
163
159
|
|
164
|
-
|
160
|
+
if (b.cost < a.cost) {
|
161
|
+
if ((a.cost - b.cost) * (1 + b.node_count) > MAX_COST_DIFFERENCE) {
|
162
|
+
return ErrorComparisonTakeRight;
|
163
|
+
} else {
|
164
|
+
return ErrorComparisonPreferRight;
|
165
|
+
}
|
166
|
+
}
|
165
167
|
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
break;
|
171
|
-
}
|
168
|
+
if (a.dynamic_precedence > b.dynamic_precedence) return ErrorComparisonPreferLeft;
|
169
|
+
if (b.dynamic_precedence > a.dynamic_precedence) return ErrorComparisonPreferRight;
|
170
|
+
return ErrorComparisonNone;
|
171
|
+
}
|
172
172
|
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
173
|
+
static ErrorStatus parser__version_status(Parser *self, StackVersion version) {
|
174
|
+
unsigned cost = ts_stack_error_cost(self->stack, version);
|
175
|
+
bool is_paused = ts_stack_is_paused(self->stack, version);
|
176
|
+
if (is_paused) cost += ERROR_COST_PER_SKIPPED_TREE;
|
177
|
+
return (ErrorStatus) {
|
178
|
+
.cost = cost,
|
179
|
+
.node_count = ts_stack_node_count_since_error(self->stack, version),
|
180
|
+
.dynamic_precedence = ts_stack_dynamic_precedence(self->stack, version),
|
181
|
+
.is_in_error = is_paused || ts_stack_state(self->stack, version) == ERROR_STATE
|
182
|
+
};
|
183
|
+
}
|
184
|
+
|
185
|
+
static bool parser__better_version_exists(Parser *self, StackVersion version,
|
186
|
+
bool is_in_error, unsigned cost) {
|
187
|
+
if (self->finished_tree && self->finished_tree->error_cost <= cost) return true;
|
188
|
+
|
189
|
+
Length position = ts_stack_position(self->stack, version);
|
190
|
+
ErrorStatus status = {
|
191
|
+
.cost = cost,
|
192
|
+
.is_in_error = is_in_error,
|
193
|
+
.dynamic_precedence = ts_stack_dynamic_precedence(self->stack, version),
|
194
|
+
.node_count = ts_stack_node_count_since_error(self->stack, version),
|
195
|
+
};
|
196
|
+
|
197
|
+
for (StackVersion i = 0, n = ts_stack_version_count(self->stack); i < n; i++) {
|
198
|
+
if (i == version ||
|
199
|
+
!ts_stack_is_active(self->stack, i) ||
|
200
|
+
ts_stack_position(self->stack, i).bytes < position.bytes) continue;
|
201
|
+
ErrorStatus status_i = parser__version_status(self, i);
|
202
|
+
switch (parser__compare_versions(self, status, status_i)) {
|
203
|
+
case ErrorComparisonTakeRight:
|
204
|
+
return true;
|
205
|
+
case ErrorComparisonPreferRight:
|
206
|
+
if (ts_stack_can_merge(self->stack, i, version)) return true;
|
207
|
+
default:
|
208
|
+
break;
|
187
209
|
}
|
188
210
|
}
|
189
|
-
|
211
|
+
|
212
|
+
return false;
|
190
213
|
}
|
191
214
|
|
192
|
-
static void parser__restore_external_scanner(Parser *self,
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
);
|
202
|
-
} else {
|
203
|
-
self->language->external_scanner.reset(self->external_scanner_payload);
|
204
|
-
}
|
215
|
+
static void parser__restore_external_scanner(Parser *self, Tree *external_token) {
|
216
|
+
if (external_token) {
|
217
|
+
self->language->external_scanner.deserialize(
|
218
|
+
self->external_scanner_payload,
|
219
|
+
ts_external_token_state_data(&external_token->external_token_state),
|
220
|
+
external_token->external_token_state.length
|
221
|
+
);
|
222
|
+
} else {
|
223
|
+
self->language->external_scanner.deserialize(self->external_scanner_payload, NULL, 0);
|
205
224
|
}
|
206
225
|
}
|
207
226
|
|
208
|
-
static Tree *parser__lex(Parser *self, StackVersion version) {
|
209
|
-
|
210
|
-
|
227
|
+
static Tree *parser__lex(Parser *self, StackVersion version, TSStateId parse_state) {
|
228
|
+
Length start_position = ts_stack_position(self->stack, version);
|
229
|
+
Tree *external_token = ts_stack_last_external_token(self->stack, version);
|
211
230
|
TSLexMode lex_mode = self->language->lex_modes[parse_state];
|
212
231
|
const bool *valid_external_tokens = ts_language_enabled_external_tokens(
|
213
232
|
self->language,
|
@@ -215,43 +234,68 @@ static Tree *parser__lex(Parser *self, StackVersion version) {
|
|
215
234
|
);
|
216
235
|
|
217
236
|
bool found_external_token = false;
|
218
|
-
bool
|
237
|
+
bool error_mode = parse_state == ERROR_STATE;
|
219
238
|
bool skipped_error = false;
|
220
239
|
int32_t first_error_character = 0;
|
221
|
-
Length error_start_position
|
240
|
+
Length error_start_position = length_zero();
|
241
|
+
Length error_end_position = length_zero();
|
242
|
+
uint32_t last_byte_scanned = start_position.bytes;
|
222
243
|
ts_lexer_reset(&self->lexer, start_position);
|
223
244
|
|
224
245
|
for (;;) {
|
225
246
|
Length current_position = self->lexer.current_position;
|
226
247
|
|
227
248
|
if (valid_external_tokens) {
|
228
|
-
LOG(
|
229
|
-
|
230
|
-
|
249
|
+
LOG(
|
250
|
+
"lex_external state:%d, row:%u, column:%u",
|
251
|
+
lex_mode.external_lex_state,
|
252
|
+
current_position.extent.row,
|
253
|
+
current_position.extent.column
|
254
|
+
);
|
231
255
|
ts_lexer_start(&self->lexer);
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
256
|
+
parser__restore_external_scanner(self, external_token);
|
257
|
+
if (self->language->external_scanner.scan(
|
258
|
+
self->external_scanner_payload,
|
259
|
+
&self->lexer.data,
|
260
|
+
valid_external_tokens
|
261
|
+
)) {
|
262
|
+
if (length_is_undefined(self->lexer.token_end_position)) {
|
263
|
+
self->lexer.token_end_position = self->lexer.current_position;
|
264
|
+
}
|
265
|
+
|
266
|
+
if (!error_mode || self->lexer.token_end_position.bytes > current_position.bytes) {
|
267
|
+
found_external_token = true;
|
268
|
+
break;
|
269
|
+
}
|
270
|
+
}
|
271
|
+
|
272
|
+
if (self->lexer.current_position.bytes > last_byte_scanned) {
|
273
|
+
last_byte_scanned = self->lexer.current_position.bytes;
|
236
274
|
}
|
237
275
|
ts_lexer_reset(&self->lexer, current_position);
|
238
276
|
}
|
239
277
|
|
240
|
-
LOG(
|
241
|
-
|
278
|
+
LOG(
|
279
|
+
"lex_internal state:%d, row:%u, column:%u",
|
280
|
+
lex_mode.lex_state,
|
281
|
+
current_position.extent.row,
|
282
|
+
current_position.extent.column
|
283
|
+
);
|
242
284
|
ts_lexer_start(&self->lexer);
|
243
285
|
if (self->language->lex_fn(&self->lexer.data, lex_mode.lex_state)) {
|
244
286
|
break;
|
245
287
|
}
|
246
288
|
|
247
|
-
if (!
|
248
|
-
|
249
|
-
found_error = true;
|
289
|
+
if (!error_mode) {
|
290
|
+
error_mode = true;
|
250
291
|
lex_mode = self->language->lex_modes[ERROR_STATE];
|
251
292
|
valid_external_tokens = ts_language_enabled_external_tokens(
|
252
293
|
self->language,
|
253
294
|
lex_mode.external_lex_state
|
254
295
|
);
|
296
|
+
if (self->lexer.current_position.bytes > last_byte_scanned) {
|
297
|
+
last_byte_scanned = self->lexer.current_position.bytes;
|
298
|
+
}
|
255
299
|
ts_lexer_reset(&self->lexer, start_position);
|
256
300
|
continue;
|
257
301
|
}
|
@@ -275,32 +319,52 @@ static Tree *parser__lex(Parser *self, StackVersion version) {
|
|
275
319
|
error_end_position = self->lexer.current_position;
|
276
320
|
}
|
277
321
|
|
322
|
+
if (self->lexer.current_position.bytes > last_byte_scanned) {
|
323
|
+
last_byte_scanned = self->lexer.current_position.bytes;
|
324
|
+
}
|
325
|
+
|
278
326
|
Tree *result;
|
279
327
|
if (skipped_error) {
|
280
328
|
Length padding = length_sub(error_start_position, start_position);
|
281
329
|
Length size = length_sub(error_end_position, error_start_position);
|
282
|
-
|
283
|
-
result = ts_tree_make_error(size, padding, first_error_character);
|
330
|
+
result = ts_tree_make_error(&self->tree_pool, size, padding, first_error_character, self->language);
|
284
331
|
} else {
|
332
|
+
if (self->lexer.token_end_position.bytes < self->lexer.token_start_position.bytes) {
|
333
|
+
self->lexer.token_start_position = self->lexer.token_end_position;
|
334
|
+
}
|
335
|
+
|
285
336
|
TSSymbol symbol = self->lexer.data.result_symbol;
|
337
|
+
Length padding = length_sub(self->lexer.token_start_position, start_position);
|
338
|
+
Length size = length_sub(self->lexer.token_end_position, self->lexer.token_start_position);
|
339
|
+
|
286
340
|
if (found_external_token) {
|
287
341
|
symbol = self->language->external_scanner.symbol_map[symbol];
|
342
|
+
} else if (symbol == self->language->keyword_capture_token && symbol != 0) {
|
343
|
+
uint32_t end_byte = self->lexer.token_end_position.bytes;
|
344
|
+
ts_lexer_reset(&self->lexer, self->lexer.token_start_position);
|
345
|
+
ts_lexer_start(&self->lexer);
|
346
|
+
if (
|
347
|
+
self->language->keyword_lex_fn(&self->lexer.data, 0) &&
|
348
|
+
self->lexer.token_end_position.bytes == end_byte &&
|
349
|
+
ts_language_has_actions(self->language, parse_state, self->lexer.data.result_symbol)
|
350
|
+
) {
|
351
|
+
symbol = self->lexer.data.result_symbol;
|
352
|
+
}
|
288
353
|
}
|
289
354
|
|
290
|
-
|
291
|
-
Length size = length_sub(self->lexer.current_position, self->lexer.token_start_position);
|
292
|
-
TSSymbolMetadata metadata = ts_language_symbol_metadata(self->language, symbol);
|
293
|
-
result = ts_tree_make_leaf(symbol, padding, size, metadata);
|
355
|
+
result = ts_tree_make_leaf(&self->tree_pool, symbol, padding, size, self->language);
|
294
356
|
|
295
357
|
if (found_external_token) {
|
296
358
|
result->has_external_tokens = true;
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
359
|
+
unsigned length = self->language->external_scanner.serialize(
|
360
|
+
self->external_scanner_payload,
|
361
|
+
self->lexer.debug_buffer
|
362
|
+
);
|
363
|
+
ts_external_token_state_init(&result->external_token_state, self->lexer.debug_buffer, length);
|
301
364
|
}
|
302
365
|
}
|
303
366
|
|
367
|
+
result->bytes_scanned = last_byte_scanned - start_position.bytes + 1;
|
304
368
|
result->parse_state = parse_state;
|
305
369
|
result->first_leaf.lex_mode = lex_mode;
|
306
370
|
|
@@ -308,93 +372,158 @@ static Tree *parser__lex(Parser *self, StackVersion version) {
|
|
308
372
|
return result;
|
309
373
|
}
|
310
374
|
|
311
|
-
static
|
312
|
-
|
313
|
-
|
375
|
+
static Tree *parser__get_cached_token(Parser *self, size_t byte_index, Tree *last_external_token) {
|
376
|
+
TokenCache *cache = &self->token_cache;
|
377
|
+
if (cache->token &&
|
378
|
+
cache->byte_index == byte_index &&
|
379
|
+
ts_tree_external_token_state_eq(cache->last_external_token, last_external_token)) {
|
380
|
+
return cache->token;
|
381
|
+
} else {
|
382
|
+
return NULL;
|
383
|
+
}
|
384
|
+
}
|
385
|
+
|
386
|
+
static void parser__set_cached_token(Parser *self, size_t byte_index, Tree *last_external_token,
|
387
|
+
Tree *token) {
|
388
|
+
TokenCache *cache = &self->token_cache;
|
389
|
+
if (token) ts_tree_retain(token);
|
390
|
+
if (last_external_token) ts_tree_retain(last_external_token);
|
391
|
+
if (cache->token) ts_tree_release(&self->tree_pool, cache->token);
|
392
|
+
if (cache->last_external_token) ts_tree_release(&self->tree_pool, cache->last_external_token);
|
393
|
+
cache->token = token;
|
394
|
+
cache->byte_index = byte_index;
|
395
|
+
cache->last_external_token = last_external_token;
|
396
|
+
}
|
397
|
+
|
398
|
+
static bool parser__can_reuse_first_leaf(Parser *self, TSStateId state, Tree *tree,
|
399
|
+
TableEntry *table_entry,
|
400
|
+
ReusableNode *next_reusable_node) {
|
401
|
+
TSLexMode current_lex_mode = self->language->lex_modes[state];
|
402
|
+
|
403
|
+
// If the token was created in a state with the same set of lookaheads, it is reusable.
|
404
|
+
if (tree->first_leaf.lex_mode.lex_state == current_lex_mode.lex_state &&
|
405
|
+
tree->first_leaf.lex_mode.external_lex_state == current_lex_mode.external_lex_state &&
|
406
|
+
(tree->first_leaf.symbol != self->language->keyword_capture_token ||
|
407
|
+
tree->parse_state == state)) return true;
|
408
|
+
|
409
|
+
// Empty tokens are not reusable in states with different lookaheads.
|
410
|
+
if (tree->size.bytes == 0 && tree->symbol != ts_builtin_sym_end) return false;
|
411
|
+
|
412
|
+
// If the current state allows external tokens or other tokens that conflict with this
|
413
|
+
// token, this token is not reusable.
|
414
|
+
return current_lex_mode.external_lex_state == 0 && table_entry->is_reusable;
|
314
415
|
}
|
315
416
|
|
316
|
-
static Tree *parser__get_lookahead(Parser *self, StackVersion version,
|
317
|
-
ReusableNode *reusable_node,
|
318
|
-
|
319
|
-
|
417
|
+
static Tree *parser__get_lookahead(Parser *self, StackVersion version, TSStateId *state,
|
418
|
+
ReusableNode *reusable_node, TableEntry *table_entry) {
|
419
|
+
Length position = ts_stack_position(self->stack, version);
|
420
|
+
Tree *last_external_token = ts_stack_last_external_token(self->stack, version);
|
320
421
|
|
321
|
-
|
422
|
+
Tree *result;
|
423
|
+
while ((result = reusable_node->tree)) {
|
322
424
|
if (reusable_node->byte_index > position.bytes) {
|
323
|
-
LOG("before_reusable_node
|
425
|
+
LOG("before_reusable_node symbol:%s", SYM_NAME(result->symbol));
|
324
426
|
break;
|
325
427
|
}
|
326
428
|
|
327
429
|
if (reusable_node->byte_index < position.bytes) {
|
328
|
-
LOG("
|
430
|
+
LOG("past_reusable_node symbol:%s", SYM_NAME(result->symbol));
|
329
431
|
reusable_node_pop(reusable_node);
|
330
432
|
continue;
|
331
433
|
}
|
332
434
|
|
333
|
-
if (reusable_node->
|
334
|
-
LOG("
|
335
|
-
|
336
|
-
reusable_node->tree->size.bytes);
|
337
|
-
if (!reusable_node_breakdown(reusable_node)) {
|
338
|
-
reusable_node_pop(reusable_node);
|
339
|
-
parser__breakdown_top_of_stack(self, version);
|
340
|
-
}
|
435
|
+
if (!ts_tree_external_token_state_eq(reusable_node->last_external_token, last_external_token)) {
|
436
|
+
LOG("reusable_node_has_different_external_scanner_state symbol:%s", SYM_NAME(result->symbol));
|
437
|
+
reusable_node_pop(reusable_node);
|
341
438
|
continue;
|
342
439
|
}
|
343
440
|
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
441
|
+
const char *reason = NULL;
|
442
|
+
if (result->has_changes) {
|
443
|
+
reason = "has_changes";
|
444
|
+
} else if (result->symbol == ts_builtin_sym_error) {
|
445
|
+
reason = "is_error";
|
446
|
+
} else if (result->is_missing) {
|
447
|
+
reason = "is_missing";
|
448
|
+
} else if (result->fragile_left || result->fragile_right) {
|
449
|
+
reason = "is_fragile";
|
450
|
+
} else if (self->in_ambiguity && result->children.size) {
|
451
|
+
reason = "in_ambiguity";
|
353
452
|
}
|
354
453
|
|
355
|
-
if (
|
356
|
-
|
357
|
-
ts_stack_external_token_state(self->stack, version))) {
|
358
|
-
LOG("cant_reuse_external_tokens tree:%s, size:%u",
|
359
|
-
SYM_NAME(reusable_node->tree->symbol),
|
360
|
-
reusable_node->tree->size.bytes);
|
454
|
+
if (reason) {
|
455
|
+
LOG("cant_reuse_node_%s tree:%s", reason, SYM_NAME(result->symbol));
|
361
456
|
if (!reusable_node_breakdown(reusable_node)) {
|
362
457
|
reusable_node_pop(reusable_node);
|
363
458
|
parser__breakdown_top_of_stack(self, version);
|
459
|
+
*state = ts_stack_state(self->stack, version);
|
364
460
|
}
|
365
461
|
continue;
|
366
462
|
}
|
367
463
|
|
368
|
-
|
464
|
+
ts_language_table_entry(self->language, *state, result->first_leaf.symbol, table_entry);
|
465
|
+
ReusableNode next_reusable_node = reusable_node_after_leaf(reusable_node);
|
466
|
+
if (!parser__can_reuse_first_leaf(self, *state, result, table_entry, &next_reusable_node)) {
|
467
|
+
LOG(
|
468
|
+
"cant_reuse_node symbol:%s, first_leaf_symbol:%s",
|
469
|
+
SYM_NAME(result->symbol),
|
470
|
+
SYM_NAME(result->first_leaf.symbol)
|
471
|
+
);
|
472
|
+
*reusable_node = next_reusable_node;
|
473
|
+
break;
|
474
|
+
}
|
475
|
+
|
476
|
+
LOG("reuse_node symbol:%s", SYM_NAME(result->symbol));
|
369
477
|
ts_tree_retain(result);
|
370
478
|
return result;
|
371
479
|
}
|
372
480
|
|
373
|
-
if (self
|
374
|
-
|
375
|
-
|
481
|
+
if ((result = parser__get_cached_token(self, position.bytes, last_external_token))) {
|
482
|
+
ts_language_table_entry(self->language, *state, result->first_leaf.symbol, table_entry);
|
483
|
+
if (parser__can_reuse_first_leaf(self, *state, result, table_entry, NULL)) {
|
484
|
+
ts_tree_retain(result);
|
485
|
+
return result;
|
486
|
+
}
|
376
487
|
}
|
377
488
|
|
378
|
-
|
379
|
-
|
489
|
+
result = parser__lex(self, version, *state);
|
490
|
+
parser__set_cached_token(self, position.bytes, last_external_token, result);
|
491
|
+
ts_language_table_entry(self->language, *state, result->symbol, table_entry);
|
492
|
+
return result;
|
380
493
|
}
|
381
494
|
|
382
495
|
static bool parser__select_tree(Parser *self, Tree *left, Tree *right) {
|
383
|
-
if (!left)
|
384
|
-
|
385
|
-
|
386
|
-
return false;
|
496
|
+
if (!left) return true;
|
497
|
+
if (!right) return false;
|
498
|
+
|
387
499
|
if (right->error_cost < left->error_cost) {
|
388
500
|
LOG("select_smaller_error symbol:%s, over_symbol:%s",
|
389
501
|
SYM_NAME(right->symbol), SYM_NAME(left->symbol));
|
390
502
|
return true;
|
391
503
|
}
|
504
|
+
|
392
505
|
if (left->error_cost < right->error_cost) {
|
393
506
|
LOG("select_smaller_error symbol:%s, over_symbol:%s",
|
394
507
|
SYM_NAME(left->symbol), SYM_NAME(right->symbol));
|
395
508
|
return false;
|
396
509
|
}
|
397
510
|
|
511
|
+
if (right->dynamic_precedence > left->dynamic_precedence) {
|
512
|
+
LOG("select_higher_precedence symbol:%s, prec:%u, over_symbol:%s, other_prec:%u",
|
513
|
+
SYM_NAME(right->symbol), right->dynamic_precedence, SYM_NAME(left->symbol),
|
514
|
+
left->dynamic_precedence);
|
515
|
+
return true;
|
516
|
+
}
|
517
|
+
|
518
|
+
if (left->dynamic_precedence > right->dynamic_precedence) {
|
519
|
+
LOG("select_higher_precedence symbol:%s, prec:%u, over_symbol:%s, other_prec:%u",
|
520
|
+
SYM_NAME(left->symbol), left->dynamic_precedence, SYM_NAME(right->symbol),
|
521
|
+
right->dynamic_precedence);
|
522
|
+
return false;
|
523
|
+
}
|
524
|
+
|
525
|
+
if (left->error_cost > 0) return true;
|
526
|
+
|
398
527
|
int comparison = ts_tree_compare(left, right);
|
399
528
|
switch (comparison) {
|
400
529
|
case -1:
|
@@ -413,37 +542,11 @@ static bool parser__select_tree(Parser *self, Tree *left, Tree *right) {
|
|
413
542
|
}
|
414
543
|
}
|
415
544
|
|
416
|
-
static bool parser__better_version_exists(Parser *self, StackVersion version,
|
417
|
-
ErrorStatus my_error_status) {
|
418
|
-
if (self->finished_tree &&
|
419
|
-
self->finished_tree->error_cost <= my_error_status.cost)
|
420
|
-
return true;
|
421
|
-
|
422
|
-
for (StackVersion i = 0, n = ts_stack_version_count(self->stack); i < n; i++) {
|
423
|
-
if (i == version || ts_stack_is_halted(self->stack, i))
|
424
|
-
continue;
|
425
|
-
|
426
|
-
switch (error_status_compare(my_error_status,
|
427
|
-
ts_stack_error_status(self->stack, i))) {
|
428
|
-
case -1:
|
429
|
-
LOG("halt_other version:%u", i);
|
430
|
-
ts_stack_halt(self->stack, i);
|
431
|
-
break;
|
432
|
-
case 1:
|
433
|
-
return true;
|
434
|
-
}
|
435
|
-
}
|
436
|
-
|
437
|
-
return false;
|
438
|
-
}
|
439
|
-
|
440
545
|
static void parser__shift(Parser *self, StackVersion version, TSStateId state,
|
441
546
|
Tree *lookahead, bool extra) {
|
442
547
|
if (extra != lookahead->extra) {
|
443
|
-
|
444
|
-
|
445
|
-
if (metadata.structural && ts_stack_version_count(self->stack) > 1) {
|
446
|
-
lookahead = ts_tree_make_copy(lookahead);
|
548
|
+
if (ts_stack_version_count(self->stack) > 1) {
|
549
|
+
lookahead = ts_tree_make_copy(&self->tree_pool, lookahead);
|
447
550
|
} else {
|
448
551
|
ts_tree_retain(lookahead);
|
449
552
|
}
|
@@ -452,83 +555,77 @@ static void parser__shift(Parser *self, StackVersion version, TSStateId state,
|
|
452
555
|
ts_tree_retain(lookahead);
|
453
556
|
}
|
454
557
|
|
455
|
-
bool is_pending = lookahead->
|
558
|
+
bool is_pending = lookahead->children.size > 0;
|
456
559
|
ts_stack_push(self->stack, version, lookahead, is_pending, state);
|
457
|
-
if (lookahead->
|
458
|
-
|
459
|
-
self->stack, version,
|
560
|
+
if (lookahead->has_external_tokens) {
|
561
|
+
ts_stack_set_last_external_token(
|
562
|
+
self->stack, version, ts_tree_last_external_token(lookahead)
|
563
|
+
);
|
460
564
|
}
|
461
|
-
ts_tree_release(lookahead);
|
462
565
|
}
|
463
566
|
|
464
|
-
static bool
|
465
|
-
|
466
|
-
self->scratch_tree.
|
467
|
-
self->scratch_tree
|
468
|
-
ts_tree_set_children(&self->scratch_tree, count, children);
|
567
|
+
static bool parser__replace_children(Parser *self, Tree *tree, TreeArray *children) {
|
568
|
+
self->scratch_tree = *tree;
|
569
|
+
self->scratch_tree.children.size = 0;
|
570
|
+
ts_tree_set_children(&self->scratch_tree, children, self->language);
|
469
571
|
if (parser__select_tree(self, tree, &self->scratch_tree)) {
|
470
|
-
tree
|
471
|
-
tree->padding = self->scratch_tree.padding;
|
472
|
-
tree->error_cost = self->scratch_tree.error_cost;
|
473
|
-
tree->children = self->scratch_tree.children;
|
474
|
-
tree->child_count = self->scratch_tree.child_count;
|
475
|
-
tree->named_child_count = self->scratch_tree.named_child_count;
|
476
|
-
tree->visible_child_count = self->scratch_tree.visible_child_count;
|
572
|
+
*tree = self->scratch_tree;
|
477
573
|
return true;
|
478
574
|
} else {
|
479
575
|
return false;
|
480
576
|
}
|
481
577
|
}
|
482
578
|
|
483
|
-
static
|
484
|
-
|
485
|
-
|
579
|
+
static StackSliceArray parser__reduce(Parser *self, StackVersion version, TSSymbol symbol,
|
580
|
+
uint32_t count, int dynamic_precedence,
|
581
|
+
uint16_t alias_sequence_id, bool fragile) {
|
486
582
|
uint32_t initial_version_count = ts_stack_version_count(self->stack);
|
487
583
|
|
488
|
-
|
489
|
-
if (pop.stopped_at_error)
|
490
|
-
return pop;
|
491
|
-
|
492
|
-
const TSLanguage *language = self->language;
|
493
|
-
TSSymbolMetadata metadata = ts_language_symbol_metadata(language, symbol);
|
584
|
+
StackSliceArray pop = ts_stack_pop_count(self->stack, version, count);
|
494
585
|
|
495
|
-
for (uint32_t i = 0; i < pop.
|
496
|
-
StackSlice slice = pop.
|
586
|
+
for (uint32_t i = 0; i < pop.size; i++) {
|
587
|
+
StackSlice slice = pop.contents[i];
|
497
588
|
|
498
589
|
// Extra tokens on top of the stack should not be included in this new parent
|
499
590
|
// node. They will be re-pushed onto the stack after the parent node is
|
500
591
|
// created and pushed.
|
501
|
-
|
502
|
-
while (
|
503
|
-
|
592
|
+
TreeArray children = slice.trees;
|
593
|
+
while (children.size > 0 && children.contents[children.size - 1]->extra) {
|
594
|
+
children.size--;
|
595
|
+
}
|
504
596
|
|
505
|
-
Tree *parent = ts_tree_make_node(
|
597
|
+
Tree *parent = ts_tree_make_node(&self->tree_pool,
|
598
|
+
symbol, &children, alias_sequence_id, self->language
|
599
|
+
);
|
506
600
|
|
507
601
|
// This pop operation may have caused multiple stack versions to collapse
|
508
602
|
// into one, because they all diverged from a common state. In that case,
|
509
603
|
// choose one of the arrays of trees to be the parent node's children, and
|
510
604
|
// delete the rest of the tree arrays.
|
511
|
-
while (i + 1 < pop.
|
512
|
-
StackSlice next_slice = pop.
|
513
|
-
if (next_slice.version != slice.version)
|
514
|
-
break;
|
605
|
+
while (i + 1 < pop.size) {
|
606
|
+
StackSlice next_slice = pop.contents[i + 1];
|
607
|
+
if (next_slice.version != slice.version) break;
|
515
608
|
i++;
|
516
609
|
|
517
|
-
|
518
|
-
while (
|
519
|
-
|
610
|
+
TreeArray children = next_slice.trees;
|
611
|
+
while (children.size > 0 && children.contents[children.size - 1]->extra) {
|
612
|
+
children.size--;
|
613
|
+
}
|
520
614
|
|
521
|
-
if (
|
522
|
-
ts_tree_array_delete(&slice.trees);
|
615
|
+
if (parser__replace_children(self, parent, &children)) {
|
616
|
+
ts_tree_array_delete(&self->tree_pool, &slice.trees);
|
523
617
|
slice = next_slice;
|
524
618
|
} else {
|
525
|
-
ts_tree_array_delete(&next_slice.trees);
|
619
|
+
ts_tree_array_delete(&self->tree_pool, &next_slice.trees);
|
526
620
|
}
|
527
621
|
}
|
528
622
|
|
529
|
-
|
530
|
-
|
531
|
-
|
623
|
+
parent->dynamic_precedence += dynamic_precedence;
|
624
|
+
parent->alias_sequence_id = alias_sequence_id;
|
625
|
+
|
626
|
+
TSStateId state = ts_stack_state(self->stack, slice.version);
|
627
|
+
TSStateId next_state = ts_language_next_state(self->language, state, symbol);
|
628
|
+
if (fragile || self->in_ambiguity || pop.size > 1 || initial_version_count > 1) {
|
532
629
|
parent->fragile_left = true;
|
533
630
|
parent->fragile_right = true;
|
534
631
|
parent->parse_state = TS_TREE_STATE_NONE;
|
@@ -536,29 +633,25 @@ static StackPopResult parser__reduce(Parser *self, StackVersion version,
|
|
536
633
|
parent->parse_state = state;
|
537
634
|
}
|
538
635
|
|
539
|
-
// If this pop operation terminated at the end of an error region, then
|
540
|
-
// create two stack versions: one in which the parent node is interpreted
|
541
|
-
// normally, and one in which the parent node is skipped.
|
542
|
-
if (state == ERROR_STATE && allow_skipping && child_count > 1) {
|
543
|
-
StackVersion other_version = ts_stack_copy_version(self->stack, slice.version);
|
544
|
-
|
545
|
-
ts_stack_push(self->stack, other_version, parent, false, ERROR_STATE);
|
546
|
-
for (uint32_t j = parent->child_count; j < slice.trees.size; j++) {
|
547
|
-
Tree *tree = slice.trees.contents[j];
|
548
|
-
ts_stack_push(self->stack, other_version, tree, false, ERROR_STATE);
|
549
|
-
}
|
550
|
-
|
551
|
-
ErrorStatus error_status = ts_stack_error_status(self->stack, other_version);
|
552
|
-
if (parser__better_version_exists(self, version, error_status))
|
553
|
-
ts_stack_remove_version(self->stack, other_version);
|
554
|
-
}
|
555
|
-
|
556
636
|
// Push the parent node onto the stack, along with any extra tokens that
|
557
637
|
// were previously on top of the stack.
|
558
|
-
|
559
|
-
for (uint32_t j = parent->
|
560
|
-
|
561
|
-
|
638
|
+
ts_stack_push(self->stack, slice.version, parent, false, next_state);
|
639
|
+
for (uint32_t j = parent->children.size; j < slice.trees.size; j++) {
|
640
|
+
ts_stack_push(self->stack, slice.version, slice.trees.contents[j], false, next_state);
|
641
|
+
}
|
642
|
+
|
643
|
+
if (ts_stack_version_count(self->stack) > MAX_VERSION_COUNT) {
|
644
|
+
i++;
|
645
|
+
while (i < pop.size) {
|
646
|
+
StackSlice slice = pop.contents[i];
|
647
|
+
ts_tree_array_delete(&self->tree_pool, &slice.trees);
|
648
|
+
ts_stack_halt(self->stack, slice.version);
|
649
|
+
i++;
|
650
|
+
}
|
651
|
+
while (ts_stack_version_count(self->stack) > slice.version + 1) {
|
652
|
+
ts_stack_remove_version(self->stack, slice.version + 1);
|
653
|
+
}
|
654
|
+
break;
|
562
655
|
}
|
563
656
|
}
|
564
657
|
|
@@ -574,205 +667,6 @@ static StackPopResult parser__reduce(Parser *self, StackVersion version,
|
|
574
667
|
return pop;
|
575
668
|
}
|
576
669
|
|
577
|
-
static inline const TSParseAction *parser__reductions_after_sequence(
|
578
|
-
Parser *self, TSStateId start_state, const TreeArray *trees_below,
|
579
|
-
uint32_t tree_count_below, const TreeArray *trees_above,
|
580
|
-
TSSymbol lookahead_symbol, uint32_t *count) {
|
581
|
-
TSStateId state = start_state;
|
582
|
-
uint32_t child_count = 0;
|
583
|
-
*count = 0;
|
584
|
-
|
585
|
-
for (uint32_t i = 0; i < trees_below->size; i++) {
|
586
|
-
if (child_count == tree_count_below)
|
587
|
-
break;
|
588
|
-
Tree *tree = trees_below->contents[trees_below->size - 1 - i];
|
589
|
-
if (tree->extra) continue;
|
590
|
-
TSStateId next_state = ts_language_next_state(self->language, state, tree->symbol);
|
591
|
-
if (next_state == ERROR_STATE)
|
592
|
-
return NULL;
|
593
|
-
if (next_state != state) {
|
594
|
-
child_count++;
|
595
|
-
state = next_state;
|
596
|
-
}
|
597
|
-
}
|
598
|
-
|
599
|
-
for (uint32_t i = 0; i < trees_above->size; i++) {
|
600
|
-
Tree *tree = trees_above->contents[i];
|
601
|
-
if (tree->extra) continue;
|
602
|
-
TSStateId next_state = ts_language_next_state(self->language, state, tree->symbol);
|
603
|
-
if (next_state == ERROR_STATE)
|
604
|
-
return NULL;
|
605
|
-
if (next_state != state) {
|
606
|
-
child_count++;
|
607
|
-
state = next_state;
|
608
|
-
}
|
609
|
-
}
|
610
|
-
|
611
|
-
const TSParseAction *actions =
|
612
|
-
ts_language_actions(self->language, state, lookahead_symbol, count);
|
613
|
-
|
614
|
-
if (*count > 0 && actions[*count - 1].type != TSParseActionTypeReduce) {
|
615
|
-
(*count)--;
|
616
|
-
}
|
617
|
-
|
618
|
-
while (*count > 0 && actions[0].params.child_count < child_count) {
|
619
|
-
actions++;
|
620
|
-
(*count)--;
|
621
|
-
}
|
622
|
-
|
623
|
-
while (*count > 0 && actions[*count - 1].params.child_count > child_count) {
|
624
|
-
(*count)--;
|
625
|
-
}
|
626
|
-
|
627
|
-
return actions;
|
628
|
-
}
|
629
|
-
|
630
|
-
static StackIterateAction parser__repair_error_callback(
|
631
|
-
void *payload, TSStateId state, TreeArray *trees, uint32_t tree_count,
|
632
|
-
bool is_done, bool is_pending) {
|
633
|
-
|
634
|
-
ErrorRepairSession *session = (ErrorRepairSession *)payload;
|
635
|
-
Parser *self = session->parser;
|
636
|
-
TSSymbol lookahead_symbol = session->lookahead_symbol;
|
637
|
-
ReduceActionSet *repairs = &self->reduce_actions;
|
638
|
-
TreeArray *trees_above_error = session->trees_above_error;
|
639
|
-
uint32_t tree_count_above_error = session->tree_count_above_error;
|
640
|
-
|
641
|
-
StackIterateAction result = StackIterateNone;
|
642
|
-
|
643
|
-
uint32_t last_repair_count = -1;
|
644
|
-
uint32_t repair_reduction_count = -1;
|
645
|
-
const TSParseAction *repair_reductions = NULL;
|
646
|
-
|
647
|
-
for (uint32_t i = 0; i < repairs->size; i++) {
|
648
|
-
ReduceAction *repair = &repairs->contents[i];
|
649
|
-
uint32_t count_needed_below_error = repair->count - tree_count_above_error;
|
650
|
-
if (count_needed_below_error > tree_count)
|
651
|
-
break;
|
652
|
-
|
653
|
-
uint32_t skip_count = tree_count - count_needed_below_error;
|
654
|
-
if (session->found_repair && skip_count >= session->best_repair_skip_count) {
|
655
|
-
array_erase(repairs, i--);
|
656
|
-
continue;
|
657
|
-
}
|
658
|
-
|
659
|
-
TSStateId state_after_repair = ts_language_next_state(self->language, state, repair->symbol);
|
660
|
-
if (state == ERROR_STATE || state_after_repair == ERROR_STATE)
|
661
|
-
continue;
|
662
|
-
|
663
|
-
uint32_t action_count;
|
664
|
-
ts_language_actions(self->language, state_after_repair, lookahead_symbol, &action_count);
|
665
|
-
if (action_count == 0)
|
666
|
-
continue;
|
667
|
-
|
668
|
-
if (count_needed_below_error != last_repair_count) {
|
669
|
-
last_repair_count = count_needed_below_error;
|
670
|
-
repair_reductions = parser__reductions_after_sequence(
|
671
|
-
self, state, trees, count_needed_below_error, trees_above_error,
|
672
|
-
lookahead_symbol, &repair_reduction_count);
|
673
|
-
}
|
674
|
-
|
675
|
-
for (uint32_t j = 0; j < repair_reduction_count; j++) {
|
676
|
-
if (repair_reductions[j].params.symbol == repair->symbol) {
|
677
|
-
result |= StackIteratePop;
|
678
|
-
session->found_repair = true;
|
679
|
-
session->best_repair = *repair;
|
680
|
-
session->best_repair_skip_count = skip_count;
|
681
|
-
session->best_repair_next_state = state_after_repair;
|
682
|
-
array_erase(repairs, i--);
|
683
|
-
break;
|
684
|
-
}
|
685
|
-
}
|
686
|
-
}
|
687
|
-
|
688
|
-
if (repairs->size == 0)
|
689
|
-
result |= StackIterateStop;
|
690
|
-
|
691
|
-
return result;
|
692
|
-
}
|
693
|
-
|
694
|
-
static bool parser__repair_error(Parser *self, StackSlice slice,
|
695
|
-
TSSymbol lookahead_symbol, TableEntry entry) {
|
696
|
-
LOG("repair_error");
|
697
|
-
ErrorRepairSession session = {
|
698
|
-
.parser = self,
|
699
|
-
.lookahead_symbol = lookahead_symbol,
|
700
|
-
.found_repair = false,
|
701
|
-
.trees_above_error = &slice.trees,
|
702
|
-
.tree_count_above_error = ts_tree_array_essential_count(&slice.trees),
|
703
|
-
};
|
704
|
-
|
705
|
-
array_clear(&self->reduce_actions);
|
706
|
-
for (uint32_t i = 0; i < entry.action_count; i++) {
|
707
|
-
if (entry.actions[i].type == TSParseActionTypeReduce) {
|
708
|
-
TSSymbol symbol = entry.actions[i].params.symbol;
|
709
|
-
uint32_t child_count = entry.actions[i].params.child_count;
|
710
|
-
if ((child_count > session.tree_count_above_error) ||
|
711
|
-
(child_count == session.tree_count_above_error &&
|
712
|
-
!ts_language_symbol_metadata(self->language, symbol).visible))
|
713
|
-
array_push(&self->reduce_actions, ((ReduceAction){
|
714
|
-
.symbol = symbol,
|
715
|
-
.count = child_count
|
716
|
-
}));
|
717
|
-
}
|
718
|
-
}
|
719
|
-
|
720
|
-
StackPopResult pop = ts_stack_iterate(
|
721
|
-
self->stack, slice.version, parser__repair_error_callback, &session);
|
722
|
-
|
723
|
-
if (!session.found_repair) {
|
724
|
-
LOG("no_repair_found");
|
725
|
-
ts_stack_remove_version(self->stack, slice.version);
|
726
|
-
ts_tree_array_delete(&slice.trees);
|
727
|
-
return false;
|
728
|
-
}
|
729
|
-
|
730
|
-
ReduceAction repair = session.best_repair;
|
731
|
-
TSStateId next_state = session.best_repair_next_state;
|
732
|
-
uint32_t skip_count = session.best_repair_skip_count;
|
733
|
-
TSSymbol symbol = repair.symbol;
|
734
|
-
|
735
|
-
StackSlice new_slice = array_pop(&pop.slices);
|
736
|
-
TreeArray children = new_slice.trees;
|
737
|
-
ts_stack_renumber_version(self->stack, new_slice.version, slice.version);
|
738
|
-
|
739
|
-
for (uint32_t i = pop.slices.size - 1; i + 1 > 0; i--) {
|
740
|
-
StackSlice other_slice = pop.slices.contents[i];
|
741
|
-
ts_tree_array_delete(&other_slice.trees);
|
742
|
-
if (other_slice.version != pop.slices.contents[i + 1].version)
|
743
|
-
ts_stack_remove_version(self->stack, other_slice.version);
|
744
|
-
}
|
745
|
-
|
746
|
-
TreeArray skipped_children = ts_tree_array_remove_last_n(&children, skip_count);
|
747
|
-
TreeArray trailing_extras = ts_tree_array_remove_trailing_extras(&skipped_children);
|
748
|
-
Tree *error = ts_tree_make_error_node(&skipped_children);
|
749
|
-
array_push(&children, error);
|
750
|
-
array_push_all(&children, &trailing_extras);
|
751
|
-
trailing_extras.size = 0;
|
752
|
-
array_delete(&trailing_extras);
|
753
|
-
|
754
|
-
for (uint32_t i = 0; i < slice.trees.size; i++)
|
755
|
-
array_push(&children, slice.trees.contents[i]);
|
756
|
-
array_delete(&slice.trees);
|
757
|
-
|
758
|
-
Tree *parent =
|
759
|
-
ts_tree_make_node(symbol, children.size, children.contents,
|
760
|
-
ts_language_symbol_metadata(self->language, symbol));
|
761
|
-
parser__push(self, slice.version, parent, next_state);
|
762
|
-
ts_stack_decrease_push_count(self->stack, slice.version, error->child_count);
|
763
|
-
|
764
|
-
ErrorStatus error_status = ts_stack_error_status(self->stack, slice.version);
|
765
|
-
if (parser__better_version_exists(self, slice.version, error_status)) {
|
766
|
-
LOG("no_better_repair_found");
|
767
|
-
ts_stack_halt(self->stack, slice.version);
|
768
|
-
return false;
|
769
|
-
} else {
|
770
|
-
LOG("repair_found sym:%s, child_count:%u, cost:%u", SYM_NAME(symbol),
|
771
|
-
repair.count, parent->error_cost);
|
772
|
-
return true;
|
773
|
-
}
|
774
|
-
}
|
775
|
-
|
776
670
|
static void parser__start(Parser *self, TSInput input, Tree *previous_tree) {
|
777
671
|
if (previous_tree) {
|
778
672
|
LOG("parse_after_edit");
|
@@ -780,257 +674,413 @@ static void parser__start(Parser *self, TSInput input, Tree *previous_tree) {
|
|
780
674
|
LOG("new_parse");
|
781
675
|
}
|
782
676
|
|
783
|
-
if (self->language->external_scanner.
|
784
|
-
self->language->external_scanner.
|
677
|
+
if (self->language->external_scanner.deserialize) {
|
678
|
+
self->language->external_scanner.deserialize(self->external_scanner_payload, NULL, 0);
|
785
679
|
}
|
786
680
|
|
787
681
|
ts_lexer_set_input(&self->lexer, input);
|
788
682
|
ts_stack_clear(self->stack);
|
789
683
|
self->reusable_node = reusable_node_new(previous_tree);
|
790
|
-
self->cached_token = NULL;
|
791
684
|
self->finished_tree = NULL;
|
685
|
+
self->accept_count = 0;
|
686
|
+
self->in_ambiguity = false;
|
792
687
|
}
|
793
688
|
|
794
|
-
static void parser__accept(Parser *self, StackVersion version,
|
795
|
-
Tree *lookahead) {
|
689
|
+
static void parser__accept(Parser *self, StackVersion version, Tree *lookahead) {
|
796
690
|
lookahead->extra = true;
|
797
691
|
assert(lookahead->symbol == ts_builtin_sym_end);
|
692
|
+
ts_tree_retain(lookahead);
|
798
693
|
ts_stack_push(self->stack, version, lookahead, false, 1);
|
799
|
-
StackPopResult pop = ts_stack_pop_all(self->stack, version);
|
800
694
|
|
801
|
-
|
802
|
-
|
803
|
-
TreeArray trees =
|
695
|
+
StackSliceArray pop = ts_stack_pop_all(self->stack, version);
|
696
|
+
for (uint32_t i = 0; i < pop.size; i++) {
|
697
|
+
TreeArray trees = pop.contents[i].trees;
|
804
698
|
|
805
699
|
Tree *root = NULL;
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
Tree *child = trees.contents[j];
|
812
|
-
if (!child->extra) {
|
813
|
-
root = ts_tree_make_copy(child);
|
814
|
-
root->child_count = 0;
|
815
|
-
for (uint32_t k = 0; k < child->child_count; k++)
|
816
|
-
ts_tree_retain(child->children[k]);
|
817
|
-
array_splice(&trees, j, 1, child->child_count, child->children);
|
818
|
-
ts_tree_set_children(root, trees.size, trees.contents);
|
819
|
-
ts_tree_release(child);
|
820
|
-
break;
|
700
|
+
for (uint32_t j = trees.size - 1; j + 1 > 0; j--) {
|
701
|
+
Tree *child = trees.contents[j];
|
702
|
+
if (!child->extra) {
|
703
|
+
for (uint32_t k = 0; k < child->children.size; k++) {
|
704
|
+
ts_tree_retain(child->children.contents[k]);
|
821
705
|
}
|
706
|
+
array_splice(&trees, j, 1, &child->children);
|
707
|
+
root = ts_tree_make_node(
|
708
|
+
&self->tree_pool, child->symbol, &trees,
|
709
|
+
child->alias_sequence_id, self->language
|
710
|
+
);
|
711
|
+
ts_tree_release(&self->tree_pool, child);
|
712
|
+
break;
|
822
713
|
}
|
823
714
|
}
|
824
715
|
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
|
716
|
+
assert(root && root->ref_count > 0);
|
717
|
+
self->accept_count++;
|
718
|
+
|
719
|
+
if (self->finished_tree) {
|
720
|
+
if (parser__select_tree(self, self->finished_tree, root)) {
|
721
|
+
ts_tree_release(&self->tree_pool, self->finished_tree);
|
722
|
+
self->finished_tree = root;
|
723
|
+
} else {
|
724
|
+
ts_tree_release(&self->tree_pool, root);
|
725
|
+
}
|
829
726
|
} else {
|
830
|
-
|
727
|
+
self->finished_tree = root;
|
831
728
|
}
|
832
729
|
}
|
833
730
|
|
834
|
-
ts_stack_remove_version(self->stack, pop.
|
731
|
+
ts_stack_remove_version(self->stack, pop.contents[0].version);
|
835
732
|
ts_stack_halt(self->stack, version);
|
836
733
|
}
|
837
734
|
|
838
|
-
static bool
|
839
|
-
|
840
|
-
|
841
|
-
uint32_t previous_version_count = ts_stack_version_count(self->stack);
|
735
|
+
static bool parser__do_all_potential_reductions(Parser *self, StackVersion starting_version,
|
736
|
+
TSSymbol lookahead_symbol) {
|
737
|
+
uint32_t initial_version_count = ts_stack_version_count(self->stack);
|
842
738
|
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
has_shift_action = true;
|
855
|
-
break;
|
856
|
-
case TSParseActionTypeReduce:
|
857
|
-
if (action.params.child_count > 0)
|
858
|
-
ts_reduce_action_set_add(&self->reduce_actions, (ReduceAction){
|
859
|
-
.symbol = action.params.symbol,
|
860
|
-
.count = action.params.child_count,
|
861
|
-
});
|
862
|
-
default:
|
863
|
-
break;
|
739
|
+
bool can_shift_lookahead_symbol = false;
|
740
|
+
StackVersion version = starting_version;
|
741
|
+
for (unsigned i = 0; true; i++) {
|
742
|
+
uint32_t version_count = ts_stack_version_count(self->stack);
|
743
|
+
if (version >= version_count) break;
|
744
|
+
|
745
|
+
bool merged = false;
|
746
|
+
for (StackVersion i = initial_version_count; i < version; i++) {
|
747
|
+
if (ts_stack_merge(self->stack, i, version)) {
|
748
|
+
merged = true;
|
749
|
+
break;
|
864
750
|
}
|
865
751
|
}
|
866
|
-
|
752
|
+
if (merged) continue;
|
867
753
|
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
if (
|
874
|
-
|
875
|
-
|
876
|
-
continue;
|
754
|
+
TSStateId state = ts_stack_state(self->stack, version);
|
755
|
+
bool has_shift_action = false;
|
756
|
+
array_clear(&self->reduce_actions);
|
757
|
+
|
758
|
+
TSSymbol first_symbol, end_symbol;
|
759
|
+
if (lookahead_symbol != 0) {
|
760
|
+
first_symbol = lookahead_symbol;
|
761
|
+
end_symbol = lookahead_symbol + 1;
|
877
762
|
} else {
|
878
|
-
|
763
|
+
first_symbol = 1;
|
764
|
+
end_symbol = self->language->token_count;
|
765
|
+
}
|
766
|
+
|
767
|
+
for (TSSymbol symbol = first_symbol; symbol < end_symbol; symbol++) {
|
768
|
+
TableEntry entry;
|
769
|
+
ts_language_table_entry(self->language, state, symbol, &entry);
|
770
|
+
for (uint32_t i = 0; i < entry.action_count; i++) {
|
771
|
+
TSParseAction action = entry.actions[i];
|
772
|
+
switch (action.type) {
|
773
|
+
case TSParseActionTypeShift:
|
774
|
+
case TSParseActionTypeRecover:
|
775
|
+
if (!action.params.extra && !action.params.repetition) has_shift_action = true;
|
776
|
+
break;
|
777
|
+
case TSParseActionTypeReduce:
|
778
|
+
if (action.params.child_count > 0)
|
779
|
+
ts_reduce_action_set_add(&self->reduce_actions, (ReduceAction){
|
780
|
+
.symbol = action.params.symbol,
|
781
|
+
.count = action.params.child_count,
|
782
|
+
.dynamic_precedence = action.params.dynamic_precedence,
|
783
|
+
.alias_sequence_id = action.params.alias_sequence_id,
|
784
|
+
});
|
785
|
+
default:
|
786
|
+
break;
|
787
|
+
}
|
788
|
+
}
|
789
|
+
}
|
790
|
+
|
791
|
+
for (uint32_t i = 0; i < self->reduce_actions.size; i++) {
|
792
|
+
ReduceAction action = self->reduce_actions.contents[i];
|
793
|
+
|
794
|
+
parser__reduce(
|
795
|
+
self, version, action.symbol, action.count,
|
796
|
+
action.dynamic_precedence, action.alias_sequence_id,
|
797
|
+
true
|
798
|
+
);
|
879
799
|
}
|
880
|
-
}
|
881
800
|
|
882
|
-
if (did_reduce) {
|
883
801
|
if (has_shift_action) {
|
884
|
-
|
802
|
+
can_shift_lookahead_symbol = true;
|
803
|
+
} else if (self->reduce_actions.size > 0 && i < MAX_VERSION_COUNT) {
|
804
|
+
ts_stack_renumber_version(self->stack, version_count, version);
|
805
|
+
continue;
|
806
|
+
} else if (lookahead_symbol != 0) {
|
807
|
+
ts_stack_remove_version(self->stack, version);
|
808
|
+
}
|
809
|
+
|
810
|
+
if (version == starting_version) {
|
811
|
+
version = version_count;
|
885
812
|
} else {
|
886
|
-
|
887
|
-
return false;
|
813
|
+
version++;
|
888
814
|
}
|
889
|
-
} else {
|
890
|
-
return true;
|
891
815
|
}
|
816
|
+
|
817
|
+
return can_shift_lookahead_symbol;
|
892
818
|
}
|
893
819
|
|
894
|
-
static
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
if (
|
905
|
-
|
820
|
+
static void parser__handle_error(Parser *self, StackVersion version, TSSymbol lookahead_symbol) {
|
821
|
+
// Perform any reductions that could have happened in this state, regardless of the lookahead.
|
822
|
+
uint32_t previous_version_count = ts_stack_version_count(self->stack);
|
823
|
+
parser__do_all_potential_reductions(self, version, 0);
|
824
|
+
uint32_t version_count = ts_stack_version_count(self->stack);
|
825
|
+
|
826
|
+
// Push a discontinuity onto the stack. Merge all of the stack versions that
|
827
|
+
// were created in the previous step.
|
828
|
+
bool did_insert_missing_token = false;
|
829
|
+
for (StackVersion v = version; v < version_count;) {
|
830
|
+
if (!did_insert_missing_token) {
|
831
|
+
TSStateId state = ts_stack_state(self->stack, v);
|
832
|
+
for (TSSymbol missing_symbol = 1;
|
833
|
+
missing_symbol < self->language->token_count;
|
834
|
+
missing_symbol++) {
|
835
|
+
TSStateId state_after_missing_symbol = ts_language_next_state(
|
836
|
+
self->language, state, missing_symbol
|
837
|
+
);
|
838
|
+
if (state_after_missing_symbol == 0) continue;
|
839
|
+
|
840
|
+
if (ts_language_has_reduce_action(
|
841
|
+
self->language,
|
842
|
+
state_after_missing_symbol,
|
843
|
+
lookahead_symbol
|
844
|
+
)) {
|
845
|
+
StackVersion version_with_missing_tree = ts_stack_copy_version(self->stack, v);
|
846
|
+
Tree *missing_tree = ts_tree_make_missing_leaf(&self->tree_pool, missing_symbol, self->language);
|
847
|
+
ts_stack_push(
|
848
|
+
self->stack, version_with_missing_tree,
|
849
|
+
missing_tree, false,
|
850
|
+
state_after_missing_symbol
|
851
|
+
);
|
852
|
+
|
853
|
+
if (parser__do_all_potential_reductions(
|
854
|
+
self, version_with_missing_tree,
|
855
|
+
lookahead_symbol
|
856
|
+
)) {
|
857
|
+
LOG(
|
858
|
+
"recover_with_missing symbol:%s, state:%u",
|
859
|
+
SYM_NAME(missing_symbol),
|
860
|
+
ts_stack_state(self->stack, version_with_missing_tree)
|
861
|
+
);
|
862
|
+
did_insert_missing_token = true;
|
863
|
+
break;
|
864
|
+
}
|
865
|
+
}
|
866
|
+
}
|
906
867
|
}
|
868
|
+
|
869
|
+
ts_stack_push(self->stack, v, NULL, false, ERROR_STATE);
|
870
|
+
v = (v == version) ? previous_version_count : v + 1;
|
871
|
+
}
|
872
|
+
|
873
|
+
for (unsigned i = previous_version_count; i < version_count; i++) {
|
874
|
+
assert(ts_stack_merge(self->stack, version, previous_version_count));
|
907
875
|
}
|
908
|
-
|
876
|
+
|
877
|
+
ts_stack_record_summary(self->stack, version, MAX_SUMMARY_DEPTH);
|
878
|
+
LOG_STACK();
|
909
879
|
}
|
910
880
|
|
911
|
-
static
|
912
|
-
|
913
|
-
|
914
|
-
|
915
|
-
|
881
|
+
static void parser__halt_parse(Parser *self) {
|
882
|
+
LOG("halting_parse");
|
883
|
+
LOG_STACK();
|
884
|
+
|
885
|
+
ts_lexer_advance_to_end(&self->lexer);
|
886
|
+
Length remaining_length = length_sub(
|
887
|
+
self->lexer.current_position,
|
888
|
+
ts_stack_position(self->stack, 0)
|
889
|
+
);
|
890
|
+
|
891
|
+
Tree *filler_node = ts_tree_make_error(&self->tree_pool, remaining_length, length_zero(), 0, self->language);
|
892
|
+
filler_node->visible = false;
|
893
|
+
ts_stack_push(self->stack, 0, filler_node, false, 0);
|
894
|
+
|
895
|
+
TreeArray children = array_new();
|
896
|
+
Tree *root_error = ts_tree_make_error_node(&self->tree_pool, &children, self->language);
|
897
|
+
ts_stack_push(self->stack, 0, root_error, false, 0);
|
916
898
|
|
899
|
+
Tree *eof = ts_tree_make_leaf(&self->tree_pool, ts_builtin_sym_end, length_zero(), length_zero(), self->language);
|
900
|
+
parser__accept(self, 0, eof);
|
901
|
+
ts_tree_release(&self->tree_pool, eof);
|
902
|
+
}
|
903
|
+
|
904
|
+
static bool parser__recover_to_state(Parser *self, StackVersion version, unsigned depth,
|
905
|
+
TSStateId goal_state) {
|
906
|
+
StackSliceArray pop = ts_stack_pop_count(self->stack, version, depth);
|
917
907
|
StackVersion previous_version = STACK_VERSION_NONE;
|
918
|
-
|
919
|
-
|
908
|
+
|
909
|
+
for (unsigned i = 0; i < pop.size; i++) {
|
910
|
+
StackSlice slice = pop.contents[i];
|
911
|
+
|
920
912
|
if (slice.version == previous_version) {
|
921
|
-
ts_tree_array_delete(&slice.trees);
|
913
|
+
ts_tree_array_delete(&self->tree_pool, &slice.trees);
|
914
|
+
array_erase(&pop, i--);
|
915
|
+
continue;
|
916
|
+
}
|
917
|
+
|
918
|
+
if (ts_stack_state(self->stack, slice.version) != goal_state) {
|
919
|
+
ts_stack_halt(self->stack, slice.version);
|
920
|
+
ts_tree_array_delete(&self->tree_pool, &slice.trees);
|
921
|
+
array_erase(&pop, i--);
|
922
922
|
continue;
|
923
923
|
}
|
924
924
|
|
925
|
+
TreeArray error_trees = ts_stack_pop_error(self->stack, slice.version);
|
926
|
+
if (error_trees.size > 0) {
|
927
|
+
assert(error_trees.size == 1);
|
928
|
+
array_splice(&slice.trees, 0, 0, &error_trees.contents[0]->children);
|
929
|
+
for (unsigned j = 0; j < error_trees.contents[0]->children.size; j++) {
|
930
|
+
ts_tree_retain(slice.trees.contents[j]);
|
931
|
+
}
|
932
|
+
ts_tree_array_delete(&self->tree_pool, &error_trees);
|
933
|
+
}
|
934
|
+
|
935
|
+
TreeArray trailing_extras = ts_tree_array_remove_trailing_extras(&slice.trees);
|
936
|
+
|
937
|
+
if (slice.trees.size > 0) {
|
938
|
+
Tree *error = ts_tree_make_error_node(&self->tree_pool, &slice.trees, self->language);
|
939
|
+
error->extra = true;
|
940
|
+
ts_stack_push(self->stack, slice.version, error, false, goal_state);
|
941
|
+
} else {
|
942
|
+
array_delete(&slice.trees);
|
943
|
+
}
|
944
|
+
|
945
|
+
for (unsigned j = 0; j < trailing_extras.size; j++) {
|
946
|
+
Tree *tree = trailing_extras.contents[j];
|
947
|
+
ts_stack_push(self->stack, slice.version, tree, false, goal_state);
|
948
|
+
}
|
949
|
+
|
925
950
|
previous_version = slice.version;
|
926
|
-
|
927
|
-
error->extra = true;
|
928
|
-
TSStateId state = ts_stack_top_state(self->stack, slice.version);
|
929
|
-
parser__push(self, slice.version, error, state);
|
951
|
+
array_delete(&trailing_extras);
|
930
952
|
}
|
931
953
|
|
932
|
-
return
|
954
|
+
return previous_version != STACK_VERSION_NONE;
|
933
955
|
}
|
934
956
|
|
935
|
-
static void
|
936
|
-
|
937
|
-
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
|
957
|
+
static void parser__recover(Parser *self, StackVersion version, Tree *lookahead) {
|
958
|
+
bool did_recover = false;
|
959
|
+
unsigned previous_version_count = ts_stack_version_count(self->stack);
|
960
|
+
Length position = ts_stack_position(self->stack, version);
|
961
|
+
StackSummary *summary = ts_stack_get_summary(self->stack, version);
|
962
|
+
unsigned node_count_since_error = ts_stack_node_count_since_error(self->stack, version);
|
963
|
+
unsigned current_error_cost = ts_stack_error_cost(self->stack, version);
|
964
|
+
|
965
|
+
if (summary && lookahead->symbol != ts_builtin_sym_error) {
|
966
|
+
for (unsigned i = 0; i < summary->size; i++) {
|
967
|
+
StackSummaryEntry entry = summary->contents[i];
|
968
|
+
|
969
|
+
if (entry.state == ERROR_STATE) continue;
|
970
|
+
if (entry.position.bytes == position.bytes) continue;
|
971
|
+
unsigned depth = entry.depth;
|
972
|
+
if (node_count_since_error > 0) depth++;
|
973
|
+
|
974
|
+
bool would_merge = false;
|
975
|
+
for (unsigned j = 0; j < previous_version_count; j++) {
|
976
|
+
if (
|
977
|
+
ts_stack_state(self->stack, j) == entry.state &&
|
978
|
+
ts_stack_position(self->stack, j).bytes == position.bytes
|
979
|
+
) {
|
980
|
+
would_merge = true;
|
981
|
+
break;
|
982
|
+
}
|
983
|
+
}
|
946
984
|
|
947
|
-
|
985
|
+
if (would_merge) continue;
|
948
986
|
|
949
|
-
|
950
|
-
|
951
|
-
|
952
|
-
|
953
|
-
|
954
|
-
|
955
|
-
}
|
987
|
+
unsigned new_cost =
|
988
|
+
current_error_cost +
|
989
|
+
entry.depth * ERROR_COST_PER_SKIPPED_TREE +
|
990
|
+
(position.bytes - entry.position.bytes) * ERROR_COST_PER_SKIPPED_CHAR +
|
991
|
+
(position.extent.row - entry.position.extent.row) * ERROR_COST_PER_SKIPPED_LINE;
|
992
|
+
if (parser__better_version_exists(self, version, false, new_cost)) break;
|
956
993
|
|
957
|
-
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
|
962
|
-
|
963
|
-
|
964
|
-
} else {
|
965
|
-
v++;
|
994
|
+
if (ts_language_has_actions(self->language, entry.state, lookahead->symbol)) {
|
995
|
+
if (parser__recover_to_state(self, version, depth, entry.state)) {
|
996
|
+
did_recover = true;
|
997
|
+
LOG("recover_to_previous state:%u, depth:%u", entry.state, depth);
|
998
|
+
LOG_STACK();
|
999
|
+
break;
|
1000
|
+
}
|
966
1001
|
}
|
967
1002
|
}
|
968
1003
|
}
|
969
1004
|
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
1005
|
+
for (unsigned i = previous_version_count; i < ts_stack_version_count(self->stack); i++) {
|
1006
|
+
if (!ts_stack_is_active(self->stack, i)) {
|
1007
|
+
ts_stack_remove_version(self->stack, i--);
|
1008
|
+
}
|
1009
|
+
}
|
1010
|
+
|
1011
|
+
if (did_recover && ts_stack_version_count(self->stack) > MAX_VERSION_COUNT) {
|
1012
|
+
ts_stack_halt(self->stack, version);
|
1013
|
+
return;
|
976
1014
|
}
|
977
|
-
}
|
978
1015
|
|
979
|
-
static void parser__recover(Parser *self, StackVersion version, TSStateId state,
|
980
|
-
Tree *lookahead) {
|
981
1016
|
if (lookahead->symbol == ts_builtin_sym_end) {
|
982
1017
|
LOG("recover_eof");
|
983
1018
|
TreeArray children = array_new();
|
984
|
-
Tree *parent = ts_tree_make_error_node(&children);
|
985
|
-
|
1019
|
+
Tree *parent = ts_tree_make_error_node(&self->tree_pool, &children, self->language);
|
1020
|
+
ts_stack_push(self->stack, version, parent, false, 1);
|
986
1021
|
parser__accept(self, version, lookahead);
|
1022
|
+
return;
|
987
1023
|
}
|
988
1024
|
|
989
|
-
|
1025
|
+
unsigned new_cost =
|
1026
|
+
current_error_cost + ERROR_COST_PER_SKIPPED_TREE +
|
1027
|
+
ts_tree_total_bytes(lookahead) * ERROR_COST_PER_SKIPPED_CHAR +
|
1028
|
+
ts_tree_total_size(lookahead).extent.row * ERROR_COST_PER_SKIPPED_LINE;
|
990
1029
|
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
self, new_version, ERROR_STATE, lookahead,
|
995
|
-
ts_language_symbol_metadata(self->language, lookahead->symbol).extra);
|
996
|
-
ErrorStatus error_status = ts_stack_error_status(self->stack, new_version);
|
997
|
-
if (parser__better_version_exists(self, version, error_status)) {
|
998
|
-
ts_stack_remove_version(self->stack, new_version);
|
999
|
-
LOG("bail_on_recovery");
|
1030
|
+
if (parser__better_version_exists(self, version, false, new_cost)) {
|
1031
|
+
ts_stack_halt(self->stack, version);
|
1032
|
+
return;
|
1000
1033
|
}
|
1001
1034
|
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1007
|
-
bool validated_lookahead = false;
|
1008
|
-
Tree *lookahead = parser__get_lookahead(self, version, reusable_node, &validated_lookahead);
|
1035
|
+
unsigned n;
|
1036
|
+
const TSParseAction *actions = ts_language_actions(self->language, 1, lookahead->symbol, &n);
|
1037
|
+
if (n > 0 && actions[n - 1].type == TSParseActionTypeShift && actions[n - 1].params.extra) {
|
1038
|
+
lookahead->extra = true;
|
1039
|
+
}
|
1009
1040
|
|
1010
|
-
|
1011
|
-
|
1041
|
+
LOG("skip_token symbol:%s", SYM_NAME(lookahead->symbol));
|
1042
|
+
ts_tree_retain(lookahead);
|
1043
|
+
TreeArray children = array_new();
|
1044
|
+
array_reserve(&children, 1);
|
1045
|
+
array_push(&children, lookahead);
|
1046
|
+
Tree *error_repeat = ts_tree_make_node(
|
1047
|
+
&self->tree_pool,
|
1048
|
+
ts_builtin_sym_error_repeat,
|
1049
|
+
&children,
|
1050
|
+
0,
|
1051
|
+
self->language
|
1052
|
+
);
|
1012
1053
|
|
1013
|
-
|
1014
|
-
|
1054
|
+
if (node_count_since_error > 0) {
|
1055
|
+
StackSliceArray pop = ts_stack_pop_count(self->stack, version, 1);
|
1056
|
+
assert(pop.size == 1);
|
1057
|
+
assert(pop.contents[0].trees.size == 1);
|
1058
|
+
ts_stack_renumber_version(self->stack, pop.contents[0].version, version);
|
1059
|
+
array_push(&pop.contents[0].trees, error_repeat);
|
1060
|
+
error_repeat = ts_tree_make_node(
|
1061
|
+
&self->tree_pool,
|
1062
|
+
ts_builtin_sym_error_repeat,
|
1063
|
+
&pop.contents[0].trees,
|
1064
|
+
0,
|
1065
|
+
self->language
|
1066
|
+
);
|
1067
|
+
}
|
1015
1068
|
|
1016
|
-
|
1017
|
-
if (!parser__can_reuse(self, state, lookahead, &table_entry)) {
|
1018
|
-
if (lookahead == reusable_node->tree) {
|
1019
|
-
reusable_node_pop_leaf(reusable_node);
|
1020
|
-
} else {
|
1021
|
-
parser__clear_cached_token(self);
|
1022
|
-
}
|
1069
|
+
ts_stack_push(self->stack, version, error_repeat, false, ERROR_STATE);
|
1023
1070
|
|
1024
|
-
|
1025
|
-
|
1026
|
-
|
1027
|
-
|
1071
|
+
if (lookahead->has_external_tokens) {
|
1072
|
+
ts_stack_set_last_external_token(
|
1073
|
+
self->stack, version, ts_tree_last_external_token(lookahead)
|
1074
|
+
);
|
1075
|
+
}
|
1076
|
+
}
|
1028
1077
|
|
1029
|
-
|
1030
|
-
|
1031
|
-
|
1078
|
+
static void parser__advance(Parser *self, StackVersion version, ReusableNode *reusable_node) {
|
1079
|
+
TSStateId state = ts_stack_state(self->stack, version);
|
1080
|
+
TableEntry table_entry;
|
1081
|
+
Tree *lookahead = parser__get_lookahead(self, version, &state, reusable_node, &table_entry);
|
1032
1082
|
|
1033
|
-
|
1083
|
+
for (;;) {
|
1034
1084
|
StackVersion last_reduction_version = STACK_VERSION_NONE;
|
1035
1085
|
|
1036
1086
|
for (uint32_t i = 0; i < table_entry.action_count; i++) {
|
@@ -1038,84 +1088,58 @@ static void parser__advance(Parser *self, StackVersion version,
|
|
1038
1088
|
|
1039
1089
|
switch (action.type) {
|
1040
1090
|
case TSParseActionTypeShift: {
|
1041
|
-
|
1091
|
+
if (action.params.repetition) break;
|
1042
1092
|
TSStateId next_state;
|
1093
|
+
if (action.params.extra) {
|
1094
|
+
|
1095
|
+
// TODO remove when TREE_SITTER_LANGUAGE_VERSION 9 is out.
|
1096
|
+
if (state == ERROR_STATE) continue;
|
1043
1097
|
|
1044
|
-
if (action.extra) {
|
1045
1098
|
next_state = state;
|
1046
1099
|
LOG("shift_extra");
|
1047
1100
|
} else {
|
1048
|
-
next_state = action.params.
|
1101
|
+
next_state = action.params.state;
|
1049
1102
|
LOG("shift state:%u", next_state);
|
1050
1103
|
}
|
1051
1104
|
|
1052
|
-
if (lookahead->
|
1053
|
-
|
1054
|
-
if (!parser__can_reuse(self, state, lookahead, &table_entry)) {
|
1055
|
-
reusable_node_pop(reusable_node);
|
1056
|
-
ts_tree_release(lookahead);
|
1057
|
-
lookahead = parser__get_lookahead(self, version, reusable_node, &validated_lookahead);
|
1058
|
-
}
|
1059
|
-
}
|
1060
|
-
|
1105
|
+
if (lookahead->children.size > 0) {
|
1106
|
+
parser__breakdown_lookahead(self, &lookahead, state, reusable_node);
|
1061
1107
|
next_state = ts_language_next_state(self->language, state, lookahead->symbol);
|
1062
1108
|
}
|
1063
1109
|
|
1064
|
-
parser__shift(self, version, next_state, lookahead, extra);
|
1065
|
-
|
1066
|
-
|
1067
|
-
reusable_node_pop(reusable_node);
|
1068
|
-
|
1069
|
-
ts_tree_release(lookahead);
|
1110
|
+
parser__shift(self, version, next_state, lookahead, action.params.extra);
|
1111
|
+
if (lookahead == reusable_node->tree) reusable_node_pop(reusable_node);
|
1112
|
+
ts_tree_release(&self->tree_pool, lookahead);
|
1070
1113
|
return;
|
1071
1114
|
}
|
1072
1115
|
|
1073
1116
|
case TSParseActionTypeReduce: {
|
1074
|
-
|
1075
|
-
|
1076
|
-
|
1077
|
-
|
1078
|
-
|
1079
|
-
|
1080
|
-
|
1081
|
-
|
1082
|
-
|
1083
|
-
StackPopResult reduction =
|
1084
|
-
parser__reduce(self, version, symbol, child_count, fragile, true);
|
1085
|
-
StackSlice slice = *array_front(&reduction.slices);
|
1086
|
-
if (reduction.stopped_at_error) {
|
1087
|
-
reduction_stopped_at_error = true;
|
1088
|
-
if (!parser__repair_error(self, slice, lookahead->first_leaf.symbol,
|
1089
|
-
table_entry))
|
1090
|
-
break;
|
1091
|
-
}
|
1092
|
-
|
1117
|
+
bool is_fragile = table_entry.action_count > 1;
|
1118
|
+
LOG("reduce sym:%s, child_count:%u", SYM_NAME(action.params.symbol), action.params.child_count);
|
1119
|
+
StackSliceArray reduction = parser__reduce(
|
1120
|
+
self, version, action.params.symbol, action.params.child_count,
|
1121
|
+
action.params.dynamic_precedence, action.params.alias_sequence_id,
|
1122
|
+
is_fragile
|
1123
|
+
);
|
1124
|
+
StackSlice slice = *array_front(&reduction);
|
1093
1125
|
last_reduction_version = slice.version;
|
1094
1126
|
break;
|
1095
1127
|
}
|
1096
1128
|
|
1097
1129
|
case TSParseActionTypeAccept: {
|
1098
|
-
if (ts_stack_error_status(self->stack, version).count > 0)
|
1099
|
-
continue;
|
1100
|
-
|
1101
1130
|
LOG("accept");
|
1102
1131
|
parser__accept(self, version, lookahead);
|
1103
|
-
ts_tree_release(lookahead);
|
1132
|
+
ts_tree_release(&self->tree_pool, lookahead);
|
1104
1133
|
return;
|
1105
1134
|
}
|
1106
1135
|
|
1107
1136
|
case TSParseActionTypeRecover: {
|
1108
|
-
while (lookahead->
|
1109
|
-
|
1110
|
-
ts_tree_release(lookahead);
|
1111
|
-
lookahead = reusable_node->tree;
|
1112
|
-
ts_tree_retain(lookahead);
|
1137
|
+
while (lookahead->children.size > 0) {
|
1138
|
+
parser__breakdown_lookahead(self, &lookahead, state, reusable_node);
|
1113
1139
|
}
|
1114
|
-
|
1115
|
-
|
1116
|
-
|
1117
|
-
reusable_node_pop(reusable_node);
|
1118
|
-
ts_tree_release(lookahead);
|
1140
|
+
parser__recover(self, version, lookahead);
|
1141
|
+
if (lookahead == reusable_node->tree) reusable_node_pop(reusable_node);
|
1142
|
+
ts_tree_release(&self->tree_pool, lookahead);
|
1119
1143
|
return;
|
1120
1144
|
}
|
1121
1145
|
}
|
@@ -1124,35 +1148,116 @@ static void parser__advance(Parser *self, StackVersion version,
|
|
1124
1148
|
if (last_reduction_version != STACK_VERSION_NONE) {
|
1125
1149
|
ts_stack_renumber_version(self->stack, last_reduction_version, version);
|
1126
1150
|
LOG_STACK();
|
1127
|
-
|
1151
|
+
} else if (state == ERROR_STATE) {
|
1152
|
+
parser__recover(self, version, lookahead);
|
1153
|
+
ts_tree_release(&self->tree_pool, lookahead);
|
1154
|
+
return;
|
1155
|
+
} else if (!parser__breakdown_top_of_stack(self, version)) {
|
1156
|
+
LOG("detect_error");
|
1157
|
+
ts_stack_pause(self->stack, version, lookahead->first_leaf.symbol);
|
1158
|
+
ts_tree_release(&self->tree_pool, lookahead);
|
1159
|
+
return;
|
1128
1160
|
}
|
1129
1161
|
|
1130
|
-
|
1162
|
+
state = ts_stack_state(self->stack, version);
|
1163
|
+
ts_language_table_entry(self->language, state, lookahead->first_leaf.symbol, &table_entry);
|
1164
|
+
}
|
1165
|
+
}
|
1166
|
+
|
1167
|
+
static unsigned parser__condense_stack(Parser *self) {
|
1168
|
+
bool made_changes = false;
|
1169
|
+
unsigned min_error_cost = UINT_MAX;
|
1170
|
+
for (StackVersion i = 0; i < ts_stack_version_count(self->stack); i++) {
|
1171
|
+
if (ts_stack_is_halted(self->stack, i)) {
|
1172
|
+
ts_stack_remove_version(self->stack, i);
|
1173
|
+
i--;
|
1131
1174
|
continue;
|
1132
1175
|
}
|
1133
1176
|
|
1134
|
-
|
1135
|
-
|
1136
|
-
|
1177
|
+
ErrorStatus status_i = parser__version_status(self, i);
|
1178
|
+
if (!status_i.is_in_error && status_i.cost < min_error_cost) {
|
1179
|
+
min_error_cost = status_i.cost;
|
1137
1180
|
}
|
1138
1181
|
|
1139
|
-
|
1182
|
+
for (StackVersion j = 0; j < i; j++) {
|
1183
|
+
ErrorStatus status_j = parser__version_status(self, j);
|
1140
1184
|
|
1141
|
-
|
1142
|
-
|
1143
|
-
|
1185
|
+
switch (parser__compare_versions(self, status_j, status_i)) {
|
1186
|
+
case ErrorComparisonTakeLeft:
|
1187
|
+
made_changes = true;
|
1188
|
+
ts_stack_remove_version(self->stack, i);
|
1189
|
+
i--;
|
1190
|
+
j = i;
|
1191
|
+
break;
|
1192
|
+
case ErrorComparisonPreferLeft:
|
1193
|
+
case ErrorComparisonNone:
|
1194
|
+
if (ts_stack_merge(self->stack, j, i)) {
|
1195
|
+
made_changes = true;
|
1196
|
+
i--;
|
1197
|
+
j = i;
|
1198
|
+
}
|
1199
|
+
break;
|
1200
|
+
case ErrorComparisonPreferRight:
|
1201
|
+
made_changes = true;
|
1202
|
+
if (ts_stack_merge(self->stack, j, i)) {
|
1203
|
+
i--;
|
1204
|
+
j = i;
|
1205
|
+
} else {
|
1206
|
+
ts_stack_swap_versions(self->stack, i, j);
|
1207
|
+
}
|
1208
|
+
break;
|
1209
|
+
case ErrorComparisonTakeRight:
|
1210
|
+
made_changes = true;
|
1211
|
+
ts_stack_remove_version(self->stack, j);
|
1212
|
+
i--;
|
1213
|
+
j--;
|
1214
|
+
break;
|
1215
|
+
}
|
1216
|
+
}
|
1217
|
+
}
|
1218
|
+
|
1219
|
+
while (ts_stack_version_count(self->stack) > MAX_VERSION_COUNT) {
|
1220
|
+
ts_stack_remove_version(self->stack, MAX_VERSION_COUNT);
|
1221
|
+
made_changes = true;
|
1222
|
+
}
|
1223
|
+
|
1224
|
+
if (ts_stack_version_count(self->stack) > 0) {
|
1225
|
+
bool has_unpaused_version = false;
|
1226
|
+
for (StackVersion i = 0, n = ts_stack_version_count(self->stack); i < n; i++) {
|
1227
|
+
if (ts_stack_is_paused(self->stack, i)) {
|
1228
|
+
if (!has_unpaused_version && self->accept_count < MAX_VERSION_COUNT) {
|
1229
|
+
LOG("resume version:%u", i);
|
1230
|
+
min_error_cost = ts_stack_error_cost(self->stack, i);
|
1231
|
+
TSSymbol lookahead_symbol = ts_stack_resume(self->stack, i);
|
1232
|
+
parser__handle_error(self, i, lookahead_symbol);
|
1233
|
+
has_unpaused_version = true;
|
1234
|
+
} else {
|
1235
|
+
ts_stack_remove_version(self->stack, i);
|
1236
|
+
i--;
|
1237
|
+
n--;
|
1238
|
+
}
|
1239
|
+
} else {
|
1240
|
+
has_unpaused_version = true;
|
1241
|
+
}
|
1144
1242
|
}
|
1145
1243
|
}
|
1244
|
+
|
1245
|
+
if (made_changes) {
|
1246
|
+
LOG("condense");
|
1247
|
+
LOG_STACK();
|
1248
|
+
}
|
1249
|
+
|
1250
|
+
return min_error_cost;
|
1146
1251
|
}
|
1147
1252
|
|
1148
1253
|
bool parser_init(Parser *self) {
|
1149
1254
|
ts_lexer_init(&self->lexer);
|
1150
1255
|
array_init(&self->reduce_actions);
|
1151
|
-
|
1152
|
-
|
1153
|
-
|
1154
|
-
self->stack = ts_stack_new();
|
1256
|
+
array_reserve(&self->reduce_actions, 4);
|
1257
|
+
ts_tree_pool_init(&self->tree_pool);
|
1258
|
+
self->stack = ts_stack_new(&self->tree_pool);
|
1155
1259
|
self->finished_tree = NULL;
|
1260
|
+
parser__set_cached_token(self, 0, NULL, NULL);
|
1156
1261
|
return true;
|
1157
1262
|
}
|
1158
1263
|
|
@@ -1173,14 +1278,11 @@ void parser_destroy(Parser *self) {
|
|
1173
1278
|
ts_stack_delete(self->stack);
|
1174
1279
|
if (self->reduce_actions.contents)
|
1175
1280
|
array_delete(&self->reduce_actions);
|
1176
|
-
|
1177
|
-
array_delete(&self->tree_path1);
|
1178
|
-
if (self->tree_path2.contents)
|
1179
|
-
array_delete(&self->tree_path2);
|
1281
|
+
ts_tree_pool_delete(&self->tree_pool);
|
1180
1282
|
parser_set_language(self, NULL);
|
1181
1283
|
}
|
1182
1284
|
|
1183
|
-
Tree *parser_parse(Parser *self, TSInput input, Tree *old_tree) {
|
1285
|
+
Tree *parser_parse(Parser *self, TSInput input, Tree *old_tree, bool halt_on_error) {
|
1184
1286
|
parser__start(self, input, old_tree);
|
1185
1287
|
|
1186
1288
|
StackVersion version = STACK_VERSION_NONE;
|
@@ -1190,38 +1292,43 @@ Tree *parser_parse(Parser *self, TSInput input, Tree *old_tree) {
|
|
1190
1292
|
do {
|
1191
1293
|
for (version = 0; version < ts_stack_version_count(self->stack); version++) {
|
1192
1294
|
reusable_node = self->reusable_node;
|
1193
|
-
last_position = position;
|
1194
|
-
|
1195
|
-
while (!ts_stack_is_halted(self->stack, version)) {
|
1196
|
-
position = ts_stack_top_position(self->stack, version).chars;
|
1197
|
-
if (position > last_position || (version > 0 && position == last_position))
|
1198
|
-
break;
|
1199
1295
|
|
1296
|
+
while (ts_stack_is_active(self->stack, version)) {
|
1200
1297
|
LOG("process version:%d, version_count:%u, state:%d, row:%u, col:%u",
|
1201
1298
|
version, ts_stack_version_count(self->stack),
|
1202
|
-
|
1203
|
-
|
1204
|
-
|
1299
|
+
ts_stack_state(self->stack, version),
|
1300
|
+
ts_stack_position(self->stack, version).extent.row,
|
1301
|
+
ts_stack_position(self->stack, version).extent.column);
|
1205
1302
|
|
1206
1303
|
parser__advance(self, version, &reusable_node);
|
1207
1304
|
LOG_STACK();
|
1305
|
+
|
1306
|
+
position = ts_stack_position(self->stack, version).bytes;
|
1307
|
+
if (position > last_position || (version > 0 && position == last_position)) {
|
1308
|
+
last_position = position;
|
1309
|
+
break;
|
1310
|
+
}
|
1208
1311
|
}
|
1209
1312
|
}
|
1210
1313
|
|
1211
1314
|
self->reusable_node = reusable_node;
|
1212
1315
|
|
1213
|
-
|
1214
|
-
|
1215
|
-
|
1316
|
+
unsigned min_error_cost = parser__condense_stack(self);
|
1317
|
+
if (self->finished_tree && self->finished_tree->error_cost < min_error_cost) {
|
1318
|
+
break;
|
1319
|
+
} else if (halt_on_error && min_error_cost > 0) {
|
1320
|
+
parser__halt_parse(self);
|
1321
|
+
break;
|
1216
1322
|
}
|
1217
1323
|
|
1218
|
-
self->
|
1324
|
+
self->in_ambiguity = version > 1;
|
1219
1325
|
} while (version != 0);
|
1220
1326
|
|
1327
|
+
ts_stack_clear(self->stack);
|
1328
|
+
parser__set_cached_token(self, 0, NULL, NULL);
|
1329
|
+
ts_tree_assign_parents(self->finished_tree, &self->tree_pool, self->language);
|
1330
|
+
|
1221
1331
|
LOG("done");
|
1222
1332
|
LOG_TREE();
|
1223
|
-
ts_stack_clear(self->stack);
|
1224
|
-
parser__clear_cached_token(self);
|
1225
|
-
ts_tree_assign_parents(self->finished_tree, &self->tree_path1);
|
1226
1333
|
return self->finished_tree;
|
1227
1334
|
}
|