Debian Codegraph @

runtime/queries/pascal/highlights.scm

raw symbols SCIP
1 ; -- Identifier type inference
2
3 ; VERY QUESTIONABLE: Highlighting of identifiers based on spelling
4 (exprBinary ((identifier) @constant
5 (#match? @constant "^[A-Z][A-Z0-9_]+$|^[a-z]{2,3}[A-Z].+$")))
6 (exprUnary ((identifier) @constant
7 (#match? @constant "^[A-Z][A-Z0-9_]+$|^[a-z]{2,3}[A-Z].+$")))
8 (assignment rhs: ((identifier) @constant
9 (#match? @constant "^[A-Z][A-Z0-9_]+$|^[a-z]{2,3}[A-Z].+$")))
10 (exprBrackets ((identifier) @constant
11 (#match? @constant "^[A-Z][A-Z0-9_]+$|^[a-z]{2,3}[A-Z].+$")))
12 (exprParens ((identifier) @constant
13 (#match? @constant "^[A-Z][A-Z0-9_]+$|^[a-z]{2,3}[A-Z].+$")))
14 (exprDot rhs: ((identifier) @constant
15 (#match? @constant "^[A-Z][A-Z0-9_]+$|^[a-z]{2,3}[A-Z].+$")))
16 (exprTpl args: ((identifier) @constant
17 (#match? @constant "^[A-Z][A-Z0-9_]+$|^[a-z]{2,3}[A-Z].+$")))
18 (exprArgs ((identifier) @constant
19 (#match? @constant "^[A-Z][A-Z0-9_]+$|^[a-z]{2,3}[A-Z].+$")))
20 (declEnumValue ((identifier) @constant
21 (#match? @constant "^[A-Z][A-Z0-9_]+$|^[a-z]{2,3}[A-Z].+$")))
22 (defaultValue ((identifier) @constant
23 (#match? @constant "^[A-Z][A-Z0-9_]+$|^[a-z]{2,3}[A-Z].+$")))
24
25 ; -- Break, Continue & Exit
26 ; (Not ideal: ideally, there would be a way to check if these special
27 ; identifiers are shadowed by a local variable)
28 (statement ((identifier) @keyword.control.return
29 (#match? @keyword.control.return "^[eE][xX][iI][tT]$")))
30 (statement (exprCall entity: ((identifier) @keyword.control.return
31 (#match? @keyword.control.return "^[eE][xX][iI][tT]$"))))
32 (statement ((identifier) @keyword.control.repeat
33 (#match? @keyword.control.repeat "^[bB][rR][eE][aA][kK]$")))
34 (statement ((identifier) @keyword.control.repeat
35 (#match? @keyword.control.repeat "^[cC][oO][nN][tT][iI][nN][uU][eE]$")))
36
37 ; -- Heuristic for procedure/function calls without parentheses
38 ; (If a statement consists only of an identifier, assume it's a procedure)
39 ; (This will still not match all procedure calls, and also may produce false
40 ; positives in rare cases, but only for nonsensical code)
41
42 (statement (exprDot rhs: (exprTpl entity: (identifier) @function)))
43 (statement (exprTpl entity: (identifier) @function))
44 (statement (exprDot rhs: (identifier) @function))
45 (statement (identifier) @function)
46
47 ; -- Procedure name in calls with parentheses
48 ; (Pascal doesn't require parentheses for procedure calls, so this will not
49 ; detect all calls)
50
51 (inherited) @function
52
53 ; foo.bar<t>
54 (exprCall entity: (exprDot rhs: (exprTpl entity: (identifier) @function)))
55 ; foo.bar
56 (exprCall entity: (exprDot rhs: (identifier) @function))
57 ; foobar<t>
58 (exprCall entity: (exprTpl entity: (identifier) @function))
59 ; foobar
60 (exprCall entity: (identifier) @function)
61
62 ; -- Fields
63
64 (declSection (declVars (declVar name:(identifier) @variable.other.member)))
65 (declSection (declField name:(identifier) @variable.other.member))
66 (declClass (declField name:(identifier) @variable.other.member))
67 (exprDot rhs: (exprDot) @variable.other.member)
68 (exprDot rhs: (identifier) @variable.other.member)
69
70 (recInitializerField name:(identifier) @variable.other.member)
71
72 ; -- Variable & constant declarations
73 ; (This is only questionable because we cannot detect types of identifiers
74 ; declared in other units, so the results will be inconsistent)
75
76 (declVar name: (identifier) @variable)
77 (declConst name: (identifier) @constant)
78 (declEnumValue name: (identifier) @constant)
79
80 ; Delphi inline variables: `var x: T` and `var y := …` (also `for var i …`).
81 (varDef (identifier) @variable)
82 (varAssignDef (identifier) @variable)
83
84 ; -- Constant usage
85
86 [
87 (caseLabel)
88 (label)
89 ] @constant
90
91 (procAttribute (identifier) @constant)
92 (procExternal (identifier) @constant)
93
94 ; -- Type usage
95
96 (typeref) @type
97
98 ; -- Exception parameters
99
100 (exceptionHandler variable: (identifier) @variable.parameter)
101
102 ; -- Template parameters
103
104 (genericArg type: (typeref) @type)
105 (genericArg name: (identifier) @variable.parameter)
106
107 (declProc name: (genericDot lhs: (identifier) @type))
108 (declType (genericDot (identifier) @type))
109
110 (genericDot (genericTpl (identifier) @type))
111 (genericDot (genericDot (identifier) @type))
112
113 (genericTpl entity: (genericDot (identifier) @type))
114 (genericTpl entity: (identifier) @type)
115
116 ; -- Function parameters
117
118 (declArg name: (identifier) @variable.parameter)
119
120 ; Treat property declarations like functions
121
122 (declProp name: (identifier) @function)
123 (declProp getter: (identifier) @variable.other.member)
124 (declProp setter: (identifier) @variable.other.member)
125
126 ; -- Procedure & function declarations
127
128 ; foo.bar<t>
129 (declProc name: (genericDot rhs: (genericTpl entity: (identifier) @function)))
130 ; foo.bar
131 (declProc name: (genericDot rhs: (identifier) @function))
132 ; foobar<t>
133 (declProc name: (genericTpl entity: (identifier) @function))
134 ; foobar
135 (declProc name: (identifier) @function)
136
137 ; -- Type declaration
138
139 (declType name: (genericTpl entity: (identifier) @type))
140 (declType name: (identifier) @type)
141
142 ; -- Comments
143
144 (comment) @comment
145 (pp) @function.macro
146
147 ; -- Variables
148
149 (exprBinary (identifier) @variable)
150 (exprUnary (identifier) @variable)
151 (assignment (identifier) @variable)
152 (exprBrackets (identifier) @variable)
153 (exprParens (identifier) @variable)
154 (exprDot (identifier) @variable)
155 (exprTpl (identifier) @variable)
156 (exprArgs (identifier) @variable)
157 (defaultValue (identifier) @variable)
158
159 ; -- Literals
160
161 (literalNumber) @constant.numeric
162 (literalString) @string
163
164 ; -- Builtin constants
165
166 [
167 (kTrue)
168 (kFalse)
169 ] @constant.builtin.boolean
170
171 [
172 (kNil)
173 ] @constant.builtin
174
175 ; -- Punctuation & operators
176
177 [
178 (kOr)
179 (kXor)
180 (kDiv)
181 (kMod)
182 (kAnd)
183 (kShl)
184 (kShr)
185 (kNot)
186 (kIs)
187 (kAs)
188 (kIn)
189 ] @keyword.operator
190
191 [
192 (kDot)
193 (kAdd)
194 (kSub)
195 (kMul)
196 (kFdiv)
197 (kAssign)
198 (kAssignAdd)
199 (kAssignSub)
200 (kAssignMul)
201 (kAssignDiv)
202 (kEq)
203 (kLt)
204 (kLte)
205 (kGt)
206 (kGte)
207 (kNeq)
208 (kAt)
209 (kHat)
210 ] @operator
211
212 [
213 ".."
214 ] @punctuation.special
215
216 [
217 ";"
218 ","
219 ":"
220 (kEndDot)
221 ] @punctuation.delimiter
222
223 [
224 "("
225 ")"
226 "["
227 "]"
228 ] @punctuation.bracket
229
230 ; -- Attributes
231
232 (procAttribute (kPublic) @attribute)
233
234 [
235 (kDefault)
236 (kIndex)
237 (kNodefault)
238 (kStored)
239 (kDispId)
240
241 (kStatic)
242 (kVirtual)
243 (kAbstract)
244 (kSealed)
245 (kDynamic)
246 (kOverride)
247 (kOverload)
248 (kReintroduce)
249 (kInline)
250
251 (kForward)
252
253 (kStdcall)
254 (kCdecl)
255 (kCppdecl)
256 (kPascal)
257 (kRegister)
258 (kMwpascal)
259 (kExternal)
260 (kName)
261 (kMessage)
262 (kDeprecated)
263 (kExperimental)
264 (kPlatform)
265 (kUnimplemented)
266 (kCvar)
267 (kExport)
268 (kFar)
269 (kNear)
270 (kSafecall)
271 (kAssembler)
272 (kNostackframe)
273 (kInterrupt)
274 (kNoreturn)
275 (kIocheck)
276 (kLocal)
277 (kHardfloat)
278 (kSoftfloat)
279 (kMs_abi_default)
280 (kMs_abi_cdecl)
281 (kSaveregisters)
282 (kSysv_abi_default)
283 (kSysv_abi_cdecl)
284 (kVectorcall)
285 (kVarargs)
286 (kWinapi)
287 (kAlias)
288 (kDelayed)
289
290 (rttiAttributes)
291 (procAttribute)
292
293 ] @attribute
294
295 ; -- Keywords
296 [
297 (kProgram)
298 (kLibrary)
299 (kUnit)
300 (kUses)
301
302 (kBegin)
303 (kEnd)
304 (kAsm)
305
306 (kVar)
307 (kThreadvar)
308 (kConst)
309 (kResourcestring)
310 (kConstref)
311 (kOut)
312 (kType)
313 (kLabel)
314 (kExports)
315
316 (kAbsolute)
317
318 (kProperty)
319 (kRead)
320 (kWrite)
321 (kImplements)
322
323 (kClass)
324 (kInterface)
325 (kDispInterface)
326 (kObject)
327 (kRecord)
328 (kObjcclass)
329 (kObjccategory)
330 (kObjcprotocol)
331 (kArray)
332 (kFile)
333 (kString)
334 (kSet)
335 (kOf)
336 (kHelper)
337 (kPacked)
338
339 (kInherited)
340
341 (kGeneric)
342 (kSpecialize)
343
344 (kFunction)
345 (kProcedure)
346 (kConstructor)
347 (kDestructor)
348 (kOperator)
349 (kReference)
350
351 (kInterface)
352 (kImplementation)
353 (kInitialization)
354 (kFinalization)
355
356 (kPublished)
357 (kPublic)
358 (kProtected)
359 (kPrivate)
360 (kStrict)
361 (kRequired)
362 (kOptional)
363
364 (kTry)
365 (kExcept)
366 (kFinally)
367 (kRaise)
368 (kOn)
369 (kCase)
370 (kWith)
371 (kGoto)
372 ] @keyword
373
374 [
375 (kFor)
376 (kTo)
377 (kDownto)
378 (kDo)
379 (kWhile)
380 (kRepeat)
381 (kUntil)
382 ] @keyword.control.repeat
383
384 [
385 (kIf)
386 (kThen)
387 (kElse)
388 ] @keyword.control.conditional