From 507b60bc454647a29f8afab8896acaba7283d6d3 Mon Sep 17 00:00:00 2001 From: Wilfred Hughes Date: Fri, 20 Dec 2024 08:49:09 -0800 Subject: [PATCH] Use tree-sitter-json from crates.io --- CHANGELOG.md | 4 +- Cargo.lock | 11 + Cargo.toml | 1 + build.rs | 5 - src/parse/tree_sitter_parser.rs | 12 +- vendored_parsers/highlights/json.scm | 1 - vendored_parsers/tree-sitter-json-src | 1 - .../tree-sitter-json/.eslintrc.js | 20 - .../tree-sitter-json/.gitattributes | 10 - .../tree-sitter-json/.github/workflows/ci.yml | 24 - .../.github/workflows/lint.yml | 19 - .../.github/workflows/publish.yml | 103 -- vendored_parsers/tree-sitter-json/.gitignore | 6 - vendored_parsers/tree-sitter-json/.npmignore | 5 - vendored_parsers/tree-sitter-json/Cargo.toml | 24 - vendored_parsers/tree-sitter-json/LICENSE | 21 - vendored_parsers/tree-sitter-json/Makefile | 114 -- .../tree-sitter-json/Package.swift | 36 - vendored_parsers/tree-sitter-json/README.md | 5 - vendored_parsers/tree-sitter-json/binding.gyp | 18 - .../bindings/c/tree-sitter.h.in | 16 - .../bindings/c/tree-sitter.pc.in | 11 - .../tree-sitter-json/bindings/node/binding.cc | 28 - .../tree-sitter-json/bindings/node/index.js | 19 - .../tree-sitter-json/bindings/rust/README.md | 37 - .../tree-sitter-json/bindings/rust/build.rs | 40 - .../tree-sitter-json/bindings/rust/lib.rs | 51 - .../bindings/swift/TreeSitterJSON/json.h | 16 - .../tree-sitter-json/corpus/main.txt | 142 --- vendored_parsers/tree-sitter-json/grammar.js | 127 -- .../tree-sitter-json/package.json | 37 - .../tree-sitter-json/queries/highlights.scm | 16 - .../tree-sitter-json/src/grammar.json | 535 -------- .../tree-sitter-json/src/node-types.json | 193 --- .../tree-sitter-json/src/parser.c | 1086 ----------------- .../tree-sitter-json/src/tree_sitter/parser.h | 224 ---- 36 files changed, 19 insertions(+), 2999 deletions(-) delete mode 120000 vendored_parsers/highlights/json.scm delete mode 120000 vendored_parsers/tree-sitter-json-src delete mode 100644 vendored_parsers/tree-sitter-json/.eslintrc.js delete mode 100644 vendored_parsers/tree-sitter-json/.gitattributes delete mode 100644 vendored_parsers/tree-sitter-json/.github/workflows/ci.yml delete mode 100644 vendored_parsers/tree-sitter-json/.github/workflows/lint.yml delete mode 100644 vendored_parsers/tree-sitter-json/.github/workflows/publish.yml delete mode 100644 vendored_parsers/tree-sitter-json/.gitignore delete mode 100644 vendored_parsers/tree-sitter-json/.npmignore delete mode 100644 vendored_parsers/tree-sitter-json/Cargo.toml delete mode 100644 vendored_parsers/tree-sitter-json/LICENSE delete mode 100644 vendored_parsers/tree-sitter-json/Makefile delete mode 100644 vendored_parsers/tree-sitter-json/Package.swift delete mode 100644 vendored_parsers/tree-sitter-json/README.md delete mode 100644 vendored_parsers/tree-sitter-json/binding.gyp delete mode 100644 vendored_parsers/tree-sitter-json/bindings/c/tree-sitter.h.in delete mode 100644 vendored_parsers/tree-sitter-json/bindings/c/tree-sitter.pc.in delete mode 100644 vendored_parsers/tree-sitter-json/bindings/node/binding.cc delete mode 100644 vendored_parsers/tree-sitter-json/bindings/node/index.js delete mode 100644 vendored_parsers/tree-sitter-json/bindings/rust/README.md delete mode 100644 vendored_parsers/tree-sitter-json/bindings/rust/build.rs delete mode 100644 vendored_parsers/tree-sitter-json/bindings/rust/lib.rs delete mode 100644 vendored_parsers/tree-sitter-json/bindings/swift/TreeSitterJSON/json.h delete mode 100644 vendored_parsers/tree-sitter-json/corpus/main.txt delete mode 100644 vendored_parsers/tree-sitter-json/grammar.js delete mode 100644 vendored_parsers/tree-sitter-json/package.json delete mode 100644 vendored_parsers/tree-sitter-json/queries/highlights.scm delete mode 100644 vendored_parsers/tree-sitter-json/src/grammar.json delete mode 100644 vendored_parsers/tree-sitter-json/src/node-types.json delete mode 100644 vendored_parsers/tree-sitter-json/src/parser.c delete mode 100644 vendored_parsers/tree-sitter-json/src/tree_sitter/parser.h diff --git a/CHANGELOG.md b/CHANGELOG.md index a370ce84a5..e5301c59d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,8 +11,8 @@ with YAML. Improved language detection when one argument is a named pipe. Updated to the latest tree-sitter parser for Bash, C, C++, C#, Go, -Haskell, Java, JavaScript, Julia, Objective-C, OCaml, PHP, Python, Ruby, -Scala and TypeScript. +Haskell, Java, JavaScript, JSON, Julia, Objective-C, OCaml, PHP, +Python, Ruby, Scala and TypeScript. ### Syntax Highlighting diff --git a/Cargo.lock b/Cargo.lock index 45ad6f5460..9ecff2d5e9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -257,6 +257,7 @@ dependencies = [ "tree-sitter-haskell", "tree-sitter-java", "tree-sitter-javascript", + "tree-sitter-json", "tree-sitter-julia", "tree-sitter-language", "tree-sitter-objc", @@ -1097,6 +1098,16 @@ dependencies = [ "tree-sitter-language", ] +[[package]] +name = "tree-sitter-json" +version = "0.24.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d727acca406c0020cffc6cf35516764f36c8e3dc4408e5ebe2cb35a947ec471" +dependencies = [ + "cc", + "tree-sitter-language", +] + [[package]] name = "tree-sitter-julia" version = "0.23.1" diff --git a/Cargo.toml b/Cargo.toml index df96704469..a7c471870d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -94,6 +94,7 @@ tree-sitter-julia = "0.23.1" tree-sitter-go = "0.23.4" tree-sitter-bash = "0.23.3" tree-sitter-php = "0.23.11" +tree-sitter-json = "0.24.8" [dev-dependencies] # assert_cmd 2.0.10 requires predicates 3. diff --git a/build.rs b/build.rs index 9cec326751..311502cee8 100644 --- a/build.rs +++ b/build.rs @@ -164,11 +164,6 @@ fn main() { src_dir: "vendored_parsers/tree-sitter-janet-simple-src", extra_files: vec!["scanner.c"], }, - TreeSitterParser { - name: "tree-sitter-json", - src_dir: "vendored_parsers/tree-sitter-json-src", - extra_files: vec![], - }, TreeSitterParser { name: "tree-sitter-kotlin", src_dir: "vendored_parsers/tree-sitter-kotlin-src", diff --git a/src/parse/tree_sitter_parser.rs b/src/parse/tree_sitter_parser.rs index 051f7d4f66..f29b8182b8 100644 --- a/src/parse/tree_sitter_parser.rs +++ b/src/parse/tree_sitter_parser.rs @@ -81,7 +81,6 @@ extern "C" { fn tree_sitter_hcl() -> ts::Language; fn tree_sitter_html() -> ts::Language; fn tree_sitter_janet_simple() -> ts::Language; - fn tree_sitter_json() -> ts::Language; fn tree_sitter_kotlin() -> ts::Language; fn tree_sitter_latex() -> ts::Language; fn tree_sitter_lua() -> ts::Language; @@ -617,16 +616,15 @@ pub(crate) fn from_language(language: guess::Language) -> TreeSitterConfig { } } Json => { - let language = unsafe { tree_sitter_json() }; + let language_fn = tree_sitter_json::LANGUAGE; + let language = tree_sitter::Language::new(language_fn); + TreeSitterConfig { language: language.clone(), atom_nodes: vec!["string"].into_iter().collect(), delimiter_tokens: vec![("{", "}"), ("[", "]")], - highlight_query: ts::Query::new( - &language, - include_str!("../../vendored_parsers/highlights/json.scm"), - ) - .unwrap(), + highlight_query: ts::Query::new(&language, tree_sitter_json::HIGHLIGHTS_QUERY) + .unwrap(), sub_languages: vec![], } } diff --git a/vendored_parsers/highlights/json.scm b/vendored_parsers/highlights/json.scm deleted file mode 120000 index 4a59f22c0e..0000000000 --- a/vendored_parsers/highlights/json.scm +++ /dev/null @@ -1 +0,0 @@ -../tree-sitter-json/queries/highlights.scm \ No newline at end of file diff --git a/vendored_parsers/tree-sitter-json-src b/vendored_parsers/tree-sitter-json-src deleted file mode 120000 index 4f9ada837c..0000000000 --- a/vendored_parsers/tree-sitter-json-src +++ /dev/null @@ -1 +0,0 @@ -tree-sitter-json/src \ No newline at end of file diff --git a/vendored_parsers/tree-sitter-json/.eslintrc.js b/vendored_parsers/tree-sitter-json/.eslintrc.js deleted file mode 100644 index b2e707a9e7..0000000000 --- a/vendored_parsers/tree-sitter-json/.eslintrc.js +++ /dev/null @@ -1,20 +0,0 @@ -module.exports = { - 'env': { - 'commonjs': true, - 'es2021': true, - }, - 'extends': 'google', - 'overrides': [ - ], - 'parserOptions': { - 'ecmaVersion': 'latest', - 'sourceType': 'module', - }, - 'rules': { - 'indent': ['error', 2, {'SwitchCase': 1}], - 'max-len': [ - 'error', - {'code': 120, 'ignoreComments': true, 'ignoreUrls': true, 'ignoreStrings': true}, - ], - }, -}; diff --git a/vendored_parsers/tree-sitter-json/.gitattributes b/vendored_parsers/tree-sitter-json/.gitattributes deleted file mode 100644 index 1491f7e120..0000000000 --- a/vendored_parsers/tree-sitter-json/.gitattributes +++ /dev/null @@ -1,10 +0,0 @@ -/src/** linguist-vendored -/examples/* linguist-vendored - -src/grammar.json linguist-generated -src/node-types.json linguist-generated -src/parser.c linguist-generated - -src/grammar.json -diff -src/node-types.json -diff -src/parser.c -diff diff --git a/vendored_parsers/tree-sitter-json/.github/workflows/ci.yml b/vendored_parsers/tree-sitter-json/.github/workflows/ci.yml deleted file mode 100644 index c739904aac..0000000000 --- a/vendored_parsers/tree-sitter-json/.github/workflows/ci.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: CI - -on: - push: - branches: - - master - pull_request: - branches: - - master - -jobs: - test: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: true - matrix: - os: [macos-latest, ubuntu-latest, windows-latest] - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: 18 - - run: npm install - - run: npm test diff --git a/vendored_parsers/tree-sitter-json/.github/workflows/lint.yml b/vendored_parsers/tree-sitter-json/.github/workflows/lint.yml deleted file mode 100644 index d94f7f39d2..0000000000 --- a/vendored_parsers/tree-sitter-json/.github/workflows/lint.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: Lint - -on: - push: - branches: - - master - pull_request: - branches: - - "**" - -jobs: - lint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Install modules - run: npm install - - name: Run ESLint - run: npm run lint diff --git a/vendored_parsers/tree-sitter-json/.github/workflows/publish.yml b/vendored_parsers/tree-sitter-json/.github/workflows/publish.yml deleted file mode 100644 index c2020e92fe..0000000000 --- a/vendored_parsers/tree-sitter-json/.github/workflows/publish.yml +++ /dev/null @@ -1,103 +0,0 @@ -name: Release - -on: - workflow_run: - workflows: ["CI"] - branches: - - master - types: - - completed - -jobs: - release: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Get previous commit SHA - id: get_previous_commit - run: | - LATEST_TAG=$(git describe --tags --abbrev=0) - if [[ -z "$LATEST_TAG" ]]; then - echo "No tag found. Failing..." - exit 1 - fi - echo "latest_tag=${LATEST_TAG#v}" >> "$GITHUB_ENV" # Remove 'v' prefix from the tag - - - name: Check if version changed and is greater than the previous - id: version_check - run: | - # Compare the current version with the version from the previous commit - PREVIOUS_NPM_VERSION=${{ env.latest_tag }} - CURRENT_NPM_VERSION=$(jq -r '.version' package.json) - CURRENT_CARGO_VERSION=$(awk -F '"' '/^version/ {print $2}' Cargo.toml) - if [[ "$CURRENT_NPM_VERSION" != "$CURRENT_CARGO_VERSION" ]]; then # Cargo.toml and package.json versions must match - echo "Mismatch: NPM version ($CURRENT_NPM_VERSION) and Cargo.toml version ($CURRENT_CARGO_VERSION)" - echo "version_changed=false" >> "$GITHUB_ENV" - else - if [[ "$PREVIOUS_NPM_VERSION" == "$CURRENT_NPM_VERSION" ]]; then - echo "version_changed=" >> "$GITHUB_ENV" - else - IFS='.' read -ra PREVIOUS_VERSION_PARTS <<< "$PREVIOUS_NPM_VERSION" - IFS='.' read -ra CURRENT_VERSION_PARTS <<< "$CURRENT_NPM_VERSION" - VERSION_CHANGED=false - for i in "${!PREVIOUS_VERSION_PARTS[@]}"; do - if [[ ${CURRENT_VERSION_PARTS[i]} -gt ${PREVIOUS_VERSION_PARTS[i]} ]]; then - VERSION_CHANGED=true - break - elif [[ ${CURRENT_VERSION_PARTS[i]} -lt ${PREVIOUS_VERSION_PARTS[i]} ]]; then - break - fi - done - - echo "version_changed=$VERSION_CHANGED" >> "$GITHUB_ENV" - echo "current_version=${CURRENT_NPM_VERSION}" >> "$GITHUB_ENV" - fi - fi - - - name: Display result - run: | - echo "Version bump detected: ${{ env.version_changed }}" - - - name: Fail if version is lower - if: env.version_changed == 'false' - run: exit 1 - - - name: Setup Node - if: env.version_changed == 'true' - uses: actions/setup-node@v3 - with: - node-version: 18 - registry-url: "https://registry.npmjs.org" - - name: Publish to NPM - if: env.version_changed == 'true' - env: - NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} - run: npm publish - - - name: Setup Rust - if: env.version_changed == 'true' - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - - name: Publish to Crates.io - if: env.version_changed == 'true' - uses: katyo/publish-crates@v2 - with: - registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }} - - - name: Tag versions - if: env.version_changed == 'true' - run: | - git checkout master - git config user.name github-actions[bot] - git config user.email github-actions[bot]@users.noreply.github.com - git tag -d "v${{ env.current_version }}" || true - git push origin --delete "v${{ env.current_version }}" || true - git tag -a "v${{ env.current_version }}" -m "Version ${{ env.current_version }}" - git push origin "v${{ env.current_version }}" diff --git a/vendored_parsers/tree-sitter-json/.gitignore b/vendored_parsers/tree-sitter-json/.gitignore deleted file mode 100644 index bd77f411ad..0000000000 --- a/vendored_parsers/tree-sitter-json/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -Cargo.lock -node_modules -build -package-lock.json -/target/ -.build/ \ No newline at end of file diff --git a/vendored_parsers/tree-sitter-json/.npmignore b/vendored_parsers/tree-sitter-json/.npmignore deleted file mode 100644 index 194ff8451e..0000000000 --- a/vendored_parsers/tree-sitter-json/.npmignore +++ /dev/null @@ -1,5 +0,0 @@ -/test -/examples -/build -/script -/target diff --git a/vendored_parsers/tree-sitter-json/Cargo.toml b/vendored_parsers/tree-sitter-json/Cargo.toml deleted file mode 100644 index b07383946b..0000000000 --- a/vendored_parsers/tree-sitter-json/Cargo.toml +++ /dev/null @@ -1,24 +0,0 @@ -[package] -name = "tree-sitter-json" -description = "JSON grammar for tree-sitter" -version = "0.20.1" -authors = ["Max Brunsfeld "] -license = "MIT" -readme = "bindings/rust/README.md" -keywords = ["incremental", "parsing", "json"] -categories = ["parsing", "text-editors"] -repository = "https://github.com/tree-sitter/tree-sitter-json" -edition = "2021" -autoexamples = false - -build = "bindings/rust/build.rs" -include = ["bindings/rust/*", "grammar.js", "queries/*", "src/*"] - -[lib] -path = "bindings/rust/lib.rs" - -[dependencies] -tree-sitter = "~0.20.10" - -[build-dependencies] -cc = "~1.0.83" diff --git a/vendored_parsers/tree-sitter-json/LICENSE b/vendored_parsers/tree-sitter-json/LICENSE deleted file mode 100644 index 4b52d191ce..0000000000 --- a/vendored_parsers/tree-sitter-json/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2014 Max Brunsfeld - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/vendored_parsers/tree-sitter-json/Makefile b/vendored_parsers/tree-sitter-json/Makefile deleted file mode 100644 index 5772f7a62e..0000000000 --- a/vendored_parsers/tree-sitter-json/Makefile +++ /dev/null @@ -1,114 +0,0 @@ -VERSION := 0.19.0 - -# Repository -SRC_DIR := src - -PARSER_REPO_URL := $(shell git -C $(SRC_DIR) remote get-url origin ) - -ifeq (, $(PARSER_NAME)) - PARSER_NAME := $(shell basename $(PARSER_REPO_URL)) - PARSER_NAME := $(subst tree-sitter-,,$(PARSER_NAME)) - PARSER_NAME := $(subst .git,,$(PARSER_NAME)) -endif - -ifeq (, $(PARSER_URL)) - PARSER_URL := $(subst :,/,$(PARSER_REPO_URL)) - PARSER_URL := $(subst git@,https://,$(PARSER_URL)) - PARSER_URL := $(subst .git,,$(PARSER_URL)) -endif - -UPPER_PARSER_NAME := $(shell echo $(PARSER_NAME) | tr a-z A-Z ) - -# install directory layout -PREFIX ?= /usr/local -INCLUDEDIR ?= $(PREFIX)/include -LIBDIR ?= $(PREFIX)/lib -PCLIBDIR ?= $(LIBDIR)/pkgconfig - -# collect C++ sources, and link if necessary -CPPSRC := $(wildcard $(SRC_DIR)/*.cc) - -ifeq (, $(CPPSRC)) - ADDITIONALLIBS := -else - ADDITIONALLIBS := -lc++ -endif - -# collect sources -SRC := $(wildcard $(SRC_DIR)/*.c) -SRC += $(CPPSRC) -OBJ := $(addsuffix .o,$(basename $(SRC))) - -# ABI versioning -SONAME_MAJOR := 0 -SONAME_MINOR := 0 - -CFLAGS ?= -O3 -Wall -Wextra -I$(SRC_DIR) -CXXFLAGS ?= -O3 -Wall -Wextra -I$(SRC_DIR) -override CFLAGS += -std=gnu99 -fPIC -override CXXFLAGS += -fPIC - -# OS-specific bits -ifeq ($(shell uname),Darwin) - SOEXT = dylib - SOEXTVER_MAJOR = $(SONAME_MAJOR).dylib - SOEXTVER = $(SONAME_MAJOR).$(SONAME_MINOR).dylib - LINKSHARED := $(LINKSHARED)-dynamiclib -Wl, - ifneq ($(ADDITIONALLIBS),) - LINKSHARED := $(LINKSHARED)$(ADDITIONALLIBS), - endif - LINKSHARED := $(LINKSHARED)-install_name,$(LIBDIR)/libtree-sitter-$(PARSER_NAME).$(SONAME_MAJOR).dylib,-rpath,@executable_path/../Frameworks -else - SOEXT = so - SOEXTVER_MAJOR = so.$(SONAME_MAJOR) - SOEXTVER = so.$(SONAME_MAJOR).$(SONAME_MINOR) - LINKSHARED := $(LINKSHARED)-shared -Wl, - ifneq ($(ADDITIONALLIBS),) - LINKSHARED := $(LINKSHARED)$(ADDITIONALLIBS), - endif - LINKSHARED := $(LINKSHARED)-soname,libtree-sitter-$(PARSER_NAME).so.$(SONAME_MAJOR) -endif -ifneq (,$(filter $(shell uname),FreeBSD NetBSD DragonFly)) - PCLIBDIR := $(PREFIX)/libdata/pkgconfig -endif - -all: libtree-sitter-$(PARSER_NAME).a libtree-sitter-$(PARSER_NAME).$(SOEXTVER) bindings/c/$(PARSER_NAME).h bindings/c/tree-sitter-$(PARSER_NAME).pc - -libtree-sitter-$(PARSER_NAME).a: $(OBJ) - $(AR) rcs $@ $^ - -libtree-sitter-$(PARSER_NAME).$(SOEXTVER): $(OBJ) - $(CC) $(LDFLAGS) $(LINKSHARED) $^ $(LDLIBS) -o $@ - ln -sf $@ libtree-sitter-$(PARSER_NAME).$(SOEXT) - ln -sf $@ libtree-sitter-$(PARSER_NAME).$(SOEXTVER_MAJOR) - -bindings/c/$(PARSER_NAME).h: - sed -e 's|@UPPER_PARSERNAME@|$(UPPER_PARSER_NAME)|' \ - -e 's|@PARSERNAME@|$(PARSER_NAME)|' \ - bindings/c/tree-sitter.h.in > $@ - -bindings/c/tree-sitter-$(PARSER_NAME).pc: - sed -e 's|@LIBDIR@|$(LIBDIR)|;s|@INCLUDEDIR@|$(INCLUDEDIR)|;s|@VERSION@|$(VERSION)|' \ - -e 's|=$(PREFIX)|=$${prefix}|' \ - -e 's|@PREFIX@|$(PREFIX)|' \ - -e 's|@ADDITIONALLIBS@|$(ADDITIONALLIBS)|' \ - -e 's|@PARSERNAME@|$(PARSER_NAME)|' \ - -e 's|@PARSERURL@|$(PARSER_URL)|' \ - bindings/c/tree-sitter.pc.in > $@ - -install: all - install -d '$(DESTDIR)$(LIBDIR)' - install -m755 libtree-sitter-$(PARSER_NAME).a '$(DESTDIR)$(LIBDIR)'/libtree-sitter-$(PARSER_NAME).a - install -m755 libtree-sitter-$(PARSER_NAME).$(SOEXTVER) '$(DESTDIR)$(LIBDIR)'/libtree-sitter-$(PARSER_NAME).$(SOEXTVER) - ln -sf libtree-sitter-$(PARSER_NAME).$(SOEXTVER) '$(DESTDIR)$(LIBDIR)'/libtree-sitter-$(PARSER_NAME).$(SOEXTVER_MAJOR) - ln -sf libtree-sitter-$(PARSER_NAME).$(SOEXTVER) '$(DESTDIR)$(LIBDIR)'/libtree-sitter-$(PARSER_NAME).$(SOEXT) - install -d '$(DESTDIR)$(INCLUDEDIR)'/tree_sitter - install -m644 bindings/c/$(PARSER_NAME).h '$(DESTDIR)$(INCLUDEDIR)'/tree_sitter/ - install -d '$(DESTDIR)$(PCLIBDIR)' - install -m644 bindings/c/tree-sitter-$(PARSER_NAME).pc '$(DESTDIR)$(PCLIBDIR)'/ - -clean: - rm -f $(OBJ) libtree-sitter-$(PARSER_NAME).a libtree-sitter-$(PARSER_NAME).$(SOEXT) libtree-sitter-$(PARSER_NAME).$(SOEXTVER_MAJOR) libtree-sitter-$(PARSER_NAME).$(SOEXTVER) - rm -f bindings/c/$(PARSER_NAME).h bindings/c/tree-sitter-$(PARSER_NAME).pc - -.PHONY: all install clean diff --git a/vendored_parsers/tree-sitter-json/Package.swift b/vendored_parsers/tree-sitter-json/Package.swift deleted file mode 100644 index 223fc56056..0000000000 --- a/vendored_parsers/tree-sitter-json/Package.swift +++ /dev/null @@ -1,36 +0,0 @@ -// swift-tools-version:5.3 - -import PackageDescription - -let package = Package( - name: "TreeSitterJSON", - platforms: [.macOS(.v10_13), .iOS(.v11)], - products: [ - .library(name: "TreeSitterJSON", targets: ["TreeSitterJSON"]), - ], - dependencies: [], - targets: [ - .target(name: "TreeSitterJSON", - path: ".", - exclude: [ - "binding.gyp", - "bindings", - "Cargo.toml", - "corpus", - "grammar.js", - "LICENSE", - "package.json", - "README.md", - "src/grammar.json", - "src/node-types.json", - ], - sources: [ - "src/parser.c", - ], - resources: [ - .copy("queries") - ], - publicHeadersPath: "bindings/swift", - cSettings: [.headerSearchPath("src")]) - ] -) diff --git a/vendored_parsers/tree-sitter-json/README.md b/vendored_parsers/tree-sitter-json/README.md deleted file mode 100644 index 4af5fb52c1..0000000000 --- a/vendored_parsers/tree-sitter-json/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# tree-sitter-json - -[![CI](https://github.com/tree-sitter/tree-sitter-json/actions/workflows/ci.yml/badge.svg)](https://github.com/tree-sitter/tree-sitter-json/actions/workflows/ci.yml) - -JSON grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter) diff --git a/vendored_parsers/tree-sitter-json/binding.gyp b/vendored_parsers/tree-sitter-json/binding.gyp deleted file mode 100644 index 29498c11cb..0000000000 --- a/vendored_parsers/tree-sitter-json/binding.gyp +++ /dev/null @@ -1,18 +0,0 @@ -{ - "targets": [ - { - "target_name": "tree_sitter_json_binding", - "include_dirs": [ - " - -#ifdef __cplusplus -extern "C" { -#endif - -extern TSLanguage *tree_sitter_@PARSERNAME@(); - -#ifdef __cplusplus -} -#endif - -#endif // TREE_SITTER_@UPPER_PARSERNAME@_H_ diff --git a/vendored_parsers/tree-sitter-json/bindings/c/tree-sitter.pc.in b/vendored_parsers/tree-sitter-json/bindings/c/tree-sitter.pc.in deleted file mode 100644 index 80d60b6db0..0000000000 --- a/vendored_parsers/tree-sitter-json/bindings/c/tree-sitter.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@PREFIX@ -libdir=@LIBDIR@ -includedir=@INCLUDEDIR@ -additionallibs=@ADDITIONALLIBS@ - -Name: tree-sitter-@PARSERNAME@ -Description: A tree-sitter grammar for the @PARSERNAME@ programming language. -URL: @PARSERURL@ -Version: @VERSION@ -Libs: -L${libdir} ${additionallibs} -ltree-sitter-@PARSERNAME@ -Cflags: -I${includedir} diff --git a/vendored_parsers/tree-sitter-json/bindings/node/binding.cc b/vendored_parsers/tree-sitter-json/bindings/node/binding.cc deleted file mode 100644 index a85ba351fd..0000000000 --- a/vendored_parsers/tree-sitter-json/bindings/node/binding.cc +++ /dev/null @@ -1,28 +0,0 @@ -#include "tree_sitter/parser.h" -#include -#include "nan.h" - -using namespace v8; - -extern "C" TSLanguage * tree_sitter_json(); - -namespace { - -NAN_METHOD(New) {} - -void Init(Local exports, Local module) { - Local tpl = Nan::New(New); - tpl->SetClassName(Nan::New("Language").ToLocalChecked()); - tpl->InstanceTemplate()->SetInternalFieldCount(1); - - Local constructor = Nan::GetFunction(tpl).ToLocalChecked(); - Local instance = constructor->NewInstance(Nan::GetCurrentContext()).ToLocalChecked(); - Nan::SetInternalFieldPointer(instance, 0, tree_sitter_json()); - - Nan::Set(instance, Nan::New("name").ToLocalChecked(), Nan::New("json").ToLocalChecked()); - Nan::Set(module, Nan::New("exports").ToLocalChecked(), instance); -} - -NODE_MODULE(tree_sitter_json_binding, Init) - -} // namespace diff --git a/vendored_parsers/tree-sitter-json/bindings/node/index.js b/vendored_parsers/tree-sitter-json/bindings/node/index.js deleted file mode 100644 index 9d40c67d5b..0000000000 --- a/vendored_parsers/tree-sitter-json/bindings/node/index.js +++ /dev/null @@ -1,19 +0,0 @@ -try { - module.exports = require("../../build/Release/tree_sitter_json_binding"); -} catch (error1) { - if (error1.code !== 'MODULE_NOT_FOUND') { - throw error1; - } - try { - module.exports = require("../../build/Debug/tree_sitter_json_binding"); - } catch (error2) { - if (error2.code !== 'MODULE_NOT_FOUND') { - throw error2; - } - throw error1 - } -} - -try { - module.exports.nodeTypeInfo = require("../../src/node-types.json"); -} catch (_) {} diff --git a/vendored_parsers/tree-sitter-json/bindings/rust/README.md b/vendored_parsers/tree-sitter-json/bindings/rust/README.md deleted file mode 100644 index 861b8e1746..0000000000 --- a/vendored_parsers/tree-sitter-json/bindings/rust/README.md +++ /dev/null @@ -1,37 +0,0 @@ -# tree-sitter-json - -This crate provides a JSON grammar for the [tree-sitter][] parsing library. -To use this crate, add it to the `[dependencies]` section of your `Cargo.toml` -file. (Note that you will probably also need to depend on the -[`tree-sitter`][tree-sitter crate] crate to use the parsed result in any useful -way.) - -```toml -[dependencies] -tree-sitter = "0.20.10" -tree-sitter-json = "0.20.1" -``` - -Typically, you will use the [language][language func] function to add this -grammar to a tree-sitter [Parser][], and then use the parser to parse some code: - -```rust -let code = r#" -{ - "name": "tree-sitter-json", - "description": "JSON parsing for tree-sitter", -} -"#; -let mut parser = Parser::new(); -parser.set_language(tree_sitter_json::language()).expect("Error loading JSON grammar"); -let parsed = parser.parse(code, None); -``` - -If you have any questions, please reach out to us in the [tree-sitter -discussions] page. - -[language func]: https://docs.rs/tree-sitter-json/*/tree_sitter_json/fn.language.html -[Parser]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Parser.html -[tree-sitter]: https://tree-sitter.github.io/ -[tree-sitter crate]: https://crates.io/crates/tree-sitter -[tree-sitter discussions]: https://github.com/tree-sitter/tree-sitter/discussions diff --git a/vendored_parsers/tree-sitter-json/bindings/rust/build.rs b/vendored_parsers/tree-sitter-json/bindings/rust/build.rs deleted file mode 100644 index c6061f0995..0000000000 --- a/vendored_parsers/tree-sitter-json/bindings/rust/build.rs +++ /dev/null @@ -1,40 +0,0 @@ -fn main() { - let src_dir = std::path::Path::new("src"); - - let mut c_config = cc::Build::new(); - c_config.include(&src_dir); - c_config - .flag_if_supported("-Wno-unused-parameter") - .flag_if_supported("-Wno-unused-but-set-variable") - .flag_if_supported("-Wno-trigraphs"); - let parser_path = src_dir.join("parser.c"); - c_config.file(&parser_path); - - // If your language uses an external scanner written in C, - // then include this block of code: - - /* - let scanner_path = src_dir.join("scanner.c"); - c_config.file(&scanner_path); - println!("cargo:rerun-if-changed={}", scanner_path.to_str().unwrap()); - */ - - c_config.compile("parser"); - println!("cargo:rerun-if-changed={}", parser_path.to_str().unwrap()); - - // If your language uses an external scanner written in C++, - // then include this block of code: - - /* - let mut cpp_config = cc::Build::new(); - cpp_config.cpp(true); - cpp_config.include(&src_dir); - cpp_config - .flag_if_supported("-Wno-unused-parameter") - .flag_if_supported("-Wno-unused-but-set-variable"); - let scanner_path = src_dir.join("scanner.cc"); - cpp_config.file(&scanner_path); - cpp_config.compile("scanner"); - println!("cargo:rerun-if-changed={}", scanner_path.to_str().unwrap()); - */ -} diff --git a/vendored_parsers/tree-sitter-json/bindings/rust/lib.rs b/vendored_parsers/tree-sitter-json/bindings/rust/lib.rs deleted file mode 100644 index 794f2c2d73..0000000000 --- a/vendored_parsers/tree-sitter-json/bindings/rust/lib.rs +++ /dev/null @@ -1,51 +0,0 @@ -//! This crate provides json language support for the [tree-sitter][] parsing library. -//! -//! Typically, you will use the [language][language func] function to add this language to a -//! tree-sitter [Parser][], and then use the parser to parse some code: -//! -//! ``` -//! let code = ""; -//! let mut parser = tree_sitter::Parser::new(); -//! parser.set_language(tree_sitter_json::language()).expect("Error loading json grammar"); -//! let tree = parser.parse(code, None).unwrap(); -//! ``` -//! -//! [Language]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Language.html -//! [language func]: fn.language.html -//! [Parser]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Parser.html -//! [tree-sitter]: https://tree-sitter.github.io/ - -use tree_sitter::Language; - -extern "C" { - fn tree_sitter_json() -> Language; -} - -/// Get the tree-sitter [Language][] for this grammar. -/// -/// [Language]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Language.html -pub fn language() -> Language { - unsafe { tree_sitter_json() } -} - -/// The content of the [`node-types.json`][] file for this grammar. -/// -/// [`node-types.json`]: https://tree-sitter.github.io/tree-sitter/using-parsers#static-node-types -pub const NODE_TYPES: &'static str = include_str!("../../src/node-types.json"); - -// Uncomment these to include any queries that this grammar contains -pub const HIGHLIGHT_QUERY: &'static str = include_str!("../../queries/highlights.scm"); -// pub const INJECTIONS_QUERY: &'static str = include_str!("../../queries/injections.scm"); -// pub const LOCALS_QUERY: &'static str = include_str!("../../queries/locals.scm"); -// pub const TAGS_QUERY: &'static str = include_str!("../../queries/tags.scm"); - -#[cfg(test)] -mod tests { - #[test] - fn test_can_load_grammar() { - let mut parser = tree_sitter::Parser::new(); - parser - .set_language(super::language()) - .expect("Error loading json language"); - } -} diff --git a/vendored_parsers/tree-sitter-json/bindings/swift/TreeSitterJSON/json.h b/vendored_parsers/tree-sitter-json/bindings/swift/TreeSitterJSON/json.h deleted file mode 100644 index 8e6de69f4e..0000000000 --- a/vendored_parsers/tree-sitter-json/bindings/swift/TreeSitterJSON/json.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef TREE_SITTER_JSON_H_ -#define TREE_SITTER_JSON_H_ - -typedef struct TSLanguage TSLanguage; - -#ifdef __cplusplus -extern "C" { -#endif - -extern TSLanguage *tree_sitter_json(); - -#ifdef __cplusplus -} -#endif - -#endif // TREE_SITTER_JSON_H_ diff --git a/vendored_parsers/tree-sitter-json/corpus/main.txt b/vendored_parsers/tree-sitter-json/corpus/main.txt deleted file mode 100644 index ec3c52fa93..0000000000 --- a/vendored_parsers/tree-sitter-json/corpus/main.txt +++ /dev/null @@ -1,142 +0,0 @@ -================================================================================ -Arrays -================================================================================ - -[ - 345, - 10.1, - 10, - -10, - null, - true, - false, - { "stuff": "good" } -] - --------------------------------------------------------------------------------- - -(document - (array - (number) - (number) - (number) - (number) - (null) - (true) - (false) - (object - (pair - (string - (string_content)) - (string - (string_content)))))) - -================================================================================ -String content -================================================================================ - -[ - "", - "abc", - "def\n", - "ghi\t", - "jkl\f", - "//", - "/**/" -] - --------------------------------------------------------------------------------- - -(document - (array - (string) - (string - (string_content)) - (string - (string_content - (escape_sequence))) - (string - (string_content - (escape_sequence))) - (string - (string_content - (escape_sequence))) - (string - (string_content)) - (string - (string_content)))) - -================================================================================ -Top-level numbers -================================================================================ - --1 - --------------------------------------------------------------------------------- - -(document - (number)) - -================================================================================ -Top-level null -================================================================================ - -null - --------------------------------------------------------------------------------- - -(document - (null)) - -================================================================================ -Comments -================================================================================ - -{ - "a": 1, - - // we allow comments, because several - // commonly used tools allow comments in - // files with the extension `.json` - "b": "2", - - /* - * Block comments are also ok - */ - "c": 3 -} - --------------------------------------------------------------------------------- - -(document - (object - (pair - (string - (string_content)) - (number)) - (comment) - (comment) - (comment) - (pair - (string - (string_content)) - (string - (string_content))) - (comment) - (pair - (string - (string_content)) - (number)))) - -=========================================== -Multiple top-level objects -========================================== - -{} -{} - ---- - -(document - (object) - (object)) diff --git a/vendored_parsers/tree-sitter-json/grammar.js b/vendored_parsers/tree-sitter-json/grammar.js deleted file mode 100644 index 126d8a8841..0000000000 --- a/vendored_parsers/tree-sitter-json/grammar.js +++ /dev/null @@ -1,127 +0,0 @@ -/** - * @file JSON grammar for tree-sitter - * @author Max Brunsfeld - * @license MIT - */ - -/* eslint-disable arrow-parens */ -/* eslint-disable camelcase */ -/* eslint-disable-next-line spaced-comment */ -/// -// @ts-check - -module.exports = grammar({ - name: 'json', - - extras: $ => [ - /\s/, - $.comment, - ], - - supertypes: $ => [ - $._value, - ], - - rules: { - document: $ => repeat($._value), - - _value: $ => choice( - $.object, - $.array, - $.number, - $.string, - $.true, - $.false, - $.null, - ), - - object: $ => seq( - '{', commaSep($.pair), '}', - ), - - pair: $ => seq( - field('key', choice($.string, $.number)), - ':', - field('value', $._value), - ), - - array: $ => seq( - '[', commaSep($._value), ']', - ), - - string: $ => choice( - seq('"', '"'), - seq('"', $.string_content, '"'), - ), - - string_content: $ => repeat1(choice( - token.immediate(prec(1, /[^\\"\n]+/)), - $.escape_sequence, - )), - - escape_sequence: _ => token.immediate(seq( - '\\', - /(\"|\\|\/|b|f|n|r|t|u)/, - )), - - number: _ => { - const decimal_digits = /\d+/; - const signed_integer = seq(optional('-'), decimal_digits); - const exponent_part = seq(choice('e', 'E'), signed_integer); - - const decimal_integer_literal = seq( - optional('-'), - choice( - '0', - seq(/[1-9]/, optional(decimal_digits)), - ), - ); - - const decimal_literal = choice( - seq(decimal_integer_literal, '.', optional(decimal_digits), optional(exponent_part)), - seq(decimal_integer_literal, optional(exponent_part)), - ); - - return token(decimal_literal); - }, - - true: _ => 'true', - - false: _ => 'false', - - null: _ => 'null', - - comment: _ => token(choice( - seq('//', /.*/), - seq( - '/*', - /[^*]*\*+([^/*][^*]*\*+)*/, - '/', - ), - )), - }, -}); - -/** - * Creates a rule to match one or more of the rules separated by a comma - * - * @param {RuleOrLiteral} rule - * - * @return {SeqRule} - * - */ -function commaSep1(rule) { - return seq(rule, repeat(seq(',', rule))); -} - -/** - * Creates a rule to optionally match one or more of the rules separated by a comma - * - * @param {RuleOrLiteral} rule - * - * @return {ChoiceRule} - * - */ -function commaSep(rule) { - return optional(commaSep1(rule)); -} diff --git a/vendored_parsers/tree-sitter-json/package.json b/vendored_parsers/tree-sitter-json/package.json deleted file mode 100644 index 48332b2d26..0000000000 --- a/vendored_parsers/tree-sitter-json/package.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "name": "tree-sitter-json", - "version": "0.20.1", - "description": "JSON grammar for tree-sitter", - "main": "bindings/node", - "keywords": [ - "parser", - "lexer", - "json" - ], - "author": "Max Brunsfeld", - "license": "MIT", - "dependencies": { - "nan": "^2.18.0" - }, - "devDependencies": { - "eslint": ">=8.50.0", - "eslint-config-google": "^0.14.0", - "tree-sitter-cli": "^0.20.8" - }, - "scripts": { - "build": "tree-sitter generate && node-gyp build", - "lint": "eslint grammar.js", - "test": "tree-sitter test" - }, - "tree-sitter": [ - { - "scope": "source.json", - "file-types": [ - "json" - ], - "highlights": [ - "queries/highlights.scm" - ] - } - ] -} diff --git a/vendored_parsers/tree-sitter-json/queries/highlights.scm b/vendored_parsers/tree-sitter-json/queries/highlights.scm deleted file mode 100644 index ece8392f0b..0000000000 --- a/vendored_parsers/tree-sitter-json/queries/highlights.scm +++ /dev/null @@ -1,16 +0,0 @@ -(pair - key: (_) @string.special.key) - -(string) @string - -(number) @number - -[ - (null) - (true) - (false) -] @constant.builtin - -(escape_sequence) @escape - -(comment) @comment diff --git a/vendored_parsers/tree-sitter-json/src/grammar.json b/vendored_parsers/tree-sitter-json/src/grammar.json deleted file mode 100644 index 8bb832992f..0000000000 --- a/vendored_parsers/tree-sitter-json/src/grammar.json +++ /dev/null @@ -1,535 +0,0 @@ -{ - "name": "json", - "rules": { - "document": { - "type": "REPEAT", - "content": { - "type": "SYMBOL", - "name": "_value" - } - }, - "_value": { - "type": "CHOICE", - "members": [ - { - "type": "SYMBOL", - "name": "object" - }, - { - "type": "SYMBOL", - "name": "array" - }, - { - "type": "SYMBOL", - "name": "number" - }, - { - "type": "SYMBOL", - "name": "string" - }, - { - "type": "SYMBOL", - "name": "true" - }, - { - "type": "SYMBOL", - "name": "false" - }, - { - "type": "SYMBOL", - "name": "null" - } - ] - }, - "object": { - "type": "SEQ", - "members": [ - { - "type": "STRING", - "value": "{" - }, - { - "type": "CHOICE", - "members": [ - { - "type": "SEQ", - "members": [ - { - "type": "SYMBOL", - "name": "pair" - }, - { - "type": "REPEAT", - "content": { - "type": "SEQ", - "members": [ - { - "type": "STRING", - "value": "," - }, - { - "type": "SYMBOL", - "name": "pair" - } - ] - } - } - ] - }, - { - "type": "BLANK" - } - ] - }, - { - "type": "STRING", - "value": "}" - } - ] - }, - "pair": { - "type": "SEQ", - "members": [ - { - "type": "FIELD", - "name": "key", - "content": { - "type": "CHOICE", - "members": [ - { - "type": "SYMBOL", - "name": "string" - }, - { - "type": "SYMBOL", - "name": "number" - } - ] - } - }, - { - "type": "STRING", - "value": ":" - }, - { - "type": "FIELD", - "name": "value", - "content": { - "type": "SYMBOL", - "name": "_value" - } - } - ] - }, - "array": { - "type": "SEQ", - "members": [ - { - "type": "STRING", - "value": "[" - }, - { - "type": "CHOICE", - "members": [ - { - "type": "SEQ", - "members": [ - { - "type": "SYMBOL", - "name": "_value" - }, - { - "type": "REPEAT", - "content": { - "type": "SEQ", - "members": [ - { - "type": "STRING", - "value": "," - }, - { - "type": "SYMBOL", - "name": "_value" - } - ] - } - } - ] - }, - { - "type": "BLANK" - } - ] - }, - { - "type": "STRING", - "value": "]" - } - ] - }, - "string": { - "type": "CHOICE", - "members": [ - { - "type": "SEQ", - "members": [ - { - "type": "STRING", - "value": "\"" - }, - { - "type": "STRING", - "value": "\"" - } - ] - }, - { - "type": "SEQ", - "members": [ - { - "type": "STRING", - "value": "\"" - }, - { - "type": "SYMBOL", - "name": "string_content" - }, - { - "type": "STRING", - "value": "\"" - } - ] - } - ] - }, - "string_content": { - "type": "REPEAT1", - "content": { - "type": "CHOICE", - "members": [ - { - "type": "IMMEDIATE_TOKEN", - "content": { - "type": "PREC", - "value": 1, - "content": { - "type": "PATTERN", - "value": "[^\\\\\"\\n]+" - } - } - }, - { - "type": "SYMBOL", - "name": "escape_sequence" - } - ] - } - }, - "escape_sequence": { - "type": "IMMEDIATE_TOKEN", - "content": { - "type": "SEQ", - "members": [ - { - "type": "STRING", - "value": "\\" - }, - { - "type": "PATTERN", - "value": "(\\\"|\\\\|\\/|b|f|n|r|t|u)" - } - ] - } - }, - "number": { - "type": "TOKEN", - "content": { - "type": "CHOICE", - "members": [ - { - "type": "SEQ", - "members": [ - { - "type": "SEQ", - "members": [ - { - "type": "CHOICE", - "members": [ - { - "type": "STRING", - "value": "-" - }, - { - "type": "BLANK" - } - ] - }, - { - "type": "CHOICE", - "members": [ - { - "type": "STRING", - "value": "0" - }, - { - "type": "SEQ", - "members": [ - { - "type": "PATTERN", - "value": "[1-9]" - }, - { - "type": "CHOICE", - "members": [ - { - "type": "PATTERN", - "value": "\\d+" - }, - { - "type": "BLANK" - } - ] - } - ] - } - ] - } - ] - }, - { - "type": "STRING", - "value": "." - }, - { - "type": "CHOICE", - "members": [ - { - "type": "PATTERN", - "value": "\\d+" - }, - { - "type": "BLANK" - } - ] - }, - { - "type": "CHOICE", - "members": [ - { - "type": "SEQ", - "members": [ - { - "type": "CHOICE", - "members": [ - { - "type": "STRING", - "value": "e" - }, - { - "type": "STRING", - "value": "E" - } - ] - }, - { - "type": "SEQ", - "members": [ - { - "type": "CHOICE", - "members": [ - { - "type": "STRING", - "value": "-" - }, - { - "type": "BLANK" - } - ] - }, - { - "type": "PATTERN", - "value": "\\d+" - } - ] - } - ] - }, - { - "type": "BLANK" - } - ] - } - ] - }, - { - "type": "SEQ", - "members": [ - { - "type": "SEQ", - "members": [ - { - "type": "CHOICE", - "members": [ - { - "type": "STRING", - "value": "-" - }, - { - "type": "BLANK" - } - ] - }, - { - "type": "CHOICE", - "members": [ - { - "type": "STRING", - "value": "0" - }, - { - "type": "SEQ", - "members": [ - { - "type": "PATTERN", - "value": "[1-9]" - }, - { - "type": "CHOICE", - "members": [ - { - "type": "PATTERN", - "value": "\\d+" - }, - { - "type": "BLANK" - } - ] - } - ] - } - ] - } - ] - }, - { - "type": "CHOICE", - "members": [ - { - "type": "SEQ", - "members": [ - { - "type": "CHOICE", - "members": [ - { - "type": "STRING", - "value": "e" - }, - { - "type": "STRING", - "value": "E" - } - ] - }, - { - "type": "SEQ", - "members": [ - { - "type": "CHOICE", - "members": [ - { - "type": "STRING", - "value": "-" - }, - { - "type": "BLANK" - } - ] - }, - { - "type": "PATTERN", - "value": "\\d+" - } - ] - } - ] - }, - { - "type": "BLANK" - } - ] - } - ] - } - ] - } - }, - "true": { - "type": "STRING", - "value": "true" - }, - "false": { - "type": "STRING", - "value": "false" - }, - "null": { - "type": "STRING", - "value": "null" - }, - "comment": { - "type": "TOKEN", - "content": { - "type": "CHOICE", - "members": [ - { - "type": "SEQ", - "members": [ - { - "type": "STRING", - "value": "//" - }, - { - "type": "PATTERN", - "value": ".*" - } - ] - }, - { - "type": "SEQ", - "members": [ - { - "type": "STRING", - "value": "/*" - }, - { - "type": "PATTERN", - "value": "[^*]*\\*+([^/*][^*]*\\*+)*" - }, - { - "type": "STRING", - "value": "/" - } - ] - } - ] - } - } - }, - "extras": [ - { - "type": "PATTERN", - "value": "\\s" - }, - { - "type": "SYMBOL", - "name": "comment" - } - ], - "conflicts": [], - "precedences": [], - "externals": [], - "inline": [], - "supertypes": [ - "_value" - ] -} - diff --git a/vendored_parsers/tree-sitter-json/src/node-types.json b/vendored_parsers/tree-sitter-json/src/node-types.json deleted file mode 100644 index bfb26885ab..0000000000 --- a/vendored_parsers/tree-sitter-json/src/node-types.json +++ /dev/null @@ -1,193 +0,0 @@ -[ - { - "type": "_value", - "named": true, - "subtypes": [ - { - "type": "array", - "named": true - }, - { - "type": "false", - "named": true - }, - { - "type": "null", - "named": true - }, - { - "type": "number", - "named": true - }, - { - "type": "object", - "named": true - }, - { - "type": "string", - "named": true - }, - { - "type": "true", - "named": true - } - ] - }, - { - "type": "array", - "named": true, - "fields": {}, - "children": { - "multiple": true, - "required": false, - "types": [ - { - "type": "_value", - "named": true - } - ] - } - }, - { - "type": "document", - "named": true, - "fields": {}, - "children": { - "multiple": true, - "required": false, - "types": [ - { - "type": "_value", - "named": true - } - ] - } - }, - { - "type": "object", - "named": true, - "fields": {}, - "children": { - "multiple": true, - "required": false, - "types": [ - { - "type": "pair", - "named": true - } - ] - } - }, - { - "type": "pair", - "named": true, - "fields": { - "key": { - "multiple": false, - "required": true, - "types": [ - { - "type": "number", - "named": true - }, - { - "type": "string", - "named": true - } - ] - }, - "value": { - "multiple": false, - "required": true, - "types": [ - { - "type": "_value", - "named": true - } - ] - } - } - }, - { - "type": "string", - "named": true, - "fields": {}, - "children": { - "multiple": false, - "required": false, - "types": [ - { - "type": "string_content", - "named": true - } - ] - } - }, - { - "type": "string_content", - "named": true, - "fields": {}, - "children": { - "multiple": true, - "required": false, - "types": [ - { - "type": "escape_sequence", - "named": true - } - ] - } - }, - { - "type": "\"", - "named": false - }, - { - "type": ",", - "named": false - }, - { - "type": ":", - "named": false - }, - { - "type": "[", - "named": false - }, - { - "type": "]", - "named": false - }, - { - "type": "comment", - "named": true - }, - { - "type": "escape_sequence", - "named": true - }, - { - "type": "false", - "named": true - }, - { - "type": "null", - "named": true - }, - { - "type": "number", - "named": true - }, - { - "type": "true", - "named": true - }, - { - "type": "{", - "named": false - }, - { - "type": "}", - "named": false - } -] \ No newline at end of file diff --git a/vendored_parsers/tree-sitter-json/src/parser.c b/vendored_parsers/tree-sitter-json/src/parser.c deleted file mode 100644 index 1c036f05ad..0000000000 --- a/vendored_parsers/tree-sitter-json/src/parser.c +++ /dev/null @@ -1,1086 +0,0 @@ -#include "tree_sitter/parser.h" - -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wmissing-field-initializers" -#endif - -#define LANGUAGE_VERSION 14 -#define STATE_COUNT 33 -#define LARGE_STATE_COUNT 4 -#define SYMBOL_COUNT 26 -#define ALIAS_COUNT 0 -#define TOKEN_COUNT 15 -#define EXTERNAL_TOKEN_COUNT 0 -#define FIELD_COUNT 2 -#define MAX_ALIAS_SEQUENCE_LENGTH 4 -#define PRODUCTION_ID_COUNT 2 - -enum ts_symbol_identifiers { - anon_sym_LBRACE = 1, - anon_sym_COMMA = 2, - anon_sym_RBRACE = 3, - anon_sym_COLON = 4, - anon_sym_LBRACK = 5, - anon_sym_RBRACK = 6, - anon_sym_DQUOTE = 7, - aux_sym_string_content_token1 = 8, - sym_escape_sequence = 9, - sym_number = 10, - sym_true = 11, - sym_false = 12, - sym_null = 13, - sym_comment = 14, - sym_document = 15, - sym__value = 16, - sym_object = 17, - sym_pair = 18, - sym_array = 19, - sym_string = 20, - sym_string_content = 21, - aux_sym_document_repeat1 = 22, - aux_sym_object_repeat1 = 23, - aux_sym_array_repeat1 = 24, - aux_sym_string_content_repeat1 = 25, -}; - -static const char * const ts_symbol_names[] = { - [ts_builtin_sym_end] = "end", - [anon_sym_LBRACE] = "{", - [anon_sym_COMMA] = ",", - [anon_sym_RBRACE] = "}", - [anon_sym_COLON] = ":", - [anon_sym_LBRACK] = "[", - [anon_sym_RBRACK] = "]", - [anon_sym_DQUOTE] = "\"", - [aux_sym_string_content_token1] = "string_content_token1", - [sym_escape_sequence] = "escape_sequence", - [sym_number] = "number", - [sym_true] = "true", - [sym_false] = "false", - [sym_null] = "null", - [sym_comment] = "comment", - [sym_document] = "document", - [sym__value] = "_value", - [sym_object] = "object", - [sym_pair] = "pair", - [sym_array] = "array", - [sym_string] = "string", - [sym_string_content] = "string_content", - [aux_sym_document_repeat1] = "document_repeat1", - [aux_sym_object_repeat1] = "object_repeat1", - [aux_sym_array_repeat1] = "array_repeat1", - [aux_sym_string_content_repeat1] = "string_content_repeat1", -}; - -static const TSSymbol ts_symbol_map[] = { - [ts_builtin_sym_end] = ts_builtin_sym_end, - [anon_sym_LBRACE] = anon_sym_LBRACE, - [anon_sym_COMMA] = anon_sym_COMMA, - [anon_sym_RBRACE] = anon_sym_RBRACE, - [anon_sym_COLON] = anon_sym_COLON, - [anon_sym_LBRACK] = anon_sym_LBRACK, - [anon_sym_RBRACK] = anon_sym_RBRACK, - [anon_sym_DQUOTE] = anon_sym_DQUOTE, - [aux_sym_string_content_token1] = aux_sym_string_content_token1, - [sym_escape_sequence] = sym_escape_sequence, - [sym_number] = sym_number, - [sym_true] = sym_true, - [sym_false] = sym_false, - [sym_null] = sym_null, - [sym_comment] = sym_comment, - [sym_document] = sym_document, - [sym__value] = sym__value, - [sym_object] = sym_object, - [sym_pair] = sym_pair, - [sym_array] = sym_array, - [sym_string] = sym_string, - [sym_string_content] = sym_string_content, - [aux_sym_document_repeat1] = aux_sym_document_repeat1, - [aux_sym_object_repeat1] = aux_sym_object_repeat1, - [aux_sym_array_repeat1] = aux_sym_array_repeat1, - [aux_sym_string_content_repeat1] = aux_sym_string_content_repeat1, -}; - -static const TSSymbolMetadata ts_symbol_metadata[] = { - [ts_builtin_sym_end] = { - .visible = false, - .named = true, - }, - [anon_sym_LBRACE] = { - .visible = true, - .named = false, - }, - [anon_sym_COMMA] = { - .visible = true, - .named = false, - }, - [anon_sym_RBRACE] = { - .visible = true, - .named = false, - }, - [anon_sym_COLON] = { - .visible = true, - .named = false, - }, - [anon_sym_LBRACK] = { - .visible = true, - .named = false, - }, - [anon_sym_RBRACK] = { - .visible = true, - .named = false, - }, - [anon_sym_DQUOTE] = { - .visible = true, - .named = false, - }, - [aux_sym_string_content_token1] = { - .visible = false, - .named = false, - }, - [sym_escape_sequence] = { - .visible = true, - .named = true, - }, - [sym_number] = { - .visible = true, - .named = true, - }, - [sym_true] = { - .visible = true, - .named = true, - }, - [sym_false] = { - .visible = true, - .named = true, - }, - [sym_null] = { - .visible = true, - .named = true, - }, - [sym_comment] = { - .visible = true, - .named = true, - }, - [sym_document] = { - .visible = true, - .named = true, - }, - [sym__value] = { - .visible = false, - .named = true, - .supertype = true, - }, - [sym_object] = { - .visible = true, - .named = true, - }, - [sym_pair] = { - .visible = true, - .named = true, - }, - [sym_array] = { - .visible = true, - .named = true, - }, - [sym_string] = { - .visible = true, - .named = true, - }, - [sym_string_content] = { - .visible = true, - .named = true, - }, - [aux_sym_document_repeat1] = { - .visible = false, - .named = false, - }, - [aux_sym_object_repeat1] = { - .visible = false, - .named = false, - }, - [aux_sym_array_repeat1] = { - .visible = false, - .named = false, - }, - [aux_sym_string_content_repeat1] = { - .visible = false, - .named = false, - }, -}; - -enum ts_field_identifiers { - field_key = 1, - field_value = 2, -}; - -static const char * const ts_field_names[] = { - [0] = NULL, - [field_key] = "key", - [field_value] = "value", -}; - -static const TSFieldMapSlice ts_field_map_slices[PRODUCTION_ID_COUNT] = { - [1] = {.index = 0, .length = 2}, -}; - -static const TSFieldMapEntry ts_field_map_entries[] = { - [0] = - {field_key, 0}, - {field_value, 2}, -}; - -static const TSSymbol ts_alias_sequences[PRODUCTION_ID_COUNT][MAX_ALIAS_SEQUENCE_LENGTH] = { - [0] = {0}, -}; - -static const uint16_t ts_non_terminal_alias_map[] = { - 0, -}; - -static const TSStateId ts_primary_state_ids[STATE_COUNT] = { - [0] = 0, - [1] = 1, - [2] = 2, - [3] = 3, - [4] = 4, - [5] = 5, - [6] = 6, - [7] = 7, - [8] = 8, - [9] = 9, - [10] = 10, - [11] = 11, - [12] = 12, - [13] = 13, - [14] = 14, - [15] = 15, - [16] = 16, - [17] = 17, - [18] = 18, - [19] = 19, - [20] = 20, - [21] = 21, - [22] = 22, - [23] = 23, - [24] = 24, - [25] = 25, - [26] = 26, - [27] = 27, - [28] = 28, - [29] = 29, - [30] = 30, - [31] = 31, - [32] = 32, -}; - -static bool ts_lex(TSLexer *lexer, TSStateId state) { - START_LEXER(); - switch (state) { - case 0: - if (eof) ADVANCE(21); - if (lookahead == '"') ADVANCE(28); - if (lookahead == ',') ADVANCE(23); - if (lookahead == '-') ADVANCE(7); - if (lookahead == '/') ADVANCE(3); - if (lookahead == '0') ADVANCE(35); - if (lookahead == ':') ADVANCE(25); - if (lookahead == '[') ADVANCE(26); - if (lookahead == '\\') ADVANCE(18); - if (lookahead == ']') ADVANCE(27); - if (lookahead == 'f') ADVANCE(8); - if (lookahead == 'n') ADVANCE(17); - if (lookahead == 't') ADVANCE(14); - if (lookahead == '{') ADVANCE(22); - if (lookahead == '}') ADVANCE(24); - if (('\t' <= lookahead && lookahead <= '\r') || - lookahead == ' ') SKIP(20) - if (('1' <= lookahead && lookahead <= '9')) ADVANCE(36); - END_STATE(); - case 1: - if (lookahead == '\n') SKIP(2) - if (lookahead == '"') ADVANCE(28); - if (lookahead == '/') ADVANCE(29); - if (lookahead == '\\') ADVANCE(18); - if (('\t' <= lookahead && lookahead <= '\r') || - lookahead == ' ') ADVANCE(32); - if (lookahead != 0) ADVANCE(33); - END_STATE(); - case 2: - if (lookahead == '"') ADVANCE(28); - if (lookahead == '/') ADVANCE(3); - if (('\t' <= lookahead && lookahead <= '\r') || - lookahead == ' ') SKIP(2) - END_STATE(); - case 3: - if (lookahead == '*') ADVANCE(5); - if (lookahead == '/') ADVANCE(43); - END_STATE(); - case 4: - if (lookahead == '*') ADVANCE(4); - if (lookahead == '/') ADVANCE(42); - if (lookahead != 0) ADVANCE(5); - END_STATE(); - case 5: - if (lookahead == '*') ADVANCE(4); - if (lookahead != 0) ADVANCE(5); - END_STATE(); - case 6: - if (lookahead == '-') ADVANCE(19); - if (('0' <= lookahead && lookahead <= '9')) ADVANCE(38); - END_STATE(); - case 7: - if (lookahead == '0') ADVANCE(35); - if (('1' <= lookahead && lookahead <= '9')) ADVANCE(36); - END_STATE(); - case 8: - if (lookahead == 'a') ADVANCE(11); - END_STATE(); - case 9: - if (lookahead == 'e') ADVANCE(39); - END_STATE(); - case 10: - if (lookahead == 'e') ADVANCE(40); - END_STATE(); - case 11: - if (lookahead == 'l') ADVANCE(15); - END_STATE(); - case 12: - if (lookahead == 'l') ADVANCE(41); - END_STATE(); - case 13: - if (lookahead == 'l') ADVANCE(12); - END_STATE(); - case 14: - if (lookahead == 'r') ADVANCE(16); - END_STATE(); - case 15: - if (lookahead == 's') ADVANCE(10); - END_STATE(); - case 16: - if (lookahead == 'u') ADVANCE(9); - END_STATE(); - case 17: - if (lookahead == 'u') ADVANCE(13); - END_STATE(); - case 18: - if (lookahead == '"' || - lookahead == '/' || - lookahead == '\\' || - lookahead == 'b' || - lookahead == 'f' || - lookahead == 'n' || - lookahead == 'r' || - lookahead == 't' || - lookahead == 'u') ADVANCE(34); - END_STATE(); - case 19: - if (('0' <= lookahead && lookahead <= '9')) ADVANCE(38); - END_STATE(); - case 20: - if (eof) ADVANCE(21); - if (lookahead == '"') ADVANCE(28); - if (lookahead == ',') ADVANCE(23); - if (lookahead == '-') ADVANCE(7); - if (lookahead == '/') ADVANCE(3); - if (lookahead == '0') ADVANCE(35); - if (lookahead == ':') ADVANCE(25); - if (lookahead == '[') ADVANCE(26); - if (lookahead == ']') ADVANCE(27); - if (lookahead == 'f') ADVANCE(8); - if (lookahead == 'n') ADVANCE(17); - if (lookahead == 't') ADVANCE(14); - if (lookahead == '{') ADVANCE(22); - if (lookahead == '}') ADVANCE(24); - if (('\t' <= lookahead && lookahead <= '\r') || - lookahead == ' ') SKIP(20) - if (('1' <= lookahead && lookahead <= '9')) ADVANCE(36); - END_STATE(); - case 21: - ACCEPT_TOKEN(ts_builtin_sym_end); - END_STATE(); - case 22: - ACCEPT_TOKEN(anon_sym_LBRACE); - END_STATE(); - case 23: - ACCEPT_TOKEN(anon_sym_COMMA); - END_STATE(); - case 24: - ACCEPT_TOKEN(anon_sym_RBRACE); - END_STATE(); - case 25: - ACCEPT_TOKEN(anon_sym_COLON); - END_STATE(); - case 26: - ACCEPT_TOKEN(anon_sym_LBRACK); - END_STATE(); - case 27: - ACCEPT_TOKEN(anon_sym_RBRACK); - END_STATE(); - case 28: - ACCEPT_TOKEN(anon_sym_DQUOTE); - END_STATE(); - case 29: - ACCEPT_TOKEN(aux_sym_string_content_token1); - if (lookahead == '*') ADVANCE(31); - if (lookahead == '/') ADVANCE(33); - if (lookahead != 0 && - lookahead != '\n' && - lookahead != '"' && - lookahead != '\\') ADVANCE(33); - END_STATE(); - case 30: - ACCEPT_TOKEN(aux_sym_string_content_token1); - if (lookahead == '*') ADVANCE(30); - if (lookahead == '/') ADVANCE(33); - if (lookahead != 0 && - lookahead != '\n' && - lookahead != '"' && - lookahead != '\\') ADVANCE(31); - END_STATE(); - case 31: - ACCEPT_TOKEN(aux_sym_string_content_token1); - if (lookahead == '*') ADVANCE(30); - if (lookahead != 0 && - lookahead != '\n' && - lookahead != '"' && - lookahead != '\\') ADVANCE(31); - END_STATE(); - case 32: - ACCEPT_TOKEN(aux_sym_string_content_token1); - if (lookahead == '/') ADVANCE(29); - if (lookahead == '\t' || - (11 <= lookahead && lookahead <= '\r') || - lookahead == ' ') ADVANCE(32); - if (lookahead != 0 && - lookahead != '\n' && - lookahead != '"' && - lookahead != '\\') ADVANCE(33); - END_STATE(); - case 33: - ACCEPT_TOKEN(aux_sym_string_content_token1); - if (lookahead != 0 && - lookahead != '\n' && - lookahead != '"' && - lookahead != '\\') ADVANCE(33); - END_STATE(); - case 34: - ACCEPT_TOKEN(sym_escape_sequence); - END_STATE(); - case 35: - ACCEPT_TOKEN(sym_number); - if (lookahead == '.') ADVANCE(37); - if (lookahead == 'E' || - lookahead == 'e') ADVANCE(6); - END_STATE(); - case 36: - ACCEPT_TOKEN(sym_number); - if (lookahead == '.') ADVANCE(37); - if (lookahead == 'E' || - lookahead == 'e') ADVANCE(6); - if (('0' <= lookahead && lookahead <= '9')) ADVANCE(36); - END_STATE(); - case 37: - ACCEPT_TOKEN(sym_number); - if (lookahead == 'E' || - lookahead == 'e') ADVANCE(6); - if (('0' <= lookahead && lookahead <= '9')) ADVANCE(37); - END_STATE(); - case 38: - ACCEPT_TOKEN(sym_number); - if (('0' <= lookahead && lookahead <= '9')) ADVANCE(38); - END_STATE(); - case 39: - ACCEPT_TOKEN(sym_true); - END_STATE(); - case 40: - ACCEPT_TOKEN(sym_false); - END_STATE(); - case 41: - ACCEPT_TOKEN(sym_null); - END_STATE(); - case 42: - ACCEPT_TOKEN(sym_comment); - END_STATE(); - case 43: - ACCEPT_TOKEN(sym_comment); - if (lookahead != 0 && - lookahead != '\n') ADVANCE(43); - END_STATE(); - default: - return false; - } -} - -static const TSLexMode ts_lex_modes[STATE_COUNT] = { - [0] = {.lex_state = 0}, - [1] = {.lex_state = 0}, - [2] = {.lex_state = 0}, - [3] = {.lex_state = 0}, - [4] = {.lex_state = 0}, - [5] = {.lex_state = 0}, - [6] = {.lex_state = 0}, - [7] = {.lex_state = 0}, - [8] = {.lex_state = 0}, - [9] = {.lex_state = 0}, - [10] = {.lex_state = 0}, - [11] = {.lex_state = 0}, - [12] = {.lex_state = 0}, - [13] = {.lex_state = 0}, - [14] = {.lex_state = 0}, - [15] = {.lex_state = 0}, - [16] = {.lex_state = 1}, - [17] = {.lex_state = 0}, - [18] = {.lex_state = 1}, - [19] = {.lex_state = 1}, - [20] = {.lex_state = 0}, - [21] = {.lex_state = 0}, - [22] = {.lex_state = 0}, - [23] = {.lex_state = 0}, - [24] = {.lex_state = 0}, - [25] = {.lex_state = 0}, - [26] = {.lex_state = 0}, - [27] = {.lex_state = 0}, - [28] = {.lex_state = 0}, - [29] = {.lex_state = 0}, - [30] = {.lex_state = 0}, - [31] = {.lex_state = 0}, - [32] = {.lex_state = 0}, -}; - -static const uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = { - [0] = { - [ts_builtin_sym_end] = ACTIONS(1), - [anon_sym_LBRACE] = ACTIONS(1), - [anon_sym_COMMA] = ACTIONS(1), - [anon_sym_RBRACE] = ACTIONS(1), - [anon_sym_COLON] = ACTIONS(1), - [anon_sym_LBRACK] = ACTIONS(1), - [anon_sym_RBRACK] = ACTIONS(1), - [anon_sym_DQUOTE] = ACTIONS(1), - [sym_escape_sequence] = ACTIONS(1), - [sym_number] = ACTIONS(1), - [sym_true] = ACTIONS(1), - [sym_false] = ACTIONS(1), - [sym_null] = ACTIONS(1), - [sym_comment] = ACTIONS(3), - }, - [1] = { - [sym_document] = STATE(30), - [sym__value] = STATE(2), - [sym_object] = STATE(8), - [sym_array] = STATE(8), - [sym_string] = STATE(8), - [aux_sym_document_repeat1] = STATE(2), - [ts_builtin_sym_end] = ACTIONS(5), - [anon_sym_LBRACE] = ACTIONS(7), - [anon_sym_LBRACK] = ACTIONS(9), - [anon_sym_DQUOTE] = ACTIONS(11), - [sym_number] = ACTIONS(13), - [sym_true] = ACTIONS(13), - [sym_false] = ACTIONS(13), - [sym_null] = ACTIONS(13), - [sym_comment] = ACTIONS(3), - }, - [2] = { - [sym__value] = STATE(3), - [sym_object] = STATE(8), - [sym_array] = STATE(8), - [sym_string] = STATE(8), - [aux_sym_document_repeat1] = STATE(3), - [ts_builtin_sym_end] = ACTIONS(15), - [anon_sym_LBRACE] = ACTIONS(7), - [anon_sym_LBRACK] = ACTIONS(9), - [anon_sym_DQUOTE] = ACTIONS(11), - [sym_number] = ACTIONS(13), - [sym_true] = ACTIONS(13), - [sym_false] = ACTIONS(13), - [sym_null] = ACTIONS(13), - [sym_comment] = ACTIONS(3), - }, - [3] = { - [sym__value] = STATE(3), - [sym_object] = STATE(8), - [sym_array] = STATE(8), - [sym_string] = STATE(8), - [aux_sym_document_repeat1] = STATE(3), - [ts_builtin_sym_end] = ACTIONS(17), - [anon_sym_LBRACE] = ACTIONS(19), - [anon_sym_LBRACK] = ACTIONS(22), - [anon_sym_DQUOTE] = ACTIONS(25), - [sym_number] = ACTIONS(28), - [sym_true] = ACTIONS(28), - [sym_false] = ACTIONS(28), - [sym_null] = ACTIONS(28), - [sym_comment] = ACTIONS(3), - }, -}; - -static const uint16_t ts_small_parse_table[] = { - [0] = 2, - ACTIONS(3), 1, - sym_comment, - ACTIONS(31), 12, - ts_builtin_sym_end, - anon_sym_LBRACE, - anon_sym_COMMA, - anon_sym_RBRACE, - anon_sym_COLON, - anon_sym_LBRACK, - anon_sym_RBRACK, - anon_sym_DQUOTE, - sym_number, - sym_true, - sym_false, - sym_null, - [18] = 2, - ACTIONS(3), 1, - sym_comment, - ACTIONS(33), 12, - ts_builtin_sym_end, - anon_sym_LBRACE, - anon_sym_COMMA, - anon_sym_RBRACE, - anon_sym_COLON, - anon_sym_LBRACK, - anon_sym_RBRACK, - anon_sym_DQUOTE, - sym_number, - sym_true, - sym_false, - sym_null, - [36] = 8, - ACTIONS(3), 1, - sym_comment, - ACTIONS(7), 1, - anon_sym_LBRACE, - ACTIONS(9), 1, - anon_sym_LBRACK, - ACTIONS(11), 1, - anon_sym_DQUOTE, - ACTIONS(35), 1, - anon_sym_RBRACK, - STATE(21), 1, - sym__value, - STATE(8), 3, - sym_object, - sym_array, - sym_string, - ACTIONS(13), 4, - sym_number, - sym_true, - sym_false, - sym_null, - [66] = 2, - ACTIONS(3), 1, - sym_comment, - ACTIONS(37), 11, - ts_builtin_sym_end, - anon_sym_LBRACE, - anon_sym_COMMA, - anon_sym_RBRACE, - anon_sym_LBRACK, - anon_sym_RBRACK, - anon_sym_DQUOTE, - sym_number, - sym_true, - sym_false, - sym_null, - [83] = 2, - ACTIONS(3), 1, - sym_comment, - ACTIONS(39), 11, - ts_builtin_sym_end, - anon_sym_LBRACE, - anon_sym_COMMA, - anon_sym_RBRACE, - anon_sym_LBRACK, - anon_sym_RBRACK, - anon_sym_DQUOTE, - sym_number, - sym_true, - sym_false, - sym_null, - [100] = 2, - ACTIONS(3), 1, - sym_comment, - ACTIONS(41), 11, - ts_builtin_sym_end, - anon_sym_LBRACE, - anon_sym_COMMA, - anon_sym_RBRACE, - anon_sym_LBRACK, - anon_sym_RBRACK, - anon_sym_DQUOTE, - sym_number, - sym_true, - sym_false, - sym_null, - [117] = 2, - ACTIONS(3), 1, - sym_comment, - ACTIONS(43), 11, - ts_builtin_sym_end, - anon_sym_LBRACE, - anon_sym_COMMA, - anon_sym_RBRACE, - anon_sym_LBRACK, - anon_sym_RBRACK, - anon_sym_DQUOTE, - sym_number, - sym_true, - sym_false, - sym_null, - [134] = 2, - ACTIONS(3), 1, - sym_comment, - ACTIONS(45), 11, - ts_builtin_sym_end, - anon_sym_LBRACE, - anon_sym_COMMA, - anon_sym_RBRACE, - anon_sym_LBRACK, - anon_sym_RBRACK, - anon_sym_DQUOTE, - sym_number, - sym_true, - sym_false, - sym_null, - [151] = 2, - ACTIONS(3), 1, - sym_comment, - ACTIONS(47), 11, - ts_builtin_sym_end, - anon_sym_LBRACE, - anon_sym_COMMA, - anon_sym_RBRACE, - anon_sym_LBRACK, - anon_sym_RBRACK, - anon_sym_DQUOTE, - sym_number, - sym_true, - sym_false, - sym_null, - [168] = 7, - ACTIONS(3), 1, - sym_comment, - ACTIONS(7), 1, - anon_sym_LBRACE, - ACTIONS(9), 1, - anon_sym_LBRACK, - ACTIONS(11), 1, - anon_sym_DQUOTE, - STATE(27), 1, - sym__value, - STATE(8), 3, - sym_object, - sym_array, - sym_string, - ACTIONS(13), 4, - sym_number, - sym_true, - sym_false, - sym_null, - [195] = 2, - ACTIONS(3), 1, - sym_comment, - ACTIONS(49), 11, - ts_builtin_sym_end, - anon_sym_LBRACE, - anon_sym_COMMA, - anon_sym_RBRACE, - anon_sym_LBRACK, - anon_sym_RBRACK, - anon_sym_DQUOTE, - sym_number, - sym_true, - sym_false, - sym_null, - [212] = 7, - ACTIONS(3), 1, - sym_comment, - ACTIONS(7), 1, - anon_sym_LBRACE, - ACTIONS(9), 1, - anon_sym_LBRACK, - ACTIONS(11), 1, - anon_sym_DQUOTE, - STATE(29), 1, - sym__value, - STATE(8), 3, - sym_object, - sym_array, - sym_string, - ACTIONS(13), 4, - sym_number, - sym_true, - sym_false, - sym_null, - [239] = 5, - ACTIONS(51), 1, - anon_sym_DQUOTE, - ACTIONS(55), 1, - sym_comment, - STATE(19), 1, - aux_sym_string_content_repeat1, - STATE(31), 1, - sym_string_content, - ACTIONS(53), 2, - aux_sym_string_content_token1, - sym_escape_sequence, - [256] = 6, - ACTIONS(3), 1, - sym_comment, - ACTIONS(11), 1, - anon_sym_DQUOTE, - ACTIONS(57), 1, - anon_sym_RBRACE, - ACTIONS(59), 1, - sym_number, - STATE(24), 1, - sym_pair, - STATE(32), 1, - sym_string, - [275] = 4, - ACTIONS(55), 1, - sym_comment, - ACTIONS(61), 1, - anon_sym_DQUOTE, - STATE(18), 1, - aux_sym_string_content_repeat1, - ACTIONS(63), 2, - aux_sym_string_content_token1, - sym_escape_sequence, - [289] = 4, - ACTIONS(55), 1, - sym_comment, - ACTIONS(66), 1, - anon_sym_DQUOTE, - STATE(18), 1, - aux_sym_string_content_repeat1, - ACTIONS(68), 2, - aux_sym_string_content_token1, - sym_escape_sequence, - [303] = 5, - ACTIONS(3), 1, - sym_comment, - ACTIONS(11), 1, - anon_sym_DQUOTE, - ACTIONS(59), 1, - sym_number, - STATE(28), 1, - sym_pair, - STATE(32), 1, - sym_string, - [319] = 4, - ACTIONS(3), 1, - sym_comment, - ACTIONS(70), 1, - anon_sym_COMMA, - ACTIONS(72), 1, - anon_sym_RBRACK, - STATE(23), 1, - aux_sym_array_repeat1, - [332] = 4, - ACTIONS(3), 1, - sym_comment, - ACTIONS(74), 1, - anon_sym_COMMA, - ACTIONS(76), 1, - anon_sym_RBRACE, - STATE(25), 1, - aux_sym_object_repeat1, - [345] = 4, - ACTIONS(3), 1, - sym_comment, - ACTIONS(70), 1, - anon_sym_COMMA, - ACTIONS(78), 1, - anon_sym_RBRACK, - STATE(26), 1, - aux_sym_array_repeat1, - [358] = 4, - ACTIONS(3), 1, - sym_comment, - ACTIONS(74), 1, - anon_sym_COMMA, - ACTIONS(80), 1, - anon_sym_RBRACE, - STATE(22), 1, - aux_sym_object_repeat1, - [371] = 4, - ACTIONS(3), 1, - sym_comment, - ACTIONS(82), 1, - anon_sym_COMMA, - ACTIONS(85), 1, - anon_sym_RBRACE, - STATE(25), 1, - aux_sym_object_repeat1, - [384] = 4, - ACTIONS(3), 1, - sym_comment, - ACTIONS(87), 1, - anon_sym_COMMA, - ACTIONS(90), 1, - anon_sym_RBRACK, - STATE(26), 1, - aux_sym_array_repeat1, - [397] = 2, - ACTIONS(3), 1, - sym_comment, - ACTIONS(92), 2, - anon_sym_COMMA, - anon_sym_RBRACE, - [405] = 2, - ACTIONS(3), 1, - sym_comment, - ACTIONS(85), 2, - anon_sym_COMMA, - anon_sym_RBRACE, - [413] = 2, - ACTIONS(3), 1, - sym_comment, - ACTIONS(90), 2, - anon_sym_COMMA, - anon_sym_RBRACK, - [421] = 2, - ACTIONS(3), 1, - sym_comment, - ACTIONS(94), 1, - ts_builtin_sym_end, - [428] = 2, - ACTIONS(3), 1, - sym_comment, - ACTIONS(96), 1, - anon_sym_DQUOTE, - [435] = 2, - ACTIONS(3), 1, - sym_comment, - ACTIONS(98), 1, - anon_sym_COLON, -}; - -static const uint32_t ts_small_parse_table_map[] = { - [SMALL_STATE(4)] = 0, - [SMALL_STATE(5)] = 18, - [SMALL_STATE(6)] = 36, - [SMALL_STATE(7)] = 66, - [SMALL_STATE(8)] = 83, - [SMALL_STATE(9)] = 100, - [SMALL_STATE(10)] = 117, - [SMALL_STATE(11)] = 134, - [SMALL_STATE(12)] = 151, - [SMALL_STATE(13)] = 168, - [SMALL_STATE(14)] = 195, - [SMALL_STATE(15)] = 212, - [SMALL_STATE(16)] = 239, - [SMALL_STATE(17)] = 256, - [SMALL_STATE(18)] = 275, - [SMALL_STATE(19)] = 289, - [SMALL_STATE(20)] = 303, - [SMALL_STATE(21)] = 319, - [SMALL_STATE(22)] = 332, - [SMALL_STATE(23)] = 345, - [SMALL_STATE(24)] = 358, - [SMALL_STATE(25)] = 371, - [SMALL_STATE(26)] = 384, - [SMALL_STATE(27)] = 397, - [SMALL_STATE(28)] = 405, - [SMALL_STATE(29)] = 413, - [SMALL_STATE(30)] = 421, - [SMALL_STATE(31)] = 428, - [SMALL_STATE(32)] = 435, -}; - -static const TSParseActionEntry ts_parse_actions[] = { - [0] = {.entry = {.count = 0, .reusable = false}}, - [1] = {.entry = {.count = 1, .reusable = false}}, RECOVER(), - [3] = {.entry = {.count = 1, .reusable = true}}, SHIFT_EXTRA(), - [5] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_document, 0), - [7] = {.entry = {.count = 1, .reusable = true}}, SHIFT(17), - [9] = {.entry = {.count = 1, .reusable = true}}, SHIFT(6), - [11] = {.entry = {.count = 1, .reusable = true}}, SHIFT(16), - [13] = {.entry = {.count = 1, .reusable = true}}, SHIFT(8), - [15] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_document, 1), - [17] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_document_repeat1, 2), - [19] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_document_repeat1, 2), SHIFT_REPEAT(17), - [22] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_document_repeat1, 2), SHIFT_REPEAT(6), - [25] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_document_repeat1, 2), SHIFT_REPEAT(16), - [28] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_document_repeat1, 2), SHIFT_REPEAT(8), - [31] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_string, 3), - [33] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_string, 2), - [35] = {.entry = {.count = 1, .reusable = true}}, SHIFT(12), - [37] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_array, 3), - [39] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__value, 1), - [41] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_array, 4), - [43] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_object, 2), - [45] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_object, 4), - [47] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_array, 2), - [49] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_object, 3), - [51] = {.entry = {.count = 1, .reusable = false}}, SHIFT(5), - [53] = {.entry = {.count = 1, .reusable = true}}, SHIFT(19), - [55] = {.entry = {.count = 1, .reusable = false}}, SHIFT_EXTRA(), - [57] = {.entry = {.count = 1, .reusable = true}}, SHIFT(10), - [59] = {.entry = {.count = 1, .reusable = true}}, SHIFT(32), - [61] = {.entry = {.count = 1, .reusable = false}}, REDUCE(aux_sym_string_content_repeat1, 2), - [63] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_string_content_repeat1, 2), SHIFT_REPEAT(18), - [66] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_string_content, 1), - [68] = {.entry = {.count = 1, .reusable = true}}, SHIFT(18), - [70] = {.entry = {.count = 1, .reusable = true}}, SHIFT(15), - [72] = {.entry = {.count = 1, .reusable = true}}, SHIFT(7), - [74] = {.entry = {.count = 1, .reusable = true}}, SHIFT(20), - [76] = {.entry = {.count = 1, .reusable = true}}, SHIFT(11), - [78] = {.entry = {.count = 1, .reusable = true}}, SHIFT(9), - [80] = {.entry = {.count = 1, .reusable = true}}, SHIFT(14), - [82] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_object_repeat1, 2), SHIFT_REPEAT(20), - [85] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_object_repeat1, 2), - [87] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_array_repeat1, 2), SHIFT_REPEAT(15), - [90] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_array_repeat1, 2), - [92] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_pair, 3, .production_id = 1), - [94] = {.entry = {.count = 1, .reusable = true}}, ACCEPT_INPUT(), - [96] = {.entry = {.count = 1, .reusable = true}}, SHIFT(4), - [98] = {.entry = {.count = 1, .reusable = true}}, SHIFT(13), -}; - -#ifdef __cplusplus -extern "C" { -#endif -#ifdef _WIN32 -#define extern __declspec(dllexport) -#endif - -extern const TSLanguage *tree_sitter_json(void) { - static const TSLanguage language = { - .version = LANGUAGE_VERSION, - .symbol_count = SYMBOL_COUNT, - .alias_count = ALIAS_COUNT, - .token_count = TOKEN_COUNT, - .external_token_count = EXTERNAL_TOKEN_COUNT, - .state_count = STATE_COUNT, - .large_state_count = LARGE_STATE_COUNT, - .production_id_count = PRODUCTION_ID_COUNT, - .field_count = FIELD_COUNT, - .max_alias_sequence_length = MAX_ALIAS_SEQUENCE_LENGTH, - .parse_table = &ts_parse_table[0][0], - .small_parse_table = ts_small_parse_table, - .small_parse_table_map = ts_small_parse_table_map, - .parse_actions = ts_parse_actions, - .symbol_names = ts_symbol_names, - .field_names = ts_field_names, - .field_map_slices = ts_field_map_slices, - .field_map_entries = ts_field_map_entries, - .symbol_metadata = ts_symbol_metadata, - .public_symbol_map = ts_symbol_map, - .alias_map = ts_non_terminal_alias_map, - .alias_sequences = &ts_alias_sequences[0][0], - .lex_modes = ts_lex_modes, - .lex_fn = ts_lex, - .primary_state_ids = ts_primary_state_ids, - }; - return &language; -} -#ifdef __cplusplus -} -#endif diff --git a/vendored_parsers/tree-sitter-json/src/tree_sitter/parser.h b/vendored_parsers/tree-sitter-json/src/tree_sitter/parser.h deleted file mode 100644 index d210325991..0000000000 --- a/vendored_parsers/tree-sitter-json/src/tree_sitter/parser.h +++ /dev/null @@ -1,224 +0,0 @@ -#ifndef TREE_SITTER_PARSER_H_ -#define TREE_SITTER_PARSER_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include - -#define ts_builtin_sym_error ((TSSymbol)-1) -#define ts_builtin_sym_end 0 -#define TREE_SITTER_SERIALIZATION_BUFFER_SIZE 1024 - -#ifndef TREE_SITTER_API_H_ -typedef uint16_t TSStateId; -typedef uint16_t TSSymbol; -typedef uint16_t TSFieldId; -typedef struct TSLanguage TSLanguage; -#endif - -typedef struct { - TSFieldId field_id; - uint8_t child_index; - bool inherited; -} TSFieldMapEntry; - -typedef struct { - uint16_t index; - uint16_t length; -} TSFieldMapSlice; - -typedef struct { - bool visible; - bool named; - bool supertype; -} TSSymbolMetadata; - -typedef struct TSLexer TSLexer; - -struct TSLexer { - int32_t lookahead; - TSSymbol result_symbol; - void (*advance)(TSLexer *, bool); - void (*mark_end)(TSLexer *); - uint32_t (*get_column)(TSLexer *); - bool (*is_at_included_range_start)(const TSLexer *); - bool (*eof)(const TSLexer *); -}; - -typedef enum { - TSParseActionTypeShift, - TSParseActionTypeReduce, - TSParseActionTypeAccept, - TSParseActionTypeRecover, -} TSParseActionType; - -typedef union { - struct { - uint8_t type; - TSStateId state; - bool extra; - bool repetition; - } shift; - struct { - uint8_t type; - uint8_t child_count; - TSSymbol symbol; - int16_t dynamic_precedence; - uint16_t production_id; - } reduce; - uint8_t type; -} TSParseAction; - -typedef struct { - uint16_t lex_state; - uint16_t external_lex_state; -} TSLexMode; - -typedef union { - TSParseAction action; - struct { - uint8_t count; - bool reusable; - } entry; -} TSParseActionEntry; - -struct TSLanguage { - uint32_t version; - uint32_t symbol_count; - uint32_t alias_count; - uint32_t token_count; - uint32_t external_token_count; - uint32_t state_count; - uint32_t large_state_count; - uint32_t production_id_count; - uint32_t field_count; - uint16_t max_alias_sequence_length; - const uint16_t *parse_table; - const uint16_t *small_parse_table; - const uint32_t *small_parse_table_map; - const TSParseActionEntry *parse_actions; - const char * const *symbol_names; - const char * const *field_names; - const TSFieldMapSlice *field_map_slices; - const TSFieldMapEntry *field_map_entries; - const TSSymbolMetadata *symbol_metadata; - const TSSymbol *public_symbol_map; - const uint16_t *alias_map; - const TSSymbol *alias_sequences; - const TSLexMode *lex_modes; - bool (*lex_fn)(TSLexer *, TSStateId); - bool (*keyword_lex_fn)(TSLexer *, TSStateId); - TSSymbol keyword_capture_token; - struct { - const bool *states; - const TSSymbol *symbol_map; - void *(*create)(void); - void (*destroy)(void *); - bool (*scan)(void *, TSLexer *, const bool *symbol_whitelist); - unsigned (*serialize)(void *, char *); - void (*deserialize)(void *, const char *, unsigned); - } external_scanner; - const TSStateId *primary_state_ids; -}; - -/* - * Lexer Macros - */ - -#define START_LEXER() \ - bool result = false; \ - bool skip = false; \ - bool eof = false; \ - int32_t lookahead; \ - goto start; \ - next_state: \ - lexer->advance(lexer, skip); \ - start: \ - skip = false; \ - lookahead = lexer->lookahead; \ - eof = lexer->eof(lexer); - -#define ADVANCE(state_value) \ - { \ - state = state_value; \ - goto next_state; \ - } - -#define SKIP(state_value) \ - { \ - skip = true; \ - state = state_value; \ - goto next_state; \ - } - -#define ACCEPT_TOKEN(symbol_value) \ - result = true; \ - lexer->result_symbol = symbol_value; \ - lexer->mark_end(lexer); - -#define END_STATE() return result; - -/* - * Parse Table Macros - */ - -#define SMALL_STATE(id) ((id) - LARGE_STATE_COUNT) - -#define STATE(id) id - -#define ACTIONS(id) id - -#define SHIFT(state_value) \ - {{ \ - .shift = { \ - .type = TSParseActionTypeShift, \ - .state = (state_value) \ - } \ - }} - -#define SHIFT_REPEAT(state_value) \ - {{ \ - .shift = { \ - .type = TSParseActionTypeShift, \ - .state = (state_value), \ - .repetition = true \ - } \ - }} - -#define SHIFT_EXTRA() \ - {{ \ - .shift = { \ - .type = TSParseActionTypeShift, \ - .extra = true \ - } \ - }} - -#define REDUCE(symbol_val, child_count_val, ...) \ - {{ \ - .reduce = { \ - .type = TSParseActionTypeReduce, \ - .symbol = symbol_val, \ - .child_count = child_count_val, \ - __VA_ARGS__ \ - }, \ - }} - -#define RECOVER() \ - {{ \ - .type = TSParseActionTypeRecover \ - }} - -#define ACCEPT_INPUT() \ - {{ \ - .type = TSParseActionTypeAccept \ - }} - -#ifdef __cplusplus -} -#endif - -#endif // TREE_SITTER_PARSER_H_