3 " Maintainer: Thomas Geulig <geulig@nentec.de>
4 " 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
7 " 2007 Oct 17, added support for new ooRexx 3.2 features
8 " Rony G. Flatscher <rony.flatscher@wu-wien.ac.at>
10 " URL: http://www.geulig.de/vim/rexx.vim
12 " Special Thanks to Dan Sharp <dwsharp@hotmail.com> and Rony G. Flatscher
13 " <Rony.Flatscher@wu-wien.ac.at> for comments and additions
15 " For version 5.x: Clear all syntax items
16 " For version 6.x: Quit when a syntax file was already loaded
19 elseif exists("b:current_syntax")
25 " add to valid identifier chars
30 " ---rgf, position important: must be before comments etc. !
31 syn match rexxOperator "[=|\/\\\+\*\[\],;:<>&\~%\-]"
33 " rgf syn match rexxIdentifier "\<[a-zA-Z\!\?_]\([a-zA-Z0-9._?!]\)*\>"
34 syn match rexxIdentifier "\<\K\k*\>"
35 syn match rexxEnvironmentSymbol "\<\.\k\+\>"
37 " 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.
40 syn match rexxClause "\(^\|;\|:\|then \|else \|when \|otherwise \)\s*\S*" contains=ALLBUT,rexxParse2,rexxRaise2,rexxForward2
42 " Considered keywords when used together in a phrase and begin a clause
43 syn match rexxParse "\<parse\s*\(\(upper\|lower\|caseless\)\s*\)\?\(arg\|linein\|pull\|source\|var\|\<value\>\|version\)\>" containedin=rexxClause contains=rexxParse2
44 syn match rexxParse2 "\<with\>" containedin=rexxParse
46 syn match rexxKeyword contained "\<numeric \(digits\|form \(scientific\|engineering\|value\)\|fuzz\)\>"
47 syn match rexxKeyword contained "\<\(address\|trace\)\( value\)\?\>"
48 syn match rexxKeyword contained "\<procedure\(\s*expose\)\?\>"
50 syn match rexxKeyword contained "\<\(do\|loop\)\>\(\s\+label\s\+\k*\)\?\(\s\+forever\)\?\>"
51 syn match rexxKeyword contained "\<use\>\s*\(strict\s*\)\?\<arg\>"
53 " Another keyword phrase, separated to aid highlighting in rexxFunction
54 syn match rexxRegularCallSignal contained "\<\(call\|signal\)\s\(\s*on\>\|\s*off\>\)\@!\(\k\+\ze\|\ze(\)\(\s*\|;\|$\|(\)"
55 syn region rexxLabel contained start="\<\(call\|signal\)\>\s*\zs\(\k*\|(\)" end="\ze\(\s*\|;\|$\|(\)" containedin=rexxRegularCallSignal
57 syn match rexxExceptionHandling contained "\<\(call\|signal\)\>\s\+\<\(on\|off\)\>.*\(;\|$\)"
59 " hilite label given after keyword "name"
60 syn match rexxLabel "name\s\+\zs\k\+\ze" containedin=rexxExceptionHandling
61 " hilite condition name (serves as label)
62 syn match rexxLabel "\<\(call\|signal\)\>\s\+\<\(on\|off\)\>\s*\zs\k\+\ze\s*\(;\|$\)" containedin=rexxExceptionHandling
63 " user exception handling, hilite user defined name
64 syn region rexxLabel contained start="user\s\+\zs\k" end="\ze\(\s\|;\|$\)" containedin=rexxExceptionHandling
66 " Considered keywords when they begin a clause
67 syn match rexxKeywordStatements "\<\(arg\|catch\|do\|drop\|end\|exit\|expose\|finally\|forward\|if\|interpret\|iterate\|leave\|loop\|nop\)\>"
68 syn match rexxKeywordStatements "\<\(options\|pull\|push\|queue\|raise\|reply\|return\|say\|select\|trace\)\>"
70 " Conditional keywords starting a new statement
71 syn match rexxConditional "\<\(then\|else\|when\|otherwise\)\(\s*\|;\|\_$\|\)\>" contains=rexxKeywordStatements
74 syn match rexxLoopKeywords "\<\(to\|by\|for\|until\|while\|over\)\>" containedin=doLoopSelectLabelRegion
76 " must be after Conditional phrases!
77 syn match doLoopSelectLabelRegion "\<\(do\|loop\|select\)\>\s\+\(label\s\+\)\?\(\s\+\k\+\s\+\zs\<over\>\)\?\k*\(\s\+forever\)\?\(\s\|;\|$\)"
80 syn match rexxLabel2 "\<\(do\|loop\|select\)\>\s\+label\s\+\zs\k*\ze" containedin=doLoopSelectLabelRegion
82 " make sure control variable is normal
83 syn match rexxControlVariable "\<\(do\|loop\)\>\(\s\+label\s\+\k*\)\?\s\+\zs.*\ze\s\+\<over\>" containedin=doLoopSelectLabelRegion
85 " make sure control variable assignment is normal
86 syn match rexxStartValueAssignment "\<\(do\|loop\)\>\(\s\+label\s\+\k*\)\?\s\+\zs.*\ze\(=.*\)\?\s\+\<to\>" containedin=doLoopSelectLabelRegion
88 " highlight label name
89 syn match endIterateLeaveLabelRegion "\<\(end\|leave\|iterate\)\>\(\s\+\K\k*\)" contains=rexxLabel2
90 syn match rexxLabel2 "\<\(end\|leave\|iterate\)\>\s\+\zs\k*\ze" containedin=endIterateLeaveLabelRegion
93 syn match rexxGuard "\(^\|;\|:\)\s*\<guard\>\s\+\<\(on\|off\)\>"
96 syn match rexxTrace "\(^\|;\|:\)\s*\<trace\>\s\+\<\K\k*\>"
99 syn match rexxRaise "\(^\|;\|:\)\s\+\<raise\>\s*\<\(propagate\|error\|failure\|syntax\|user\)\>\?" contains=rexxRaise2
100 syn match rexxRaise2 "\<\(additional\|array\|description\|exit\|propagate\|return\)\>" containedin=rexxRaise
103 syn match rexxForward "\(^\|;\|:\)\<forward\>\s*" contains=rexxForward2
104 syn match rexxForward2 "\<\(arguments\|array\|continue\|message\|class\|to\)\>" contained
106 " Functions/Procedures
107 syn match rexxFunction "\<\<[a-zA-Z\!\?_]\k*\>("me=e-1
108 syn match rexxFunction "[()]"
111 syn region rexxString start=+"+ skip=+""+ end=+"\(x\|b\)\?+ oneline
112 syn region rexxString start=+'+ skip=+''+ end=+'\(x\|b\)\?+ oneline
114 syn region rexxParen transparent start='(' end=')' contains=ALLBUT,rexxParenError,rexxTodo,rexxLabel,rexxKeyword
115 " Catch errors caused by wrong parenthesis
116 syn match rexxParenError ")"
117 syn match rexxInParen "[\\[\\]{}]"
120 syn region rexxComment start="/\*" end="\*/" contains=rexxTodo,rexxComment
121 syn match rexxCommentError "\*/"
122 syn region rexxLineComment start="--" end="\_$" oneline
124 " Highlight User Labels
125 " check for labels between comments, labels stated in a statement in the middle of a line
126 syn match rexxLabel "\(\_^\|;\)\s*\(\/\*.*\*\/\)*\s*\k\+\s*\(\/\*.*\*\/\)*\s*:"me=e-1 contains=rexxTodo,rexxComment
128 syn keyword rexxTodo contained TODO FIXME XXX
131 syn region rexxMessageOperator start="\(\~\|\~\~\)" end="\(\S\|\s\)"me=e-1
132 syn match rexxMessage "\(\~\|\~\~\)\s*\<\.*[a-zA-Z]\([a-zA-Z0-9._?!]\)*\>" contains=rexxMessageOperator
134 " line continuations, take care of (line-)comments after it
135 syn match rexxLineContinue ",\ze\s*\(--.*\|\/\*.*\)*$"
137 " the following is necessary, otherwise three consecutive dashes will cause it to highlight the first one
138 syn match rexxLineContinue "-\ze-\@!\s*\(--.*\|\s*\/\*.*\)\?$"
141 syn keyword rexxSpecialVariable sigl rc result self super
142 syn keyword rexxSpecialVariable .environment .error .input .local .methods .output .rs .stderr .stdin .stdout .stdque
145 syn keyword rexxConst .true .false .nil .endOfLine .line
147 syn match rexxNumber "\(-\|+\)\?\s*\zs\<\(\d\+\.\?\|\d*\.\d\+\(E\(+\|-\)\d\{2,2}\)\?\)\?\>"
149 " ooRexx builtin classes (as of version 3.2.0, fall 2007), first define dot to be o.k. in keywords
150 syn keyword rexxBuiltinClass .Alarm .ArgUtil .Array .Bag .CaselessColumnComparator
151 syn keyword rexxBuiltinClass .CaselessComparator .CaselessDescendingComparator .CircularQueue
152 syn keyword rexxBuiltinClass .Class .Collection .ColumnComparator .Comparable .Comparator
153 syn keyword rexxBuiltinClass .DateTime .DescendingComparator .Directory .InputOutputStream
154 syn keyword rexxBuiltinClass .InputStream .InvertingComparator .List .MapCollection
155 syn keyword rexxBuiltinClass .Message .Method .Monitor .MutableBuffer .Object
156 syn keyword rexxBuiltinClass .OrderedCollection .OutputStream .Properties .Queue
157 syn keyword rexxBuiltinClass .Relation .RexxQueue .Set .SetCollection .Stem .Stream
158 syn keyword rexxBuiltinClass .StreamSupplier .String .Supplier .Table .TimeSpan
160 " Windows-only classes
161 syn keyword rexxBuiltinClass .AdvancedControls .AnimatedButton .BaseDialog .ButtonControl
162 syn keyword rexxBuiltinClass .CategoryDialog .CheckBox .CheckList .ComboBox .DialogControl
163 syn keyword rexxBuiltinClass .DialogExtensions .DlgArea .DlgAreaU .DynamicDialog
164 syn keyword rexxBuiltinClass .EditControl .InputBox .IntegerBox .ListBox .ListChoice
165 syn keyword rexxBuiltinClass .ListControl .MenuObject .MessageExtensions .MultiInputBox
166 syn keyword rexxBuiltinClass .MultiListChoice .PasswordBox .PlainBaseDialog .PlainUserDialog
167 syn keyword rexxBuiltinClass .ProgressBar .ProgressIndicator .PropertySheet .RadioButton
168 syn keyword rexxBuiltinClass .RcDialog .ResDialog .ScrollBar .SingleSelection .SliderControl
169 syn keyword rexxBuiltinClass .StateIndicator .StaticControl .TabControl .TimedMessage
170 syn keyword rexxBuiltinClass .TreeControl .UserDialog .VirtualKeyCodes .WindowBase
171 syn keyword rexxBuiltinClass .WindowExtensions .WindowObject .WindowsClassesBase .WindowsClipboard
172 syn keyword rexxBuiltinClass .WindowsEventLog .WindowsManager .WindowsProgramManager .WindowsRegistry
174 " ooRexx directives, ---rgf location important, otherwise directives in top of file not matched!
175 syn region rexxClassDirective start="::\s*class\s*"ms=e+1 end="\ze\(\s\|;\|$\)"
176 syn region rexxMethodDirective start="::\s*method\s*"ms=e+1 end="\ze\(\s\|;\|$\)"
177 syn region rexxRequiresDirective start="::\s*requires\s*"ms=e+1 end="\ze\(\s\|;\|$\)"
178 syn region rexxRoutineDirective start="::\s*routine\s*"ms=e+1 end="\ze\(\s\|;\|$\)"
179 syn region rexxAttributeDirective start="::\s*attribute\s*"ms=e+1 end="\ze\(\s\|;\|$\)"
181 syn region rexxDirective start="\(^\|;\)\s*::\s*\w\+" end="\($\|;\)" contains=rexxString,rexxComment,rexxLineComment,rexxClassDirective,rexxMethodDirective,rexxRoutineDirective,rexxRequiresDirective,rexxAttributeDirective keepend
183 syn region rexxVariable start="\zs\<\(\.\)\@!\K\k\+\>\ze\s*\(=\|,\|)\|%\|\]\|\\\||\|&\|+=\|-=\|<\|>\)" end="\(\_$\|.\)"me=e-1
184 syn match rexxVariable "\(=\|,\|)\|%\|\]\|\\\||\|&\|+=\|-=\|<\|>\)\s*\zs\K\k*\ze"
186 " 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
196 " 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
203 hi par1 ctermfg=red guifg=red
204 hi par2 ctermfg=blue guifg=blue
205 hi par3 ctermfg=darkgreen guifg=darkgreen
206 hi par4 ctermfg=darkyellow guifg=darkyellow
207 hi par5 ctermfg=darkgrey guifg=darkgrey
209 " line continuation (trailing comma or single dash)
210 syn sync linecont "\(,\|-\ze-\@!\)\ze\s*\(--.*\|\/\*.*\)*$"
212 " if !exists("rexx_minlines")
213 " let rexx_minlines = 500
215 " exec "syn sync ccomment rexxComment minlines=" . rexx_minlines
217 " always scan from start, PCs are powerful enough for that in 2007 !
218 exec "syn sync fromstart"
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
223 if version >= 508 || !exists("did_rexx_syn_inits")
225 let did_rexx_syn_inits = 1
226 command -nargs=+ HiLink hi link <args>
228 command -nargs=+ HiLink hi def link <args>
231 " make binary and hex strings stand out
232 hi rexxStringConstant term=bold,underline ctermfg=5 cterm=bold guifg=darkMagenta gui=bold
234 HiLink rexxLabel2 Function
235 HiLink doLoopSelectLabelRegion rexxKeyword
236 HiLink endIterateLeaveLabelRegion rexxKeyword
237 HiLink rexxLoopKeywords rexxKeyword " Todo
239 HiLink rexxNumber Normal
240 " HiLink rexxIdentifier DiffChange
242 HiLink rexxRegularCallSignal Statement
243 HiLink rexxExceptionHandling Statement
245 HiLink rexxLabel Function
246 HiLink rexxCharacter Character
247 HiLink rexxParenError rexxError
248 HiLink rexxInParen rexxError
249 HiLink rexxCommentError rexxError
250 HiLink rexxError Error
251 HiLink rexxKeyword Statement
252 HiLink rexxKeywordStatements Statement
254 HiLink rexxFunction Function
255 HiLink rexxString String
256 HiLink rexxComment Comment
258 HiLink rexxSpecialVariable Special
259 HiLink rexxConditional rexxKeyword
261 HiLink rexxOperator Operator
262 HiLink rexxMessageOperator rexxOperator
263 HiLink rexxLineComment Comment
265 HiLink rexxLineContinue WildMenu
267 HiLink rexxDirective rexxKeyword
268 HiLink rexxClassDirective Type
269 HiLink rexxMethodDirective rexxFunction
270 HiLink rexxAttributeDirective rexxFunction
271 HiLink rexxRequiresDirective Include
272 HiLink rexxRoutineDirective rexxFunction
274 HiLink rexxConst Constant
275 HiLink rexxTypeSpecifier Type
276 HiLink rexxBuiltinClass rexxTypeSpecifier
278 HiLink rexxEnvironmentSymbol rexxConst
279 HiLink rexxMessage rexxFunction
281 HiLink rexxParse rexxKeyword
282 HiLink rexxParse2 rexxParse
284 HiLink rexxGuard rexxKeyword
285 HiLink rexxTrace rexxKeyword
287 HiLink rexxRaise rexxKeyword
288 HiLink rexxRaise2 rexxRaise
290 HiLink rexxForward rexxKeyword
291 HiLink rexxForward2 rexxForward
296 let b:current_syntax = "rexx"