tree-sitter-delphi13-pure 1.2.2 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tree-sitter-delphi13-pure",
3
- "version": "1.2.2",
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
- "src/**"
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
@@ -0,0 +1,183 @@
1
+ ; tags.scm -- tree-sitter-delphi13-pure
2
+ ;
3
+ ; Symbol extraction in the standard tree-sitter "tags" format. This is the file
4
+ ; code-intelligence consumers read to build a symbol index: GitHub's tree-sitter
5
+ ; tags CLI, nvim-treesitter, and the VS Code / Cursor codebase indexers.
6
+ ;
7
+ ; Capture convention (tree-sitter-tags):
8
+ ; @name the identifier indexed for the symbol
9
+ ; @definition.<kind> the node the symbol spans
10
+ ; @reference.<kind> a use site
11
+ ; Every @name MUST sit inside its @definition node.
12
+ ;
13
+ ; NODE NAMES ARE DELPHI-SHAPED
14
+ ; This grammar uses declType / declClass / declIntf / declHelper / declProc /
15
+ ; defProc / declProp -- NOT the class_declaration / procedure_declaration names
16
+ ; of the generic Pascal grammars. A tags query copied from a Pascal grammar
17
+ ; compiles here but matches nothing.
18
+ ;
19
+ ; GENERICS
20
+ ; `TFoo<T: class>` parses as (genericTpl entity: (identifier) args: ...), so every
21
+ ; declaration pattern below is written twice: once for a plain or dotted name,
22
+ ; once unwrapping `entity:` out of a generic. Without the second form the indexed
23
+ ; symbol would be the literal text `TFoo<T: class>` rather than `TFoo` -- which
24
+ ; matters a great deal in Spring4D-heavy code.
25
+ ;
26
+ ; Qualified implementation names (`TFoo<T>.Bar`) are captured whole, matching
27
+ ; queries/outline.scm, so the indexed symbol stays unambiguous.
28
+
29
+ ;; ---------------------------------------------------------------- modules --
30
+
31
+ (unit (moduleName) @name) @definition.module
32
+ (program (moduleName) @name) @definition.module
33
+ (library (moduleName) @name) @definition.module
34
+ (package (moduleName) @name) @definition.module
35
+
36
+ (declUsesUnit (moduleName) @name) @reference.module
37
+
38
+ ;; ------------------------------------------------------------------ types --
39
+
40
+ ; type TFoo = class(TBar, IBaz) ... end; / = object ... end;
41
+ (declType
42
+ name: [(identifier) (genericDot)] @name
43
+ type: [(declClass (kClass)) (type (declClass (kClass)))]) @definition.class
44
+ (declType
45
+ name: (genericTpl entity: [(identifier) (genericDot)] @name)
46
+ type: [(declClass (kClass)) (type (declClass (kClass)))]) @definition.class
47
+
48
+ (declType
49
+ name: [(identifier) (genericDot)] @name
50
+ type: [(declClass (kObject)) (type (declClass (kObject)))]) @definition.class
51
+ (declType
52
+ name: (genericTpl entity: [(identifier) (genericDot)] @name)
53
+ type: [(declClass (kObject)) (type (declClass (kObject)))]) @definition.class
54
+
55
+ ; type TFoo = record ... end;
56
+ (declType
57
+ name: [(identifier) (genericDot)] @name
58
+ type: [(declClass (kRecord)) (type (declClass (kRecord)))]) @definition.struct
59
+ (declType
60
+ name: (genericTpl entity: [(identifier) (genericDot)] @name)
61
+ type: [(declClass (kRecord)) (type (declClass (kRecord)))]) @definition.struct
62
+
63
+ ; type IFoo = interface / dispinterface ... end;
64
+ (declType
65
+ name: [(identifier) (genericDot)] @name
66
+ type: (declIntf)) @definition.interface
67
+ (declType
68
+ name: (genericTpl entity: [(identifier) (genericDot)] @name)
69
+ type: (declIntf)) @definition.interface
70
+
71
+ ; type TFooHelper = class helper for TFoo ... end;
72
+ (declType
73
+ name: [(identifier) (genericDot)] @name
74
+ type: (declHelper)) @definition.class
75
+ (declType
76
+ name: (genericTpl entity: [(identifier) (genericDot)] @name)
77
+ type: (declHelper)) @definition.class
78
+
79
+ ; type TColor = (clRed, clGreen);
80
+ (declType
81
+ name: [(identifier) (genericDot)] @name
82
+ type: (type (declEnum))) @definition.enum
83
+
84
+ (declEnumValue name: (identifier) @name) @definition.constant
85
+
86
+ ; aliases, sets, arrays, strings, files, procedural types, metaclasses, subranges
87
+ (declType
88
+ name: [(identifier) (genericDot)] @name
89
+ type: [
90
+ (identifier)
91
+ (subrangeType)
92
+ (type (typeref))
93
+ (type (declSet))
94
+ (type (declArray))
95
+ (type (declString))
96
+ (type (declFile))
97
+ (type (declProcRef))
98
+ (type (declMetaClass))
99
+ ]) @definition.type
100
+ (declType
101
+ name: (genericTpl entity: [(identifier) (genericDot)] @name)
102
+ type: [
103
+ (identifier)
104
+ (subrangeType)
105
+ (type (typeref))
106
+ (type (declSet))
107
+ (type (declArray))
108
+ (type (declString))
109
+ (type (declFile))
110
+ (type (declProcRef))
111
+ (type (declMetaClass))
112
+ ]) @definition.type
113
+
114
+ ;; ---------------------------------------------------------------- methods --
115
+ ;
116
+ ; Routines declared inside a class / record / interface / helper body, either
117
+ ; directly or under a visibility section (private / protected / public /
118
+ ; published / strict private ...).
119
+
120
+ (declClass (declProc name: (identifier) @name) @definition.method)
121
+ (declClass (declProc name: (genericTpl entity: (identifier) @name)) @definition.method)
122
+ (declClass (declSection (declProc name: (identifier) @name) @definition.method))
123
+ (declClass (declSection (declProc name: (genericTpl entity: (identifier) @name)) @definition.method))
124
+
125
+ (declIntf (declProc name: (identifier) @name) @definition.method)
126
+ (declIntf (declProc name: (genericTpl entity: (identifier) @name)) @definition.method)
127
+ (declIntf (declSection (declProc name: (identifier) @name) @definition.method))
128
+ (declIntf (declSection (declProc name: (genericTpl entity: (identifier) @name)) @definition.method))
129
+
130
+ (declHelper (declProc name: (identifier) @name) @definition.method)
131
+ (declHelper (declProc name: (genericTpl entity: (identifier) @name)) @definition.method)
132
+ (declHelper (declSection (declProc name: (identifier) @name) @definition.method))
133
+ (declHelper (declSection (declProc name: (genericTpl entity: (identifier) @name)) @definition.method))
134
+
135
+ ; property Name: string read GetName write SetName;
136
+ (declProp name: (identifier) @name) @definition.property
137
+
138
+ ; FName: string; (only ever occurs in a class-like body)
139
+ (declField name: (identifier) @name) @definition.field
140
+
141
+ ;; -------------------------------------------------------------- functions --
142
+ ;
143
+ ; Free routines: declared in the interface section, forward-declared in the
144
+ ; implementation section, or written straight into a program / library /
145
+ ; package / bare include fragment.
146
+
147
+ (interface (declProc name: (identifier) @name) @definition.function)
148
+ (implementation (declProc name: (identifier) @name) @definition.function)
149
+ (program (declProc name: (identifier) @name) @definition.function)
150
+ (library (declProc name: (identifier) @name) @definition.function)
151
+ (package (declProc name: (identifier) @name) @definition.function)
152
+ (root (declProc name: (identifier) @name) @definition.function)
153
+
154
+ (interface (declProc name: (genericTpl entity: (identifier) @name)) @definition.function)
155
+ (implementation (declProc name: (genericTpl entity: (identifier) @name)) @definition.function)
156
+ (program (declProc name: (genericTpl entity: (identifier) @name)) @definition.function)
157
+ (library (declProc name: (genericTpl entity: (identifier) @name)) @definition.function)
158
+ (package (declProc name: (genericTpl entity: (identifier) @name)) @definition.function)
159
+ (root (declProc name: (genericTpl entity: (identifier) @name)) @definition.function)
160
+
161
+ ; Implemented bodies.
162
+ ; procedure TFoo.Bar; begin ... end; -> a method implementation
163
+ ; function Helper(...); begin ... end; -> a free routine implementation
164
+ (defProc header: (declProc name: (genericDot) @name)) @definition.method
165
+ (defProc header: (declProc name: (identifier) @name)) @definition.function
166
+ (defProc header: (declProc name: (genericTpl entity: (identifier) @name))) @definition.function
167
+
168
+ ;; ------------------------------------------------------ constants and vars --
169
+
170
+ (declConst name: (identifier) @name) @definition.constant
171
+ (declVar name: (identifier) @name) @definition.variable
172
+
173
+ ;; ------------------------------------------------------------- references --
174
+
175
+ ; Foo(...), Unit.Foo(...) / Obj.Foo(...), Foo<T>(...)
176
+ (exprCall entity: (identifier) @name) @reference.call
177
+ (exprCall entity: (exprDot rhs: (identifier) @name)) @reference.call
178
+ (exprCall entity: (exprTpl entity: (identifier) @name)) @reference.call
179
+
180
+ ; Ancestor class and implemented interfaces.
181
+ (declClass parent: (typeref (identifier) @name) @reference.implementation)
182
+ (declIntf parent: (typeref (identifier) @name) @reference.implementation)
183
+ (declHelper parent: (typeref (identifier) @name) @reference.implementation)
Binary file
@@ -0,0 +1,22 @@
1
+ {
2
+ "$schema": "https://tree-sitter.github.io/tree-sitter/assets/schemas/config.schema.json",
3
+ "grammars": [
4
+ {
5
+ "name": "delphi13_pure",
6
+ "camelcase": "Delphi13Pure",
7
+ "title": "Delphi 13 (pure, no preprocessor)",
8
+ "scope": "source.delphi-pure",
9
+ "file-types": [],
10
+ "class-name": "TreeSitterDelphi13Pure"
11
+ }
12
+ ],
13
+ "metadata": {
14
+ "version": "1.3.0",
15
+ "license": "MIT",
16
+ "description": "Pure Delphi 13 sub-tree-sitter — knows no IFDEFs"
17
+ },
18
+ "bindings": {
19
+ "c": true,
20
+ "node": true
21
+ }
22
+ }