7
|
1 " Vim syntax file
|
|
2 " Language: Rexx
|
|
3 " Maintainer: Thomas Geulig <geulig@nentec.de>
|
3893
|
4 " Last Change: 2012 Sep 14, added support for new ooRexx 4.0 features
|
826
|
5 " URL: http://www.geulig.de/vim/rexx.vim
|
|
6 " Special Thanks to Dan Sharp <dwsharp@hotmail.com> and Rony G. Flatscher
|
|
7 " <Rony.Flatscher@wu-wien.ac.at> for comments and additions
|
7
|
8
|
|
9 " For version 5.x: Clear all syntax items
|
|
10 " For version 6.x: Quit when a syntax file was already loaded
|
|
11 if version < 600
|
|
12 syntax clear
|
|
13 elseif exists("b:current_syntax")
|
|
14 finish
|
|
15 endif
|
|
16
|
|
17 syn case ignore
|
|
18
|
826
|
19 " add to valid identifier chars
|
|
20 setlocal iskeyword+=.
|
|
21 setlocal iskeyword+=!
|
|
22 setlocal iskeyword+=?
|
|
23
|
|
24 " ---rgf, position important: must be before comments etc. !
|
1624
|
25 syn match rexxOperator "[=|\/\\\+\*\[\],;:<>&\~%\-]"
|
826
|
26
|
1624
|
27 " rgf syn match rexxIdentifier "\<[a-zA-Z\!\?_]\([a-zA-Z0-9._?!]\)*\>"
|
|
28 syn match rexxIdentifier "\<\K\k*\>"
|
|
29 syn match rexxEnvironmentSymbol "\<\.\k\+\>"
|
826
|
30
|
7
|
31 " A Keyword is the first symbol in a clause. A clause begins at the start
|
|
32 " of a line or after a semicolon. THEN, ELSE, OTHERWISE, and colons are always
|
|
33 " followed by an implied semicolon.
|
1624
|
34 syn match rexxClause "\(^\|;\|:\|then \|else \|when \|otherwise \)\s*\S*" contains=ALLBUT,rexxParse2,rexxRaise2,rexxForward2
|
7
|
35
|
|
36 " Considered keywords when used together in a phrase and begin a clause
|
1624
|
37 syn match rexxParse "\<parse\s*\(\(upper\|lower\|caseless\)\s*\)\?\(arg\|linein\|pull\|source\|var\|\<value\>\|version\)\>" containedin=rexxClause contains=rexxParse2
|
|
38 syn match rexxParse2 "\<with\>" containedin=rexxParse
|
826
|
39
|
7
|
40 syn match rexxKeyword contained "\<numeric \(digits\|form \(scientific\|engineering\|value\)\|fuzz\)\>"
|
1624
|
41 syn match rexxKeyword contained "\<\(address\|trace\)\( value\)\?\>"
|
|
42 syn match rexxKeyword contained "\<procedure\(\s*expose\)\?\>"
|
|
43
|
|
44 syn match rexxKeyword contained "\<\(do\|loop\)\>\(\s\+label\s\+\k*\)\?\(\s\+forever\)\?\>"
|
|
45 syn match rexxKeyword contained "\<use\>\s*\(strict\s*\)\?\<arg\>"
|
7
|
46
|
|
47 " Another keyword phrase, separated to aid highlighting in rexxFunction
|
1624
|
48 syn match rexxRegularCallSignal contained "\<\(call\|signal\)\s\(\s*on\>\|\s*off\>\)\@!\(\k\+\ze\|\ze(\)\(\s*\|;\|$\|(\)"
|
|
49 syn region rexxLabel contained start="\<\(call\|signal\)\>\s*\zs\(\k*\|(\)" end="\ze\(\s*\|;\|$\|(\)" containedin=rexxRegularCallSignal
|
|
50
|
3893
|
51 syn match rexxExceptionHandling contained "\<\(call\|signal\)\>\s\+\<\(on\|off\)\>.*\(;\|$\)" contains=rexxComment
|
826
|
52
|
1624
|
53 " hilite label given after keyword "name"
|
|
54 syn match rexxLabel "name\s\+\zs\k\+\ze" containedin=rexxExceptionHandling
|
|
55 " hilite condition name (serves as label)
|
|
56 syn match rexxLabel "\<\(call\|signal\)\>\s\+\<\(on\|off\)\>\s*\zs\k\+\ze\s*\(;\|$\)" containedin=rexxExceptionHandling
|
|
57 " user exception handling, hilite user defined name
|
|
58 syn region rexxLabel contained start="user\s\+\zs\k" end="\ze\(\s\|;\|$\)" containedin=rexxExceptionHandling
|
7
|
59
|
|
60 " Considered keywords when they begin a clause
|
1624
|
61 syn match rexxKeywordStatements "\<\(arg\|catch\|do\|drop\|end\|exit\|expose\|finally\|forward\|if\|interpret\|iterate\|leave\|loop\|nop\)\>"
|
|
62 syn match rexxKeywordStatements "\<\(options\|pull\|push\|queue\|raise\|reply\|return\|say\|select\|trace\)\>"
|
|
63
|
|
64 " Conditional keywords starting a new statement
|
|
65 syn match rexxConditional "\<\(then\|else\|when\|otherwise\)\(\s*\|;\|\_$\|\)\>" contains=rexxKeywordStatements
|
7
|
66
|
|
67 " Conditional phrases
|
1624
|
68 syn match rexxLoopKeywords "\<\(to\|by\|for\|until\|while\|over\)\>" containedin=doLoopSelectLabelRegion
|
826
|
69
|
|
70 " must be after Conditional phrases!
|
3893
|
71 syn match doLoopSelectLabelRegion "\<\(do\|loop\|select\)\>\s\+\(label\s\+\)\?\(\s\+\k\+\s\+\zs\<over\>\)\?\k*\(\s\+forever\)\?\(\s\|;\|$\)" contains=doLoopSelectLabelRegion,rexxStartValueAssignment,rexxLoopKeywords
|
1624
|
72
|
|
73 " color label's name
|
|
74 syn match rexxLabel2 "\<\(do\|loop\|select\)\>\s\+label\s\+\zs\k*\ze" containedin=doLoopSelectLabelRegion
|
|
75
|
|
76 " make sure control variable is normal
|
3893
|
77 " TODO: re-activate ?
|
|
78 "rgf syn match rexxControlVariable "\<\(do\|loop\)\>\(\s\+label\s\+\k*\)\?\s\+\zs.*\ze\s\+\<over\>" containedin=doLoopSelectLabelRegion
|
1624
|
79
|
|
80 " make sure control variable assignment is normal
|
|
81 syn match rexxStartValueAssignment "\<\(do\|loop\)\>\(\s\+label\s\+\k*\)\?\s\+\zs.*\ze\(=.*\)\?\s\+\<to\>" containedin=doLoopSelectLabelRegion
|
|
82
|
|
83 " highlight label name
|
|
84 syn match endIterateLeaveLabelRegion "\<\(end\|leave\|iterate\)\>\(\s\+\K\k*\)" contains=rexxLabel2
|
|
85 syn match rexxLabel2 "\<\(end\|leave\|iterate\)\>\s\+\zs\k*\ze" containedin=endIterateLeaveLabelRegion
|
|
86
|
|
87 " Guard statement
|
|
88 syn match rexxGuard "\(^\|;\|:\)\s*\<guard\>\s\+\<\(on\|off\)\>"
|
|
89
|
|
90 " Trace statement
|
|
91 syn match rexxTrace "\(^\|;\|:\)\s*\<trace\>\s\+\<\K\k*\>"
|
7
|
92
|
826
|
93 " Raise statement
|
3893
|
94 " syn match rexxRaise "\(^\|;\|:\)\s\+\<raise\>\s*\<\(propagate\|error\|failure\|syntax\|user\)\>\?" contains=rexxRaise2
|
|
95 syn match rexxRaise "\(^\|;\|:\)\s*\<raise\>\s*\<\(propagate\|error\|failure\|syntax\|user\)\>\?" contains=rexxRaise2
|
1624
|
96 syn match rexxRaise2 "\<\(additional\|array\|description\|exit\|propagate\|return\)\>" containedin=rexxRaise
|
826
|
97
|
1624
|
98 " Forward statement
|
|
99 syn match rexxForward "\(^\|;\|:\)\<forward\>\s*" contains=rexxForward2
|
|
100 syn match rexxForward2 "\<\(arguments\|array\|continue\|message\|class\|to\)\>" contained
|
7
|
101
|
|
102 " Functions/Procedures
|
1624
|
103 syn match rexxFunction "\<\<[a-zA-Z\!\?_]\k*\>("me=e-1
|
826
|
104 syn match rexxFunction "[()]"
|
7
|
105
|
|
106 " String constants
|
1624
|
107 syn region rexxString start=+"+ skip=+""+ end=+"\(x\|b\)\?+ oneline
|
|
108 syn region rexxString start=+'+ skip=+''+ end=+'\(x\|b\)\?+ oneline
|
7
|
109
|
1624
|
110 syn region rexxParen transparent start='(' end=')' contains=ALLBUT,rexxParenError,rexxTodo,rexxLabel,rexxKeyword
|
7
|
111 " Catch errors caused by wrong parenthesis
|
|
112 syn match rexxParenError ")"
|
|
113 syn match rexxInParen "[\\[\\]{}]"
|
|
114
|
|
115 " Comments
|
1624
|
116 syn region rexxComment start="/\*" end="\*/" contains=rexxTodo,rexxComment
|
|
117 syn match rexxCommentError "\*/"
|
|
118 syn region rexxLineComment start="--" end="\_$" oneline
|
|
119
|
|
120 " Highlight User Labels
|
|
121 " check for labels between comments, labels stated in a statement in the middle of a line
|
|
122 syn match rexxLabel "\(\_^\|;\)\s*\(\/\*.*\*\/\)*\s*\k\+\s*\(\/\*.*\*\/\)*\s*:"me=e-1 contains=rexxTodo,rexxComment
|
7
|
123
|
|
124 syn keyword rexxTodo contained TODO FIXME XXX
|
|
125
|
826
|
126 " ooRexx messages
|
|
127 syn region rexxMessageOperator start="\(\~\|\~\~\)" end="\(\S\|\s\)"me=e-1
|
|
128 syn match rexxMessage "\(\~\|\~\~\)\s*\<\.*[a-zA-Z]\([a-zA-Z0-9._?!]\)*\>" contains=rexxMessageOperator
|
|
129
|
1624
|
130 " line continuations, take care of (line-)comments after it
|
|
131 syn match rexxLineContinue ",\ze\s*\(--.*\|\/\*.*\)*$"
|
826
|
132
|
|
133 " the following is necessary, otherwise three consecutive dashes will cause it to highlight the first one
|
1624
|
134 syn match rexxLineContinue "-\ze-\@!\s*\(--.*\|\s*\/\*.*\)\?$"
|
7
|
135
|
|
136 " Special Variables
|
826
|
137 syn keyword rexxSpecialVariable sigl rc result self super
|
1624
|
138 syn keyword rexxSpecialVariable .environment .error .input .local .methods .output .rs .stderr .stdin .stdout .stdque
|
826
|
139
|
|
140 " Constants
|
3893
|
141 syn keyword rexxConst .true .false .nil .endOfLine .line .context
|
|
142
|
|
143 " Rexx numbers
|
|
144 " int like number
|
|
145 syn match rexxNumber '\d\+' contained
|
|
146 syn match rexxNumber '[-+]\s*\d\+' contained
|
1624
|
147
|
3893
|
148 " Floating point number with decimal
|
|
149 syn match rexxNumber '\d\+\.\d*' contained
|
|
150 syn match rexxNumber '[-+]\s*\d\+\.\d*' contained
|
|
151
|
|
152 " Floating point like number with E
|
|
153 syn match rexxNumber '[-+]\s*\d*[eE][\-+]\d\+' contained
|
|
154 syn match rexxNumber '\d*[eE][\-+]\d\+' contained
|
|
155
|
|
156 " Floating point like number with E and decimal point (+,-)
|
|
157 syn match rexxNumber '[-+]\s*\d*\.\d*[eE][\-+]\d\+' contained
|
|
158 syn match rexxNumber '\d*\.\d*[eE][\-+]\d\+' contained
|
|
159
|
826
|
160
|
1624
|
161 " ooRexx builtin classes (as of version 3.2.0, fall 2007), first define dot to be o.k. in keywords
|
|
162 syn keyword rexxBuiltinClass .Alarm .ArgUtil .Array .Bag .CaselessColumnComparator
|
|
163 syn keyword rexxBuiltinClass .CaselessComparator .CaselessDescendingComparator .CircularQueue
|
|
164 syn keyword rexxBuiltinClass .Class .Collection .ColumnComparator .Comparable .Comparator
|
3893
|
165 syn keyword rexxBuiltinClass .DateTime .DescendingComparator .Directory .File .InputOutputStream
|
1624
|
166 syn keyword rexxBuiltinClass .InputStream .InvertingComparator .List .MapCollection
|
|
167 syn keyword rexxBuiltinClass .Message .Method .Monitor .MutableBuffer .Object
|
3893
|
168 syn keyword rexxBuiltinClass .OrderedCollection .OutputStream .Package .Properties .Queue
|
|
169 syn keyword rexxBuiltinClass .RegularExpression .Relation .RexxContext .RexxQueue .Routine
|
|
170 syn keyword rexxBuiltinClass .Set .SetCollection .Stem .Stream
|
1624
|
171 syn keyword rexxBuiltinClass .StreamSupplier .String .Supplier .Table .TimeSpan
|
826
|
172
|
|
173 " Windows-only classes
|
1624
|
174 syn keyword rexxBuiltinClass .AdvancedControls .AnimatedButton .BaseDialog .ButtonControl
|
|
175 syn keyword rexxBuiltinClass .CategoryDialog .CheckBox .CheckList .ComboBox .DialogControl
|
|
176 syn keyword rexxBuiltinClass .DialogExtensions .DlgArea .DlgAreaU .DynamicDialog
|
|
177 syn keyword rexxBuiltinClass .EditControl .InputBox .IntegerBox .ListBox .ListChoice
|
|
178 syn keyword rexxBuiltinClass .ListControl .MenuObject .MessageExtensions .MultiInputBox
|
3893
|
179 syn keyword rexxBuiltinClass .MultiListChoice .OLEObject .OLEVariant
|
|
180 syn keyword rexxBuiltinClass .PasswordBox .PlainBaseDialog .PlainUserDialog
|
1624
|
181 syn keyword rexxBuiltinClass .ProgressBar .ProgressIndicator .PropertySheet .RadioButton
|
|
182 syn keyword rexxBuiltinClass .RcDialog .ResDialog .ScrollBar .SingleSelection .SliderControl
|
|
183 syn keyword rexxBuiltinClass .StateIndicator .StaticControl .TabControl .TimedMessage
|
|
184 syn keyword rexxBuiltinClass .TreeControl .UserDialog .VirtualKeyCodes .WindowBase
|
|
185 syn keyword rexxBuiltinClass .WindowExtensions .WindowObject .WindowsClassesBase .WindowsClipboard
|
|
186 syn keyword rexxBuiltinClass .WindowsEventLog .WindowsManager .WindowsProgramManager .WindowsRegistry
|
826
|
187
|
3893
|
188 " BSF4ooRexx classes
|
|
189 syn keyword rexxBuiltinClass .BSF .bsf.dialog .bsf_proxy
|
|
190 syn keyword rexxBuiltinClass .UNO .UNO_ENUM .UNO_CONSTANTS .UNO_PROPERTIES
|
|
191
|
1624
|
192 " ooRexx directives, ---rgf location important, otherwise directives in top of file not matched!
|
|
193 syn region rexxClassDirective start="::\s*class\s*"ms=e+1 end="\ze\(\s\|;\|$\)"
|
|
194 syn region rexxMethodDirective start="::\s*method\s*"ms=e+1 end="\ze\(\s\|;\|$\)"
|
|
195 syn region rexxRequiresDirective start="::\s*requires\s*"ms=e+1 end="\ze\(\s\|;\|$\)"
|
|
196 syn region rexxRoutineDirective start="::\s*routine\s*"ms=e+1 end="\ze\(\s\|;\|$\)"
|
|
197 syn region rexxAttributeDirective start="::\s*attribute\s*"ms=e+1 end="\ze\(\s\|;\|$\)"
|
3893
|
198 " rgf, 2012-09-09
|
|
199 syn region rexxOptionsDirective start="::\s*options\s*"ms=e+1 end="\ze\(\s\|;\|$\)"
|
|
200 syn region rexxConstantDirective start="::\s*constant\s*"ms=e+1 end="\ze\(\s\|;\|$\)"
|
1624
|
201
|
3893
|
202 syn region rexxDirective start="\(^\|;\)\s*::\s*\w\+" end="\($\|;\)" contains=rexxString,rexxNumber,rexxComment,rexxLineComment,rexxClassDirective,rexxMethodDirective,rexxRoutineDirective,rexxRequiresDirective,rexxAttributeDirective,rexxOptionsDirective,rexxConstantDirective keepend
|
|
203
|
|
204 syn match rexxOptionsDirective2 "\<\(digits\|form\|fuzz\|trace\)\>" containedin = rexxOptionsDirective3
|
|
205 syn region rexxOptionsDirective3 start="\(^\|;\)\s*::\s*options\s"ms=e+1 end="\($\|;\)" contains=rexxString,rexxNumber,rexxVariable,rexxComment,rexxLineComment containedin = rexxDirective
|
|
206
|
1624
|
207
|
|
208 syn region rexxVariable start="\zs\<\(\.\)\@!\K\k\+\>\ze\s*\(=\|,\|)\|%\|\]\|\\\||\|&\|+=\|-=\|<\|>\)" end="\(\_$\|.\)"me=e-1
|
3893
|
209 syn match rexxVariable "\(=\|,\|)\|%\|\]\|\\\||\|&\|+=\|-=\|<\|>\)\s*\zs\K\k*\ze"
|
826
|
210
|
1624
|
211 " rgf, 2007-07-22: unfortunately, the entire region is colored (not only the
|
|
212 " patterns), hence useless (vim 7.0)! (syntax-docs hint that that should work)
|
|
213 " attempt: just colorize the parenthesis in matching colors, keep content
|
|
214 " transparent to keep the formatting already done to it!
|
3893
|
215 " TODO: test on 7.3
|
1624
|
216 " syn region par1 matchgroup=par1 start="(" matchgroup=par1 end=")" transparent contains=par2
|
|
217 " syn region par2 matchgroup=par2 start="(" matchgroup=par2 end=")" transparent contains=par3 contained
|
|
218 " syn region par3 matchgroup=par3 start="(" matchgroup=par3 end=")" transparent contains=par4 contained
|
|
219 " syn region par4 matchgroup=par4 start="(" matchgroup=par4 end=")" transparent contains=par5 contained
|
|
220 " syn region par5 matchgroup=par5 start="(" matchgroup=par5 end=")" transparent contains=par1 contained
|
|
221
|
|
222 " this will colorize the entire region, removing any colorizing already done!
|
|
223 " syn region par1 matchgroup=par1 start="(" end=")" contains=par2
|
|
224 " syn region par2 matchgroup=par2 start="(" end=")" contains=par3 contained
|
|
225 " syn region par3 matchgroup=par3 start="(" end=")" contains=par4 contained
|
|
226 " syn region par4 matchgroup=par4 start="(" end=")" contains=par5 contained
|
|
227 " syn region par5 matchgroup=par5 start="(" end=")" contains=par1 contained
|
826
|
228
|
3893
|
229 hi par1 ctermfg=red guifg=red "guibg=grey
|
|
230 hi par2 ctermfg=blue guifg=blue "guibg=grey
|
|
231 hi par3 ctermfg=darkgreen guifg=darkgreen "guibg=grey
|
|
232 hi par4 ctermfg=darkyellow guifg=darkyellow "guibg=grey
|
|
233 hi par5 ctermfg=darkgrey guifg=darkgrey "guibg=grey
|
7
|
234
|
1624
|
235 " line continuation (trailing comma or single dash)
|
|
236 syn sync linecont "\(,\|-\ze-\@!\)\ze\s*\(--.*\|\/\*.*\)*$"
|
|
237
|
|
238 " if !exists("rexx_minlines")
|
|
239 " let rexx_minlines = 500
|
|
240 " endif
|
|
241 " exec "syn sync ccomment rexxComment minlines=" . rexx_minlines
|
|
242
|
3893
|
243 " always scan from start, PCs have long become to be powerful enough for that
|
1624
|
244 exec "syn sync fromstart"
|
7
|
245
|
|
246 " Define the default highlighting.
|
|
247 " For version 5.7 and earlier: only when not done already
|
|
248 " For version 5.8 and later: only when an item doesn't have highlighting yet
|
|
249 if version >= 508 || !exists("did_rexx_syn_inits")
|
|
250 if version < 508
|
|
251 let did_rexx_syn_inits = 1
|
|
252 command -nargs=+ HiLink hi link <args>
|
|
253 else
|
|
254 command -nargs=+ HiLink hi def link <args>
|
|
255 endif
|
|
256
|
1624
|
257 " make binary and hex strings stand out
|
|
258 hi rexxStringConstant term=bold,underline ctermfg=5 cterm=bold guifg=darkMagenta gui=bold
|
|
259
|
|
260 HiLink rexxLabel2 Function
|
|
261 HiLink doLoopSelectLabelRegion rexxKeyword
|
|
262 HiLink endIterateLeaveLabelRegion rexxKeyword
|
|
263 HiLink rexxLoopKeywords rexxKeyword " Todo
|
|
264
|
3893
|
265 HiLink rexxNumber Normal "DiffChange
|
1624
|
266 " HiLink rexxIdentifier DiffChange
|
|
267
|
|
268 HiLink rexxRegularCallSignal Statement
|
|
269 HiLink rexxExceptionHandling Statement
|
|
270
|
826
|
271 HiLink rexxLabel Function
|
7
|
272 HiLink rexxCharacter Character
|
|
273 HiLink rexxParenError rexxError
|
|
274 HiLink rexxInParen rexxError
|
|
275 HiLink rexxCommentError rexxError
|
|
276 HiLink rexxError Error
|
|
277 HiLink rexxKeyword Statement
|
3893
|
278 HiLink rexxKeywordStatements Statement
|
1624
|
279
|
7
|
280 HiLink rexxFunction Function
|
|
281 HiLink rexxString String
|
|
282 HiLink rexxComment Comment
|
|
283 HiLink rexxTodo Todo
|
|
284 HiLink rexxSpecialVariable Special
|
|
285 HiLink rexxConditional rexxKeyword
|
|
286
|
826
|
287 HiLink rexxOperator Operator
|
|
288 HiLink rexxMessageOperator rexxOperator
|
1624
|
289 HiLink rexxLineComment Comment
|
826
|
290
|
|
291 HiLink rexxLineContinue WildMenu
|
|
292
|
|
293 HiLink rexxDirective rexxKeyword
|
1624
|
294 HiLink rexxClassDirective Type
|
|
295 HiLink rexxMethodDirective rexxFunction
|
|
296 HiLink rexxAttributeDirective rexxFunction
|
|
297 HiLink rexxRequiresDirective Include
|
|
298 HiLink rexxRoutineDirective rexxFunction
|
826
|
299
|
3893
|
300 " rgf, 2012-09-09
|
|
301 HiLink rexxOptionsDirective rexxFunction
|
|
302 HiLink rexxOptionsDirective2 rexxOptionsDirective
|
|
303 HiLink rexxOptionsDirective3 Normal " rexxOptionsDirective
|
|
304
|
|
305 HiLink rexxConstantDirective rexxFunction
|
|
306
|
826
|
307 HiLink rexxConst Constant
|
|
308 HiLink rexxTypeSpecifier Type
|
|
309 HiLink rexxBuiltinClass rexxTypeSpecifier
|
|
310
|
|
311 HiLink rexxEnvironmentSymbol rexxConst
|
|
312 HiLink rexxMessage rexxFunction
|
|
313
|
|
314 HiLink rexxParse rexxKeyword
|
|
315 HiLink rexxParse2 rexxParse
|
|
316
|
1624
|
317 HiLink rexxGuard rexxKeyword
|
|
318 HiLink rexxTrace rexxKeyword
|
|
319
|
826
|
320 HiLink rexxRaise rexxKeyword
|
|
321 HiLink rexxRaise2 rexxRaise
|
|
322
|
|
323 HiLink rexxForward rexxKeyword
|
|
324 HiLink rexxForward2 rexxForward
|
|
325
|
7
|
326 delcommand HiLink
|
|
327 endif
|
|
328
|
|
329 let b:current_syntax = "rexx"
|
|
330
|
|
331 "vim: ts=8
|