From 5a40dc60673fd7fd59a0e7e410cb13ed6729cae0 Mon Sep 17 00:00:00 2001 From: Erik Krogh Kristensen Date: Fri, 3 May 2024 14:13:24 +0200 Subject: [PATCH 1/9] add CI workflow --- .github/workflows/node.js.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/node.js.yml diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml new file mode 100644 index 0000000..525afc4 --- /dev/null +++ b/.github/workflows/node.js.yml @@ -0,0 +1,22 @@ +name: Build/test +on: + pull_request: + branches: + - "**" + push: + branches: + - "main" +jobs: + test: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: true + matrix: + os: [macos-latest, ubuntu-latest, windows-latest] + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 21 + - run: npm install + - run: npm test From f4e1a9488f9bc588752a44b45caf937d7e0ec787 Mon Sep 17 00:00:00 2001 From: erik-krogh Date: Fri, 3 May 2024 14:19:54 +0200 Subject: [PATCH 2/9] use the reference tree-sitter workflow --- .github/workflows/ci.yml | 71 +++++++++++++++++++++++++++++++++++ .github/workflows/node.js.yml | 22 ----------- 2 files changed, 71 insertions(+), 22 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/node.js.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..3fda1d4 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,71 @@ +name: CI + +on: + push: + branches: [master] + paths: + - grammar.js + - src/** + - test/** + - bindings/** + - binding.gyp + pull_request: + paths: + - grammar.js + - src/** + - test/** + - bindings/** + - binding.gyp + +concurrency: + group: ${{github.workflow}}-${{github.ref}} + cancel-in-progress: true + +jobs: + test: + name: Test parser + runs-on: ${{matrix.os}} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macos-14] + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Set up tree-sitter + uses: tree-sitter/setup-action/cli@v1 + - name: Run parser and binding tests + uses: tree-sitter/parser-test-action@v2 + with: + test-rust: ${{runner.os == 'Linux'}} + test-swift: ${{runner.os == 'macOS'}} + - name: Parse sample files + uses: tree-sitter/parse-action@v4 + id: parse-files + with: + files: examples/** + - name: Upload failures artifact + uses: actions/upload-artifact@v4 + if: "!cancelled() && steps.parse-files.outcome == 'failure'" + with: + name: failures-${{runner.os}} + path: ${{steps.parse-files.outputs.failures}} + fuzz: + name: Fuzz scanner + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 2 + - name: Check for scanner changes + id: scanner-check + run: |- + if git diff --quiet HEAD^ -- src/scanner.c; then + printf 'changed=false\n' >> "$GITHUB_OUTPUT" + else + printf 'changed=true\n' >> "$GITHUB_OUTPUT" + fi + - name: Run the fuzzer + uses: tree-sitter/fuzz-action@v4 + if: steps.scanner-check.outputs.changed == 'true' \ No newline at end of file diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml deleted file mode 100644 index 525afc4..0000000 --- a/.github/workflows/node.js.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: Build/test -on: - pull_request: - branches: - - "**" - push: - branches: - - "main" -jobs: - test: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: true - matrix: - os: [macos-latest, ubuntu-latest, windows-latest] - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: 21 - - run: npm install - - run: npm test From 6ba05ac926a6ebc0c85c99d7e8ab751ffb3969fe Mon Sep 17 00:00:00 2001 From: erik-krogh Date: Fri, 3 May 2024 14:20:57 +0200 Subject: [PATCH 3/9] trigger the workflow on workflow changes --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3fda1d4..58f6320 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,6 +4,7 @@ on: push: branches: [master] paths: + - .github/ - grammar.js - src/** - test/** @@ -11,6 +12,7 @@ on: - binding.gyp pull_request: paths: + - .github/ - grammar.js - src/** - test/** From b66431c9f5a84aef8f40d96f1b213a23c46f426d Mon Sep 17 00:00:00 2001 From: erik-krogh Date: Fri, 3 May 2024 14:21:37 +0200 Subject: [PATCH 4/9] just trigger the CI all the time --- .github/workflows/ci.yml | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 58f6320..217f928 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,23 +1,12 @@ name: CI on: - push: - branches: [master] - paths: - - .github/ - - grammar.js - - src/** - - test/** - - bindings/** - - binding.gyp pull_request: - paths: - - .github/ - - grammar.js - - src/** - - test/** - - bindings/** - - binding.gyp + branches: + - "**" + push: + branches: + - "main" concurrency: group: ${{github.workflow}}-${{github.ref}} From 9f9f21636d6112beb187c5040a4dca0efd16f8ef Mon Sep 17 00:00:00 2001 From: erik-krogh Date: Fri, 3 May 2024 14:30:53 +0200 Subject: [PATCH 5/9] try to update package.json with build-script etc. --- .gitignore | 2 + package-lock.json | 532 +++++++++++++++++++++++++++++++++++++++ package.json | 21 +- src/parser.c | 105 +++++++- src/tree_sitter/parser.h | 1 + 5 files changed, 657 insertions(+), 4 deletions(-) create mode 100644 .gitignore create mode 100644 package-lock.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b51ea71 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +node_modules/ +build/ \ No newline at end of file diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..d20f3c8 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,532 @@ +{ + "name": "tree-sitter-ql-dbscheme", + "version": "0.0.1", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "tree-sitter-ql-dbscheme", + "version": "0.0.1", + "hasInstallScript": true, + "dependencies": { + "nan": "^2.12.1", + "node-addon-api": "^8.0.0", + "node-gyp-build": "^4.8.1" + }, + "devDependencies": { + "prebuildify": "^6.0.0", + "tree-sitter-cli": "^0.20.2" + }, + "peerDependencies": { + "tree-sitter": "^0.20.2" + }, + "peerDependenciesMeta": { + "tree_sitter": { + "optional": true + } + } + }, + "node_modules/base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/bl": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz", + "integrity": "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==", + "dependencies": { + "buffer": "^5.5.0", + "inherits": "^2.0.4", + "readable-stream": "^3.4.0" + } + }, + "node_modules/buffer": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", + "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.1.13" + } + }, + "node_modules/chownr": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz", + "integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==" + }, + "node_modules/decompress-response": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz", + "integrity": "sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==", + "peer": true, + "dependencies": { + "mimic-response": "^3.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/deep-extend": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", + "integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==", + "peer": true, + "engines": { + "node": ">=4.0.0" + } + }, + "node_modules/detect-libc": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.3.tgz", + "integrity": "sha512-bwy0MGW55bG41VqxxypOsdSdGqLwXPI/focwgTYCFMbdUiBAxLg9CFzG08sz2aqzknwiX7Hkl0bQENjg8iLByw==", + "peer": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/end-of-stream": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", + "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", + "dependencies": { + "once": "^1.4.0" + } + }, + "node_modules/expand-template": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/expand-template/-/expand-template-2.0.3.tgz", + "integrity": "sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg==", + "peer": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/fs-constants": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", + "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==" + }, + "node_modules/github-from-package": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/github-from-package/-/github-from-package-0.0.0.tgz", + "integrity": "sha512-SyHy3T1v2NUXn29OsWdxmK6RwHD+vkj3v8en8AOBZ1wBQ/hCAQ5bAQTD02kW4W9tUp/3Qh6J8r9EvntiyCmOOw==", + "peer": true + }, + "node_modules/ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "node_modules/ini": { + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz", + "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==", + "peer": true + }, + "node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/mimic-response": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz", + "integrity": "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==", + "peer": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/minimist": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/mkdirp-classic": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz", + "integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==" + }, + "node_modules/nan": { + "version": "2.19.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.19.0.tgz", + "integrity": "sha512-nO1xXxfh/RWNxfd/XPfbIfFk5vgLsAxUR9y5O0cHMJu/AW9U95JLXqthYHjEp+8gQ5p96K9jUp8nbVOxCdRbtw==" + }, + "node_modules/napi-build-utils": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/napi-build-utils/-/napi-build-utils-1.0.2.tgz", + "integrity": "sha512-ONmRUqK7zj7DWX0D9ADe03wbwOBZxNAfF20PlGfCWQcD3+/MakShIHrMqx9YwPTfxDdF1zLeL+RGZiR9kGMLdg==", + "peer": true + }, + "node_modules/node-abi": { + "version": "3.62.0", + "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.62.0.tgz", + "integrity": "sha512-CPMcGa+y33xuL1E0TcNIu4YyaZCxnnvkVaEXrsosR3FxN+fV8xvb7Mzpb7IgKler10qeMkE6+Dp8qJhpzdq35g==", + "dependencies": { + "semver": "^7.3.5" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/node-addon-api": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-8.0.0.tgz", + "integrity": "sha512-ipO7rsHEBqa9STO5C5T10fj732ml+5kLN1cAG8/jdHd56ldQeGj3Q7+scUS+VHK/qy1zLEwC4wMK5+yM0btPvw==", + "engines": { + "node": "^18 || ^20 || >= 21" + } + }, + "node_modules/node-gyp-build": { + "version": "4.8.1", + "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.8.1.tgz", + "integrity": "sha512-OSs33Z9yWr148JZcbZd5WiAXhh/n9z8TxQcdMhIOlpN9AhWpLfvVFO73+m77bBABQMaY9XSvIa+qk0jlI7Gcaw==", + "bin": { + "node-gyp-build": "bin.js", + "node-gyp-build-optional": "optional.js", + "node-gyp-build-test": "build-test.js" + } + }, + "node_modules/npm-run-path": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-3.1.0.tgz", + "integrity": "sha512-Dbl4A/VfiVGLgQv29URL9xshU8XDY1GeLy+fsaZ1AA8JDSfjvr5P5+pzRbWqRSBxk6/DW7MIh8lTM/PaGnP2kg==", + "dev": true, + "dependencies": { + "path-key": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/prebuild-install": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-7.1.2.tgz", + "integrity": "sha512-UnNke3IQb6sgarcZIDU3gbMeTp/9SSU1DAIkil7PrqG1vZlBtY5msYccSKSHDqa3hNg436IXK+SNImReuA1wEQ==", + "peer": true, + "dependencies": { + "detect-libc": "^2.0.0", + "expand-template": "^2.0.3", + "github-from-package": "0.0.0", + "minimist": "^1.2.3", + "mkdirp-classic": "^0.5.3", + "napi-build-utils": "^1.0.1", + "node-abi": "^3.3.0", + "pump": "^3.0.0", + "rc": "^1.2.7", + "simple-get": "^4.0.0", + "tar-fs": "^2.0.0", + "tunnel-agent": "^0.6.0" + }, + "bin": { + "prebuild-install": "bin.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/prebuildify": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/prebuildify/-/prebuildify-6.0.1.tgz", + "integrity": "sha512-8Y2oOOateom/s8dNBsGIcnm6AxPmLH4/nanQzL5lQMU+sC0CMhzARZHizwr36pUPLdvBnOkCNQzxg4djuFSgIw==", + "dev": true, + "dependencies": { + "minimist": "^1.2.5", + "mkdirp-classic": "^0.5.3", + "node-abi": "^3.3.0", + "npm-run-path": "^3.1.0", + "pump": "^3.0.0", + "tar-fs": "^2.1.0" + }, + "bin": { + "prebuildify": "bin.js" + } + }, + "node_modules/pump": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", + "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", + "dependencies": { + "end-of-stream": "^1.1.0", + "once": "^1.3.1" + } + }, + "node_modules/rc": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", + "integrity": "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==", + "peer": true, + "dependencies": { + "deep-extend": "^0.6.0", + "ini": "~1.3.0", + "minimist": "^1.2.0", + "strip-json-comments": "~2.0.1" + }, + "bin": { + "rc": "cli.js" + } + }, + "node_modules/readable-stream": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", + "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/semver": { + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz", + "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==", + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/simple-concat": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.1.tgz", + "integrity": "sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "peer": true + }, + "node_modules/simple-get": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/simple-get/-/simple-get-4.0.1.tgz", + "integrity": "sha512-brv7p5WgH0jmQJr1ZDDfKDOSeWWg+OVypG99A/5vYGPqJ6pxiaHLy8nxtFjBA7oMa01ebA9gfh1uMCFqOuXxvA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "peer": true, + "dependencies": { + "decompress-response": "^6.0.0", + "once": "^1.3.1", + "simple-concat": "^1.0.0" + } + }, + "node_modules/string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "dependencies": { + "safe-buffer": "~5.2.0" + } + }, + "node_modules/strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha512-4gB8na07fecVVkOI6Rs4e7T6NOTki5EmL7TUduTs6bu3EdnSycntVJ4re8kgZA+wx9IueI2Y11bfbgwtzuE0KQ==", + "peer": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/tar-fs": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.1.tgz", + "integrity": "sha512-V0r2Y9scmbDRLCNex/+hYzvp/zyYjvFbHPNgVTKfQvVrb6guiE/fxP+XblDNR011utopbkex2nM4dHNV6GDsng==", + "dependencies": { + "chownr": "^1.1.1", + "mkdirp-classic": "^0.5.2", + "pump": "^3.0.0", + "tar-stream": "^2.1.4" + } + }, + "node_modules/tar-stream": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.2.0.tgz", + "integrity": "sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==", + "dependencies": { + "bl": "^4.0.3", + "end-of-stream": "^1.4.1", + "fs-constants": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^3.1.1" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/tree-sitter": { + "version": "0.20.6", + "resolved": "https://registry.npmjs.org/tree-sitter/-/tree-sitter-0.20.6.tgz", + "integrity": "sha512-GxJodajVpfgb3UREzzIbtA1hyRnTxVbWVXrbC6sk4xTMH5ERMBJk9HJNq4c8jOJeUaIOmLcwg+t6mez/PDvGqg==", + "hasInstallScript": true, + "peer": true, + "dependencies": { + "nan": "^2.18.0", + "prebuild-install": "^7.1.1" + } + }, + "node_modules/tree-sitter-cli": { + "version": "0.20.8", + "resolved": "https://registry.npmjs.org/tree-sitter-cli/-/tree-sitter-cli-0.20.8.tgz", + "integrity": "sha512-XjTcS3wdTy/2cc/ptMLc/WRyOLECRYcMTrSWyhZnj1oGSOWbHLTklgsgRICU3cPfb0vy+oZCC33M43u6R1HSCA==", + "dev": true, + "hasInstallScript": true, + "bin": { + "tree-sitter": "cli.js" + } + }, + "node_modules/tunnel-agent": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", + "integrity": "sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w==", + "peer": true, + "dependencies": { + "safe-buffer": "^5.0.1" + }, + "engines": { + "node": "*" + } + }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==" + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" + }, + "node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + } + } +} diff --git a/package.json b/package.json index 097d380..c403615 100644 --- a/package.json +++ b/package.json @@ -8,12 +8,27 @@ "incremental" ], "dependencies": { - "nan": "^2.12.1" + "nan": "^2.12.1", + "node-addon-api": "^8.0.0", + "node-gyp-build": "^4.8.1" }, "devDependencies": { - "tree-sitter-cli": "^0.20.2" + "tree-sitter-cli": "^0.20.2", + "prebuildify": "^6.0.0" + }, + "peerDependencies": { + "tree-sitter": "^0.20.2" + }, + "peerDependenciesMeta": { + "tree_sitter": { + "optional": true + } }, "scripts": { - "test": "tree-sitter test" + "tree-sitter": "tree-sitter", + "generate": "tree-sitter generate", + "test": "tree-sitter test", + "build": "tree-sitter generate && node-gyp build", + "install": "node-gyp-build" } } diff --git a/src/parser.c b/src/parser.c index 738fb99..584d38f 100644 --- a/src/parser.c +++ b/src/parser.c @@ -5,7 +5,7 @@ #pragma GCC diagnostic ignored "-Wmissing-field-initializers" #endif -#define LANGUAGE_VERSION 13 +#define LANGUAGE_VERSION 14 #define STATE_COUNT 99 #define LARGE_STATE_COUNT 2 #define SYMBOL_COUNT 50 @@ -499,6 +499,108 @@ 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, + [33] = 33, + [34] = 34, + [35] = 35, + [36] = 36, + [37] = 37, + [38] = 38, + [39] = 39, + [40] = 40, + [41] = 41, + [42] = 42, + [43] = 43, + [44] = 44, + [45] = 45, + [46] = 46, + [47] = 47, + [48] = 48, + [49] = 49, + [50] = 50, + [51] = 51, + [52] = 52, + [53] = 53, + [54] = 54, + [55] = 55, + [56] = 56, + [57] = 57, + [58] = 58, + [59] = 59, + [60] = 60, + [61] = 61, + [62] = 62, + [63] = 63, + [64] = 64, + [65] = 65, + [66] = 66, + [67] = 67, + [68] = 68, + [69] = 69, + [70] = 70, + [71] = 71, + [72] = 72, + [73] = 73, + [74] = 74, + [75] = 75, + [76] = 76, + [77] = 77, + [78] = 78, + [79] = 79, + [80] = 80, + [81] = 81, + [82] = 82, + [83] = 83, + [84] = 84, + [85] = 85, + [86] = 86, + [87] = 87, + [88] = 88, + [89] = 89, + [90] = 90, + [91] = 91, + [92] = 92, + [93] = 93, + [94] = 94, + [95] = 95, + [96] = 96, + [97] = 97, + [98] = 98, +}; + static bool ts_lex(TSLexer *lexer, TSStateId state) { START_LEXER(); eof = lexer->eof(lexer); @@ -2386,6 +2488,7 @@ extern const TSLanguage *tree_sitter_dbscheme(void) { .lex_fn = ts_lex, .keyword_lex_fn = ts_lex_keywords, .keyword_capture_token = sym__lower_id, + .primary_state_ids = ts_primary_state_ids, }; return &language; } diff --git a/src/tree_sitter/parser.h b/src/tree_sitter/parser.h index cbbc7b4..2b14ac1 100644 --- a/src/tree_sitter/parser.h +++ b/src/tree_sitter/parser.h @@ -123,6 +123,7 @@ struct TSLanguage { unsigned (*serialize)(void *, char *); void (*deserialize)(void *, const char *, unsigned); } external_scanner; + const TSStateId *primary_state_ids; }; /* From 60945c572ab3c05c08a295b38eb368a59752541a Mon Sep 17 00:00:00 2001 From: erik-krogh Date: Fri, 3 May 2024 14:45:34 +0200 Subject: [PATCH 6/9] update tree-sitter and generate the new files --- .editorconfig | 39 +++ .gitattributes | 11 + .gitignore | 3 +- Cargo.lock | 71 +++++ Makefile | 112 +++++++ Package.swift | 47 +++ binding.gyp | 25 +- bindings/c/tree-sitter-dbscheme.h | 16 + bindings/c/tree-sitter-dbscheme.pc.in | 11 + bindings/go/binding.go | 13 + bindings/go/binding_test.go | 15 + bindings/go/go.mod | 5 + bindings/node/binding.cc | 36 +-- bindings/node/index.d.ts | 28 ++ bindings/node/index.js | 18 +- .../python/tree_sitter_dbscheme/__init__.py | 5 + .../python/tree_sitter_dbscheme/__init__.pyi | 1 + .../python/tree_sitter_dbscheme/binding.c | 27 ++ bindings/python/tree_sitter_dbscheme/py.typed | 0 bindings/rust/build.rs | 3 + bindings/swift/TreeSitterDbscheme/dbscheme.h | 16 + package-lock.json | 258 ++++------------ package.json | 29 +- pyproject.toml | 29 ++ setup.py | 60 ++++ src/grammar.json | 1 - src/parser.c | 239 ++++++++------- src/tree_sitter/alloc.h | 54 ++++ src/tree_sitter/array.h | 290 ++++++++++++++++++ src/tree_sitter/parser.h | 67 +++- 30 files changed, 1143 insertions(+), 386 deletions(-) create mode 100644 .editorconfig create mode 100644 .gitattributes create mode 100644 Cargo.lock create mode 100644 Makefile create mode 100644 Package.swift create mode 100644 bindings/c/tree-sitter-dbscheme.h create mode 100644 bindings/c/tree-sitter-dbscheme.pc.in create mode 100644 bindings/go/binding.go create mode 100644 bindings/go/binding_test.go create mode 100644 bindings/go/go.mod create mode 100644 bindings/node/index.d.ts create mode 100644 bindings/python/tree_sitter_dbscheme/__init__.py create mode 100644 bindings/python/tree_sitter_dbscheme/__init__.pyi create mode 100644 bindings/python/tree_sitter_dbscheme/binding.c create mode 100644 bindings/python/tree_sitter_dbscheme/py.typed create mode 100644 bindings/swift/TreeSitterDbscheme/dbscheme.h create mode 100644 pyproject.toml create mode 100644 setup.py create mode 100644 src/tree_sitter/alloc.h create mode 100644 src/tree_sitter/array.h diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..d3a8b5b --- /dev/null +++ b/.editorconfig @@ -0,0 +1,39 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true + +[*.{json,toml,yml,gyp}] +indent_style = space +indent_size = 2 + +[*.js] +indent_style = space +indent_size = 2 + +[*.rs] +indent_style = space +indent_size = 4 + +[*.{c,cc,h}] +indent_style = space +indent_size = 4 + +[*.{py,pyi}] +indent_style = space +indent_size = 4 + +[*.swift] +indent_style = space +indent_size = 4 + +[*.go] +indent_style = tab +indent_size = 8 + +[Makefile] +indent_style = tab +indent_size = 8 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..ffb52ab --- /dev/null +++ b/.gitattributes @@ -0,0 +1,11 @@ +* text eol=lf + +src/*.json linguist-generated +src/parser.c linguist-generated +src/tree_sitter/* linguist-generated + +bindings/** linguist-generated +binding.gyp linguist-generated +setup.py linguist-generated +Makefile linguist-generated +Package.swift linguist-generated diff --git a/.gitignore b/.gitignore index b51ea71..c986f74 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules/ -build/ \ No newline at end of file +build/ +target/ \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..0a40fd6 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,71 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] +name = "cc" +version = "1.0.96" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "065a29261d53ba54260972629f9ca6bffa69bac13cd1fed61420f7fa68b9f8bd" + +[[package]] +name = "memchr" +version = "2.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" + +[[package]] +name = "regex" +version = "1.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" + +[[package]] +name = "tree-sitter" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e747b1f9b7b931ed39a548c1fae149101497de3c1fc8d9e18c62c1a66c683d3d" +dependencies = [ + "cc", + "regex", +] + +[[package]] +name = "tree-sitter-ql-dbscheme" +version = "0.0.1" +dependencies = [ + "cc", + "tree-sitter", +] diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e557714 --- /dev/null +++ b/Makefile @@ -0,0 +1,112 @@ +VERSION := 0.0.1 + +LANGUAGE_NAME := tree-sitter-dbscheme + +# repository +SRC_DIR := src + +PARSER_REPO_URL := $(shell git -C $(SRC_DIR) remote get-url origin 2>/dev/null) + +ifeq ($(PARSER_URL),) + PARSER_URL := $(subst .git,,$(PARSER_REPO_URL)) +ifeq ($(shell echo $(PARSER_URL) | grep '^[a-z][-+.0-9a-z]*://'),) + PARSER_URL := $(subst :,/,$(PARSER_URL)) + PARSER_URL := $(subst git@,https://,$(PARSER_URL)) +endif +endif + +TS ?= tree-sitter + +# ABI versioning +SONAME_MAJOR := $(word 1,$(subst ., ,$(VERSION))) +SONAME_MINOR := $(word 2,$(subst ., ,$(VERSION))) + +# install directory layout +PREFIX ?= /usr/local +INCLUDEDIR ?= $(PREFIX)/include +LIBDIR ?= $(PREFIX)/lib +PCLIBDIR ?= $(LIBDIR)/pkgconfig + +# source/object files +PARSER := $(SRC_DIR)/parser.c +EXTRAS := $(filter-out $(PARSER),$(wildcard $(SRC_DIR)/*.c)) +OBJS := $(patsubst %.c,%.o,$(PARSER) $(EXTRAS)) + +# flags +ARFLAGS ?= rcs +override CFLAGS += -I$(SRC_DIR) -std=c11 -fPIC + +# OS-specific bits +ifeq ($(OS),Windows_NT) + $(error "Windows is not supported") +else ifeq ($(shell uname),Darwin) + SOEXT = dylib + SOEXTVER_MAJOR = $(SONAME_MAJOR).dylib + SOEXTVER = $(SONAME_MAJOR).$(SONAME_MINOR).dylib + LINKSHARED := $(LINKSHARED)-dynamiclib -Wl, + ifneq ($(ADDITIONAL_LIBS),) + LINKSHARED := $(LINKSHARED)$(ADDITIONAL_LIBS), + endif + LINKSHARED := $(LINKSHARED)-install_name,$(LIBDIR)/lib$(LANGUAGE_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 ($(ADDITIONAL_LIBS),) + LINKSHARED := $(LINKSHARED)$(ADDITIONAL_LIBS) + endif + LINKSHARED := $(LINKSHARED)-soname,lib$(LANGUAGE_NAME).so.$(SONAME_MAJOR) +endif +ifneq ($(filter $(shell uname),FreeBSD NetBSD DragonFly),) + PCLIBDIR := $(PREFIX)/libdata/pkgconfig +endif + +all: lib$(LANGUAGE_NAME).a lib$(LANGUAGE_NAME).$(SOEXT) $(LANGUAGE_NAME).pc + +lib$(LANGUAGE_NAME).a: $(OBJS) + $(AR) $(ARFLAGS) $@ $^ + +lib$(LANGUAGE_NAME).$(SOEXT): $(OBJS) + $(CC) $(LDFLAGS) $(LINKSHARED) $^ $(LDLIBS) -o $@ +ifneq ($(STRIP),) + $(STRIP) $@ +endif + +$(LANGUAGE_NAME).pc: bindings/c/$(LANGUAGE_NAME).pc.in + sed -e 's|@URL@|$(PARSER_URL)|' \ + -e 's|@VERSION@|$(VERSION)|' \ + -e 's|@LIBDIR@|$(LIBDIR)|' \ + -e 's|@INCLUDEDIR@|$(INCLUDEDIR)|' \ + -e 's|@REQUIRES@|$(REQUIRES)|' \ + -e 's|@ADDITIONAL_LIBS@|$(ADDITIONAL_LIBS)|' \ + -e 's|=$(PREFIX)|=$${prefix}|' \ + -e 's|@PREFIX@|$(PREFIX)|' $< > $@ + +$(PARSER): $(SRC_DIR)/grammar.json + $(TS) generate --no-bindings $^ + +install: all + install -d '$(DESTDIR)$(INCLUDEDIR)'/tree_sitter '$(DESTDIR)$(PCLIBDIR)' '$(DESTDIR)$(LIBDIR)' + install -m644 bindings/c/$(LANGUAGE_NAME).h '$(DESTDIR)$(INCLUDEDIR)'/tree_sitter/$(LANGUAGE_NAME).h + install -m644 $(LANGUAGE_NAME).pc '$(DESTDIR)$(PCLIBDIR)'/$(LANGUAGE_NAME).pc + install -m644 lib$(LANGUAGE_NAME).a '$(DESTDIR)$(LIBDIR)'/lib$(LANGUAGE_NAME).a + install -m755 lib$(LANGUAGE_NAME).$(SOEXT) '$(DESTDIR)$(LIBDIR)'/lib$(LANGUAGE_NAME).$(SOEXTVER) + ln -sf lib$(LANGUAGE_NAME).$(SOEXTVER) '$(DESTDIR)$(LIBDIR)'/lib$(LANGUAGE_NAME).$(SOEXTVER_MAJOR) + ln -sf lib$(LANGUAGE_NAME).$(SOEXTVER_MAJOR) '$(DESTDIR)$(LIBDIR)'/lib$(LANGUAGE_NAME).$(SOEXT) + +uninstall: + $(RM) '$(DESTDIR)$(LIBDIR)'/lib$(LANGUAGE_NAME).a \ + '$(DESTDIR)$(LIBDIR)'/lib$(LANGUAGE_NAME).$(SOEXTVER) \ + '$(DESTDIR)$(LIBDIR)'/lib$(LANGUAGE_NAME).$(SOEXTVER_MAJOR) \ + '$(DESTDIR)$(LIBDIR)'/lib$(LANGUAGE_NAME).$(SOEXT) \ + '$(DESTDIR)$(INCLUDEDIR)'/tree_sitter/$(LANGUAGE_NAME).h \ + '$(DESTDIR)$(PCLIBDIR)'/$(LANGUAGE_NAME).pc + +clean: + $(RM) $(OBJS) $(LANGUAGE_NAME).pc lib$(LANGUAGE_NAME).a lib$(LANGUAGE_NAME).$(SOEXT) + +test: + $(TS) test + +.PHONY: all install uninstall clean test diff --git a/Package.swift b/Package.swift new file mode 100644 index 0000000..35645b4 --- /dev/null +++ b/Package.swift @@ -0,0 +1,47 @@ +// swift-tools-version:5.3 +import PackageDescription + +let package = Package( + name: "TreeSitterDbscheme", + products: [ + .library(name: "TreeSitterDbscheme", targets: ["TreeSitterDbscheme"]), + ], + dependencies: [], + targets: [ + .target(name: "TreeSitterDbscheme", + path: ".", + exclude: [ + "Cargo.toml", + "Makefile", + "binding.gyp", + "bindings/c", + "bindings/go", + "bindings/node", + "bindings/python", + "bindings/rust", + "prebuilds", + "grammar.js", + "package.json", + "package-lock.json", + "pyproject.toml", + "setup.py", + "test", + "examples", + ".editorconfig", + ".github", + ".gitignore", + ".gitattributes", + ".gitmodules", + ], + sources: [ + "src/parser.c", + // NOTE: if your language has an external scanner, add it here. + ], + resources: [ + .copy("queries") + ], + publicHeadersPath: "bindings/swift", + cSettings: [.headerSearchPath("src")]) + ], + cLanguageStandard: .c11 +) diff --git a/binding.gyp b/binding.gyp index b39ec5e..79e42b1 100644 --- a/binding.gyp +++ b/binding.gyp @@ -1,19 +1,30 @@ { "targets": [ { - "target_name": "tree_sitter_ql_binding", + "target_name": "tree_sitter_dbscheme_binding", + "dependencies": [ + " -#include "nan.h" +#include -using namespace v8; +typedef struct TSLanguage TSLanguage; -extern "C" TSLanguage * tree_sitter_dbscheme(); +extern "C" TSLanguage *tree_sitter_dbscheme(); -namespace { +// "tree-sitter", "language" hashed with BLAKE2 +const napi_type_tag LANGUAGE_TYPE_TAG = { + 0x8AF2E5212AD58ABF, 0xD5006CAD83ABBA16 +}; -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_dbscheme()); - - Nan::Set(instance, Nan::New("name").ToLocalChecked(), Nan::New("dbscheme").ToLocalChecked()); - Nan::Set(module, Nan::New("exports").ToLocalChecked(), instance); +Napi::Object Init(Napi::Env env, Napi::Object exports) { + exports["name"] = Napi::String::New(env, "dbscheme"); + auto language = Napi::External::New(env, tree_sitter_dbscheme()); + language.TypeTag(&LANGUAGE_TYPE_TAG); + exports["language"] = language; + return exports; } -NODE_MODULE(tree_sitter_dbscheme_binding, Init) - -} // namespace +NODE_API_MODULE(tree_sitter_dbscheme_binding, Init) diff --git a/bindings/node/index.d.ts b/bindings/node/index.d.ts new file mode 100644 index 0000000..efe259e --- /dev/null +++ b/bindings/node/index.d.ts @@ -0,0 +1,28 @@ +type BaseNode = { + type: string; + named: boolean; +}; + +type ChildNode = { + multiple: boolean; + required: boolean; + types: BaseNode[]; +}; + +type NodeInfo = + | (BaseNode & { + subtypes: BaseNode[]; + }) + | (BaseNode & { + fields: { [name: string]: ChildNode }; + children: ChildNode[]; + }); + +type Language = { + name: string; + language: unknown; + nodeTypeInfo: NodeInfo[]; +}; + +declare const language: Language; +export = language; diff --git a/bindings/node/index.js b/bindings/node/index.js index 30ab2aa..6657bcf 100644 --- a/bindings/node/index.js +++ b/bindings/node/index.js @@ -1,18 +1,6 @@ -try { - module.exports = require("../../build/Release/tree_sitter_dbscheme_binding"); -} catch (error1) { - if (error1.code !== 'MODULE_NOT_FOUND') { - throw error1; - } - try { - module.exports = require("../../build/Debug/tree_sitter_dbscheme_binding"); - } catch (error2) { - if (error2.code !== 'MODULE_NOT_FOUND') { - throw error2; - } - throw error1 - } -} +const root = require("path").join(__dirname, "..", ".."); + +module.exports = require("node-gyp-build")(root); try { module.exports.nodeTypeInfo = require("../../src/node-types.json"); diff --git a/bindings/python/tree_sitter_dbscheme/__init__.py b/bindings/python/tree_sitter_dbscheme/__init__.py new file mode 100644 index 0000000..d597a37 --- /dev/null +++ b/bindings/python/tree_sitter_dbscheme/__init__.py @@ -0,0 +1,5 @@ +"Dbscheme grammar for tree-sitter" + +from ._binding import language + +__all__ = ["language"] diff --git a/bindings/python/tree_sitter_dbscheme/__init__.pyi b/bindings/python/tree_sitter_dbscheme/__init__.pyi new file mode 100644 index 0000000..5416666 --- /dev/null +++ b/bindings/python/tree_sitter_dbscheme/__init__.pyi @@ -0,0 +1 @@ +def language() -> int: ... diff --git a/bindings/python/tree_sitter_dbscheme/binding.c b/bindings/python/tree_sitter_dbscheme/binding.c new file mode 100644 index 0000000..28fb67e --- /dev/null +++ b/bindings/python/tree_sitter_dbscheme/binding.c @@ -0,0 +1,27 @@ +#include + +typedef struct TSLanguage TSLanguage; + +TSLanguage *tree_sitter_dbscheme(void); + +static PyObject* _binding_language(PyObject *self, PyObject *args) { + return PyLong_FromVoidPtr(tree_sitter_dbscheme()); +} + +static PyMethodDef methods[] = { + {"language", _binding_language, METH_NOARGS, + "Get the tree-sitter language for this grammar."}, + {NULL, NULL, 0, NULL} +}; + +static struct PyModuleDef module = { + .m_base = PyModuleDef_HEAD_INIT, + .m_name = "_binding", + .m_doc = NULL, + .m_size = -1, + .m_methods = methods +}; + +PyMODINIT_FUNC PyInit__binding(void) { + return PyModule_Create(&module); +} diff --git a/bindings/python/tree_sitter_dbscheme/py.typed b/bindings/python/tree_sitter_dbscheme/py.typed new file mode 100644 index 0000000..e69de29 diff --git a/bindings/rust/build.rs b/bindings/rust/build.rs index c6061f0..4cc26f5 100644 --- a/bindings/rust/build.rs +++ b/bindings/rust/build.rs @@ -7,6 +7,9 @@ fn main() { .flag_if_supported("-Wno-unused-parameter") .flag_if_supported("-Wno-unused-but-set-variable") .flag_if_supported("-Wno-trigraphs"); + #[cfg(target_env = "msvc")] + c_config.flag("-utf-8"); + let parser_path = src_dir.join("parser.c"); c_config.file(&parser_path); diff --git a/bindings/swift/TreeSitterDbscheme/dbscheme.h b/bindings/swift/TreeSitterDbscheme/dbscheme.h new file mode 100644 index 0000000..f2f6c22 --- /dev/null +++ b/bindings/swift/TreeSitterDbscheme/dbscheme.h @@ -0,0 +1,16 @@ +#ifndef TREE_SITTER_DBSCHEME_H_ +#define TREE_SITTER_DBSCHEME_H_ + +typedef struct TSLanguage TSLanguage; + +#ifdef __cplusplus +extern "C" { +#endif + +const TSLanguage *tree_sitter_dbscheme(void); + +#ifdef __cplusplus +} +#endif + +#endif // TREE_SITTER_DBSCHEME_H_ diff --git a/package-lock.json b/package-lock.json index d20f3c8..60b370b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,16 +9,16 @@ "version": "0.0.1", "hasInstallScript": true, "dependencies": { - "nan": "^2.12.1", - "node-addon-api": "^8.0.0", - "node-gyp-build": "^4.8.1" + "node-addon-api": "^7.1.0", + "node-gyp-build": "^4.8.1", + "tree-sitter": "^0.21.1" }, "devDependencies": { "prebuildify": "^6.0.0", - "tree-sitter-cli": "^0.20.2" + "tree-sitter-cli": "^0.22.5" }, "peerDependencies": { - "tree-sitter": "^0.20.2" + "tree-sitter": "^0.21.1" }, "peerDependenciesMeta": { "tree_sitter": { @@ -30,6 +30,7 @@ "version": "1.5.1", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "dev": true, "funding": [ { "type": "github", @@ -49,6 +50,7 @@ "version": "4.1.0", "resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz", "integrity": "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==", + "dev": true, "dependencies": { "buffer": "^5.5.0", "inherits": "^2.0.4", @@ -59,6 +61,7 @@ "version": "5.7.1", "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", + "dev": true, "funding": [ { "type": "github", @@ -81,73 +84,29 @@ "node_modules/chownr": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz", - "integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==" - }, - "node_modules/decompress-response": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz", - "integrity": "sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==", - "peer": true, - "dependencies": { - "mimic-response": "^3.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/deep-extend": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", - "integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==", - "peer": true, - "engines": { - "node": ">=4.0.0" - } - }, - "node_modules/detect-libc": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.3.tgz", - "integrity": "sha512-bwy0MGW55bG41VqxxypOsdSdGqLwXPI/focwgTYCFMbdUiBAxLg9CFzG08sz2aqzknwiX7Hkl0bQENjg8iLByw==", - "peer": true, - "engines": { - "node": ">=8" - } + "integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==", + "dev": true }, "node_modules/end-of-stream": { "version": "1.4.4", "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", + "dev": true, "dependencies": { "once": "^1.4.0" } }, - "node_modules/expand-template": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/expand-template/-/expand-template-2.0.3.tgz", - "integrity": "sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg==", - "peer": true, - "engines": { - "node": ">=6" - } - }, "node_modules/fs-constants": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", - "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==" - }, - "node_modules/github-from-package": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/github-from-package/-/github-from-package-0.0.0.tgz", - "integrity": "sha512-SyHy3T1v2NUXn29OsWdxmK6RwHD+vkj3v8en8AOBZ1wBQ/hCAQ5bAQTD02kW4W9tUp/3Qh6J8r9EvntiyCmOOw==", - "peer": true + "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==", + "dev": true }, "node_modules/ieee754": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "dev": true, "funding": [ { "type": "github", @@ -166,18 +125,14 @@ "node_modules/inherits": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" - }, - "node_modules/ini": { - "version": "1.3.8", - "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz", - "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==", - "peer": true + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true }, "node_modules/lru-cache": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, "dependencies": { "yallist": "^4.0.0" }, @@ -185,22 +140,11 @@ "node": ">=10" } }, - "node_modules/mimic-response": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz", - "integrity": "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==", - "peer": true, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/minimist": { "version": "1.2.8", "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", + "dev": true, "funding": { "url": "https://github.com/sponsors/ljharb" } @@ -208,23 +152,14 @@ "node_modules/mkdirp-classic": { "version": "0.5.3", "resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz", - "integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==" - }, - "node_modules/nan": { - "version": "2.19.0", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.19.0.tgz", - "integrity": "sha512-nO1xXxfh/RWNxfd/XPfbIfFk5vgLsAxUR9y5O0cHMJu/AW9U95JLXqthYHjEp+8gQ5p96K9jUp8nbVOxCdRbtw==" - }, - "node_modules/napi-build-utils": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/napi-build-utils/-/napi-build-utils-1.0.2.tgz", - "integrity": "sha512-ONmRUqK7zj7DWX0D9ADe03wbwOBZxNAfF20PlGfCWQcD3+/MakShIHrMqx9YwPTfxDdF1zLeL+RGZiR9kGMLdg==", - "peer": true + "integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==", + "dev": true }, "node_modules/node-abi": { "version": "3.62.0", "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.62.0.tgz", "integrity": "sha512-CPMcGa+y33xuL1E0TcNIu4YyaZCxnnvkVaEXrsosR3FxN+fV8xvb7Mzpb7IgKler10qeMkE6+Dp8qJhpzdq35g==", + "dev": true, "dependencies": { "semver": "^7.3.5" }, @@ -233,11 +168,11 @@ } }, "node_modules/node-addon-api": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-8.0.0.tgz", - "integrity": "sha512-ipO7rsHEBqa9STO5C5T10fj732ml+5kLN1cAG8/jdHd56ldQeGj3Q7+scUS+VHK/qy1zLEwC4wMK5+yM0btPvw==", + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-7.1.0.tgz", + "integrity": "sha512-mNcltoe1R8o7STTegSOHdnJNN7s5EUvhoS7ShnTHDyOSd+8H+UdWODq6qSv67PjC8Zc5JRT8+oLAMCr0SIXw7g==", "engines": { - "node": "^18 || ^20 || >= 21" + "node": "^16 || ^18 || >= 20" } }, "node_modules/node-gyp-build": { @@ -266,6 +201,7 @@ "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dev": true, "dependencies": { "wrappy": "1" } @@ -279,32 +215,6 @@ "node": ">=8" } }, - "node_modules/prebuild-install": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-7.1.2.tgz", - "integrity": "sha512-UnNke3IQb6sgarcZIDU3gbMeTp/9SSU1DAIkil7PrqG1vZlBtY5msYccSKSHDqa3hNg436IXK+SNImReuA1wEQ==", - "peer": true, - "dependencies": { - "detect-libc": "^2.0.0", - "expand-template": "^2.0.3", - "github-from-package": "0.0.0", - "minimist": "^1.2.3", - "mkdirp-classic": "^0.5.3", - "napi-build-utils": "^1.0.1", - "node-abi": "^3.3.0", - "pump": "^3.0.0", - "rc": "^1.2.7", - "simple-get": "^4.0.0", - "tar-fs": "^2.0.0", - "tunnel-agent": "^0.6.0" - }, - "bin": { - "prebuild-install": "bin.js" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/prebuildify": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/prebuildify/-/prebuildify-6.0.1.tgz", @@ -326,30 +236,17 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", + "dev": true, "dependencies": { "end-of-stream": "^1.1.0", "once": "^1.3.1" } }, - "node_modules/rc": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", - "integrity": "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==", - "peer": true, - "dependencies": { - "deep-extend": "^0.6.0", - "ini": "~1.3.0", - "minimist": "^1.2.0", - "strip-json-comments": "~2.0.1" - }, - "bin": { - "rc": "cli.js" - } - }, "node_modules/readable-stream": { "version": "3.6.2", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", + "dev": true, "dependencies": { "inherits": "^2.0.3", "string_decoder": "^1.1.1", @@ -363,6 +260,7 @@ "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "dev": true, "funding": [ { "type": "github", @@ -382,6 +280,7 @@ "version": "7.6.0", "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz", "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==", + "dev": true, "dependencies": { "lru-cache": "^6.0.0" }, @@ -392,72 +291,20 @@ "node": ">=10" } }, - "node_modules/simple-concat": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.1.tgz", - "integrity": "sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "peer": true - }, - "node_modules/simple-get": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/simple-get/-/simple-get-4.0.1.tgz", - "integrity": "sha512-brv7p5WgH0jmQJr1ZDDfKDOSeWWg+OVypG99A/5vYGPqJ6pxiaHLy8nxtFjBA7oMa01ebA9gfh1uMCFqOuXxvA==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "peer": true, - "dependencies": { - "decompress-response": "^6.0.0", - "once": "^1.3.1", - "simple-concat": "^1.0.0" - } - }, "node_modules/string_decoder": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "dev": true, "dependencies": { "safe-buffer": "~5.2.0" } }, - "node_modules/strip-json-comments": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", - "integrity": "sha512-4gB8na07fecVVkOI6Rs4e7T6NOTki5EmL7TUduTs6bu3EdnSycntVJ4re8kgZA+wx9IueI2Y11bfbgwtzuE0KQ==", - "peer": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/tar-fs": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.1.tgz", "integrity": "sha512-V0r2Y9scmbDRLCNex/+hYzvp/zyYjvFbHPNgVTKfQvVrb6guiE/fxP+XblDNR011utopbkex2nM4dHNV6GDsng==", + "dev": true, "dependencies": { "chownr": "^1.1.1", "mkdirp-classic": "^0.5.2", @@ -469,6 +316,7 @@ "version": "2.2.0", "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.2.0.tgz", "integrity": "sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==", + "dev": true, "dependencies": { "bl": "^4.0.3", "end-of-stream": "^1.4.1", @@ -481,52 +329,50 @@ } }, "node_modules/tree-sitter": { - "version": "0.20.6", - "resolved": "https://registry.npmjs.org/tree-sitter/-/tree-sitter-0.20.6.tgz", - "integrity": "sha512-GxJodajVpfgb3UREzzIbtA1hyRnTxVbWVXrbC6sk4xTMH5ERMBJk9HJNq4c8jOJeUaIOmLcwg+t6mez/PDvGqg==", + "version": "0.21.1", + "resolved": "https://registry.npmjs.org/tree-sitter/-/tree-sitter-0.21.1.tgz", + "integrity": "sha512-7dxoA6kYvtgWw80265MyqJlkRl4yawIjO7S5MigytjELkX43fV2WsAXzsNfO7sBpPPCF5Gp0+XzHk0DwLCq3xQ==", "hasInstallScript": true, - "peer": true, "dependencies": { - "nan": "^2.18.0", - "prebuild-install": "^7.1.1" + "node-addon-api": "^8.0.0", + "node-gyp-build": "^4.8.0" } }, "node_modules/tree-sitter-cli": { - "version": "0.20.8", - "resolved": "https://registry.npmjs.org/tree-sitter-cli/-/tree-sitter-cli-0.20.8.tgz", - "integrity": "sha512-XjTcS3wdTy/2cc/ptMLc/WRyOLECRYcMTrSWyhZnj1oGSOWbHLTklgsgRICU3cPfb0vy+oZCC33M43u6R1HSCA==", + "version": "0.22.5", + "resolved": "https://registry.npmjs.org/tree-sitter-cli/-/tree-sitter-cli-0.22.5.tgz", + "integrity": "sha512-c3VT46Bc3a6pEd0JAwufbqEw9Q2FRLDp5E230hGvnr+Hivw+Y6jyeP+3T89KDptvn48MOPVmbgaLm69xYgLVTw==", "dev": true, "hasInstallScript": true, "bin": { "tree-sitter": "cli.js" } }, - "node_modules/tunnel-agent": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", - "integrity": "sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w==", - "peer": true, - "dependencies": { - "safe-buffer": "^5.0.1" - }, + "node_modules/tree-sitter/node_modules/node-addon-api": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-8.0.0.tgz", + "integrity": "sha512-ipO7rsHEBqa9STO5C5T10fj732ml+5kLN1cAG8/jdHd56ldQeGj3Q7+scUS+VHK/qy1zLEwC4wMK5+yM0btPvw==", "engines": { - "node": "*" + "node": "^18 || ^20 || >= 21" } }, "node_modules/util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==" + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", + "dev": true }, "node_modules/wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "dev": true }, "node_modules/yallist": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true } } } diff --git a/package.json b/package.json index c403615..82c6af8 100644 --- a/package.json +++ b/package.json @@ -3,32 +3,49 @@ "version": "0.0.1", "description": "ql dbscheme grammar for tree-sitter", "main": "bindings/node", + "types": "bindings/node", "keywords": [ "parsing", "incremental" ], + "files": [ + "grammar.js", + "binding.gyp", + "prebuilds/**", + "bindings/node/*", + "queries/*", + "src/**" + ], "dependencies": { - "nan": "^2.12.1", - "node-addon-api": "^8.0.0", + "tree-sitter": "^0.21.1", + "node-addon-api": "^7.1.0", "node-gyp-build": "^4.8.1" }, "devDependencies": { - "tree-sitter-cli": "^0.20.2", - "prebuildify": "^6.0.0" + "prebuildify": "^6.0.0", + "tree-sitter-cli": "^0.22.5" }, "peerDependencies": { - "tree-sitter": "^0.20.2" + "tree-sitter": "^0.21.1" }, "peerDependenciesMeta": { "tree_sitter": { "optional": true } }, + "tree-sitter": [ + { + "file-types": [ + "dbscheme" + ] + } + ], "scripts": { "tree-sitter": "tree-sitter", "generate": "tree-sitter generate", "test": "tree-sitter test", "build": "tree-sitter generate && node-gyp build", - "install": "node-gyp-build" + "install": "node-gyp-build", + "prebuildify": "prebuildify --napi --strip" } } diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..4621bf8 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,29 @@ +[build-system] +requires = ["setuptools>=42", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "tree-sitter-dbscheme" +description = "Dbscheme grammar for tree-sitter" +version = "0.0.1" +keywords = ["incremental", "parsing", "tree-sitter", "dbscheme"] +classifiers = [ + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Topic :: Software Development :: Compilers", + "Topic :: Text Processing :: Linguistic", + "Typing :: Typed" +] +requires-python = ">=3.8" +license.text = "MIT" +readme = "README.md" + +[project.urls] +Homepage = "https://github.com/tree-sitter/tree-sitter-dbscheme" + +[project.optional-dependencies] +core = ["tree-sitter~=0.21"] + +[tool.cibuildwheel] +build = "cp38-*" +build-frontend = "build" diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..14572e4 --- /dev/null +++ b/setup.py @@ -0,0 +1,60 @@ +from os.path import isdir, join +from platform import system + +from setuptools import Extension, find_packages, setup +from setuptools.command.build import build +from wheel.bdist_wheel import bdist_wheel + + +class Build(build): + def run(self): + if isdir("queries"): + dest = join(self.build_lib, "tree_sitter_dbscheme", "queries") + self.copy_tree("queries", dest) + super().run() + + +class BdistWheel(bdist_wheel): + def get_tag(self): + python, abi, platform = super().get_tag() + if python.startswith("cp"): + python, abi = "cp38", "abi3" + return python, abi, platform + + +setup( + packages=find_packages("bindings/python"), + package_dir={"": "bindings/python"}, + package_data={ + "tree_sitter_dbscheme": ["*.pyi", "py.typed"], + "tree_sitter_dbscheme.queries": ["*.scm"], + }, + ext_package="tree_sitter_dbscheme", + ext_modules=[ + Extension( + name="_binding", + sources=[ + "bindings/python/tree_sitter_dbscheme/binding.c", + "src/parser.c", + # NOTE: if your language uses an external scanner, add it here. + ], + extra_compile_args=[ + "-std=c11", + ] if system() != "Windows" else [ + "/std:c11", + "/utf-8", + ], + define_macros=[ + ("Py_LIMITED_API", "0x03080000"), + ("PY_SSIZE_T_CLEAN", None) + ], + include_dirs=["src"], + py_limited_api=True, + ) + ], + cmdclass={ + "build": Build, + "bdist_wheel": BdistWheel + }, + zip_safe=False +) diff --git a/src/grammar.json b/src/grammar.json index eebc374..2bd7ec4 100644 --- a/src/grammar.json +++ b/src/grammar.json @@ -612,4 +612,3 @@ "inline": [], "supertypes": [] } - diff --git a/src/parser.c b/src/parser.c index 584d38f..dba7410 100644 --- a/src/parser.c +++ b/src/parser.c @@ -1,7 +1,6 @@ -#include +#include "tree_sitter/parser.h" #if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wmissing-field-initializers" #endif @@ -16,7 +15,7 @@ #define MAX_ALIAS_SEQUENCE_LENGTH 8 #define PRODUCTION_ID_COUNT 17 -enum { +enum ts_symbol_identifiers { sym__lower_id = 1, anon_sym_LPAREN = 2, anon_sym_COMMA = 3, @@ -377,7 +376,7 @@ static const TSSymbolMetadata ts_symbol_metadata[] = { }, }; -enum { +enum ts_field_identifiers { field_argsAnnotation = 1, field_base = 2, field_colName = 3, @@ -607,23 +606,25 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) { switch (state) { case 0: if (eof) ADVANCE(13); - if (lookahead == '#') ADVANCE(18); - if (lookahead == '(') ADVANCE(14); - if (lookahead == ')') ADVANCE(16); - if (lookahead == ',') ADVANCE(15); - if (lookahead == '.') ADVANCE(24); - if (lookahead == '/') ADVANCE(1); - if (lookahead == ':') ADVANCE(21); - if (lookahead == ';') ADVANCE(17); - if (lookahead == '=') ADVANCE(22); - if (lookahead == '@') ADVANCE(11); - if (lookahead == '[') ADVANCE(19); - if (lookahead == ']') ADVANCE(20); - if (lookahead == '|') ADVANCE(23); + ADVANCE_MAP( + '#', 18, + '(', 14, + ')', 16, + ',', 15, + '.', 24, + '/', 1, + ':', 21, + ';', 17, + '=', 22, + '@', 11, + '[', 19, + ']', 20, + '|', 23, + ); if (lookahead == '\t' || lookahead == '\n' || lookahead == '\r' || - lookahead == ' ') SKIP(0) + lookahead == ' ') SKIP(0); if (('0' <= lookahead && lookahead <= '9')) ADVANCE(27); if (('A' <= lookahead && lookahead <= 'Z')) ADVANCE(26); if (('a' <= lookahead && lookahead <= 'z')) ADVANCE(25); @@ -675,21 +676,23 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) { END_STATE(); case 12: if (eof) ADVANCE(13); - if (lookahead == '#') ADVANCE(18); - if (lookahead == '(') ADVANCE(14); - if (lookahead == ')') ADVANCE(16); - if (lookahead == ',') ADVANCE(15); - if (lookahead == '.') ADVANCE(24); - if (lookahead == '/') ADVANCE(4); - if (lookahead == ':') ADVANCE(21); - if (lookahead == '=') ADVANCE(22); - if (lookahead == '@') ADVANCE(11); - if (lookahead == '[') ADVANCE(19); - if (lookahead == ']') ADVANCE(20); + ADVANCE_MAP( + '#', 18, + '(', 14, + ')', 16, + ',', 15, + '.', 24, + '/', 4, + ':', 21, + '=', 22, + '@', 11, + '[', 19, + ']', 20, + ); if (lookahead == '\t' || lookahead == '\n' || lookahead == '\r' || - lookahead == ' ') SKIP(12) + lookahead == ' ') SKIP(12); if (('0' <= lookahead && lookahead <= '9')) ADVANCE(27); if (('A' <= lookahead && lookahead <= 'Z')) ADVANCE(26); if (('a' <= lookahead && lookahead <= 'z')) ADVANCE(25); @@ -782,21 +785,23 @@ static bool ts_lex_keywords(TSLexer *lexer, TSStateId state) { eof = lexer->eof(lexer); switch (state) { case 0: - if (lookahead == 'b') ADVANCE(1); - if (lookahead == 'c') ADVANCE(2); - if (lookahead == 'd') ADVANCE(3); - if (lookahead == 'f') ADVANCE(4); - if (lookahead == 'i') ADVANCE(5); - if (lookahead == 'k') ADVANCE(6); - if (lookahead == 'o') ADVANCE(7); - if (lookahead == 'r') ADVANCE(8); - if (lookahead == 's') ADVANCE(9); - if (lookahead == 'u') ADVANCE(10); - if (lookahead == 'v') ADVANCE(11); + ADVANCE_MAP( + 'b', 1, + 'c', 2, + 'd', 3, + 'f', 4, + 'i', 5, + 'k', 6, + 'o', 7, + 'r', 8, + 's', 9, + 'u', 10, + 'v', 11, + ); if (lookahead == '\t' || lookahead == '\n' || lookahead == '\r' || - lookahead == ' ') SKIP(0) + lookahead == ' ') SKIP(0); END_STATE(); case 1: if (lookahead == 'o') ADVANCE(12); @@ -2321,116 +2326,116 @@ static const TSParseActionEntry ts_parse_actions[] = { [1] = {.entry = {.count = 1, .reusable = false}}, RECOVER(), [3] = {.entry = {.count = 1, .reusable = true}}, SHIFT_EXTRA(), [5] = {.entry = {.count = 1, .reusable = false}}, SHIFT_EXTRA(), - [7] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_dbscheme, 0), + [7] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_dbscheme, 0, 0, 0), [9] = {.entry = {.count = 1, .reusable = false}}, SHIFT(39), [11] = {.entry = {.count = 1, .reusable = true}}, SHIFT(74), [13] = {.entry = {.count = 1, .reusable = false}}, SHIFT(97), [15] = {.entry = {.count = 1, .reusable = true}}, SHIFT(39), [17] = {.entry = {.count = 1, .reusable = true}}, SHIFT(93), [19] = {.entry = {.count = 1, .reusable = true}}, SHIFT(36), - [21] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_dbscheme_repeat1, 2), - [23] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_dbscheme_repeat1, 2), SHIFT_REPEAT(39), - [26] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_dbscheme_repeat1, 2), SHIFT_REPEAT(74), - [29] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_dbscheme_repeat1, 2), SHIFT_REPEAT(97), - [32] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_dbscheme_repeat1, 2), SHIFT_REPEAT(39), - [35] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_dbscheme_repeat1, 2), SHIFT_REPEAT(93), - [38] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_dbscheme_repeat1, 2), SHIFT_REPEAT(36), - [41] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_dbscheme, 1), + [21] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_dbscheme_repeat1, 2, 0, 0), + [23] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_dbscheme_repeat1, 2, 0, 0), SHIFT_REPEAT(39), + [26] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_dbscheme_repeat1, 2, 0, 0), SHIFT_REPEAT(74), + [29] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_dbscheme_repeat1, 2, 0, 0), SHIFT_REPEAT(97), + [32] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_dbscheme_repeat1, 2, 0, 0), SHIFT_REPEAT(39), + [35] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_dbscheme_repeat1, 2, 0, 0), SHIFT_REPEAT(93), + [38] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_dbscheme_repeat1, 2, 0, 0), SHIFT_REPEAT(36), + [41] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_dbscheme, 1, 0, 0), [43] = {.entry = {.count = 1, .reusable = true}}, SHIFT(68), [45] = {.entry = {.count = 1, .reusable = true}}, SHIFT(94), [47] = {.entry = {.count = 1, .reusable = true}}, SHIFT(26), [49] = {.entry = {.count = 1, .reusable = true}}, SHIFT(22), - [51] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_unionDecl, 3, .production_id = 3), - [53] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_unionDecl, 3, .production_id = 3), + [51] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_unionDecl, 3, 0, 3), + [53] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_unionDecl, 3, 0, 3), [55] = {.entry = {.count = 1, .reusable = true}}, SHIFT(31), [57] = {.entry = {.count = 1, .reusable = true}}, SHIFT(91), - [59] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_unionDecl_repeat1, 2), - [61] = {.entry = {.count = 1, .reusable = false}}, REDUCE(aux_sym_unionDecl_repeat1, 2), - [63] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_unionDecl_repeat1, 2), SHIFT_REPEAT(91), - [66] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_unionDecl, 4, .production_id = 3), - [68] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_unionDecl, 4, .production_id = 3), + [59] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_unionDecl_repeat1, 2, 0, 0), + [61] = {.entry = {.count = 1, .reusable = false}}, REDUCE(aux_sym_unionDecl_repeat1, 2, 0, 0), + [63] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_unionDecl_repeat1, 2, 0, 0), SHIFT_REPEAT(91), + [66] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_unionDecl, 4, 0, 3), + [68] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_unionDecl, 4, 0, 3), [70] = {.entry = {.count = 1, .reusable = true}}, SHIFT(33), - [72] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_caseDecl, 7, .production_id = 7), - [74] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_caseDecl, 7, .production_id = 7), + [72] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_caseDecl, 7, 0, 7), + [74] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_caseDecl, 7, 0, 7), [76] = {.entry = {.count = 1, .reusable = true}}, SHIFT(37), [78] = {.entry = {.count = 1, .reusable = true}}, SHIFT(56), - [80] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_caseDecl_repeat1, 2), - [82] = {.entry = {.count = 1, .reusable = false}}, REDUCE(aux_sym_caseDecl_repeat1, 2), - [84] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_caseDecl_repeat1, 2), SHIFT_REPEAT(56), - [87] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_caseDecl, 6, .production_id = 7), - [89] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_caseDecl, 6, .production_id = 7), + [80] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_caseDecl_repeat1, 2, 0, 0), + [82] = {.entry = {.count = 1, .reusable = false}}, REDUCE(aux_sym_caseDecl_repeat1, 2, 0, 0), + [84] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_caseDecl_repeat1, 2, 0, 0), SHIFT_REPEAT(56), + [87] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_caseDecl, 6, 0, 7), + [89] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_caseDecl, 6, 0, 7), [91] = {.entry = {.count = 1, .reusable = true}}, SHIFT(30), - [93] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_branch, 3), - [95] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_branch, 3), - [97] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_branch, 4, .production_id = 15), - [99] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_branch, 4, .production_id = 15), - [101] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_table, 4, .production_id = 5), - [103] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_table, 4, .production_id = 5), + [93] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_branch, 3, 0, 0), + [95] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_branch, 3, 0, 0), + [97] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_branch, 4, 0, 15), + [99] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_branch, 4, 0, 15), + [101] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_table, 4, 0, 5), + [103] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_table, 4, 0, 5), [105] = {.entry = {.count = 1, .reusable = true}}, SHIFT(32), - [107] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_table, 5, .production_id = 5), - [109] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_table, 5, .production_id = 5), + [107] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_table, 5, 0, 5), + [109] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_table, 5, 0, 5), [111] = {.entry = {.count = 1, .reusable = true}}, SHIFT(24), - [113] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_table, 5, .production_id = 6), - [115] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_table, 5, .production_id = 6), + [113] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_table, 5, 0, 6), + [115] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_table, 5, 0, 6), [117] = {.entry = {.count = 1, .reusable = true}}, SHIFT(28), - [119] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_table, 6, .production_id = 6), - [121] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_table, 6, .production_id = 6), + [119] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_table, 6, 0, 6), + [121] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_table, 6, 0, 6), [123] = {.entry = {.count = 1, .reusable = true}}, SHIFT(35), [125] = {.entry = {.count = 1, .reusable = true}}, SHIFT(34), [127] = {.entry = {.count = 1, .reusable = true}}, SHIFT(59), - [129] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_table, 6, .production_id = 5), - [131] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_table, 6, .production_id = 5), - [133] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_unionDecl, 5, .production_id = 3), - [135] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_unionDecl, 5, .production_id = 3), - [137] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_table, 7, .production_id = 6), - [139] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_table, 7, .production_id = 6), - [141] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_entry, 1), - [143] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_entry, 1), - [145] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_caseDecl, 8, .production_id = 7), - [147] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_caseDecl, 8, .production_id = 7), - [149] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_table_repeat1, 2), - [151] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_table_repeat1, 2), SHIFT_REPEAT(74), - [154] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_simpleId, 1), + [129] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_table, 6, 0, 5), + [131] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_table, 6, 0, 5), + [133] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_unionDecl, 5, 0, 3), + [135] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_unionDecl, 5, 0, 3), + [137] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_table, 7, 0, 6), + [139] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_table, 7, 0, 6), + [141] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_entry, 1, 0, 0), + [143] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_entry, 1, 0, 0), + [145] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_caseDecl, 8, 0, 7), + [147] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_caseDecl, 8, 0, 7), + [149] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_table_repeat1, 2, 0, 0), + [151] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_table_repeat1, 2, 0, 0), SHIFT_REPEAT(74), + [154] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_simpleId, 1, 0, 0), [156] = {.entry = {.count = 1, .reusable = true}}, SHIFT(67), - [158] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_annotation, 2, .production_id = 2), + [158] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_annotation, 2, 0, 2), [160] = {.entry = {.count = 1, .reusable = true}}, SHIFT(40), - [162] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_annotName, 1), + [162] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_annotName, 1, 0, 0), [164] = {.entry = {.count = 1, .reusable = true}}, SHIFT(47), [166] = {.entry = {.count = 1, .reusable = true}}, SHIFT(65), - [168] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_column, 5, .production_id = 9), + [168] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_column, 5, 0, 9), [170] = {.entry = {.count = 1, .reusable = true}}, SHIFT(73), - [172] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_column, 6, .production_id = 13), + [172] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_column, 6, 0, 13), [174] = {.entry = {.count = 1, .reusable = true}}, SHIFT(69), [176] = {.entry = {.count = 1, .reusable = true}}, SHIFT(4), [178] = {.entry = {.count = 1, .reusable = true}}, SHIFT(20), - [180] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_argsAnnotation, 5, .production_id = 4), + [180] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_argsAnnotation, 5, 0, 4), [182] = {.entry = {.count = 1, .reusable = true}}, SHIFT(87), [184] = {.entry = {.count = 1, .reusable = true}}, SHIFT(82), - [186] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_annotation, 1, .production_id = 1), - [188] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_column, 5, .production_id = 10), + [186] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_annotation, 1, 0, 1), + [188] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_column, 5, 0, 10), [190] = {.entry = {.count = 1, .reusable = true}}, SHIFT(72), [192] = {.entry = {.count = 1, .reusable = true}}, SHIFT(19), - [194] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_column, 4, .production_id = 8), + [194] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_column, 4, 0, 8), [196] = {.entry = {.count = 1, .reusable = true}}, SHIFT(75), - [198] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_colType, 1), - [200] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_table_repeat2, 2), SHIFT_REPEAT(4), - [203] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_table_repeat2, 2), + [198] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_colType, 1, 0, 0), + [200] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_table_repeat2, 2, 0, 0), SHIFT_REPEAT(4), + [203] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_table_repeat2, 2, 0, 0), [205] = {.entry = {.count = 1, .reusable = true}}, SHIFT(17), [207] = {.entry = {.count = 1, .reusable = true}}, SHIFT(48), [209] = {.entry = {.count = 1, .reusable = true}}, SHIFT(21), - [211] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_argsAnnotation, 6, .production_id = 4), - [213] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_argsAnnotation_repeat1, 2), SHIFT_REPEAT(47), - [216] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_argsAnnotation_repeat1, 2), - [218] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_argsAnnotation, 4, .production_id = 4), - [220] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_reprType, 1), - [222] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_column, 7, .production_id = 16), - [224] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_reprType, 4), - [226] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_column, 6, .production_id = 14), - [228] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_column, 6, .production_id = 12), + [211] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_argsAnnotation, 6, 0, 4), + [213] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_argsAnnotation_repeat1, 2, 0, 0), SHIFT_REPEAT(47), + [216] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_argsAnnotation_repeat1, 2, 0, 0), + [218] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_argsAnnotation, 4, 0, 4), + [220] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_reprType, 1, 0, 0), + [222] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_column, 7, 0, 16), + [224] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_reprType, 4, 0, 0), + [226] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_column, 6, 0, 14), + [228] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_column, 6, 0, 12), [230] = {.entry = {.count = 1, .reusable = true}}, SHIFT(42), - [232] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_column, 5, .production_id = 11), + [232] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_column, 5, 0, 11), [234] = {.entry = {.count = 1, .reusable = true}}, SHIFT(25), - [236] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_tableName, 1), + [236] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_tableName, 1, 0, 0), [238] = {.entry = {.count = 1, .reusable = true}}, SHIFT(15), [240] = {.entry = {.count = 1, .reusable = true}}, SHIFT(90), [242] = {.entry = {.count = 1, .reusable = true}}, SHIFT(11), @@ -2456,11 +2461,15 @@ static const TSParseActionEntry ts_parse_actions[] = { #ifdef __cplusplus extern "C" { #endif -#ifdef _WIN32 -#define extern __declspec(dllexport) +#ifdef TREE_SITTER_HIDE_SYMBOLS +#define TS_PUBLIC +#elif defined(_WIN32) +#define TS_PUBLIC __declspec(dllexport) +#else +#define TS_PUBLIC __attribute__((visibility("default"))) #endif -extern const TSLanguage *tree_sitter_dbscheme(void) { +TS_PUBLIC const TSLanguage *tree_sitter_dbscheme(void) { static const TSLanguage language = { .version = LANGUAGE_VERSION, .symbol_count = SYMBOL_COUNT, diff --git a/src/tree_sitter/alloc.h b/src/tree_sitter/alloc.h new file mode 100644 index 0000000..1f4466d --- /dev/null +++ b/src/tree_sitter/alloc.h @@ -0,0 +1,54 @@ +#ifndef TREE_SITTER_ALLOC_H_ +#define TREE_SITTER_ALLOC_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + +// Allow clients to override allocation functions +#ifdef TREE_SITTER_REUSE_ALLOCATOR + +extern void *(*ts_current_malloc)(size_t); +extern void *(*ts_current_calloc)(size_t, size_t); +extern void *(*ts_current_realloc)(void *, size_t); +extern void (*ts_current_free)(void *); + +#ifndef ts_malloc +#define ts_malloc ts_current_malloc +#endif +#ifndef ts_calloc +#define ts_calloc ts_current_calloc +#endif +#ifndef ts_realloc +#define ts_realloc ts_current_realloc +#endif +#ifndef ts_free +#define ts_free ts_current_free +#endif + +#else + +#ifndef ts_malloc +#define ts_malloc malloc +#endif +#ifndef ts_calloc +#define ts_calloc calloc +#endif +#ifndef ts_realloc +#define ts_realloc realloc +#endif +#ifndef ts_free +#define ts_free free +#endif + +#endif + +#ifdef __cplusplus +} +#endif + +#endif // TREE_SITTER_ALLOC_H_ diff --git a/src/tree_sitter/array.h b/src/tree_sitter/array.h new file mode 100644 index 0000000..15a3b23 --- /dev/null +++ b/src/tree_sitter/array.h @@ -0,0 +1,290 @@ +#ifndef TREE_SITTER_ARRAY_H_ +#define TREE_SITTER_ARRAY_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "./alloc.h" + +#include +#include +#include +#include +#include + +#ifdef _MSC_VER +#pragma warning(disable : 4101) +#elif defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-variable" +#endif + +#define Array(T) \ + struct { \ + T *contents; \ + uint32_t size; \ + uint32_t capacity; \ + } + +/// Initialize an array. +#define array_init(self) \ + ((self)->size = 0, (self)->capacity = 0, (self)->contents = NULL) + +/// Create an empty array. +#define array_new() \ + { NULL, 0, 0 } + +/// Get a pointer to the element at a given `index` in the array. +#define array_get(self, _index) \ + (assert((uint32_t)(_index) < (self)->size), &(self)->contents[_index]) + +/// Get a pointer to the first element in the array. +#define array_front(self) array_get(self, 0) + +/// Get a pointer to the last element in the array. +#define array_back(self) array_get(self, (self)->size - 1) + +/// Clear the array, setting its size to zero. Note that this does not free any +/// memory allocated for the array's contents. +#define array_clear(self) ((self)->size = 0) + +/// Reserve `new_capacity` elements of space in the array. If `new_capacity` is +/// less than the array's current capacity, this function has no effect. +#define array_reserve(self, new_capacity) \ + _array__reserve((Array *)(self), array_elem_size(self), new_capacity) + +/// Free any memory allocated for this array. Note that this does not free any +/// memory allocated for the array's contents. +#define array_delete(self) _array__delete((Array *)(self)) + +/// Push a new `element` onto the end of the array. +#define array_push(self, element) \ + (_array__grow((Array *)(self), 1, array_elem_size(self)), \ + (self)->contents[(self)->size++] = (element)) + +/// Increase the array's size by `count` elements. +/// New elements are zero-initialized. +#define array_grow_by(self, count) \ + do { \ + if ((count) == 0) break; \ + _array__grow((Array *)(self), count, array_elem_size(self)); \ + memset((self)->contents + (self)->size, 0, (count) * array_elem_size(self)); \ + (self)->size += (count); \ + } while (0) + +/// Append all elements from one array to the end of another. +#define array_push_all(self, other) \ + array_extend((self), (other)->size, (other)->contents) + +/// Append `count` elements to the end of the array, reading their values from the +/// `contents` pointer. +#define array_extend(self, count, contents) \ + _array__splice( \ + (Array *)(self), array_elem_size(self), (self)->size, \ + 0, count, contents \ + ) + +/// Remove `old_count` elements from the array starting at the given `index`. At +/// the same index, insert `new_count` new elements, reading their values from the +/// `new_contents` pointer. +#define array_splice(self, _index, old_count, new_count, new_contents) \ + _array__splice( \ + (Array *)(self), array_elem_size(self), _index, \ + old_count, new_count, new_contents \ + ) + +/// Insert one `element` into the array at the given `index`. +#define array_insert(self, _index, element) \ + _array__splice((Array *)(self), array_elem_size(self), _index, 0, 1, &(element)) + +/// Remove one element from the array at the given `index`. +#define array_erase(self, _index) \ + _array__erase((Array *)(self), array_elem_size(self), _index) + +/// Pop the last element off the array, returning the element by value. +#define array_pop(self) ((self)->contents[--(self)->size]) + +/// Assign the contents of one array to another, reallocating if necessary. +#define array_assign(self, other) \ + _array__assign((Array *)(self), (const Array *)(other), array_elem_size(self)) + +/// Swap one array with another +#define array_swap(self, other) \ + _array__swap((Array *)(self), (Array *)(other)) + +/// Get the size of the array contents +#define array_elem_size(self) (sizeof *(self)->contents) + +/// Search a sorted array for a given `needle` value, using the given `compare` +/// callback to determine the order. +/// +/// If an existing element is found to be equal to `needle`, then the `index` +/// out-parameter is set to the existing value's index, and the `exists` +/// out-parameter is set to true. Otherwise, `index` is set to an index where +/// `needle` should be inserted in order to preserve the sorting, and `exists` +/// is set to false. +#define array_search_sorted_with(self, compare, needle, _index, _exists) \ + _array__search_sorted(self, 0, compare, , needle, _index, _exists) + +/// Search a sorted array for a given `needle` value, using integer comparisons +/// of a given struct field (specified with a leading dot) to determine the order. +/// +/// See also `array_search_sorted_with`. +#define array_search_sorted_by(self, field, needle, _index, _exists) \ + _array__search_sorted(self, 0, _compare_int, field, needle, _index, _exists) + +/// Insert a given `value` into a sorted array, using the given `compare` +/// callback to determine the order. +#define array_insert_sorted_with(self, compare, value) \ + do { \ + unsigned _index, _exists; \ + array_search_sorted_with(self, compare, &(value), &_index, &_exists); \ + if (!_exists) array_insert(self, _index, value); \ + } while (0) + +/// Insert a given `value` into a sorted array, using integer comparisons of +/// a given struct field (specified with a leading dot) to determine the order. +/// +/// See also `array_search_sorted_by`. +#define array_insert_sorted_by(self, field, value) \ + do { \ + unsigned _index, _exists; \ + array_search_sorted_by(self, field, (value) field, &_index, &_exists); \ + if (!_exists) array_insert(self, _index, value); \ + } while (0) + +// Private + +typedef Array(void) Array; + +/// This is not what you're looking for, see `array_delete`. +static inline void _array__delete(Array *self) { + if (self->contents) { + ts_free(self->contents); + self->contents = NULL; + self->size = 0; + self->capacity = 0; + } +} + +/// This is not what you're looking for, see `array_erase`. +static inline void _array__erase(Array *self, size_t element_size, + uint32_t index) { + assert(index < self->size); + char *contents = (char *)self->contents; + memmove(contents + index * element_size, contents + (index + 1) * element_size, + (self->size - index - 1) * element_size); + self->size--; +} + +/// This is not what you're looking for, see `array_reserve`. +static inline void _array__reserve(Array *self, size_t element_size, uint32_t new_capacity) { + if (new_capacity > self->capacity) { + if (self->contents) { + self->contents = ts_realloc(self->contents, new_capacity * element_size); + } else { + self->contents = ts_malloc(new_capacity * element_size); + } + self->capacity = new_capacity; + } +} + +/// This is not what you're looking for, see `array_assign`. +static inline void _array__assign(Array *self, const Array *other, size_t element_size) { + _array__reserve(self, element_size, other->size); + self->size = other->size; + memcpy(self->contents, other->contents, self->size * element_size); +} + +/// This is not what you're looking for, see `array_swap`. +static inline void _array__swap(Array *self, Array *other) { + Array swap = *other; + *other = *self; + *self = swap; +} + +/// This is not what you're looking for, see `array_push` or `array_grow_by`. +static inline void _array__grow(Array *self, uint32_t count, size_t element_size) { + uint32_t new_size = self->size + count; + if (new_size > self->capacity) { + uint32_t new_capacity = self->capacity * 2; + if (new_capacity < 8) new_capacity = 8; + if (new_capacity < new_size) new_capacity = new_size; + _array__reserve(self, element_size, new_capacity); + } +} + +/// This is not what you're looking for, see `array_splice`. +static inline void _array__splice(Array *self, size_t element_size, + uint32_t index, uint32_t old_count, + uint32_t new_count, const void *elements) { + uint32_t new_size = self->size + new_count - old_count; + uint32_t old_end = index + old_count; + uint32_t new_end = index + new_count; + assert(old_end <= self->size); + + _array__reserve(self, element_size, new_size); + + char *contents = (char *)self->contents; + if (self->size > old_end) { + memmove( + contents + new_end * element_size, + contents + old_end * element_size, + (self->size - old_end) * element_size + ); + } + if (new_count > 0) { + if (elements) { + memcpy( + (contents + index * element_size), + elements, + new_count * element_size + ); + } else { + memset( + (contents + index * element_size), + 0, + new_count * element_size + ); + } + } + self->size += new_count - old_count; +} + +/// A binary search routine, based on Rust's `std::slice::binary_search_by`. +/// This is not what you're looking for, see `array_search_sorted_with` or `array_search_sorted_by`. +#define _array__search_sorted(self, start, compare, suffix, needle, _index, _exists) \ + do { \ + *(_index) = start; \ + *(_exists) = false; \ + uint32_t size = (self)->size - *(_index); \ + if (size == 0) break; \ + int comparison; \ + while (size > 1) { \ + uint32_t half_size = size / 2; \ + uint32_t mid_index = *(_index) + half_size; \ + comparison = compare(&((self)->contents[mid_index] suffix), (needle)); \ + if (comparison <= 0) *(_index) = mid_index; \ + size -= half_size; \ + } \ + comparison = compare(&((self)->contents[*(_index)] suffix), (needle)); \ + if (comparison == 0) *(_exists) = true; \ + else if (comparison < 0) *(_index) += 1; \ + } while (0) + +/// Helper macro for the `_sorted_by` routines below. This takes the left (existing) +/// parameter by reference in order to work with the generic sorting function above. +#define _compare_int(a, b) ((int)*(a) - (int)(b)) + +#ifdef _MSC_VER +#pragma warning(default : 4101) +#elif defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic pop +#endif + +#ifdef __cplusplus +} +#endif + +#endif // TREE_SITTER_ARRAY_H_ diff --git a/src/tree_sitter/parser.h b/src/tree_sitter/parser.h index 2b14ac1..17f0e94 100644 --- a/src/tree_sitter/parser.h +++ b/src/tree_sitter/parser.h @@ -13,9 +13,8 @@ extern "C" { #define ts_builtin_sym_end 0 #define TREE_SITTER_SERIALIZATION_BUFFER_SIZE 1024 -typedef uint16_t TSStateId; - #ifndef TREE_SITTER_API_H_ +typedef uint16_t TSStateId; typedef uint16_t TSSymbol; typedef uint16_t TSFieldId; typedef struct TSLanguage TSLanguage; @@ -87,6 +86,11 @@ typedef union { } entry; } TSParseActionEntry; +typedef struct { + int32_t start; + int32_t end; +} TSCharacterRange; + struct TSLanguage { uint32_t version; uint32_t symbol_count; @@ -126,13 +130,38 @@ struct TSLanguage { const TSStateId *primary_state_ids; }; +static inline bool set_contains(TSCharacterRange *ranges, uint32_t len, int32_t lookahead) { + uint32_t index = 0; + uint32_t size = len - index; + while (size > 1) { + uint32_t half_size = size / 2; + uint32_t mid_index = index + half_size; + TSCharacterRange *range = &ranges[mid_index]; + if (lookahead >= range->start && lookahead <= range->end) { + return true; + } else if (lookahead > range->end) { + index = mid_index; + } + size -= half_size; + } + TSCharacterRange *range = &ranges[index]; + return (lookahead >= range->start && lookahead <= range->end); +} + /* * Lexer Macros */ +#ifdef _MSC_VER +#define UNUSED __pragma(warning(suppress : 4101)) +#else +#define UNUSED __attribute__((unused)) +#endif + #define START_LEXER() \ bool result = false; \ bool skip = false; \ + UNUSED \ bool eof = false; \ int32_t lookahead; \ goto start; \ @@ -148,6 +177,17 @@ struct TSLanguage { goto next_state; \ } +#define ADVANCE_MAP(...) \ + { \ + static const uint16_t map[] = { __VA_ARGS__ }; \ + for (uint32_t i = 0; i < sizeof(map) / sizeof(map[0]); i += 2) { \ + if (map[i] == lookahead) { \ + state = map[i + 1]; \ + goto next_state; \ + } \ + } \ + } + #define SKIP(state_value) \ { \ skip = true; \ @@ -166,7 +206,7 @@ struct TSLanguage { * Parse Table Macros */ -#define SMALL_STATE(id) id - LARGE_STATE_COUNT +#define SMALL_STATE(id) ((id) - LARGE_STATE_COUNT) #define STATE(id) id @@ -176,7 +216,7 @@ struct TSLanguage { {{ \ .shift = { \ .type = TSParseActionTypeShift, \ - .state = state_value \ + .state = (state_value) \ } \ }} @@ -184,7 +224,7 @@ struct TSLanguage { {{ \ .shift = { \ .type = TSParseActionTypeShift, \ - .state = state_value, \ + .state = (state_value), \ .repetition = true \ } \ }} @@ -197,14 +237,15 @@ struct TSLanguage { } \ }} -#define REDUCE(symbol_val, child_count_val, ...) \ - {{ \ - .reduce = { \ - .type = TSParseActionTypeReduce, \ - .symbol = symbol_val, \ - .child_count = child_count_val, \ - __VA_ARGS__ \ - }, \ +#define REDUCE(symbol_name, children, precedence, prod_id) \ + {{ \ + .reduce = { \ + .type = TSParseActionTypeReduce, \ + .symbol = symbol_name, \ + .child_count = children, \ + .dynamic_precedence = precedence, \ + .production_id = prod_id \ + }, \ }} #define RECOVER() \ From d4d11ad2225c02538eb4981ac4f6bdf0e47d019a Mon Sep 17 00:00:00 2001 From: erik-krogh Date: Fri, 3 May 2024 14:51:33 +0200 Subject: [PATCH 7/9] re-generate Rust files --- Cargo.lock | 6 +++--- Cargo.toml | 25 +++++++++++-------------- bindings/rust/build.rs | 31 +++++-------------------------- bindings/rust/lib.rs | 22 ++++++++++++---------- 4 files changed, 31 insertions(+), 53 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0a40fd6..f67e85f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -54,16 +54,16 @@ checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" [[package]] name = "tree-sitter" -version = "0.20.10" +version = "0.22.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e747b1f9b7b931ed39a548c1fae149101497de3c1fc8d9e18c62c1a66c683d3d" +checksum = "688200d842c76dd88f9a7719ecb0483f79f5a766fb1c100756d5d8a059abc71b" dependencies = [ "cc", "regex", ] [[package]] -name = "tree-sitter-ql-dbscheme" +name = "tree-sitter-dbscheme" version = "0.0.1" dependencies = [ "cc", diff --git a/Cargo.toml b/Cargo.toml index e06b842..f85b046 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,26 +1,23 @@ [package] -name = "tree-sitter-ql-dbscheme" -description = "ql dbscheme grammar for the tree-sitter parsing library" +name = "tree-sitter-dbscheme" +description = "Dbscheme grammar for tree-sitter" version = "0.0.1" -keywords = ["incremental", "parsing", "ql"] -categories = ["parsing", "text-editors"] -repository = "https://github.com/tausbn/tree-sitter-ql-dbscheme" -edition = "2018" license = "MIT" +readme = "README.md" +keywords = ["incremental", "parsing", "tree-sitter", "dbscheme"] +categories = ["parsing", "text-editors"] +repository = "https://github.com/tree-sitter/tree-sitter-dbscheme" +edition = "2021" +autoexamples = false build = "bindings/rust/build.rs" -include = [ - "bindings/rust/*", - "grammar.js", - "queries/*", - "src/*", -] +include = ["bindings/rust/*", "grammar.js", "queries/*", "src/*"] [lib] path = "bindings/rust/lib.rs" [dependencies] -tree-sitter = ">= 0.20, < 0.21" +tree-sitter = ">=0.22.5" [build-dependencies] -cc = "1.0" +cc = "1.0.87" diff --git a/bindings/rust/build.rs b/bindings/rust/build.rs index 4cc26f5..a6664b1 100644 --- a/bindings/rust/build.rs +++ b/bindings/rust/build.rs @@ -2,42 +2,21 @@ 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"); + c_config.std("c11").include(src_dir); + #[cfg(target_env = "msvc")] c_config.flag("-utf-8"); let parser_path = src_dir.join("parser.c"); c_config.file(&parser_path); + 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: - + // NOTE: if your language uses an external scanner, uncomment this block: /* 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()); - */ + c_config.compile("tree-sitter-dbscheme"); } diff --git a/bindings/rust/lib.rs b/bindings/rust/lib.rs index 00240bd..b967ec2 100644 --- a/bindings/rust/lib.rs +++ b/bindings/rust/lib.rs @@ -1,13 +1,15 @@ -//! This crate provides dbscheme language support for the [tree-sitter][] parsing library. +//! This crate provides Dbscheme 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 code = r#" +//! "#; //! let mut parser = tree_sitter::Parser::new(); -//! parser.set_language(tree_sitter_dbscheme::language()).expect("Error loading dbscheme grammar"); +//! parser.set_language(&tree_sitter_dbscheme::language()).expect("Error loading Dbscheme grammar"); //! let tree = parser.parse(code, None).unwrap(); +//! assert!(!tree.root_node().has_error()); //! ``` //! //! [Language]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Language.html @@ -31,14 +33,14 @@ pub fn language() -> Language { /// 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"); +pub const NODE_TYPES: &str = include_str!("../../src/node-types.json"); // Uncomment these to include any queries that this grammar contains -// pub const HIGHLIGHTS_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"); +// pub const HIGHLIGHTS_QUERY: &str = include_str!("../../queries/highlights.scm"); +// pub const INJECTIONS_QUERY: &str = include_str!("../../queries/injections.scm"); +// pub const LOCALS_QUERY: &str = include_str!("../../queries/locals.scm"); +// pub const TAGS_QUERY: &str = include_str!("../../queries/tags.scm"); #[cfg(test)] mod tests { @@ -46,7 +48,7 @@ mod tests { fn test_can_load_grammar() { let mut parser = tree_sitter::Parser::new(); parser - .set_language(super::language()) - .expect("Error loading dbscheme language"); + .set_language(&super::language()) + .expect("Error loading Dbscheme grammar"); } } From 5d93fa48c8e78b7cc7177376266874ed6caa51b6 Mon Sep 17 00:00:00 2001 From: erik-krogh Date: Fri, 3 May 2024 15:02:17 +0200 Subject: [PATCH 8/9] get Swift tests to actually work, because the Swift files generated by `tree-sitter generate` does not work with the reference tree-sitter workflow --- .gitignore | 3 ++- Package.resolved | 16 ++++++++++++++++ Package.swift | 16 ++++++++++++++-- .../TreeSitterTestTests.swift | 12 ++++++++++++ 4 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 Package.resolved create mode 100644 bindings/swift/TreeSitterDbschemeTests/TreeSitterTestTests.swift diff --git a/.gitignore b/.gitignore index c986f74..e721622 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ node_modules/ build/ -target/ \ No newline at end of file +target/ +.build/ diff --git a/Package.resolved b/Package.resolved new file mode 100644 index 0000000..9e0a023 --- /dev/null +++ b/Package.resolved @@ -0,0 +1,16 @@ +{ + "object": { + "pins": [ + { + "package": "SwiftTreeSitter", + "repositoryURL": "https://github.com/ChimeHQ/SwiftTreeSitter", + "state": { + "branch": null, + "revision": "2599e95310b3159641469d8a21baf2d3d200e61f", + "version": "0.8.0" + } + } + ] + }, + "version": 1 +} diff --git a/Package.swift b/Package.swift index 35645b4..cc34f73 100644 --- a/Package.swift +++ b/Package.swift @@ -6,7 +6,9 @@ let package = Package( products: [ .library(name: "TreeSitterDbscheme", targets: ["TreeSitterDbscheme"]), ], - dependencies: [], + dependencies: [ + .package(url: "https://github.com/ChimeHQ/SwiftTreeSitter", from: "0.8.0"), + ], targets: [ .target(name: "TreeSitterDbscheme", path: ".", @@ -41,7 +43,17 @@ let package = Package( .copy("queries") ], publicHeadersPath: "bindings/swift", - cSettings: [.headerSearchPath("src")]) + cSettings: [.headerSearchPath("src")] + ), + .testTarget( + name: "TreeSitterDbschemeTests", + dependencies: [ + "SwiftTreeSitter", + "TreeSitterDbscheme", + ], + path: "bindings/swift/TreeSitterDbschemeTests" + ) ], + cLanguageStandard: .c11 ) diff --git a/bindings/swift/TreeSitterDbschemeTests/TreeSitterTestTests.swift b/bindings/swift/TreeSitterDbschemeTests/TreeSitterTestTests.swift new file mode 100644 index 0000000..b71075b --- /dev/null +++ b/bindings/swift/TreeSitterDbschemeTests/TreeSitterTestTests.swift @@ -0,0 +1,12 @@ +import XCTest +import SwiftTreeSitter +import TreeSitterDbscheme + +final class TreeSitterTestTests: XCTestCase { + func testCanLoadGrammar() throws { + let parser = Parser() + let language = Language(language: tree_sitter_dbscheme()) + XCTAssertNoThrow(try parser.setLanguage(language), + "Error loading Test grammar") + } +} From 39e159986ce2dd2f95fcc0df014dd87ac78dc7ec Mon Sep 17 00:00:00 2001 From: erik-krogh Date: Fri, 3 May 2024 15:38:49 +0200 Subject: [PATCH 9/9] name the grammar ql_dbscheme, and re-generate everything --- Cargo.lock | 2 +- Cargo.toml | 8 ++++---- Makefile | 2 +- Package.swift | 9 ++++----- binding.gyp | 2 +- bindings/c/tree-sitter-dbscheme.h | 16 ---------------- bindings/c/tree-sitter-dbscheme.pc.in | 11 ----------- bindings/c/tree-sitter-ql_dbscheme.h | 16 ++++++++++++++++ bindings/c/tree-sitter-ql_dbscheme.pc.in | 11 +++++++++++ bindings/go/binding.go | 4 ++-- bindings/go/binding_test.go | 8 ++++---- bindings/go/go.mod | 2 +- bindings/node/binding.cc | 8 ++++---- .../__init__.py | 2 +- .../__init__.pyi | 0 .../binding.c | 4 ++-- .../py.typed | 0 bindings/rust/build.rs | 2 +- bindings/rust/lib.rs | 10 +++++----- bindings/swift/TreeSitterDbscheme/dbscheme.h | 16 ---------------- .../TreeSitterTestTests.swift | 4 ++-- .../swift/TreeSitterQlDbscheme/ql_dbscheme.h | 16 ++++++++++++++++ grammar.js | 2 +- package.json | 4 ++++ pyproject.toml | 8 ++++---- setup.py | 10 +++++----- src/grammar.json | 2 +- src/parser.c | 2 +- 28 files changed, 92 insertions(+), 89 deletions(-) delete mode 100644 bindings/c/tree-sitter-dbscheme.h delete mode 100644 bindings/c/tree-sitter-dbscheme.pc.in create mode 100644 bindings/c/tree-sitter-ql_dbscheme.h create mode 100644 bindings/c/tree-sitter-ql_dbscheme.pc.in rename bindings/python/{tree_sitter_dbscheme => tree_sitter_ql_dbscheme}/__init__.py (60%) rename bindings/python/{tree_sitter_dbscheme => tree_sitter_ql_dbscheme}/__init__.pyi (100%) rename bindings/python/{tree_sitter_dbscheme => tree_sitter_ql_dbscheme}/binding.c (84%) rename bindings/python/{tree_sitter_dbscheme => tree_sitter_ql_dbscheme}/py.typed (100%) delete mode 100644 bindings/swift/TreeSitterDbscheme/dbscheme.h create mode 100644 bindings/swift/TreeSitterQlDbscheme/ql_dbscheme.h diff --git a/Cargo.lock b/Cargo.lock index f67e85f..757e716 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -63,7 +63,7 @@ dependencies = [ ] [[package]] -name = "tree-sitter-dbscheme" +name = "tree-sitter-ql-dbscheme" version = "0.0.1" dependencies = [ "cc", diff --git a/Cargo.toml b/Cargo.toml index f85b046..ab737b4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,12 +1,12 @@ [package] -name = "tree-sitter-dbscheme" -description = "Dbscheme grammar for tree-sitter" +name = "tree-sitter-ql-dbscheme" +description = "QlDbscheme grammar for tree-sitter" version = "0.0.1" license = "MIT" readme = "README.md" -keywords = ["incremental", "parsing", "tree-sitter", "dbscheme"] +keywords = ["incremental", "parsing", "tree-sitter", "ql-dbscheme"] categories = ["parsing", "text-editors"] -repository = "https://github.com/tree-sitter/tree-sitter-dbscheme" +repository = "https://github.com/tree-sitter/tree-sitter-ql-dbscheme" edition = "2021" autoexamples = false diff --git a/Makefile b/Makefile index e557714..86ac402 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ VERSION := 0.0.1 -LANGUAGE_NAME := tree-sitter-dbscheme +LANGUAGE_NAME := tree-sitter-ql_dbscheme # repository SRC_DIR := src diff --git a/Package.swift b/Package.swift index cc34f73..7149ea1 100644 --- a/Package.swift +++ b/Package.swift @@ -2,15 +2,15 @@ import PackageDescription let package = Package( - name: "TreeSitterDbscheme", + name: "TreeSitterQlDbscheme", products: [ - .library(name: "TreeSitterDbscheme", targets: ["TreeSitterDbscheme"]), + .library(name: "TreeSitterQlDbscheme", targets: ["TreeSitterQlDbscheme"]), ], dependencies: [ .package(url: "https://github.com/ChimeHQ/SwiftTreeSitter", from: "0.8.0"), ], targets: [ - .target(name: "TreeSitterDbscheme", + .target(name: "TreeSitterQlDbscheme", path: ".", exclude: [ "Cargo.toml", @@ -49,11 +49,10 @@ let package = Package( name: "TreeSitterDbschemeTests", dependencies: [ "SwiftTreeSitter", - "TreeSitterDbscheme", + "TreeSitterQlDbscheme", ], path: "bindings/swift/TreeSitterDbschemeTests" ) ], - cLanguageStandard: .c11 ) diff --git a/binding.gyp b/binding.gyp index 79e42b1..453e638 100644 --- a/binding.gyp +++ b/binding.gyp @@ -1,7 +1,7 @@ { "targets": [ { - "target_name": "tree_sitter_dbscheme_binding", + "target_name": "tree_sitter_ql_dbscheme_binding", "dependencies": [ "::New(env, tree_sitter_dbscheme()); + exports["name"] = Napi::String::New(env, "ql_dbscheme"); + auto language = Napi::External::New(env, tree_sitter_ql_dbscheme()); language.TypeTag(&LANGUAGE_TYPE_TAG); exports["language"] = language; return exports; } -NODE_API_MODULE(tree_sitter_dbscheme_binding, Init) +NODE_API_MODULE(tree_sitter_ql_dbscheme_binding, Init) diff --git a/bindings/python/tree_sitter_dbscheme/__init__.py b/bindings/python/tree_sitter_ql_dbscheme/__init__.py similarity index 60% rename from bindings/python/tree_sitter_dbscheme/__init__.py rename to bindings/python/tree_sitter_ql_dbscheme/__init__.py index d597a37..6094857 100644 --- a/bindings/python/tree_sitter_dbscheme/__init__.py +++ b/bindings/python/tree_sitter_ql_dbscheme/__init__.py @@ -1,4 +1,4 @@ -"Dbscheme grammar for tree-sitter" +"QlDbscheme grammar for tree-sitter" from ._binding import language diff --git a/bindings/python/tree_sitter_dbscheme/__init__.pyi b/bindings/python/tree_sitter_ql_dbscheme/__init__.pyi similarity index 100% rename from bindings/python/tree_sitter_dbscheme/__init__.pyi rename to bindings/python/tree_sitter_ql_dbscheme/__init__.pyi diff --git a/bindings/python/tree_sitter_dbscheme/binding.c b/bindings/python/tree_sitter_ql_dbscheme/binding.c similarity index 84% rename from bindings/python/tree_sitter_dbscheme/binding.c rename to bindings/python/tree_sitter_ql_dbscheme/binding.c index 28fb67e..a31cbaf 100644 --- a/bindings/python/tree_sitter_dbscheme/binding.c +++ b/bindings/python/tree_sitter_ql_dbscheme/binding.c @@ -2,10 +2,10 @@ typedef struct TSLanguage TSLanguage; -TSLanguage *tree_sitter_dbscheme(void); +TSLanguage *tree_sitter_ql_dbscheme(void); static PyObject* _binding_language(PyObject *self, PyObject *args) { - return PyLong_FromVoidPtr(tree_sitter_dbscheme()); + return PyLong_FromVoidPtr(tree_sitter_ql_dbscheme()); } static PyMethodDef methods[] = { diff --git a/bindings/python/tree_sitter_dbscheme/py.typed b/bindings/python/tree_sitter_ql_dbscheme/py.typed similarity index 100% rename from bindings/python/tree_sitter_dbscheme/py.typed rename to bindings/python/tree_sitter_ql_dbscheme/py.typed diff --git a/bindings/rust/build.rs b/bindings/rust/build.rs index a6664b1..ceb006d 100644 --- a/bindings/rust/build.rs +++ b/bindings/rust/build.rs @@ -18,5 +18,5 @@ fn main() { println!("cargo:rerun-if-changed={}", scanner_path.to_str().unwrap()); */ - c_config.compile("tree-sitter-dbscheme"); + c_config.compile("tree-sitter-ql_dbscheme"); } diff --git a/bindings/rust/lib.rs b/bindings/rust/lib.rs index b967ec2..ab26ccb 100644 --- a/bindings/rust/lib.rs +++ b/bindings/rust/lib.rs @@ -1,4 +1,4 @@ -//! This crate provides Dbscheme language support for the [tree-sitter][] parsing library. +//! This crate provides QlDbscheme 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: @@ -7,7 +7,7 @@ //! let code = r#" //! "#; //! let mut parser = tree_sitter::Parser::new(); -//! parser.set_language(&tree_sitter_dbscheme::language()).expect("Error loading Dbscheme grammar"); +//! parser.set_language(&tree_sitter_ql_dbscheme::language()).expect("Error loading QlDbscheme grammar"); //! let tree = parser.parse(code, None).unwrap(); //! assert!(!tree.root_node().has_error()); //! ``` @@ -20,14 +20,14 @@ use tree_sitter::Language; extern "C" { - fn tree_sitter_dbscheme() -> Language; + fn tree_sitter_ql_dbscheme() -> 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_dbscheme() } + unsafe { tree_sitter_ql_dbscheme() } } /// The content of the [`node-types.json`][] file for this grammar. @@ -49,6 +49,6 @@ mod tests { let mut parser = tree_sitter::Parser::new(); parser .set_language(&super::language()) - .expect("Error loading Dbscheme grammar"); + .expect("Error loading QlDbscheme grammar"); } } diff --git a/bindings/swift/TreeSitterDbscheme/dbscheme.h b/bindings/swift/TreeSitterDbscheme/dbscheme.h deleted file mode 100644 index f2f6c22..0000000 --- a/bindings/swift/TreeSitterDbscheme/dbscheme.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef TREE_SITTER_DBSCHEME_H_ -#define TREE_SITTER_DBSCHEME_H_ - -typedef struct TSLanguage TSLanguage; - -#ifdef __cplusplus -extern "C" { -#endif - -const TSLanguage *tree_sitter_dbscheme(void); - -#ifdef __cplusplus -} -#endif - -#endif // TREE_SITTER_DBSCHEME_H_ diff --git a/bindings/swift/TreeSitterDbschemeTests/TreeSitterTestTests.swift b/bindings/swift/TreeSitterDbschemeTests/TreeSitterTestTests.swift index b71075b..3126948 100644 --- a/bindings/swift/TreeSitterDbschemeTests/TreeSitterTestTests.swift +++ b/bindings/swift/TreeSitterDbschemeTests/TreeSitterTestTests.swift @@ -1,11 +1,11 @@ import XCTest import SwiftTreeSitter -import TreeSitterDbscheme +import TreeSitterQlDbscheme final class TreeSitterTestTests: XCTestCase { func testCanLoadGrammar() throws { let parser = Parser() - let language = Language(language: tree_sitter_dbscheme()) + let language = Language(language: tree_sitter_ql_dbscheme()) XCTAssertNoThrow(try parser.setLanguage(language), "Error loading Test grammar") } diff --git a/bindings/swift/TreeSitterQlDbscheme/ql_dbscheme.h b/bindings/swift/TreeSitterQlDbscheme/ql_dbscheme.h new file mode 100644 index 0000000..45eafa5 --- /dev/null +++ b/bindings/swift/TreeSitterQlDbscheme/ql_dbscheme.h @@ -0,0 +1,16 @@ +#ifndef TREE_SITTER_QL_DBSCHEME_H_ +#define TREE_SITTER_QL_DBSCHEME_H_ + +typedef struct TSLanguage TSLanguage; + +#ifdef __cplusplus +extern "C" { +#endif + +const TSLanguage *tree_sitter_ql_dbscheme(void); + +#ifdef __cplusplus +} +#endif + +#endif // TREE_SITTER_QL_DBSCHEME_H_ diff --git a/grammar.js b/grammar.js index e07718f..9c751cc 100644 --- a/grammar.js +++ b/grammar.js @@ -1,5 +1,5 @@ module.exports = grammar({ - name: 'dbscheme', + name: 'ql_dbscheme', extras: $ => [ /[ \t\r\n]/, diff --git a/package.json b/package.json index 82c6af8..cab3989 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,10 @@ "queries/*", "src/**" ], + "repository": { + "type": "git", + "url": "git+https://github.com/tree-sitter/tree-sitter-ql-dbscheme.git" + }, "dependencies": { "tree-sitter": "^0.21.1", "node-addon-api": "^7.1.0", diff --git a/pyproject.toml b/pyproject.toml index 4621bf8..c5366fd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,10 +3,10 @@ requires = ["setuptools>=42", "wheel"] build-backend = "setuptools.build_meta" [project] -name = "tree-sitter-dbscheme" -description = "Dbscheme grammar for tree-sitter" +name = "tree-sitter-ql-dbscheme" +description = "QlDbscheme grammar for tree-sitter" version = "0.0.1" -keywords = ["incremental", "parsing", "tree-sitter", "dbscheme"] +keywords = ["incremental", "parsing", "tree-sitter", "ql-dbscheme"] classifiers = [ "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", @@ -19,7 +19,7 @@ license.text = "MIT" readme = "README.md" [project.urls] -Homepage = "https://github.com/tree-sitter/tree-sitter-dbscheme" +Homepage = "https://github.com/tree-sitter/tree-sitter-ql-dbscheme" [project.optional-dependencies] core = ["tree-sitter~=0.21"] diff --git a/setup.py b/setup.py index 14572e4..fcff189 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,7 @@ class Build(build): def run(self): if isdir("queries"): - dest = join(self.build_lib, "tree_sitter_dbscheme", "queries") + dest = join(self.build_lib, "tree_sitter_ql_dbscheme", "queries") self.copy_tree("queries", dest) super().run() @@ -26,15 +26,15 @@ def get_tag(self): packages=find_packages("bindings/python"), package_dir={"": "bindings/python"}, package_data={ - "tree_sitter_dbscheme": ["*.pyi", "py.typed"], - "tree_sitter_dbscheme.queries": ["*.scm"], + "tree_sitter_ql_dbscheme": ["*.pyi", "py.typed"], + "tree_sitter_ql_dbscheme.queries": ["*.scm"], }, - ext_package="tree_sitter_dbscheme", + ext_package="tree_sitter_ql_dbscheme", ext_modules=[ Extension( name="_binding", sources=[ - "bindings/python/tree_sitter_dbscheme/binding.c", + "bindings/python/tree_sitter_ql_dbscheme/binding.c", "src/parser.c", # NOTE: if your language uses an external scanner, add it here. ], diff --git a/src/grammar.json b/src/grammar.json index 2bd7ec4..875998c 100644 --- a/src/grammar.json +++ b/src/grammar.json @@ -1,5 +1,5 @@ { - "name": "dbscheme", + "name": "ql_dbscheme", "word": "_lower_id", "rules": { "dbscheme": { diff --git a/src/parser.c b/src/parser.c index dba7410..001f46d 100644 --- a/src/parser.c +++ b/src/parser.c @@ -2469,7 +2469,7 @@ extern "C" { #define TS_PUBLIC __attribute__((visibility("default"))) #endif -TS_PUBLIC const TSLanguage *tree_sitter_dbscheme(void) { +TS_PUBLIC const TSLanguage *tree_sitter_ql_dbscheme(void) { static const TSLanguage language = { .version = LANGUAGE_VERSION, .symbol_count = SYMBOL_COUNT,