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