tree-sitter-postgres 1.2.1 → 1.2.3
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/package.json +1 -1
- package/plpgsql/grammar.js +17 -6
- package/plpgsql/src/grammar.json +80 -48
- package/plpgsql/src/node-types.json +17 -1
- package/plpgsql/src/parser.c +13730 -13606
- package/postgres/grammar.js +1 -1
- package/postgres/src/grammar.json +1 -1
- package/postgres/src/parser.c +17428 -17454
- package/prebuilds/darwin-arm64/tree-sitter-postgres.node +0 -0
- package/prebuilds/darwin-x64/tree-sitter-postgres.node +0 -0
- package/prebuilds/linux-arm64/tree-sitter-postgres.node +0 -0
- package/prebuilds/linux-x64/tree-sitter-postgres.node +0 -0
- package/prebuilds/win32-arm64/tree-sitter-postgres.node +0 -0
- package/prebuilds/win32-x64/tree-sitter-postgres.node +0 -0
- package/tree-sitter-postgres.wasm +0 -0
package/package.json
CHANGED
package/plpgsql/grammar.js
CHANGED
|
@@ -102,7 +102,8 @@ module.exports = grammar({
|
|
|
102
102
|
decl_statement: $ => choice(
|
|
103
103
|
// Alias declaration: name ALIAS FOR target ;
|
|
104
104
|
// Must precede variable declaration so ALIAS is not consumed as a type name.
|
|
105
|
-
|
|
105
|
+
// The target may be an identifier or a positional parameter ($1, $2, ...).
|
|
106
|
+
seq($.decl_varname, $.kw_alias, $.kw_for, choice($.any_identifier, $.param), ';'),
|
|
106
107
|
// Variable declaration: name [CONSTANT] type [COLLATE collation] [NOT NULL] [DEFAULT|:=|= expr] ;
|
|
107
108
|
seq(
|
|
108
109
|
$.decl_varname,
|
|
@@ -138,10 +139,17 @@ module.exports = grammar({
|
|
|
138
139
|
seq($.dotted_name, '%', $.kw_type),
|
|
139
140
|
// variable%ROWTYPE / table%ROWTYPE
|
|
140
141
|
seq($.dotted_name, '%', $.kw_rowtype),
|
|
141
|
-
// Regular type: name or schema.name, with optional
|
|
142
|
+
// Regular type: name or schema.name, with optional multi-word modifiers
|
|
143
|
+
// (e.g. `character varying`, `double precision`, `timestamp with time
|
|
144
|
+
// zone`), precision specifiers, and array modifiers. Trailing words are
|
|
145
|
+
// plain identifiers, so this stops at keyword terminators such as
|
|
146
|
+
// DEFAULT, NOT NULL, and COLLATE.
|
|
142
147
|
seq(
|
|
143
148
|
$.dotted_name,
|
|
144
|
-
|
|
149
|
+
repeat(choice(
|
|
150
|
+
$.identifier,
|
|
151
|
+
seq('(', $.integer_literal, optional(seq(',', $.integer_literal)), ')')
|
|
152
|
+
)),
|
|
145
153
|
repeat(seq('[', optional($.integer_literal), ']'))
|
|
146
154
|
)
|
|
147
155
|
),
|
|
@@ -154,7 +162,7 @@ module.exports = grammar({
|
|
|
154
162
|
decl_collate: $ => seq($.kw_collate, $.dotted_name),
|
|
155
163
|
|
|
156
164
|
decl_defval: $ => seq(
|
|
157
|
-
choice('=', ':='),
|
|
165
|
+
choice('=', ':=', $.kw_default),
|
|
158
166
|
$._sql_semicolon_expr
|
|
159
167
|
),
|
|
160
168
|
|
|
@@ -331,8 +339,8 @@ module.exports = grammar({
|
|
|
331
339
|
stmt_return: $ => choice(
|
|
332
340
|
// RETURN expression ; — guarded so NEXT/QUERY lex as keywords below
|
|
333
341
|
seq($.kw_return, optional($._sql_semicolon_guarded_expr), ';'),
|
|
334
|
-
// RETURN NEXT expression ;
|
|
335
|
-
seq($.kw_return, $.kw_next, $._sql_semicolon_expr, ';'),
|
|
342
|
+
// RETURN NEXT [expression] ; — expression omitted with OUT parameters
|
|
343
|
+
seq($.kw_return, $.kw_next, optional($._sql_semicolon_expr), ';'),
|
|
336
344
|
// RETURN QUERY sql ; — guarded so EXECUTE lexes as a keyword below
|
|
337
345
|
seq($.kw_return, $.kw_query, $._sql_semicolon_guarded_expr, ';'),
|
|
338
346
|
// RETURN QUERY EXECUTE expression [USING ...] ;
|
|
@@ -818,6 +826,9 @@ module.exports = grammar({
|
|
|
818
826
|
|
|
819
827
|
identifier: _ => token(prec(0, /[a-zA-Z_\u0080-\u00ff][a-zA-Z0-9_$\u0080-\u00ff]*/)),
|
|
820
828
|
|
|
829
|
+
// Positional parameter reference ($1, $2, ...) \u2014 used as an ALIAS target.
|
|
830
|
+
param: _ => token(/\$[0-9]+/),
|
|
831
|
+
|
|
821
832
|
integer_literal: _ => token(/[0-9](_?[0-9])*/),
|
|
822
833
|
|
|
823
834
|
string_literal: _ => token(/'([^']|'')*'/),
|
package/plpgsql/src/grammar.json
CHANGED
|
@@ -288,8 +288,17 @@
|
|
|
288
288
|
"name": "kw_for"
|
|
289
289
|
},
|
|
290
290
|
{
|
|
291
|
-
"type": "
|
|
292
|
-
"
|
|
291
|
+
"type": "CHOICE",
|
|
292
|
+
"members": [
|
|
293
|
+
{
|
|
294
|
+
"type": "SYMBOL",
|
|
295
|
+
"name": "any_identifier"
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
"type": "SYMBOL",
|
|
299
|
+
"name": "param"
|
|
300
|
+
}
|
|
301
|
+
]
|
|
293
302
|
},
|
|
294
303
|
{
|
|
295
304
|
"type": "STRING",
|
|
@@ -493,50 +502,54 @@
|
|
|
493
502
|
"name": "dotted_name"
|
|
494
503
|
},
|
|
495
504
|
{
|
|
496
|
-
"type": "
|
|
497
|
-
"
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
505
|
+
"type": "REPEAT",
|
|
506
|
+
"content": {
|
|
507
|
+
"type": "CHOICE",
|
|
508
|
+
"members": [
|
|
509
|
+
{
|
|
510
|
+
"type": "SYMBOL",
|
|
511
|
+
"name": "identifier"
|
|
512
|
+
},
|
|
513
|
+
{
|
|
514
|
+
"type": "SEQ",
|
|
515
|
+
"members": [
|
|
516
|
+
{
|
|
517
|
+
"type": "STRING",
|
|
518
|
+
"value": "("
|
|
519
|
+
},
|
|
520
|
+
{
|
|
521
|
+
"type": "SYMBOL",
|
|
522
|
+
"name": "integer_literal"
|
|
523
|
+
},
|
|
524
|
+
{
|
|
525
|
+
"type": "CHOICE",
|
|
526
|
+
"members": [
|
|
527
|
+
{
|
|
528
|
+
"type": "SEQ",
|
|
529
|
+
"members": [
|
|
530
|
+
{
|
|
531
|
+
"type": "STRING",
|
|
532
|
+
"value": ","
|
|
533
|
+
},
|
|
534
|
+
{
|
|
535
|
+
"type": "SYMBOL",
|
|
536
|
+
"name": "integer_literal"
|
|
537
|
+
}
|
|
538
|
+
]
|
|
539
|
+
},
|
|
540
|
+
{
|
|
541
|
+
"type": "BLANK"
|
|
542
|
+
}
|
|
543
|
+
]
|
|
544
|
+
},
|
|
545
|
+
{
|
|
546
|
+
"type": "STRING",
|
|
547
|
+
"value": ")"
|
|
548
|
+
}
|
|
549
|
+
]
|
|
550
|
+
}
|
|
551
|
+
]
|
|
552
|
+
}
|
|
540
553
|
},
|
|
541
554
|
{
|
|
542
555
|
"type": "REPEAT",
|
|
@@ -621,6 +634,10 @@
|
|
|
621
634
|
{
|
|
622
635
|
"type": "STRING",
|
|
623
636
|
"value": ":="
|
|
637
|
+
},
|
|
638
|
+
{
|
|
639
|
+
"type": "SYMBOL",
|
|
640
|
+
"name": "kw_default"
|
|
624
641
|
}
|
|
625
642
|
]
|
|
626
643
|
},
|
|
@@ -1588,8 +1605,16 @@
|
|
|
1588
1605
|
"name": "kw_next"
|
|
1589
1606
|
},
|
|
1590
1607
|
{
|
|
1591
|
-
"type": "
|
|
1592
|
-
"
|
|
1608
|
+
"type": "CHOICE",
|
|
1609
|
+
"members": [
|
|
1610
|
+
{
|
|
1611
|
+
"type": "SYMBOL",
|
|
1612
|
+
"name": "_sql_semicolon_expr"
|
|
1613
|
+
},
|
|
1614
|
+
{
|
|
1615
|
+
"type": "BLANK"
|
|
1616
|
+
}
|
|
1617
|
+
]
|
|
1593
1618
|
},
|
|
1594
1619
|
{
|
|
1595
1620
|
"type": "STRING",
|
|
@@ -4542,6 +4567,13 @@
|
|
|
4542
4567
|
}
|
|
4543
4568
|
}
|
|
4544
4569
|
},
|
|
4570
|
+
"param": {
|
|
4571
|
+
"type": "TOKEN",
|
|
4572
|
+
"content": {
|
|
4573
|
+
"type": "PATTERN",
|
|
4574
|
+
"value": "\\$[0-9]+"
|
|
4575
|
+
}
|
|
4576
|
+
},
|
|
4545
4577
|
"integer_literal": {
|
|
4546
4578
|
"type": "TOKEN",
|
|
4547
4579
|
"content": {
|
|
@@ -191,9 +191,13 @@
|
|
|
191
191
|
"named": true,
|
|
192
192
|
"fields": {},
|
|
193
193
|
"children": {
|
|
194
|
-
"multiple":
|
|
194
|
+
"multiple": true,
|
|
195
195
|
"required": true,
|
|
196
196
|
"types": [
|
|
197
|
+
{
|
|
198
|
+
"type": "kw_default",
|
|
199
|
+
"named": true
|
|
200
|
+
},
|
|
197
201
|
{
|
|
198
202
|
"type": "sql_expression",
|
|
199
203
|
"named": true
|
|
@@ -284,6 +288,10 @@
|
|
|
284
288
|
"type": "opt_scrollable",
|
|
285
289
|
"named": true
|
|
286
290
|
},
|
|
291
|
+
{
|
|
292
|
+
"type": "param",
|
|
293
|
+
"named": true
|
|
294
|
+
},
|
|
287
295
|
{
|
|
288
296
|
"type": "sql_expression",
|
|
289
297
|
"named": true
|
|
@@ -1799,6 +1807,10 @@
|
|
|
1799
1807
|
"type": "dotted_name",
|
|
1800
1808
|
"named": true
|
|
1801
1809
|
},
|
|
1810
|
+
{
|
|
1811
|
+
"type": "identifier",
|
|
1812
|
+
"named": true
|
|
1813
|
+
},
|
|
1802
1814
|
{
|
|
1803
1815
|
"type": "integer_literal",
|
|
1804
1816
|
"named": true
|
|
@@ -2642,6 +2654,10 @@
|
|
|
2642
2654
|
"type": "kw_while",
|
|
2643
2655
|
"named": true
|
|
2644
2656
|
},
|
|
2657
|
+
{
|
|
2658
|
+
"type": "param",
|
|
2659
|
+
"named": true
|
|
2660
|
+
},
|
|
2645
2661
|
{
|
|
2646
2662
|
"type": "sql_expression",
|
|
2647
2663
|
"named": true
|