@@ -0,0 +1,382 @@
1+; -- Identifier type inferrence
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].+$")))
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]$")))
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)
42+(statement (exprDot rhs: (exprTpl entity: (identifier) @function)))
43+(statement (exprTpl entity: (identifier) @function))
44+(statement (exprDot rhs: (identifier) @function))
45+(statement (identifier) @function)
47+; -- Procedure name in calls with parentheses
48+; (Pascal doesn't require parentheses for procedure calls, so this will not
54+(exprCall entity: (exprDot rhs: (exprTpl entity: (identifier) @function)))
56+(exprCall entity: (exprDot rhs: (identifier) @function))
58+(exprCall entity: (exprTpl entity: (identifier) @function))
60+(exprCall entity: (identifier) @function)
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)
70+(recInitializerField name:(identifier) @variable.other.member)
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)
76+(declVar name: (identifier) @variable)
77+(declConst name: (identifier) @constant)
78+(declEnumValue name: (identifier) @constant)
87+(procAttribute (identifier) @constant)
88+(procExternal (identifier) @constant)
94+; -- Exception parameters
96+(exceptionHandler variable: (identifier) @variable.parameter)
98+; -- Template parameters
100+(genericArg type: (typeref) @type)
101+(genericArg name: (identifier) @variable.parameter)
103+(declProc name: (genericDot lhs: (identifier) @type))
104+(declType (genericDot (identifier) @type))
106+(genericDot (genericTpl (identifier) @type))
107+(genericDot (genericDot (identifier) @type))
109+(genericTpl entity: (genericDot (identifier) @type))
110+(genericTpl entity: (identifier) @type)
112+; -- Function parameters
114+(declArg name: (identifier) @variable.parameter)
116+; Treat property declarations like functions
118+(declProp name: (identifier) @function)
119+(declProp getter: (identifier) @variable.other.member)
120+(declProp setter: (identifier) @variable.other.member)
122+; -- Procedure & function declarations
125+(declProc name: (genericDot rhs: (genericTpl entity: (identifier) @function)))
127+(declProc name: (genericDot rhs: (identifier) @function))
129+(declProc name: (genericTpl entity: (identifier) @function))
131+(declProc name: (identifier) @function)
133+; -- Type declaration
135+(declType name: (genericTpl entity: (identifier) @type))
136+(declType name: (identifier) @type)
145+(exprBinary (identifier) @variable)
146+(exprUnary (identifier) @variable)
147+(assignment (identifier) @variable)
148+(exprBrackets (identifier) @variable)
149+(exprParens (identifier) @variable)
150+(exprDot (identifier) @variable)
151+(exprTpl (identifier) @variable)
152+(exprArgs (identifier) @variable)
153+(defaultValue (identifier) @variable)
157+(literalNumber) @constant.builtin.numeric
158+(literalString) @string
160+; -- Builtin constants
165+] @constant.builtin.boolean
171+; -- Punctuation & operators
210+] @punctuation.special
217+] @punctuation.delimiter
224+] @punctuation.bracket
228+(procAttribute (kPublic) @attribute)
376+] @keyword.control.repeat
382+] @keyword.control.conditional