xref: /vim-8.2.3635/runtime/syntax/rexx.vim (revision 00a927d6)
1" Vim syntax file
2" Language:	Rexx
3" Maintainer:	Thomas Geulig <[email protected]>
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 <[email protected]>
9"
10" URL:		http://www.geulig.de/vim/rexx.vim
11"
12" Special Thanks to Dan Sharp <[email protected]> and Rony G. Flatscher
13" <[email protected]> for comments and additions
14
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
25" add to valid identifier chars
26setlocal iskeyword+=.
27setlocal iskeyword+=!
28setlocal iskeyword+=?
29
30" ---rgf, position important: must be before comments etc. !
31syn match rexxOperator "[=|\/\\\+\*\[\],;:<>&\~%\-]"
32
33" rgf syn match rexxIdentifier        "\<[a-zA-Z\!\?_]\([a-zA-Z0-9._?!]\)*\>"
34syn match rexxIdentifier        "\<\K\k*\>"
35syn match rexxEnvironmentSymbol "\<\.\k\+\>"
36
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.
40syn match rexxClause "\(^\|;\|:\|then \|else \|when \|otherwise \)\s*\S*" contains=ALLBUT,rexxParse2,rexxRaise2,rexxForward2
41
42" Considered keywords when used together in a phrase and begin a clause
43syn 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
45
46syn match rexxKeyword contained "\<numeric \(digits\|form \(scientific\|engineering\|value\)\|fuzz\)\>"
47syn 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\>"
52
53" Another keyword phrase, separated to aid highlighting in rexxFunction
54syn 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
56
57syn 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
65
66" Considered keywords when they begin a clause
67syn 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
72
73" Conditional phrases
74syn match rexxLoopKeywords "\<\(to\|by\|for\|until\|while\|over\)\>" containedin=doLoopSelectLabelRegion
75
76" must be after Conditional phrases!
77syn 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*\>"
97
98" Raise statement
99syn match rexxRaise "\(^\|;\|:\)\s\+\<raise\>\s*\<\(propagate\|error\|failure\|syntax\|user\)\>\?" contains=rexxRaise2
100syn match rexxRaise2 "\<\(additional\|array\|description\|exit\|propagate\|return\)\>" containedin=rexxRaise
101
102" Forward statement
103syn match rexxForward  "\(^\|;\|:\)\<forward\>\s*" contains=rexxForward2
104syn match rexxForward2 "\<\(arguments\|array\|continue\|message\|class\|to\)\>" contained
105
106" Functions/Procedures
107syn match rexxFunction 	"\<\<[a-zA-Z\!\?_]\k*\>("me=e-1
108syn match rexxFunction "[()]"
109
110" String constants
111syn region rexxString	start=+"+ skip=+""+ end=+"\(x\|b\)\?+ oneline
112syn region rexxString	start=+'+ skip=+''+ end=+'\(x\|b\)\?+ oneline
113
114syn region rexxParen transparent start='(' end=')' contains=ALLBUT,rexxParenError,rexxTodo,rexxLabel,rexxKeyword
115" Catch errors caused by wrong parenthesis
116syn match rexxParenError	 ")"
117syn match rexxInParen		"[\\[\\]{}]"
118
119" Comments
120syn 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
127
128syn keyword rexxTodo contained	TODO FIXME XXX
129
130" 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
134" line continuations, take care of (line-)comments after it
135syn match rexxLineContinue ",\ze\s*\(--.*\|\/\*.*\)*$"
136
137" the following is necessary, otherwise three consecutive dashes will cause it to highlight the first one
138syn match rexxLineContinue "-\ze-\@!\s*\(--.*\|\s*\/\*.*\)\?$"
139
140" Special Variables
141syn keyword rexxSpecialVariable  sigl rc result self super
142syn keyword rexxSpecialVariable  .environment .error .input .local .methods .output .rs .stderr .stdin .stdout .stdque
143
144" Constants
145syn keyword rexxConst .true .false .nil .endOfLine .line
146
147syn 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
159
160" Windows-only classes
161syn 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
173
174" 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\|;\|$\)"
180
181syn region rexxDirective start="\(^\|;\)\s*::\s*\w\+"  end="\($\|;\)" contains=rexxString,rexxComment,rexxLineComment,rexxClassDirective,rexxMethodDirective,rexxRoutineDirective,rexxRequiresDirective,rexxAttributeDirective keepend
182
183syn region rexxVariable start="\zs\<\(\.\)\@!\K\k\+\>\ze\s*\(=\|,\|)\|%\|\]\|\\\||\|&\|+=\|-=\|<\|>\)" end="\(\_$\|.\)"me=e-1
184syn match rexxVariable "\(=\|,\|)\|%\|\]\|\\\||\|&\|+=\|-=\|<\|>\)\s*\zs\K\k*\ze"
185
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
195
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
202
203hi 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"
219
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
231  " 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
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
253
254  HiLink rexxFunction		Function
255  HiLink rexxString		String
256  HiLink rexxComment		Comment
257  HiLink rexxTodo		Todo
258  HiLink rexxSpecialVariable	Special
259  HiLink rexxConditional	rexxKeyword
260
261  HiLink rexxOperator		Operator
262  HiLink rexxMessageOperator	rexxOperator
263  HiLink rexxLineComment	Comment
264
265  HiLink rexxLineContinue	WildMenu
266
267  HiLink rexxDirective		rexxKeyword
268  HiLink rexxClassDirective	Type
269  HiLink rexxMethodDirective	rexxFunction
270  HiLink rexxAttributeDirective	rexxFunction
271  HiLink rexxRequiresDirective	Include
272  HiLink rexxRoutineDirective	rexxFunction
273
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
284  HiLink rexxGuard              rexxKeyword
285  HiLink rexxTrace              rexxKeyword
286
287  HiLink rexxRaise              rexxKeyword
288  HiLink rexxRaise2             rexxRaise
289
290  HiLink rexxForward            rexxKeyword
291  HiLink rexxForward2           rexxForward
292
293  delcommand HiLink
294endif
295
296let b:current_syntax = "rexx"
297
298"vim: ts=8
299