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 " Rony G. Flatscher <rony.flatscher@wu-wien.ac.at>
9 " URL: http://www.geulig.de/vim/rexx.vim
11 " Special Thanks to Dan Sharp <dwsharp@hotmail.com> and Rony G. Flatscher
12 " <Rony.Flatscher@wu-wien.ac.at> for comments and additions
14 " For version 5.x: Clear all syntax items
15 " For version 6.x: Quit when a syntax file was already loaded
18 elseif exists("b:current_syntax")
24 " add to valid identifier chars
29 " ---rgf, position important: must be before comments etc. !
30 syn match rexxOperator "[-=|\/\\\+\*\[\],;<>&\~]"
32 syn match rexxIdentifier "\<[a-zA-Z\!\?_]\([a-zA-Z0-9._?!]\)*\>"
33 syn match rexxEnvironmentSymbol "\<\.\+\([a-zA-Z0-9._?!]\)*\>"
36 " A Keyword is the first symbol in a clause. A clause begins at the start
37 " of a line or after a semicolon. THEN, ELSE, OTHERWISE, and colons are always
38 " followed by an implied semicolon.
39 syn match rexxClause "\(^\|;\|:\|then \|else \|otherwise \)\s*\w\+" contains=ALLBUT,rexxParse2,rexxRaise2
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\)\>"
44 syn match rexxParse2 "\<with\>" contained containedin=rexxParse
47 syn match rexxKeyword contained "\<numeric \(digits\|form \(scientific\|engineering\|value\)\|fuzz\)\>"
48 syn match rexxKeyword contained "\<\(address\|trace\)\( value\)\=\>"
49 syn match rexxKeyword contained "\<procedure\(\s*expose\)\=\>"
50 syn match rexxKeyword contained "\<do\>\(\s*forever\)\=\>"
51 syn match rexxKeyword contained "\<use\>\s*\<arg\>"
53 " Another keyword phrase, separated to aid highlighting in rexxFunction
54 syn match rexxKeyword contained "\<signal\(\s*\(on\|off\)\s*\(any\|error\|failure\|halt\|lostdigits\|nomethod\|nostring\|notready\|novalue\|syntax\|user\s*\k*\)\(\s\+name\)\=\)\=\>"
55 syn match rexxKeyword2 contained "\<call\(\s*\(on\|off\)\s*\(any\|error\|failure\|halt\|notready\|user\s*\k*\)\(\s\+name\)\=\)\=\>"
58 " Considered keywords when they begin a clause
59 syn match rexxKeyword contained "\<\(arg\|do\|drop\|end\|exit\|expose\|forward\|if\|interpret\|iterate\|leave\|nop\)\>"
60 syn match rexxKeyword contained "\<\(options\|pull\|push\|queue\|raise\|reply\|return\|say\|select\|trace\)\>"
63 syn match rexxConditional "\(^\s*\| \)\(to\|by\|for\|until\|while\|then\|when\|otherwise\|else\|over\)\( \|\s*$\)"
64 syn match rexxConditional contained "\<\(to\|by\|for\|until\|while\|then\|when\|otherwise\|else\|over\)\>"
66 " must be after Conditional phrases!
67 syn match rexxKeyword ".*\<\(then\|else\)\s*\<do\>"
70 syn match rexxRaise "\(^\|;\|:\)\s\+\<raise\>\s*\<\(propagate\|error\|failure\|syntax\|user\)\>\="
71 syn match rexxRaise2 "\<\(additional\|array\|description\|exit\|return\)\>" contained containedin=rexxRaise
73 " Forward statement keywords
74 syn match rexxForward "\(^\|;\|:\)\<forward\>\s*"
75 syn match rexxForward2 "\<\(arguments\|array\|continue\|message\|class\|to\)\>" contained containedin=rexxForward
77 " Functions/Procedures
78 syn match rexxFunction "\<\w*\(/\*\s*\*/\)*("me=e-1 contains=rexxComment,rexxConditional,rexxKeyword,rexxIdentifier
79 syn match rexxFunction "\<\<[a-zA-Z\!\?_]\([a-zA-Z0-9._?!]\)*\>("me=e-1
80 syn match rexxFunction "\<call\s\+\k\+\>" contains=rexxKeyword2
81 syn match rexxFunction "[()]"
84 syn region rexxString start=+"+ skip=+""+ end=+"\(x\|b\)\=+ oneline
85 syn region rexxString start=+'+ skip=+''+ end=+'\(x\|b\)\=+ oneline
87 " Catch errors caused by wrong parenthesis
88 syn region rexxParen transparent start='(' end=')' contains=ALLBUT,rexxParenError,rexxTodo,rexxLabel,rexxKeyword
89 syn match rexxParenError ")"
90 syn match rexxInParen "[\\[\\]{}]"
93 syn region rexxComment start="/\*" end="\*/" contains=rexxTodo,rexxComment
94 syn match rexxCommentError "\*/"
95 syn match rexxLineComment /--.*/
97 syn keyword rexxTodo contained TODO FIXME XXX
101 syn region rexxMessageOperator start="\(\~\|\~\~\)" end="\(\S\|\s\)"me=e-1
102 syn match rexxMessage "\(\~\|\~\~\)\s*\<\.*[a-zA-Z]\([a-zA-Z0-9._?!]\)*\>" contains=rexxMessageOperator
104 " Highlight User Labels
105 syn match rexxLabel "^\s*\k*\s*:"me=e-1
107 syn match rexxLineContinue ",\ze\s*\(--.*\|\/\*.*\)*$"
108 " the following is necessary, otherwise three consecutive dashes will cause it to highlight the first one
109 syn match rexxLineContinue "-\ze\(\s+--.*\|\s*\/\*.*\)*$"
112 syn keyword rexxSpecialVariable sigl rc result self super
115 syn keyword rexxConst .true .false .nil
117 " ooRexx builtin classes, first define dot to be o.k. in keywords
118 syn keyword rexxBuiltinClass .object .class .method .message
119 syn keyword rexxBuiltinClass .monitor .alarm
120 syn keyword rexxBuiltinClass .stem .stream .string
121 syn keyword rexxBuiltinClass .mutablebuffer
122 syn keyword rexxBuiltinClass .array .list .queue .directory .table .set
123 syn keyword rexxBuiltinClass .relation .bag .supplier .regularExpressions
125 " Windows-only classes
126 syn keyword rexxBuiltinClass .OLEObject .MenuObject .WindowsClipboard .WindowsEventLog
127 syn keyword rexxBuiltinClass .WindowsManager .WindowObject .WindowsProgramManager
130 " ooRexx directives, ---rgf location important, otherwise directives in top of
132 syn region rexxClass start="::\s*class\s*"ms=e+1 end="\ze\(\s\|;\|$\)"
133 syn region rexxMethod start="::\s*method\s*"ms=e+1 end="\ze\(\s\|;\|$\)"
134 syn region rexxRequires start="::\s*requires\s*"ms=e+1 end="\ze\(\s\|;\|$\)"
135 syn region rexxRoutine start="::\s*routine\s*"ms=e+1 end="\ze\(\s\|;\|$\)"
137 syn region rexxDirective start="\(^\|;\)\s*::\s*\w\+" end="\($\|;\)" contains=rexxString,rexxComment,rexxLineComment,rexxClass,rexxMethod,rexxRoutine,rexxRequires keepend
141 if !exists("rexx_minlines")
142 " let rexx_minlines = 10
143 let rexx_minlines = 500
145 exec "syn sync ccomment rexxComment minlines=" . rexx_minlines
147 " Define the default highlighting.
148 " For version 5.7 and earlier: only when not done already
149 " For version 5.8 and later: only when an item doesn't have highlighting yet
150 if version >= 508 || !exists("did_rexx_syn_inits")
152 let did_rexx_syn_inits = 1
153 command -nargs=+ HiLink hi link <args>
155 command -nargs=+ HiLink hi def link <args>
158 HiLink rexxLabel Function
159 HiLink rexxCharacter Character
160 HiLink rexxParenError rexxError
161 HiLink rexxInParen rexxError
162 HiLink rexxCommentError rexxError
163 HiLink rexxError Error
164 HiLink rexxKeyword Statement
165 HiLink rexxKeyword2 rexxKeyword
166 HiLink rexxFunction Function
167 HiLink rexxString String
168 HiLink rexxComment Comment
170 HiLink rexxSpecialVariable Special
171 HiLink rexxConditional rexxKeyword
173 HiLink rexxOperator Operator
174 HiLink rexxMessageOperator rexxOperator
175 HiLink rexxLineComment RexxComment
177 HiLink rexxLineContinue WildMenu
179 HiLink rexxDirective rexxKeyword
180 HiLink rexxClass Type
181 HiLink rexxMethod rexxFunction
182 HiLink rexxRequires Include
183 HiLink rexxRoutine rexxFunction
185 HiLink rexxConst Constant
186 HiLink rexxTypeSpecifier Type
187 HiLink rexxBuiltinClass rexxTypeSpecifier
189 HiLink rexxEnvironmentSymbol rexxConst
190 HiLink rexxMessage rexxFunction
192 HiLink rexxParse rexxKeyword
193 HiLink rexxParse2 rexxParse
195 HiLink rexxRaise rexxKeyword
196 HiLink rexxRaise2 rexxRaise
198 HiLink rexxForward rexxKeyword
199 HiLink rexxForward2 rexxForward
204 let b:current_syntax = "rexx"