blob: 179e453c93abdd0c587a730d5bba46ef0c00a96b [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
7" Rony G. Flatscher <rony.flatscher@wu-wien.ac.at>
Bram Moolenaar071d4272004-06-13 20:20:40 +00008"
Bram Moolenaar4c3f5362006-04-11 21:38:50 +00009" URL: http://www.geulig.de/vim/rexx.vim
10"
11" Special Thanks to Dan Sharp <dwsharp@hotmail.com> and Rony G. Flatscher
12" <Rony.Flatscher@wu-wien.ac.at> for comments and additions
Bram Moolenaar071d4272004-06-13 20:20:40 +000013
14" For version 5.x: Clear all syntax items
15" For version 6.x: Quit when a syntax file was already loaded
16if version < 600
17 syntax clear
18elseif exists("b:current_syntax")
19 finish
20endif
21
22syn case ignore
23
Bram Moolenaar4c3f5362006-04-11 21:38:50 +000024" add to valid identifier chars
25setlocal iskeyword+=.
26setlocal iskeyword+=!
27setlocal iskeyword+=?
28
29" ---rgf, position important: must be before comments etc. !
30syn match rexxOperator "[-=|\/\\\+\*\[\],;<>&\~]"
31
32syn match rexxIdentifier "\<[a-zA-Z\!\?_]\([a-zA-Z0-9._?!]\)*\>"
33syn match rexxEnvironmentSymbol "\<\.\+\([a-zA-Z0-9._?!]\)*\>"
34
35
Bram Moolenaar071d4272004-06-13 20:20:40 +000036" 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.
Bram Moolenaar4c3f5362006-04-11 21:38:50 +000039syn match rexxClause "\(^\|;\|:\|then \|else \|otherwise \)\s*\w\+" contains=ALLBUT,rexxParse2,rexxRaise2
40
Bram Moolenaar071d4272004-06-13 20:20:40 +000041
42" Considered keywords when used together in a phrase and begin a clause
Bram Moolenaar4c3f5362006-04-11 21:38:50 +000043syn match rexxParse "\<parse\s*\(\(upper\|lower\|caseless\)\s*\)\=\(arg\|linein\|pull\|source\|var\|\<value\>\|version\)\>"
44syn match rexxParse2 "\<with\>" contained containedin=rexxParse
45
46
Bram Moolenaar071d4272004-06-13 20:20:40 +000047syn match rexxKeyword contained "\<numeric \(digits\|form \(scientific\|engineering\|value\)\|fuzz\)\>"
48syn match rexxKeyword contained "\<\(address\|trace\)\( value\)\=\>"
Bram Moolenaar4c3f5362006-04-11 21:38:50 +000049syn match rexxKeyword contained "\<procedure\(\s*expose\)\=\>"
50syn match rexxKeyword contained "\<do\>\(\s*forever\)\=\>"
51syn match rexxKeyword contained "\<use\>\s*\<arg\>"
Bram Moolenaar071d4272004-06-13 20:20:40 +000052
53" Another keyword phrase, separated to aid highlighting in rexxFunction
Bram Moolenaar4c3f5362006-04-11 21:38:50 +000054syn match rexxKeyword contained "\<signal\(\s*\(on\|off\)\s*\(any\|error\|failure\|halt\|lostdigits\|nomethod\|nostring\|notready\|novalue\|syntax\|user\s*\k*\)\(\s\+name\)\=\)\=\>"
55syn match rexxKeyword2 contained "\<call\(\s*\(on\|off\)\s*\(any\|error\|failure\|halt\|notready\|user\s*\k*\)\(\s\+name\)\=\)\=\>"
56
Bram Moolenaar071d4272004-06-13 20:20:40 +000057
58" Considered keywords when they begin a clause
Bram Moolenaar4c3f5362006-04-11 21:38:50 +000059syn match rexxKeyword contained "\<\(arg\|do\|drop\|end\|exit\|expose\|forward\|if\|interpret\|iterate\|leave\|nop\)\>"
60syn match rexxKeyword contained "\<\(options\|pull\|push\|queue\|raise\|reply\|return\|say\|select\|trace\)\>"
Bram Moolenaar071d4272004-06-13 20:20:40 +000061
62" Conditional phrases
Bram Moolenaar4c3f5362006-04-11 21:38:50 +000063syn match rexxConditional "\(^\s*\| \)\(to\|by\|for\|until\|while\|then\|when\|otherwise\|else\|over\)\( \|\s*$\)"
64syn match rexxConditional contained "\<\(to\|by\|for\|until\|while\|then\|when\|otherwise\|else\|over\)\>"
Bram Moolenaar071d4272004-06-13 20:20:40 +000065
Bram Moolenaar4c3f5362006-04-11 21:38:50 +000066" must be after Conditional phrases!
67syn match rexxKeyword ".*\<\(then\|else\)\s*\<do\>"
68
69" Raise statement
70syn match rexxRaise "\(^\|;\|:\)\s\+\<raise\>\s*\<\(propagate\|error\|failure\|syntax\|user\)\>\="
71syn match rexxRaise2 "\<\(additional\|array\|description\|exit\|return\)\>" contained containedin=rexxRaise
72
73" Forward statement keywords
74syn match rexxForward "\(^\|;\|:\)\<forward\>\s*"
75syn match rexxForward2 "\<\(arguments\|array\|continue\|message\|class\|to\)\>" contained containedin=rexxForward
Bram Moolenaar071d4272004-06-13 20:20:40 +000076
77" Functions/Procedures
Bram Moolenaar4c3f5362006-04-11 21:38:50 +000078syn match rexxFunction "\<\w*\(/\*\s*\*/\)*("me=e-1 contains=rexxComment,rexxConditional,rexxKeyword,rexxIdentifier
79syn match rexxFunction "\<\<[a-zA-Z\!\?_]\([a-zA-Z0-9._?!]\)*\>("me=e-1
80syn match rexxFunction "\<call\s\+\k\+\>" contains=rexxKeyword2
81syn match rexxFunction "[()]"
Bram Moolenaar071d4272004-06-13 20:20:40 +000082
83" String constants
Bram Moolenaar4c3f5362006-04-11 21:38:50 +000084syn region rexxString start=+"+ skip=+""+ end=+"\(x\|b\)\=+ oneline
85syn region rexxString start=+'+ skip=+''+ end=+'\(x\|b\)\=+ oneline
Bram Moolenaar071d4272004-06-13 20:20:40 +000086
87" Catch errors caused by wrong parenthesis
Bram Moolenaar4c3f5362006-04-11 21:38:50 +000088syn region rexxParen transparent start='(' end=')' contains=ALLBUT,rexxParenError,rexxTodo,rexxLabel,rexxKeyword
Bram Moolenaar071d4272004-06-13 20:20:40 +000089syn match rexxParenError ")"
90syn match rexxInParen "[\\[\\]{}]"
91
92" Comments
93syn region rexxComment start="/\*" end="\*/" contains=rexxTodo,rexxComment
94syn match rexxCommentError "\*/"
Bram Moolenaar4c3f5362006-04-11 21:38:50 +000095syn match rexxLineComment /--.*/
Bram Moolenaar071d4272004-06-13 20:20:40 +000096
97syn keyword rexxTodo contained TODO FIXME XXX
98
Bram Moolenaar4c3f5362006-04-11 21:38:50 +000099
100" ooRexx messages
101syn region rexxMessageOperator start="\(\~\|\~\~\)" end="\(\S\|\s\)"me=e-1
102syn match rexxMessage "\(\~\|\~\~\)\s*\<\.*[a-zA-Z]\([a-zA-Z0-9._?!]\)*\>" contains=rexxMessageOperator
103
Bram Moolenaar071d4272004-06-13 20:20:40 +0000104" Highlight User Labels
Bram Moolenaar4c3f5362006-04-11 21:38:50 +0000105syn match rexxLabel "^\s*\k*\s*:"me=e-1
106
107syn match rexxLineContinue ",\ze\s*\(--.*\|\/\*.*\)*$"
108" the following is necessary, otherwise three consecutive dashes will cause it to highlight the first one
109syn match rexxLineContinue "-\ze\(\s+--.*\|\s*\/\*.*\)*$"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000110
111" Special Variables
Bram Moolenaar4c3f5362006-04-11 21:38:50 +0000112syn keyword rexxSpecialVariable sigl rc result self super
113
114" Constants
115syn keyword rexxConst .true .false .nil
116
117" ooRexx builtin classes, first define dot to be o.k. in keywords
118syn keyword rexxBuiltinClass .object .class .method .message
119syn keyword rexxBuiltinClass .monitor .alarm
120syn keyword rexxBuiltinClass .stem .stream .string
121syn keyword rexxBuiltinClass .mutablebuffer
122syn keyword rexxBuiltinClass .array .list .queue .directory .table .set
123syn keyword rexxBuiltinClass .relation .bag .supplier .regularExpressions
124
125" Windows-only classes
126syn keyword rexxBuiltinClass .OLEObject .MenuObject .WindowsClipboard .WindowsEventLog
127syn keyword rexxBuiltinClass .WindowsManager .WindowObject .WindowsProgramManager
128
129
130" ooRexx directives, ---rgf location important, otherwise directives in top of
131" file not matched!
132syn region rexxClass start="::\s*class\s*"ms=e+1 end="\ze\(\s\|;\|$\)"
133syn region rexxMethod start="::\s*method\s*"ms=e+1 end="\ze\(\s\|;\|$\)"
134syn region rexxRequires start="::\s*requires\s*"ms=e+1 end="\ze\(\s\|;\|$\)"
135syn region rexxRoutine start="::\s*routine\s*"ms=e+1 end="\ze\(\s\|;\|$\)"
136
137syn region rexxDirective start="\(^\|;\)\s*::\s*\w\+" end="\($\|;\)" contains=rexxString,rexxComment,rexxLineComment,rexxClass,rexxMethod,rexxRoutine,rexxRequires keepend
138
139
Bram Moolenaar071d4272004-06-13 20:20:40 +0000140
141if !exists("rexx_minlines")
Bram Moolenaar4c3f5362006-04-11 21:38:50 +0000142" let rexx_minlines = 10
143 let rexx_minlines = 500
Bram Moolenaar071d4272004-06-13 20:20:40 +0000144endif
145exec "syn sync ccomment rexxComment minlines=" . rexx_minlines
146
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
150if version >= 508 || !exists("did_rexx_syn_inits")
151 if version < 508
152 let did_rexx_syn_inits = 1
153 command -nargs=+ HiLink hi link <args>
154 else
155 command -nargs=+ HiLink hi def link <args>
156 endif
157
Bram Moolenaar4c3f5362006-04-11 21:38:50 +0000158 HiLink rexxLabel Function
Bram Moolenaar071d4272004-06-13 20:20:40 +0000159 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
169 HiLink rexxTodo Todo
170 HiLink rexxSpecialVariable Special
171 HiLink rexxConditional rexxKeyword
172
Bram Moolenaar4c3f5362006-04-11 21:38:50 +0000173 HiLink rexxOperator Operator
174 HiLink rexxMessageOperator rexxOperator
175 HiLink rexxLineComment RexxComment
176
177 HiLink rexxLineContinue WildMenu
178
179 HiLink rexxDirective rexxKeyword
180 HiLink rexxClass Type
181 HiLink rexxMethod rexxFunction
182 HiLink rexxRequires Include
183 HiLink rexxRoutine rexxFunction
184
185 HiLink rexxConst Constant
186 HiLink rexxTypeSpecifier Type
187 HiLink rexxBuiltinClass rexxTypeSpecifier
188
189 HiLink rexxEnvironmentSymbol rexxConst
190 HiLink rexxMessage rexxFunction
191
192 HiLink rexxParse rexxKeyword
193 HiLink rexxParse2 rexxParse
194
195 HiLink rexxRaise rexxKeyword
196 HiLink rexxRaise2 rexxRaise
197
198 HiLink rexxForward rexxKeyword
199 HiLink rexxForward2 rexxForward
200
Bram Moolenaar071d4272004-06-13 20:20:40 +0000201 delcommand HiLink
202endif
203
204let b:current_syntax = "rexx"
205
206"vim: ts=8