blob: b4d07323d1accc22acffee1b3000353d7d7e5926 [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Vim syntax file
2" Language: Rexx
3" Maintainer: Thomas Geulig <geulig@nentec.de>
Bram Moolenaar4c3f5362006-04-11 21:38:50 +00004" Last Change: 2005 Dez 9, added some <http://www.ooRexx.org>-coloring,
5" line comments, do *over*, messages, directives,
6" highlighting classes, methods, routines and requires
Bram Moolenaar8c8de832008-06-24 22:58:06 +00007" 2007 Oct 17, added support for new ooRexx 3.2 features
Bram Moolenaar4c3f5362006-04-11 21:38:50 +00008" Rony G. Flatscher <rony.flatscher@wu-wien.ac.at>
Bram Moolenaar071d4272004-06-13 20:20:40 +00009"
Bram Moolenaar4c3f5362006-04-11 21:38:50 +000010" URL: http://www.geulig.de/vim/rexx.vim
11"
12" Special Thanks to Dan Sharp <dwsharp@hotmail.com> and Rony G. Flatscher
13" <Rony.Flatscher@wu-wien.ac.at> for comments and additions
Bram Moolenaar071d4272004-06-13 20:20:40 +000014
15" For version 5.x: Clear all syntax items
16" For version 6.x: Quit when a syntax file was already loaded
17if version < 600
18 syntax clear
19elseif exists("b:current_syntax")
20 finish
21endif
22
23syn case ignore
24
Bram Moolenaar4c3f5362006-04-11 21:38:50 +000025" add to valid identifier chars
26setlocal iskeyword+=.
27setlocal iskeyword+=!
28setlocal iskeyword+=?
29
30" ---rgf, position important: must be before comments etc. !
Bram Moolenaar8c8de832008-06-24 22:58:06 +000031syn match rexxOperator "[=|\/\\\+\*\[\],;:<>&\~%\-]"
Bram Moolenaar4c3f5362006-04-11 21:38:50 +000032
Bram Moolenaar8c8de832008-06-24 22:58:06 +000033" rgf syn match rexxIdentifier "\<[a-zA-Z\!\?_]\([a-zA-Z0-9._?!]\)*\>"
34syn match rexxIdentifier "\<\K\k*\>"
35syn match rexxEnvironmentSymbol "\<\.\k\+\>"
Bram Moolenaar4c3f5362006-04-11 21:38:50 +000036
Bram Moolenaar071d4272004-06-13 20:20:40 +000037" A Keyword is the first symbol in a clause. A clause begins at the start
38" of a line or after a semicolon. THEN, ELSE, OTHERWISE, and colons are always
39" followed by an implied semicolon.
Bram Moolenaar8c8de832008-06-24 22:58:06 +000040syn match rexxClause "\(^\|;\|:\|then \|else \|when \|otherwise \)\s*\S*" contains=ALLBUT,rexxParse2,rexxRaise2,rexxForward2
Bram Moolenaar071d4272004-06-13 20:20:40 +000041
42" Considered keywords when used together in a phrase and begin a clause
Bram Moolenaar8c8de832008-06-24 22:58:06 +000043syn match rexxParse "\<parse\s*\(\(upper\|lower\|caseless\)\s*\)\?\(arg\|linein\|pull\|source\|var\|\<value\>\|version\)\>" containedin=rexxClause contains=rexxParse2
44syn match rexxParse2 "\<with\>" containedin=rexxParse
Bram Moolenaar4c3f5362006-04-11 21:38:50 +000045
Bram Moolenaar071d4272004-06-13 20:20:40 +000046syn match rexxKeyword contained "\<numeric \(digits\|form \(scientific\|engineering\|value\)\|fuzz\)\>"
Bram Moolenaar8c8de832008-06-24 22:58:06 +000047syn match rexxKeyword contained "\<\(address\|trace\)\( value\)\?\>"
48syn match rexxKeyword contained "\<procedure\(\s*expose\)\?\>"
49
50syn match rexxKeyword contained "\<\(do\|loop\)\>\(\s\+label\s\+\k*\)\?\(\s\+forever\)\?\>"
51syn match rexxKeyword contained "\<use\>\s*\(strict\s*\)\?\<arg\>"
Bram Moolenaar071d4272004-06-13 20:20:40 +000052
53" Another keyword phrase, separated to aid highlighting in rexxFunction
Bram Moolenaar8c8de832008-06-24 22:58:06 +000054syn match rexxRegularCallSignal contained "\<\(call\|signal\)\s\(\s*on\>\|\s*off\>\)\@!\(\k\+\ze\|\ze(\)\(\s*\|;\|$\|(\)"
55syn region rexxLabel contained start="\<\(call\|signal\)\>\s*\zs\(\k*\|(\)" end="\ze\(\s*\|;\|$\|(\)" containedin=rexxRegularCallSignal
Bram Moolenaar4c3f5362006-04-11 21:38:50 +000056
Bram Moolenaar8c8de832008-06-24 22:58:06 +000057syn match rexxExceptionHandling contained "\<\(call\|signal\)\>\s\+\<\(on\|off\)\>.*\(;\|$\)"
58
59" hilite label given after keyword "name"
60syn match rexxLabel "name\s\+\zs\k\+\ze" containedin=rexxExceptionHandling
61" hilite condition name (serves as label)
62syn match rexxLabel "\<\(call\|signal\)\>\s\+\<\(on\|off\)\>\s*\zs\k\+\ze\s*\(;\|$\)" containedin=rexxExceptionHandling
63" user exception handling, hilite user defined name
64syn region rexxLabel contained start="user\s\+\zs\k" end="\ze\(\s\|;\|$\)" containedin=rexxExceptionHandling
Bram Moolenaar071d4272004-06-13 20:20:40 +000065
66" Considered keywords when they begin a clause
Bram Moolenaar8c8de832008-06-24 22:58:06 +000067syn match rexxKeywordStatements "\<\(arg\|catch\|do\|drop\|end\|exit\|expose\|finally\|forward\|if\|interpret\|iterate\|leave\|loop\|nop\)\>"
68syn match rexxKeywordStatements "\<\(options\|pull\|push\|queue\|raise\|reply\|return\|say\|select\|trace\)\>"
69
70" Conditional keywords starting a new statement
71syn match rexxConditional "\<\(then\|else\|when\|otherwise\)\(\s*\|;\|\_$\|\)\>" contains=rexxKeywordStatements
Bram Moolenaar071d4272004-06-13 20:20:40 +000072
73" Conditional phrases
Bram Moolenaar8c8de832008-06-24 22:58:06 +000074syn match rexxLoopKeywords "\<\(to\|by\|for\|until\|while\|over\)\>" containedin=doLoopSelectLabelRegion
Bram Moolenaar071d4272004-06-13 20:20:40 +000075
Bram Moolenaar4c3f5362006-04-11 21:38:50 +000076" must be after Conditional phrases!
Bram Moolenaar8c8de832008-06-24 22:58:06 +000077syn match doLoopSelectLabelRegion "\<\(do\|loop\|select\)\>\s\+\(label\s\+\)\?\(\s\+\k\+\s\+\zs\<over\>\)\?\k*\(\s\+forever\)\?\(\s\|;\|$\)"
78
79" color label's name
80syn match rexxLabel2 "\<\(do\|loop\|select\)\>\s\+label\s\+\zs\k*\ze" containedin=doLoopSelectLabelRegion
81
82" make sure control variable is normal
83syn match rexxControlVariable "\<\(do\|loop\)\>\(\s\+label\s\+\k*\)\?\s\+\zs.*\ze\s\+\<over\>" containedin=doLoopSelectLabelRegion
84
85" make sure control variable assignment is normal
86syn match rexxStartValueAssignment "\<\(do\|loop\)\>\(\s\+label\s\+\k*\)\?\s\+\zs.*\ze\(=.*\)\?\s\+\<to\>" containedin=doLoopSelectLabelRegion
87
88" highlight label name
89syn match endIterateLeaveLabelRegion "\<\(end\|leave\|iterate\)\>\(\s\+\K\k*\)" contains=rexxLabel2
90syn match rexxLabel2 "\<\(end\|leave\|iterate\)\>\s\+\zs\k*\ze" containedin=endIterateLeaveLabelRegion
91
92" Guard statement
93syn match rexxGuard "\(^\|;\|:\)\s*\<guard\>\s\+\<\(on\|off\)\>"
94
95" Trace statement
96syn match rexxTrace "\(^\|;\|:\)\s*\<trace\>\s\+\<\K\k*\>"
Bram Moolenaar4c3f5362006-04-11 21:38:50 +000097
98" Raise statement
Bram Moolenaar8c8de832008-06-24 22:58:06 +000099syn match rexxRaise "\(^\|;\|:\)\s\+\<raise\>\s*\<\(propagate\|error\|failure\|syntax\|user\)\>\?" contains=rexxRaise2
100syn match rexxRaise2 "\<\(additional\|array\|description\|exit\|propagate\|return\)\>" containedin=rexxRaise
Bram Moolenaar4c3f5362006-04-11 21:38:50 +0000101
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000102" Forward statement
103syn match rexxForward "\(^\|;\|:\)\<forward\>\s*" contains=rexxForward2
104syn match rexxForward2 "\<\(arguments\|array\|continue\|message\|class\|to\)\>" contained
Bram Moolenaar071d4272004-06-13 20:20:40 +0000105
106" Functions/Procedures
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000107syn match rexxFunction "\<\<[a-zA-Z\!\?_]\k*\>("me=e-1
Bram Moolenaar4c3f5362006-04-11 21:38:50 +0000108syn match rexxFunction "[()]"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000109
110" String constants
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000111syn region rexxString start=+"+ skip=+""+ end=+"\(x\|b\)\?+ oneline
112syn region rexxString start=+'+ skip=+''+ end=+'\(x\|b\)\?+ oneline
Bram Moolenaar071d4272004-06-13 20:20:40 +0000113
Bram Moolenaar4c3f5362006-04-11 21:38:50 +0000114syn region rexxParen transparent start='(' end=')' contains=ALLBUT,rexxParenError,rexxTodo,rexxLabel,rexxKeyword
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000115" Catch errors caused by wrong parenthesis
Bram Moolenaar071d4272004-06-13 20:20:40 +0000116syn match rexxParenError ")"
117syn match rexxInParen "[\\[\\]{}]"
118
119" Comments
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000120syn region rexxComment start="/\*" end="\*/" contains=rexxTodo,rexxComment
121syn match rexxCommentError "\*/"
122syn region rexxLineComment start="--" end="\_$" oneline
123
124" Highlight User Labels
125" check for labels between comments, labels stated in a statement in the middle of a line
126syn match rexxLabel "\(\_^\|;\)\s*\(\/\*.*\*\/\)*\s*\k\+\s*\(\/\*.*\*\/\)*\s*:"me=e-1 contains=rexxTodo,rexxComment
Bram Moolenaar071d4272004-06-13 20:20:40 +0000127
128syn keyword rexxTodo contained TODO FIXME XXX
129
Bram Moolenaar4c3f5362006-04-11 21:38:50 +0000130" ooRexx messages
131syn region rexxMessageOperator start="\(\~\|\~\~\)" end="\(\S\|\s\)"me=e-1
132syn match rexxMessage "\(\~\|\~\~\)\s*\<\.*[a-zA-Z]\([a-zA-Z0-9._?!]\)*\>" contains=rexxMessageOperator
133
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000134" line continuations, take care of (line-)comments after it
Bram Moolenaar4c3f5362006-04-11 21:38:50 +0000135syn match rexxLineContinue ",\ze\s*\(--.*\|\/\*.*\)*$"
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000136
Bram Moolenaar4c3f5362006-04-11 21:38:50 +0000137" the following is necessary, otherwise three consecutive dashes will cause it to highlight the first one
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000138syn match rexxLineContinue "-\ze-\@!\s*\(--.*\|\s*\/\*.*\)\?$"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000139
140" Special Variables
Bram Moolenaar4c3f5362006-04-11 21:38:50 +0000141syn keyword rexxSpecialVariable sigl rc result self super
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000142syn keyword rexxSpecialVariable .environment .error .input .local .methods .output .rs .stderr .stdin .stdout .stdque
Bram Moolenaar4c3f5362006-04-11 21:38:50 +0000143
144" Constants
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000145syn keyword rexxConst .true .false .nil .endOfLine .line
Bram Moolenaar4c3f5362006-04-11 21:38:50 +0000146
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000147syn match rexxNumber "\(-\|+\)\?\s*\zs\<\(\d\+\.\?\|\d*\.\d\+\(E\(+\|-\)\d\{2,2}\)\?\)\?\>"
148
149" ooRexx builtin classes (as of version 3.2.0, fall 2007), first define dot to be o.k. in keywords
150syn keyword rexxBuiltinClass .Alarm .ArgUtil .Array .Bag .CaselessColumnComparator
151syn keyword rexxBuiltinClass .CaselessComparator .CaselessDescendingComparator .CircularQueue
152syn keyword rexxBuiltinClass .Class .Collection .ColumnComparator .Comparable .Comparator
153syn keyword rexxBuiltinClass .DateTime .DescendingComparator .Directory .InputOutputStream
154syn keyword rexxBuiltinClass .InputStream .InvertingComparator .List .MapCollection
155syn keyword rexxBuiltinClass .Message .Method .Monitor .MutableBuffer .Object
156syn keyword rexxBuiltinClass .OrderedCollection .OutputStream .Properties .Queue
157syn keyword rexxBuiltinClass .Relation .RexxQueue .Set .SetCollection .Stem .Stream
158syn keyword rexxBuiltinClass .StreamSupplier .String .Supplier .Table .TimeSpan
Bram Moolenaar4c3f5362006-04-11 21:38:50 +0000159
160" Windows-only classes
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000161syn keyword rexxBuiltinClass .AdvancedControls .AnimatedButton .BaseDialog .ButtonControl
162syn keyword rexxBuiltinClass .CategoryDialog .CheckBox .CheckList .ComboBox .DialogControl
163syn keyword rexxBuiltinClass .DialogExtensions .DlgArea .DlgAreaU .DynamicDialog
164syn keyword rexxBuiltinClass .EditControl .InputBox .IntegerBox .ListBox .ListChoice
165syn keyword rexxBuiltinClass .ListControl .MenuObject .MessageExtensions .MultiInputBox
166syn keyword rexxBuiltinClass .MultiListChoice .PasswordBox .PlainBaseDialog .PlainUserDialog
167syn keyword rexxBuiltinClass .ProgressBar .ProgressIndicator .PropertySheet .RadioButton
168syn keyword rexxBuiltinClass .RcDialog .ResDialog .ScrollBar .SingleSelection .SliderControl
169syn keyword rexxBuiltinClass .StateIndicator .StaticControl .TabControl .TimedMessage
170syn keyword rexxBuiltinClass .TreeControl .UserDialog .VirtualKeyCodes .WindowBase
171syn keyword rexxBuiltinClass .WindowExtensions .WindowObject .WindowsClassesBase .WindowsClipboard
172syn keyword rexxBuiltinClass .WindowsEventLog .WindowsManager .WindowsProgramManager .WindowsRegistry
Bram Moolenaar4c3f5362006-04-11 21:38:50 +0000173
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000174" ooRexx directives, ---rgf location important, otherwise directives in top of file not matched!
175syn region rexxClassDirective start="::\s*class\s*"ms=e+1 end="\ze\(\s\|;\|$\)"
176syn region rexxMethodDirective start="::\s*method\s*"ms=e+1 end="\ze\(\s\|;\|$\)"
177syn region rexxRequiresDirective start="::\s*requires\s*"ms=e+1 end="\ze\(\s\|;\|$\)"
178syn region rexxRoutineDirective start="::\s*routine\s*"ms=e+1 end="\ze\(\s\|;\|$\)"
179syn region rexxAttributeDirective start="::\s*attribute\s*"ms=e+1 end="\ze\(\s\|;\|$\)"
Bram Moolenaar4c3f5362006-04-11 21:38:50 +0000180
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000181syn region rexxDirective start="\(^\|;\)\s*::\s*\w\+" end="\($\|;\)" contains=rexxString,rexxComment,rexxLineComment,rexxClassDirective,rexxMethodDirective,rexxRoutineDirective,rexxRequiresDirective,rexxAttributeDirective keepend
Bram Moolenaar4c3f5362006-04-11 21:38:50 +0000182
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000183syn region rexxVariable start="\zs\<\(\.\)\@!\K\k\+\>\ze\s*\(=\|,\|)\|%\|\]\|\\\||\|&\|+=\|-=\|<\|>\)" end="\(\_$\|.\)"me=e-1
184syn match rexxVariable "\(=\|,\|)\|%\|\]\|\\\||\|&\|+=\|-=\|<\|>\)\s*\zs\K\k*\ze"
Bram Moolenaar4c3f5362006-04-11 21:38:50 +0000185
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000186" rgf, 2007-07-22: unfortunately, the entire region is colored (not only the
187" patterns), hence useless (vim 7.0)! (syntax-docs hint that that should work)
188" attempt: just colorize the parenthesis in matching colors, keep content
189" transparent to keep the formatting already done to it!
190" syn region par1 matchgroup=par1 start="(" matchgroup=par1 end=")" transparent contains=par2
191" syn region par2 matchgroup=par2 start="(" matchgroup=par2 end=")" transparent contains=par3 contained
192" syn region par3 matchgroup=par3 start="(" matchgroup=par3 end=")" transparent contains=par4 contained
193" syn region par4 matchgroup=par4 start="(" matchgroup=par4 end=")" transparent contains=par5 contained
194" syn region par5 matchgroup=par5 start="(" matchgroup=par5 end=")" transparent contains=par1 contained
Bram Moolenaar4c3f5362006-04-11 21:38:50 +0000195
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000196" this will colorize the entire region, removing any colorizing already done!
197" syn region par1 matchgroup=par1 start="(" end=")" contains=par2
198" syn region par2 matchgroup=par2 start="(" end=")" contains=par3 contained
199" syn region par3 matchgroup=par3 start="(" end=")" contains=par4 contained
200" syn region par4 matchgroup=par4 start="(" end=")" contains=par5 contained
201" syn region par5 matchgroup=par5 start="(" end=")" contains=par1 contained
Bram Moolenaar071d4272004-06-13 20:20:40 +0000202
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000203hi par1 ctermfg=red guifg=red
204hi par2 ctermfg=blue guifg=blue
205hi par3 ctermfg=darkgreen guifg=darkgreen
206hi par4 ctermfg=darkyellow guifg=darkyellow
207hi par5 ctermfg=darkgrey guifg=darkgrey
208
209" line continuation (trailing comma or single dash)
210syn sync linecont "\(,\|-\ze-\@!\)\ze\s*\(--.*\|\/\*.*\)*$"
211
212" if !exists("rexx_minlines")
213" let rexx_minlines = 500
214" endif
215" exec "syn sync ccomment rexxComment minlines=" . rexx_minlines
216
217" always scan from start, PCs are powerful enough for that in 2007 !
218exec "syn sync fromstart"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000219
220" Define the default highlighting.
221" For version 5.7 and earlier: only when not done already
222" For version 5.8 and later: only when an item doesn't have highlighting yet
223if version >= 508 || !exists("did_rexx_syn_inits")
224 if version < 508
225 let did_rexx_syn_inits = 1
226 command -nargs=+ HiLink hi link <args>
227 else
228 command -nargs=+ HiLink hi def link <args>
229 endif
230
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000231 " make binary and hex strings stand out
232 hi rexxStringConstant term=bold,underline ctermfg=5 cterm=bold guifg=darkMagenta gui=bold
233
234 HiLink rexxLabel2 Function
235 HiLink doLoopSelectLabelRegion rexxKeyword
236 HiLink endIterateLeaveLabelRegion rexxKeyword
237 HiLink rexxLoopKeywords rexxKeyword " Todo
238
239 HiLink rexxNumber Normal
240" HiLink rexxIdentifier DiffChange
241
242 HiLink rexxRegularCallSignal Statement
243 HiLink rexxExceptionHandling Statement
244
Bram Moolenaar4c3f5362006-04-11 21:38:50 +0000245 HiLink rexxLabel Function
Bram Moolenaar071d4272004-06-13 20:20:40 +0000246 HiLink rexxCharacter Character
247 HiLink rexxParenError rexxError
248 HiLink rexxInParen rexxError
249 HiLink rexxCommentError rexxError
250 HiLink rexxError Error
251 HiLink rexxKeyword Statement
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000252 HiLink rexxKeywordStatements Statement
253
Bram Moolenaar071d4272004-06-13 20:20:40 +0000254 HiLink rexxFunction Function
255 HiLink rexxString String
256 HiLink rexxComment Comment
257 HiLink rexxTodo Todo
258 HiLink rexxSpecialVariable Special
259 HiLink rexxConditional rexxKeyword
260
Bram Moolenaar4c3f5362006-04-11 21:38:50 +0000261 HiLink rexxOperator Operator
262 HiLink rexxMessageOperator rexxOperator
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000263 HiLink rexxLineComment Comment
Bram Moolenaar4c3f5362006-04-11 21:38:50 +0000264
265 HiLink rexxLineContinue WildMenu
266
267 HiLink rexxDirective rexxKeyword
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000268 HiLink rexxClassDirective Type
269 HiLink rexxMethodDirective rexxFunction
270 HiLink rexxAttributeDirective rexxFunction
271 HiLink rexxRequiresDirective Include
272 HiLink rexxRoutineDirective rexxFunction
Bram Moolenaar4c3f5362006-04-11 21:38:50 +0000273
274 HiLink rexxConst Constant
275 HiLink rexxTypeSpecifier Type
276 HiLink rexxBuiltinClass rexxTypeSpecifier
277
278 HiLink rexxEnvironmentSymbol rexxConst
279 HiLink rexxMessage rexxFunction
280
281 HiLink rexxParse rexxKeyword
282 HiLink rexxParse2 rexxParse
283
Bram Moolenaar8c8de832008-06-24 22:58:06 +0000284 HiLink rexxGuard rexxKeyword
285 HiLink rexxTrace rexxKeyword
286
Bram Moolenaar4c3f5362006-04-11 21:38:50 +0000287 HiLink rexxRaise rexxKeyword
288 HiLink rexxRaise2 rexxRaise
289
290 HiLink rexxForward rexxKeyword
291 HiLink rexxForward2 rexxForward
292
Bram Moolenaar071d4272004-06-13 20:20:40 +0000293 delcommand HiLink
294endif
295
296let b:current_syntax = "rexx"
297
298"vim: ts=8