tree-sitter-delphi13-pure 1.2.1 → 1.3.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/grammar.js +13 -1
- package/package.json +6 -2
- package/queries/folds.scm +53 -0
- package/queries/highlights.scm +335 -0
- package/queries/indents.scm +58 -0
- package/queries/injections.scm +34 -0
- package/queries/outline.scm +35 -0
- package/queries/tags.scm +183 -0
- package/src/grammar.json +72 -2
- package/src/parser.c +315568 -314506
- package/tree-sitter-delphi13_pure.wasm +0 -0
- package/tree-sitter.json +22 -0
package/grammar.js
CHANGED
|
@@ -700,7 +700,13 @@ module.exports = grammar({
|
|
|
700
700
|
field('body', choice(tr($, 'block'), tr($, 'asm'))),
|
|
701
701
|
),
|
|
702
702
|
|
|
703
|
-
inherited: $ => prec.right(seq($.kInherited, optional(
|
|
703
|
+
inherited: $ => prec.right(seq($.kInherited, optional(choice(
|
|
704
|
+
$.identifier,
|
|
705
|
+
// Soft keyword `at` (raise-with-address) as an INHERITED method
|
|
706
|
+
// name: `inherited At(Offset)` (JCL JclCLR.pas). Mirrors the root
|
|
707
|
+
// full grammar's fix (2026-07-17).
|
|
708
|
+
alias($.kAtWord, $.identifier),
|
|
709
|
+
)))),
|
|
704
710
|
|
|
705
711
|
exprDot: $ => choice(
|
|
706
712
|
op.infix(5, $._ref, $.kDot, $._ref),
|
|
@@ -1198,6 +1204,9 @@ module.exports = grammar({
|
|
|
1198
1204
|
// conflicts with typerefDot in this position.)
|
|
1199
1205
|
seq($.identifier, '.', $.identifier),
|
|
1200
1206
|
seq($.identifier, '(', $.identifier, ')'),
|
|
1207
|
+
// Nested const-expr call bound — `2 .. Succ(High(TV))` (JCL
|
|
1208
|
+
// JclSysUtils). Mirrors the root full grammar's fix (2026-07-17).
|
|
1209
|
+
seq($.identifier, '(', seq($.identifier, '(', $.identifier, ')'), ')'),
|
|
1201
1210
|
// `hid - 1`, `MaxN + 2` — narrow `identifier OP integer` form for
|
|
1202
1211
|
// real-corpus patterns like `TNmbrRange = 0 .. hid - 1;`.
|
|
1203
1212
|
// Kept narrow (no full _expr) to avoid the conflict cascade hit
|
|
@@ -1546,6 +1555,9 @@ module.exports = grammar({
|
|
|
1546
1555
|
field('name', delimited1(choice(
|
|
1547
1556
|
$.identifier,
|
|
1548
1557
|
alias($.kRegister, $.identifier),
|
|
1558
|
+
// `Operator` as a FIELD NAME (JVCL JvXmlDatabase). Mirrors the
|
|
1559
|
+
// root full grammar's fix (2026-07-17).
|
|
1560
|
+
alias($.kOperator, $.identifier),
|
|
1549
1561
|
))),
|
|
1550
1562
|
':',
|
|
1551
1563
|
// Ported from root v1.1.x: field type may be a subrange
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tree-sitter-delphi13-pure",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Pure Delphi 13 tree-sitter sub-grammar — drops {$IFDEF}/pp_* tokens entirely and expects preprocessor-resolved source as input. Pairs with delphi13-preprocessor to reach 99%+ pass on real Delphi 13 corpora.",
|
|
5
5
|
"main": "bindings/node",
|
|
6
6
|
"types": "bindings/node",
|
|
@@ -29,15 +29,19 @@
|
|
|
29
29
|
},
|
|
30
30
|
"scripts": {
|
|
31
31
|
"build": "tree-sitter generate && node-gyp build",
|
|
32
|
+
"build-wasm": "tree-sitter build --wasm -o tree-sitter-delphi13_pure.wasm .",
|
|
32
33
|
"install": "node-gyp-build",
|
|
33
34
|
"prebuildify": "prebuildify --napi --strip"
|
|
34
35
|
},
|
|
35
36
|
"files": [
|
|
36
37
|
"grammar.js",
|
|
37
38
|
"binding.gyp",
|
|
39
|
+
"tree-sitter.json",
|
|
38
40
|
"prebuilds/**",
|
|
39
41
|
"bindings/node/*",
|
|
40
|
-
"
|
|
42
|
+
"queries/*",
|
|
43
|
+
"src/**",
|
|
44
|
+
"tree-sitter-delphi13_pure.wasm"
|
|
41
45
|
],
|
|
42
46
|
"dependencies": {
|
|
43
47
|
"node-gyp-build": "^4.8.4"
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
; folds.scm -- tree-sitter-delphi13-pure
|
|
2
|
+
;
|
|
3
|
+
; Nodes that may be collapsed to a single line. The `@fold` capture is the
|
|
4
|
+
; convention read by nvim-treesitter, Helix and Zed; editors that compute folds
|
|
5
|
+
; from the syntax tree use the captured node's span as the foldable region.
|
|
6
|
+
;
|
|
7
|
+
; Rule of thumb: fold anything with its own `end`, plus the declaration groups
|
|
8
|
+
; that routinely run to hundreds of lines in real Delphi units (a `uses` clause,
|
|
9
|
+
; a `type` section, a visibility section of a large form class).
|
|
10
|
+
|
|
11
|
+
[
|
|
12
|
+
; --- module structure ---
|
|
13
|
+
(interface)
|
|
14
|
+
(implementation)
|
|
15
|
+
(initialization)
|
|
16
|
+
(finalization)
|
|
17
|
+
|
|
18
|
+
; --- declaration groups ---
|
|
19
|
+
(declUses)
|
|
20
|
+
(declTypes)
|
|
21
|
+
(declConsts)
|
|
22
|
+
(declVars)
|
|
23
|
+
(declExports)
|
|
24
|
+
(declLabels)
|
|
25
|
+
(declArgs)
|
|
26
|
+
|
|
27
|
+
; --- type bodies ---
|
|
28
|
+
(declClass)
|
|
29
|
+
(declIntf)
|
|
30
|
+
(declHelper)
|
|
31
|
+
(declEnum)
|
|
32
|
+
(declSection)
|
|
33
|
+
(declVariant)
|
|
34
|
+
|
|
35
|
+
; --- routines ---
|
|
36
|
+
(defProc)
|
|
37
|
+
(block)
|
|
38
|
+
(asm)
|
|
39
|
+
|
|
40
|
+
; --- statements with an `end` / closing keyword ---
|
|
41
|
+
(try)
|
|
42
|
+
(exceptionHandler)
|
|
43
|
+
(case)
|
|
44
|
+
(caseCase)
|
|
45
|
+
(if)
|
|
46
|
+
(ifElse)
|
|
47
|
+
(while)
|
|
48
|
+
(for)
|
|
49
|
+
(foreach)
|
|
50
|
+
(repeat)
|
|
51
|
+
(with)
|
|
52
|
+
(lambda)
|
|
53
|
+
] @fold
|
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
; highlights.scm -- tree-sitter-delphi13
|
|
2
|
+
;
|
|
3
|
+
; Syntax highlighting queries for Delphi 13 (Object Pascal).
|
|
4
|
+
; Consumed by Zed, Neovim, Helix and anything else using tree-sitter-highlight.
|
|
5
|
+
;
|
|
6
|
+
; Capture names follow the common tree-sitter highlight vocabulary that Zed's
|
|
7
|
+
; theme syntax keys map directly (keyword, type, function, string, number,
|
|
8
|
+
; boolean, comment, operator, property, attribute, preproc, punctuation.*).
|
|
9
|
+
;
|
|
10
|
+
; NOTE ON ORDER: tree-sitter-highlight resolves the FIRST matching pattern for a
|
|
11
|
+
; node, so specific patterns are listed before general ones.
|
|
12
|
+
|
|
13
|
+
; ---------------------------------------------------------------------------
|
|
14
|
+
; Comments
|
|
15
|
+
; ---------------------------------------------------------------------------
|
|
16
|
+
|
|
17
|
+
(comment) @comment
|
|
18
|
+
|
|
19
|
+
; ---------------------------------------------------------------------------
|
|
20
|
+
; Preprocessor / conditional compilation {$IFDEF} {$R} {$I} ...
|
|
21
|
+
; ---------------------------------------------------------------------------
|
|
22
|
+
|
|
23
|
+
; PURE-GRAMMAR VARIANT.
|
|
24
|
+
; The pure grammar is a strict subset of the full one: identical named node types
|
|
25
|
+
; except for four preprocessor nodes it does not produce, because conditional
|
|
26
|
+
; compilation is resolved by the preprocessor before this grammar ever sees the
|
|
27
|
+
; source. Three of those four are referenced by the full grammar's highlights.scm
|
|
28
|
+
; and are omitted here -- `pp_open`, `pp_else_tail`, `pp_end_only`. Leaving them in
|
|
29
|
+
; is not a harmless no-op: tree-sitter rejects the pattern as impossible and the
|
|
30
|
+
; WHOLE query fails to compile, taking all highlighting with it.
|
|
31
|
+
;
|
|
32
|
+
; `pp` itself exists in both grammars, so it stays.
|
|
33
|
+
(pp) @preproc
|
|
34
|
+
|
|
35
|
+
; ---------------------------------------------------------------------------
|
|
36
|
+
; Literals
|
|
37
|
+
; ---------------------------------------------------------------------------
|
|
38
|
+
|
|
39
|
+
(literalString) @string
|
|
40
|
+
(literalChar) @string.special
|
|
41
|
+
(char_literal) @string.special
|
|
42
|
+
(literalNumber) @number
|
|
43
|
+
(trailing_dot_float) @number
|
|
44
|
+
(guid) @string.special
|
|
45
|
+
|
|
46
|
+
[
|
|
47
|
+
(kTrue)
|
|
48
|
+
(kFalse)
|
|
49
|
+
] @boolean
|
|
50
|
+
|
|
51
|
+
(kNil) @constant
|
|
52
|
+
|
|
53
|
+
; ---------------------------------------------------------------------------
|
|
54
|
+
; Attributes -- [Weak], [Ref], custom RTTI attributes
|
|
55
|
+
; ---------------------------------------------------------------------------
|
|
56
|
+
|
|
57
|
+
(rttiAttributes) @attribute
|
|
58
|
+
(declAssemblyAttribute) @attribute
|
|
59
|
+
|
|
60
|
+
; ---------------------------------------------------------------------------
|
|
61
|
+
; Module structure
|
|
62
|
+
; ---------------------------------------------------------------------------
|
|
63
|
+
|
|
64
|
+
[
|
|
65
|
+
(kUnit)
|
|
66
|
+
(kProgram)
|
|
67
|
+
(kLibrary)
|
|
68
|
+
(kPackage)
|
|
69
|
+
(kInterface)
|
|
70
|
+
(kImplementation)
|
|
71
|
+
(kInitialization)
|
|
72
|
+
(kFinalization)
|
|
73
|
+
(kUses)
|
|
74
|
+
(kExports)
|
|
75
|
+
(kContains)
|
|
76
|
+
(kRequires)
|
|
77
|
+
] @keyword
|
|
78
|
+
|
|
79
|
+
(moduleName) @type
|
|
80
|
+
|
|
81
|
+
; ---------------------------------------------------------------------------
|
|
82
|
+
; Declaration introducers
|
|
83
|
+
; ---------------------------------------------------------------------------
|
|
84
|
+
|
|
85
|
+
[
|
|
86
|
+
(kType)
|
|
87
|
+
(kVar)
|
|
88
|
+
(kConst)
|
|
89
|
+
(kThreadvar)
|
|
90
|
+
(kResourcestring)
|
|
91
|
+
(kLabel)
|
|
92
|
+
(kAbsolute)
|
|
93
|
+
] @keyword
|
|
94
|
+
|
|
95
|
+
; ---------------------------------------------------------------------------
|
|
96
|
+
; Routines
|
|
97
|
+
; ---------------------------------------------------------------------------
|
|
98
|
+
|
|
99
|
+
[
|
|
100
|
+
(kProcedure)
|
|
101
|
+
(kFunction)
|
|
102
|
+
(kConstructor)
|
|
103
|
+
(kDestructor)
|
|
104
|
+
(kOperator)
|
|
105
|
+
(kProperty)
|
|
106
|
+
(kRead)
|
|
107
|
+
(kWrite)
|
|
108
|
+
(kReadonly)
|
|
109
|
+
(kWriteonly)
|
|
110
|
+
(kStored)
|
|
111
|
+
(kDefault)
|
|
112
|
+
(kNodefault)
|
|
113
|
+
(kIndex)
|
|
114
|
+
(kImplements)
|
|
115
|
+
] @keyword
|
|
116
|
+
|
|
117
|
+
; ---------------------------------------------------------------------------
|
|
118
|
+
; Type-forming keywords
|
|
119
|
+
; ---------------------------------------------------------------------------
|
|
120
|
+
|
|
121
|
+
[
|
|
122
|
+
(kClass)
|
|
123
|
+
(kRecord)
|
|
124
|
+
(kObject)
|
|
125
|
+
(kArray)
|
|
126
|
+
(kSet)
|
|
127
|
+
(kFile)
|
|
128
|
+
(kString)
|
|
129
|
+
(kHelper)
|
|
130
|
+
(kDispInterface)
|
|
131
|
+
(kPacked)
|
|
132
|
+
(kGeneric)
|
|
133
|
+
(kReference)
|
|
134
|
+
(kOf)
|
|
135
|
+
] @keyword
|
|
136
|
+
|
|
137
|
+
; ---------------------------------------------------------------------------
|
|
138
|
+
; Visibility
|
|
139
|
+
; ---------------------------------------------------------------------------
|
|
140
|
+
|
|
141
|
+
[
|
|
142
|
+
(kPrivate)
|
|
143
|
+
(kProtected)
|
|
144
|
+
(kPublic)
|
|
145
|
+
(kPublished)
|
|
146
|
+
(kStrict)
|
|
147
|
+
] @keyword
|
|
148
|
+
|
|
149
|
+
; ---------------------------------------------------------------------------
|
|
150
|
+
; Control flow
|
|
151
|
+
; ---------------------------------------------------------------------------
|
|
152
|
+
|
|
153
|
+
[
|
|
154
|
+
(kBegin)
|
|
155
|
+
(kEnd)
|
|
156
|
+
(kEndDot)
|
|
157
|
+
(kIf)
|
|
158
|
+
(kThen)
|
|
159
|
+
(kElse)
|
|
160
|
+
(kCase)
|
|
161
|
+
(kFor)
|
|
162
|
+
(kTo)
|
|
163
|
+
(kDownto)
|
|
164
|
+
(kDo)
|
|
165
|
+
(kWhile)
|
|
166
|
+
(kRepeat)
|
|
167
|
+
(kUntil)
|
|
168
|
+
(kWith)
|
|
169
|
+
(kGoto)
|
|
170
|
+
(kTry)
|
|
171
|
+
(kExcept)
|
|
172
|
+
(kFinally)
|
|
173
|
+
(kRaise)
|
|
174
|
+
(kOn)
|
|
175
|
+
(kInherited)
|
|
176
|
+
(kAsm)
|
|
177
|
+
(kAssembler)
|
|
178
|
+
] @keyword
|
|
179
|
+
|
|
180
|
+
; ---------------------------------------------------------------------------
|
|
181
|
+
; Routine directives / modifiers
|
|
182
|
+
; ---------------------------------------------------------------------------
|
|
183
|
+
|
|
184
|
+
[
|
|
185
|
+
(kVirtual)
|
|
186
|
+
(kOverride)
|
|
187
|
+
(kAbstract)
|
|
188
|
+
(kSealed)
|
|
189
|
+
(kFinal)
|
|
190
|
+
(kStatic)
|
|
191
|
+
(kOverload)
|
|
192
|
+
(kReintroduce)
|
|
193
|
+
(kInline)
|
|
194
|
+
(kForward)
|
|
195
|
+
(kExternal)
|
|
196
|
+
(kDynamic)
|
|
197
|
+
(kDelayed)
|
|
198
|
+
(kDispId)
|
|
199
|
+
(kMessage)
|
|
200
|
+
(kName)
|
|
201
|
+
(kDeprecated)
|
|
202
|
+
(kExperimental)
|
|
203
|
+
(kPlatform)
|
|
204
|
+
(kNoreturn)
|
|
205
|
+
(kUnsafe)
|
|
206
|
+
(kVarargs)
|
|
207
|
+
(kLocal)
|
|
208
|
+
(kAlign)
|
|
209
|
+
(kDependency)
|
|
210
|
+
(kOut)
|
|
211
|
+
(kConstref)
|
|
212
|
+
] @keyword
|
|
213
|
+
|
|
214
|
+
; ---------------------------------------------------------------------------
|
|
215
|
+
; Calling conventions
|
|
216
|
+
; ---------------------------------------------------------------------------
|
|
217
|
+
|
|
218
|
+
[
|
|
219
|
+
(kCdecl)
|
|
220
|
+
(kStdcall)
|
|
221
|
+
(kSafecall)
|
|
222
|
+
(kRegister)
|
|
223
|
+
(kPascal)
|
|
224
|
+
(kWinapi)
|
|
225
|
+
(kFar)
|
|
226
|
+
(kNear)
|
|
227
|
+
(kExport)
|
|
228
|
+
(kInterrupt)
|
|
229
|
+
] @keyword
|
|
230
|
+
|
|
231
|
+
; ---------------------------------------------------------------------------
|
|
232
|
+
; Operator keywords
|
|
233
|
+
; ---------------------------------------------------------------------------
|
|
234
|
+
|
|
235
|
+
[
|
|
236
|
+
(kAnd)
|
|
237
|
+
(kOr)
|
|
238
|
+
(kNot)
|
|
239
|
+
(kXor)
|
|
240
|
+
(kDiv)
|
|
241
|
+
(kMod)
|
|
242
|
+
(kShl)
|
|
243
|
+
(kShr)
|
|
244
|
+
(kIn)
|
|
245
|
+
(kIs)
|
|
246
|
+
(kAs)
|
|
247
|
+
(kAt)
|
|
248
|
+
] @operator
|
|
249
|
+
|
|
250
|
+
; ---------------------------------------------------------------------------
|
|
251
|
+
; Symbolic operators
|
|
252
|
+
; ---------------------------------------------------------------------------
|
|
253
|
+
|
|
254
|
+
[
|
|
255
|
+
(kAssign)
|
|
256
|
+
(kAssignAdd)
|
|
257
|
+
(kAssignSub)
|
|
258
|
+
(kAssignMul)
|
|
259
|
+
(kAssignDiv)
|
|
260
|
+
(kEq)
|
|
261
|
+
(kNeq)
|
|
262
|
+
(kLt)
|
|
263
|
+
(kLte)
|
|
264
|
+
(kGt)
|
|
265
|
+
(kGte)
|
|
266
|
+
(kAdd)
|
|
267
|
+
(kSub)
|
|
268
|
+
(kMul)
|
|
269
|
+
(kFdiv)
|
|
270
|
+
(kHat)
|
|
271
|
+
(kAtWord)
|
|
272
|
+
] @operator
|
|
273
|
+
|
|
274
|
+
(kDot) @punctuation.delimiter
|
|
275
|
+
|
|
276
|
+
; ---------------------------------------------------------------------------
|
|
277
|
+
; Types
|
|
278
|
+
; ---------------------------------------------------------------------------
|
|
279
|
+
|
|
280
|
+
(typeref) @type
|
|
281
|
+
(typerefDot) @type
|
|
282
|
+
(typerefPtr) @type
|
|
283
|
+
(typerefTpl) @type
|
|
284
|
+
(genericTpl) @type
|
|
285
|
+
(genericDot) @type
|
|
286
|
+
(declEnumValue) @constant
|
|
287
|
+
|
|
288
|
+
; ---------------------------------------------------------------------------
|
|
289
|
+
; Labels
|
|
290
|
+
; ---------------------------------------------------------------------------
|
|
291
|
+
|
|
292
|
+
(label) @label
|
|
293
|
+
(declLabel) @label
|
|
294
|
+
(caseLabel) @label
|
|
295
|
+
|
|
296
|
+
; ---------------------------------------------------------------------------
|
|
297
|
+
; Punctuation
|
|
298
|
+
; ---------------------------------------------------------------------------
|
|
299
|
+
|
|
300
|
+
[
|
|
301
|
+
"("
|
|
302
|
+
")"
|
|
303
|
+
"["
|
|
304
|
+
"]"
|
|
305
|
+
] @punctuation.bracket
|
|
306
|
+
|
|
307
|
+
[
|
|
308
|
+
","
|
|
309
|
+
";"
|
|
310
|
+
":"
|
|
311
|
+
"."
|
|
312
|
+
".."
|
|
313
|
+
] @punctuation.delimiter
|
|
314
|
+
|
|
315
|
+
; ---------------------------------------------------------------------------
|
|
316
|
+
; Declaration names -- more specific than the bare identifier rule below, so
|
|
317
|
+
; they must be listed first (tree-sitter-highlight takes the first match).
|
|
318
|
+
; ---------------------------------------------------------------------------
|
|
319
|
+
|
|
320
|
+
(declProc name: (identifier) @function)
|
|
321
|
+
(declProc name: (genericDot) @function)
|
|
322
|
+
(declProc name: (genericTpl) @function)
|
|
323
|
+
|
|
324
|
+
(declType name: (identifier) @type)
|
|
325
|
+
(declType name: (genericDot) @type)
|
|
326
|
+
(declType name: (genericTpl) @type)
|
|
327
|
+
|
|
328
|
+
(declProp name: (identifier) @property)
|
|
329
|
+
(declField name: (identifier) @property)
|
|
330
|
+
|
|
331
|
+
; ---------------------------------------------------------------------------
|
|
332
|
+
; Identifiers -- least specific, listed last
|
|
333
|
+
; ---------------------------------------------------------------------------
|
|
334
|
+
|
|
335
|
+
(identifier) @variable
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
; indents.scm -- tree-sitter-delphi13
|
|
2
|
+
;
|
|
3
|
+
; Auto-indent behaviour. This is the query users actually *feel*: it decides
|
|
4
|
+
; where the caret lands after `begin`, `case`, `try`, `record`, `class`.
|
|
5
|
+
;
|
|
6
|
+
; Convention (matches Zed's own language extensions):
|
|
7
|
+
; @indent the node whose body should be indented
|
|
8
|
+
; @start the token that opens the indented region
|
|
9
|
+
; @end the token that closes it (dedents the line it appears on)
|
|
10
|
+
|
|
11
|
+
; --- begin ... end -------------------------------------------------------
|
|
12
|
+
(block
|
|
13
|
+
(kBegin) @start
|
|
14
|
+
(kEnd)? @end) @indent
|
|
15
|
+
|
|
16
|
+
; --- try ... except / finally ... end ------------------------------------
|
|
17
|
+
(try
|
|
18
|
+
(kTry) @start
|
|
19
|
+
(kEnd)? @end) @indent
|
|
20
|
+
|
|
21
|
+
; --- case ... of ... end -------------------------------------------------
|
|
22
|
+
(case
|
|
23
|
+
(kCase) @start
|
|
24
|
+
(kEnd)? @end) @indent
|
|
25
|
+
|
|
26
|
+
; --- record ... end ------------------------------------------------------
|
|
27
|
+
(declClass
|
|
28
|
+
(kEnd)? @end) @indent
|
|
29
|
+
|
|
30
|
+
(declIntf
|
|
31
|
+
(kEnd)? @end) @indent
|
|
32
|
+
|
|
33
|
+
(declHelper
|
|
34
|
+
(kEnd)? @end) @indent
|
|
35
|
+
|
|
36
|
+
; --- asm ... end ---------------------------------------------------------
|
|
37
|
+
(asm
|
|
38
|
+
(kAsm) @start
|
|
39
|
+
(kEnd)? @end) @indent
|
|
40
|
+
|
|
41
|
+
; --- repeat ... until ----------------------------------------------------
|
|
42
|
+
(repeat
|
|
43
|
+
(kRepeat) @start
|
|
44
|
+
(kUntil)? @end) @indent
|
|
45
|
+
|
|
46
|
+
; --- declaration sections: the names under type/var/const line up --------
|
|
47
|
+
(declTypes) @indent
|
|
48
|
+
(declVars) @indent
|
|
49
|
+
(declConsts) @indent
|
|
50
|
+
|
|
51
|
+
; --- bracketed continuations --------------------------------------------
|
|
52
|
+
(exprParens
|
|
53
|
+
"(" @start
|
|
54
|
+
")" @end) @indent
|
|
55
|
+
|
|
56
|
+
(declArgs
|
|
57
|
+
"(" @start
|
|
58
|
+
")" @end) @indent
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
; injections.scm -- tree-sitter-delphi13-pure
|
|
2
|
+
;
|
|
3
|
+
; Embeds other languages inside Delphi source.
|
|
4
|
+
;
|
|
5
|
+
; SQL-in-string is the high-value case for this codebase: FireDAC/Firebird
|
|
6
|
+
; projects carry a lot of SQL in string literals and assembling it by hand is
|
|
7
|
+
; where the bugs live. Highlighting it as SQL makes malformed statements
|
|
8
|
+
; visible without running them.
|
|
9
|
+
;
|
|
10
|
+
; Matching is deliberately conservative -- anchored at the start of the literal
|
|
11
|
+
; on a leading SQL verb. A loose pattern would paint ordinary prose strings as
|
|
12
|
+
; SQL, which is worse than no injection at all: it makes correct code look
|
|
13
|
+
; broken.
|
|
14
|
+
|
|
15
|
+
; A LEADING VERB ALONE IS NOT ENOUGH. `'Select a file to continue'` starts with
|
|
16
|
+
; "Select " and is obviously prose -- an early draft of this query painted it as
|
|
17
|
+
; SQL. Every branch below therefore demands a PAIRED keyword (SELECT..FROM,
|
|
18
|
+
; UPDATE..SET, INSERT INTO, ...), which prose effectively never satisfies.
|
|
19
|
+
;
|
|
20
|
+
; NO INLINE `(?i)` FLAG -- THIS IS LOAD-BEARING, DO NOT "SIMPLIFY" IT.
|
|
21
|
+
; Native tree-sitter matches #match? with the Rust regex crate, which supports
|
|
22
|
+
; the inline `(?i)` group. web-tree-sitter (the WASM build that VS Code, Cursor
|
|
23
|
+
; and every browser host use) hands the pattern to JavaScript's RegExp, which
|
|
24
|
+
; rejects `(?i)` outright with "Invalid group" -- and a query that throws on
|
|
25
|
+
; compile takes the WHOLE injections file down with it, silently, in exactly
|
|
26
|
+
; the editors this grammar is meant to ship in. Case-insensitivity is therefore
|
|
27
|
+
; spelled out as [Ss][Ee][Ll]... character classes, which both engines accept.
|
|
28
|
+
((literalString) @injection.content
|
|
29
|
+
(#match? @injection.content "^'\\s*([Ss][Ee][Ll][Ee][Cc][Tt]\\b[\\s\\S]*\\b[Ff][Rr][Oo][Mm]\\b|[Ii][Nn][Ss][Ee][Rr][Tt]\\s+[Ii][Nn][Tt][Oo]\\b|[Uu][Pp][Dd][Aa][Tt][Ee]\\b[\\s\\S]*\\b[Ss][Ee][Tt]\\b|[Dd][Ee][Ll][Ee][Tt][Ee]\\s+[Ff][Rr][Oo][Mm]\\b|[Cc][Rr][Ee][Aa][Tt][Ee]\\s+([Oo][Rr]\\s+[Aa][Ll][Tt][Ee][Rr]\\s+)?([Tt][Aa][Bb][Ll][Ee]|[Vv][Ii][Ee][Ww]|[Ii][Nn][Dd][Ee][Xx]|[Pp][Rr][Oo][Cc][Ee][Dd][Uu][Rr][Ee]|[Tt][Rr][Ii][Gg][Gg][Ee][Rr]|[Gg][Ee][Nn][Ee][Rr][Aa][Tt][Oo][Rr]|[Ss][Ee][Qq][Uu][Ee][Nn][Cc][Ee]|[Dd][Oo][Mm][Aa][Ii][Nn]|[Ee][Xx][Cc][Ee][Pp][Tt][Ii][Oo][Nn])\\b|[Aa][Ll][Tt][Ee][Rr]\\s+([Tt][Aa][Bb][Ll][Ee]|[Vv][Ii][Ee][Ww]|[Ii][Nn][Dd][Ee][Xx]|[Pp][Rr][Oo][Cc][Ee][Dd][Uu][Rr][Ee]|[Tt][Rr][Ii][Gg][Gg][Ee][Rr]|[Dd][Aa][Tt][Aa][Bb][Aa][Ss][Ee])\\b|[Dd][Rr][Oo][Pp]\\s+([Tt][Aa][Bb][Ll][Ee]|[Vv][Ii][Ee][Ww]|[Ii][Nn][Dd][Ee][Xx]|[Pp][Rr][Oo][Cc][Ee][Dd][Uu][Rr][Ee]|[Tt][Rr][Ii][Gg][Gg][Ee][Rr]|[Gg][Ee][Nn][Ee][Rr][Aa][Tt][Oo][Rr]|[Ss][Ee][Qq][Uu][Ee][Nn][Cc][Ee]|[Dd][Oo][Mm][Aa][Ii][Nn]|[Ee][Xx][Cc][Ee][Pp][Tt][Ii][Oo][Nn])\\b|[Ee][Xx][Ee][Cc][Uu][Tt][Ee]\\s+([Pp][Rr][Oo][Cc][Ee][Dd][Uu][Rr][Ee]|[Bb][Ll][Oo][Cc][Kk]|[Ss][Tt][Aa][Tt][Ee][Mm][Ee][Nn][Tt])\\b|[Mm][Ee][Rr][Gg][Ee]\\s+[Ii][Nn][Tt][Oo]\\b)")
|
|
30
|
+
(#set! injection.language "sql"))
|
|
31
|
+
|
|
32
|
+
; Inline assembler blocks.
|
|
33
|
+
((asmBody) @injection.content
|
|
34
|
+
(#set! injection.language "asm"))
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
; outline.scm -- tree-sitter-delphi13
|
|
2
|
+
;
|
|
3
|
+
; Drives Zed's outline panel (Ctrl-Shift-O / the breadcrumb symbol list).
|
|
4
|
+
;
|
|
5
|
+
; Convention:
|
|
6
|
+
; @item the whole entry
|
|
7
|
+
; @name the text shown for it
|
|
8
|
+
; @context surrounding keywords shown greyed next to the name
|
|
9
|
+
|
|
10
|
+
; Types: type TFoo = class ... end;
|
|
11
|
+
(declType
|
|
12
|
+
(kType)? @context
|
|
13
|
+
name: [(identifier) (genericDot) (genericTpl)] @name) @item
|
|
14
|
+
|
|
15
|
+
; Routines in the interface section and standalone declarations:
|
|
16
|
+
; procedure Foo(const X: Integer);
|
|
17
|
+
(declProc
|
|
18
|
+
[
|
|
19
|
+
(kProcedure)
|
|
20
|
+
(kFunction)
|
|
21
|
+
(kConstructor)
|
|
22
|
+
(kDestructor)
|
|
23
|
+
(kOperator)
|
|
24
|
+
] @context
|
|
25
|
+
name: [(identifier) (genericDot) (genericTpl)] @name) @item
|
|
26
|
+
|
|
27
|
+
; NOTE: implemented routines (procedure TFoo.Bar; begin ... end;) are NOT given
|
|
28
|
+
; their own pattern. A defProc's `header:` IS a declProc, so the pattern above
|
|
29
|
+
; already matches it -- adding a defProc pattern here produced every
|
|
30
|
+
; implementation twice in the outline.
|
|
31
|
+
|
|
32
|
+
; Properties: property Count: Integer read FCount;
|
|
33
|
+
(declProp
|
|
34
|
+
(kProperty) @context
|
|
35
|
+
name: (identifier) @name) @item
|