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