@willbooster/tree-sitter-sql 5.0.0 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -10,8 +10,8 @@
10
10
 
11
11
  SQL grammars for [tree-sitter](https://github.com/tree-sitter/tree-sitter), generated with the
12
12
  [WillBooster/tree-sitter](https://github.com/WillBooster/tree-sitter) generator. Each generated `TSLanguage` carries
13
- the WillBooster ABI (`0x5742000d`), which upstream `tree-sitter` runtimes and WillBooster runtimes prior to 22.0.0
14
- reject. The supported WillBooster runtime is version 23.0.0 or later in the 23.x series.
13
+ the WillBooster ABI (`0x5742000e`), which upstream `tree-sitter` runtimes and WillBooster runtimes prior to 23.1.0
14
+ reject. The supported WillBooster runtime is version 26.3.0 through 27.x.
15
15
 
16
16
  ## Dialects
17
17
 
@@ -48,8 +48,7 @@ as new major versions.
48
48
  ## Usage
49
49
 
50
50
  The npm package ships one `.wasm` file per dialect for
51
- [@willbooster/web-tree-sitter](https://www.npmjs.com/package/@willbooster/web-tree-sitter) version 23.0.0 or later in
52
- the 23.x series, which runs in Node.js, Bun, browsers, and Cloudflare Workers. Replace `tree-sitter-sqlite.wasm` in the
51
+ [@willbooster/web-tree-sitter](https://www.npmjs.com/package/@willbooster/web-tree-sitter) version 26.3.0 through 27.x, which runs in Node.js, Bun, browsers, and Cloudflare Workers. Replace `tree-sitter-sqlite.wasm` in the
53
52
  examples below with `tree-sitter-postgresql.wasm`, `tree-sitter-mysql.wasm`, or `tree-sitter-oracle.wasm` for another
54
53
  dialect.
55
54
 
@@ -96,10 +95,10 @@ The package also ships each dialect's `src/node-types.json`, `sqlite/grammar.js`
96
95
  `common/common.mjs`, and `tree-sitter.json`.
97
96
 
98
97
  In Rust, depend on [willbooster-tree-sitter-sql](https://crates.io/crates/willbooster-tree-sitter-sql) and on
99
- [willbooster-tree-sitter](https://crates.io/crates/willbooster-tree-sitter) version 23.0.0 or later in the 23.x series:
98
+ [willbooster-tree-sitter](https://crates.io/crates/willbooster-tree-sitter) version 26.3.0 through 27.x:
100
99
 
101
100
  ```sh
102
- cargo add willbooster-tree-sitter@23 --rename tree-sitter
101
+ cargo add willbooster-tree-sitter@27.0.0 --rename tree-sitter
103
102
  cargo add willbooster-tree-sitter-sql --rename tree-sitter-sql
104
103
  ```
105
104
 
package/common/common.mjs CHANGED
@@ -3,23 +3,16 @@
3
3
  /** @import {RuleOrLiteral} from '@willbooster/web-tree-sitter/dsl' */
4
4
 
5
5
  // The CLI injects the DSL before loading the grammar that imports this module.
6
- const { alias, optional, repeat, seq } = /** @type {typeof globalThis & import('@willbooster/web-tree-sitter/dsl').DSL} */ (
6
+ const { optional, repeat, seq } = /** @type {typeof globalThis & import('@willbooster/web-tree-sitter/dsl').DSL} */ (
7
7
  globalThis
8
8
  );
9
9
 
10
- // SQL keywords are ASCII words that match without regard to case. A pattern with the `i` flag would also match the
11
- // Unicode characters that fold to an ASCII letter (e.g. U+212A KELVIN SIGN for `k`), which SQL dialects read as an
12
- // identifier, so each letter lists its two ASCII cases instead.
13
- /** @param {string} word */
14
- export const keywordPattern = (word) =>
15
- new RegExp(word.replaceAll(/[A-Za-z]/g, (letter) => `[${letter.toUpperCase()}${letter.toLowerCase()}]`));
16
-
17
10
  /**
18
11
  * A keyword token, which appears in the tree as an anonymous node named after the keyword in upper case.
19
12
  *
20
13
  * @param {string} word
21
14
  */
22
- export const keyword = (word) => alias(keywordPattern(word), word.toUpperCase());
15
+ export const keyword = (word) => word.toUpperCase();
23
16
 
24
17
  /**
25
18
  * A sequence of keywords separated by spaces in `phrase`, such as `'PRIMARY KEY'`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-sql",
3
- "version": "5.0.0",
3
+ "version": "6.0.0",
4
4
  "description": "SQL grammars (SQLite, PostgreSQL, MySQL, and Oracle) for tree-sitter",
5
5
  "keywords": [
6
6
  "mysql",
@@ -59,7 +59,7 @@
59
59
  "@vitest/browser-playwright": "5.0.5",
60
60
  "@willbooster/oxlint-config": "1.4.9",
61
61
  "@willbooster/wb": "24.3.3",
62
- "@willbooster/web-tree-sitter": "23.0.2",
62
+ "@willbooster/web-tree-sitter": "27.0.0",
63
63
  "lefthook": "2.2.3",
64
64
  "oxlint": "1.95.0",
65
65
  "oxlint-tsgolint": "7.0.2008",
@@ -69,7 +69,7 @@
69
69
  "wrangler": "4.156.0"
70
70
  },
71
71
  "peerDependencies": {
72
- "@willbooster/web-tree-sitter": "^23.0.0"
72
+ "@willbooster/web-tree-sitter": "^26.3.0 || ^27.0.0"
73
73
  },
74
74
  "peerDependenciesMeta": {
75
75
  "@willbooster/web-tree-sitter": {
package/sqlite/grammar.js CHANGED
@@ -7,7 +7,7 @@
7
7
  // and its tokenizer, src/tokenize.c, and also reject what SQLite rejects while parsing, beyond those two files (e.g. an
8
8
  // unknown join type, or ORDER BY on a SELECT before UNION).
9
9
 
10
- import { commaSep, commaSep1, keyword, keywordPattern, keywords } from '../common/common.mjs';
10
+ import { commaSep, commaSep1, keyword, keywords } from '../common/common.mjs';
11
11
 
12
12
  // The CLI injects the DSL before loading this grammar.
13
13
  const { grammar, alias, choice, field, optional, prec, repeat, repeat1, reserved, seq, token } =
@@ -154,6 +154,7 @@ const triggerInsert = ($, head) =>
154
154
  const triggerDelete = ($, target) => seq(keywords('DELETE FROM'), field('table', target), optional($.where_clause));
155
155
 
156
156
  export default grammar({
157
+ caseInsensitiveKeywords: true,
157
158
  name: 'sqlite',
158
159
 
159
160
  // A byte order mark is white space anywhere.
@@ -174,12 +175,12 @@ export default grammar({
174
175
  word: ($) => $.identifier,
175
176
 
176
177
  reserved: {
177
- global: () => RESERVED.map(keywordPattern),
178
+ global: () => RESERVED.map(keyword),
178
179
  // `ids` in parse.y: the alias that follows an expression or a table without `AS`, a type name, or a collation.
179
- ids: () => [...RESERVED, ...JOIN_KEYWORDS, 'INDEXED'].map(keywordPattern),
180
- window_name: () => [...RESERVED, 'FILTER', 'INDEXED'].map(keywordPattern),
180
+ ids: () => [...RESERVED, ...JOIN_KEYWORDS, 'INDEXED'].map(keyword),
181
+ window_name: () => [...RESERVED, 'FILTER', 'INDEXED'].map(keyword),
181
182
  // `id` in parse.y: an identifier as a default value.
182
- id: () => [...RESERVED, ...JOIN_KEYWORDS].map(keywordPattern),
183
+ id: () => [...RESERVED, ...JOIN_KEYWORDS].map(keyword),
183
184
  },
184
185
 
185
186
  supertypes: ($) => [$._statement],
Binary file
Binary file
Binary file
Binary file
package/tree-sitter.json CHANGED
@@ -34,7 +34,7 @@
34
34
  }
35
35
  ],
36
36
  "metadata": {
37
- "version": "5.0.0",
37
+ "version": "6.0.0",
38
38
  "license": "MIT",
39
39
  "description": "SQL grammars (SQLite, PostgreSQL, MySQL, and Oracle) for tree-sitter",
40
40
  "authors": [