tree-sitter-postgres 1.1.1__tar.gz → 1.1.2__tar.gz

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.
Files changed (19) hide show
  1. {tree_sitter_postgres-1.1.1 → tree_sitter_postgres-1.1.2}/PKG-INFO +1 -1
  2. {tree_sitter_postgres-1.1.1 → tree_sitter_postgres-1.1.2}/bindings/python/tree_sitter_postgres.egg-info/PKG-INFO +1 -1
  3. {tree_sitter_postgres-1.1.1 → tree_sitter_postgres-1.1.2}/plpgsql/src/scanner.c +35 -7
  4. {tree_sitter_postgres-1.1.1 → tree_sitter_postgres-1.1.2}/pyproject.toml +1 -1
  5. {tree_sitter_postgres-1.1.1 → tree_sitter_postgres-1.1.2}/LICENSE +0 -0
  6. {tree_sitter_postgres-1.1.1 → tree_sitter_postgres-1.1.2}/README.md +0 -0
  7. {tree_sitter_postgres-1.1.1 → tree_sitter_postgres-1.1.2}/bindings/python/tree_sitter_postgres/__init__.py +0 -0
  8. {tree_sitter_postgres-1.1.1 → tree_sitter_postgres-1.1.2}/bindings/python/tree_sitter_postgres/__init__.pyi +0 -0
  9. {tree_sitter_postgres-1.1.1 → tree_sitter_postgres-1.1.2}/bindings/python/tree_sitter_postgres/binding.c +0 -0
  10. {tree_sitter_postgres-1.1.1 → tree_sitter_postgres-1.1.2}/bindings/python/tree_sitter_postgres/py.typed +0 -0
  11. {tree_sitter_postgres-1.1.1 → tree_sitter_postgres-1.1.2}/bindings/python/tree_sitter_postgres.egg-info/SOURCES.txt +0 -0
  12. {tree_sitter_postgres-1.1.1 → tree_sitter_postgres-1.1.2}/bindings/python/tree_sitter_postgres.egg-info/dependency_links.txt +0 -0
  13. {tree_sitter_postgres-1.1.1 → tree_sitter_postgres-1.1.2}/bindings/python/tree_sitter_postgres.egg-info/not-zip-safe +0 -0
  14. {tree_sitter_postgres-1.1.1 → tree_sitter_postgres-1.1.2}/bindings/python/tree_sitter_postgres.egg-info/requires.txt +0 -0
  15. {tree_sitter_postgres-1.1.1 → tree_sitter_postgres-1.1.2}/bindings/python/tree_sitter_postgres.egg-info/top_level.txt +0 -0
  16. {tree_sitter_postgres-1.1.1 → tree_sitter_postgres-1.1.2}/plpgsql/src/parser.c +0 -0
  17. {tree_sitter_postgres-1.1.1 → tree_sitter_postgres-1.1.2}/postgres/src/parser.c +0 -0
  18. {tree_sitter_postgres-1.1.1 → tree_sitter_postgres-1.1.2}/setup.cfg +0 -0
  19. {tree_sitter_postgres-1.1.1 → tree_sitter_postgres-1.1.2}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tree-sitter-postgres
3
- Version: 1.1.1
3
+ Version: 1.1.2
4
4
  Summary: Postgres grammar for tree-sitter
5
5
  License: BSD-3-Clause
6
6
  Project-URL: Homepage, https://github.com/gmr/tree-sitter-postgres
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tree-sitter-postgres
3
- Version: 1.1.1
3
+ Version: 1.1.2
4
4
  Summary: Postgres grammar for tree-sitter
5
5
  License: BSD-3-Clause
6
6
  Project-URL: Homepage, https://github.com/gmr/tree-sitter-postgres
@@ -12,7 +12,6 @@
12
12
  #include "tree_sitter/parser.h"
13
13
 
14
14
  #include <string.h>
15
- #include <ctype.h>
16
15
 
17
16
  enum TokenType {
18
17
  SQL_BODY,
@@ -30,6 +29,35 @@ static void skip_whitespace(TSLexer *lexer) {
30
29
  }
31
30
  }
32
31
 
32
+ /*
33
+ * Keep the scanner self-contained for WebAssembly builds.
34
+ *
35
+ * Zed loads tree-sitter grammars as Wasm modules. If this scanner calls
36
+ * libc ctype helpers like isalpha/isalnum/tolower, the compiled Wasm can
37
+ * contain imports named "isalpha", "isalnum", or "tolower". Zed's grammar
38
+ * runtime does not provide those imports, causing errors like:
39
+ *
40
+ * Failed to instantiate Wasm module: invalid import 'isalnum'
41
+ *
42
+ * For delimiter keyword detection we only need ASCII PL/pgSQL keywords, so
43
+ * small local helpers are sufficient and avoid external libc imports.
44
+ */
45
+ static bool is_ascii_alpha(int c) {
46
+ return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
47
+ }
48
+
49
+ static bool is_ascii_digit(int c) {
50
+ return c >= '0' && c <= '9';
51
+ }
52
+
53
+ static bool is_ascii_alnum(int c) {
54
+ return is_ascii_alpha(c) || is_ascii_digit(c);
55
+ }
56
+
57
+ static char ascii_tolower(int c) {
58
+ return (c >= 'A' && c <= 'Z') ? (char)(c + ('a' - 'A')) : (char)c;
59
+ }
60
+
33
61
  bool tree_sitter_plpgsql_external_scanner_scan(
34
62
  void *payload, TSLexer *lexer, const bool *valid_symbols
35
63
  ) {
@@ -196,13 +224,13 @@ bool tree_sitter_plpgsql_external_scanner_scan(
196
224
 
197
225
  /* At depth 0, check for PL/pgSQL delimiter keywords.
198
226
  * We mark the position before checking, and if it's a delimiter, we stop. */
199
- if (depth == 0 && isalpha(lexer->lookahead)) {
227
+ if (depth == 0 && is_ascii_alpha(lexer->lookahead)) {
200
228
  lexer->mark_end(lexer);
201
229
  /* Read the identifier */
202
230
  char word[32];
203
231
  int len = 0;
204
- while (isalnum(lexer->lookahead) || lexer->lookahead == '_') {
205
- if (len < 30) word[len++] = tolower(lexer->lookahead);
232
+ while (is_ascii_alnum(lexer->lookahead) || lexer->lookahead == '_') {
233
+ if (len < 30) word[len++] = ascii_tolower(lexer->lookahead);
206
234
  lexer->advance(lexer, false);
207
235
  }
208
236
  word[len] = '\0';
@@ -276,7 +304,7 @@ bool tree_sitter_plpgsql_external_scanner_scan(
276
304
 
277
305
  /* Identifiers starting with underscore or non-ASCII */
278
306
  if (depth == 0 && (lexer->lookahead == '_' || (lexer->lookahead >= 0x80))) {
279
- while (isalnum(lexer->lookahead) || lexer->lookahead == '_' ||
307
+ while (is_ascii_alnum(lexer->lookahead) || lexer->lookahead == '_' ||
280
308
  lexer->lookahead == '$' || lexer->lookahead >= 0x80) {
281
309
  lexer->advance(lexer, false);
282
310
  }
@@ -285,8 +313,8 @@ bool tree_sitter_plpgsql_external_scanner_scan(
285
313
  continue;
286
314
  }
287
315
  /* Inside parens, consume identifiers without keyword checking */
288
- if (depth > 0 && (isalpha(lexer->lookahead) || lexer->lookahead == '_')) {
289
- while (isalnum(lexer->lookahead) || lexer->lookahead == '_' ||
316
+ if (depth > 0 && (is_ascii_alpha(lexer->lookahead) || lexer->lookahead == '_')) {
317
+ while (is_ascii_alnum(lexer->lookahead) || lexer->lookahead == '_' ||
290
318
  lexer->lookahead == '$') {
291
319
  lexer->advance(lexer, false);
292
320
  }
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
5
5
  [project]
6
6
  name = "tree-sitter-postgres"
7
7
  description = "Postgres grammar for tree-sitter"
8
- version = "1.1.1"
8
+ version = "1.1.2"
9
9
  keywords = ["incremental", "parsing", "tree-sitter", "postgres"]
10
10
  classifiers = [
11
11
  "Intended Audience :: Developers",