3 " Maintainer: Mike Williams <mrw@netcomuk.co.uk>
5 " Last Change: 2001 May 09
10 " For version 5.x: Clear all syntax items
11 " For version 6.x: Quit when a syntax file was already loaded
14 elseif exists("b:current_syntax")
18 " Rebol is case insensitive
21 " As per current users documentation
23 set isk=@,48-57,?,!,.,',+,-,*,&,\|,=,_,~
25 setlocal isk=@,48-57,?,!,.,',+,-,*,&,\|,=,_,~
28 " Yer TODO highlighter
29 syn keyword rebolTodo contained TODO
32 syn match rebolComment ";.*$" contains=rebolTodo
35 syn match rebolWord "\a\k*"
36 syn match rebolWordPath "[^[:space:]]/[^[:space]]"ms=s+1,me=e-1
39 syn keyword rebolBoolean true false on off yes no
43 syn match rebolInteger "\<[+-]\=\d\+\('\d*\)*\>"
45 syn match rebolDecimal "[+-]\=\(\d\+\('\d*\)*\)\=[,.]\d*\(e[+-]\=\d\+\)\="
46 syn match rebolDecimal "[+-]\=\d\+\('\d*\)*\(e[+-]\=\d\+\)\="
48 syn match rebolTime "[+-]\=\(\d\+\('\d*\)*\:\)\{1,2}\d\+\('\d*\)*\([.,]\d\+\)\=\([AP]M\)\=\>"
49 syn match rebolTime "[+-]\=:\d\+\([.,]\d*\)\=\([AP]M\)\=\>"
51 " DD-MMM-YY & YYYY format
52 syn match rebolDate "\d\{1,2}\([/-]\)\(Jan\|Feb\|Mar\|Apr\|May\|Jun\|Jul\|Aug\|Sep\|Oct\|Nov\|Dec\)\1\(\d\{2}\)\{1,2}\>"
53 " DD-month-YY & YYYY format
54 syn match rebolDate "\d\{1,2}\([/-]\)\(January\|February\|March\|April\|May\|June\|July\|August\|September\|October\|November\|December\)\1\(\d\{2}\)\{1,2}\>"
55 " DD-MM-YY & YY format
56 syn match rebolDate "\d\{1,2}\([/-]\)\d\{1,2}\1\(\d\{2}\)\{1,2}\>"
58 syn match rebolDate "\d\{4}-\d\{1,2}-\d\{1,2}\>"
60 syn match rebolDate "\d\{1,2}\.\d\{1,2}\.\d\{4}\>"
62 syn match rebolMoney "\a*\$\d\+\('\d*\)*\([,.]\d\+\)\="
64 syn region rebolString oneline start=+"+ skip=+^"+ end=+"+ contains=rebolSpecialCharacter
65 syn region rebolString start=+[^#]{+ end=+}+ skip=+{[^}]*}+ contains=rebolSpecialCharacter
67 syn region rebolBinary start=+\d*#{+ end=+}+ contains=rebolComment
69 syn match rebolEmail "\<\k\+@\(\k\+\.\)*\k\+\>"
71 syn match rebolFile "%\(\k\+/\)*\k\+[/]\=" contains=rebolSpecialCharacter
72 syn region rebolFile oneline start=+%"+ end=+"+ contains=rebolSpecialCharacter
74 syn match rebolURL "http://\k\+\(\.\k\+\)*\(:\d\+\)\=\(/\(\k\+/\)*\(\k\+\)\=\)*"
75 syn match rebolURL "file://\k\+\(\.\k\+\)*/\(\k\+/\)*\k\+"
76 syn match rebolURL "ftp://\(\k\+:\k\+@\)\=\k\+\(\.\k\+\)*\(:\d\+\)\=/\(\k\+/\)*\k\+"
77 syn match rebolURL "mailto:\k\+\(\.\k\+\)*@\k\+\(\.\k\+\)*"
79 syn match rebolIssue "#\(\d\+-\)*\d\+"
81 syn match rebolTuple "\(\d\+\.\)\{2,}"
84 syn match rebolSpecialCharacter contained "\^[^[:space:][]"
85 syn match rebolSpecialCharacter contained "%\d\+"
90 syn match rebolMathOperator "\(\*\{1,2}\|+\|-\|/\{1,2}\)"
91 syn keyword rebolMathFunction abs absolute add arccosine arcsine arctangent cosine
92 syn keyword rebolMathFunction divide exp log-10 log-2 log-e max maximum min
93 syn keyword rebolMathFunction minimum multiply negate power random remainder sine
94 syn keyword rebolMathFunction square-root subtract tangent
96 syn keyword rebolBinaryOperator complement and or xor ~
98 syn match rebolLogicOperator "[<>=]=\="
99 syn match rebolLogicOperator "<>"
100 syn keyword rebolLogicOperator not
101 syn keyword rebolLogicFunction all any
102 syn keyword rebolLogicFunction head? tail?
103 syn keyword rebolLogicFunction negative? positive? zero? even? odd?
104 syn keyword rebolLogicFunction binary? block? char? date? decimal? email? empty?
105 syn keyword rebolLogicFunction file? found? function? integer? issue? logic? money?
106 syn keyword rebolLogicFunction native? none? object? paren? path? port? series?
107 syn keyword rebolLogicFunction string? time? tuple? url? word?
108 syn keyword rebolLogicFunction exists? input? same? value?
111 syn keyword rebolType binary! block! char! date! decimal! email! file!
112 syn keyword rebolType function! integer! issue! logic! money! native!
113 syn keyword rebolType none! object! paren! path! port! string! time!
114 syn keyword rebolType tuple! url! word!
115 syn keyword rebolTypeFunction type?
118 syn keyword rebolStatement break catch exit halt reduce return shield
119 syn keyword rebolConditional if else
120 syn keyword rebolRepeat for forall foreach forskip loop repeat while until do
123 syn keyword rebolStatement change clear copy fifth find first format fourth free
124 syn keyword rebolStatement func function head insert last match next parse past
125 syn keyword rebolStatement pick remove second select skip sort tail third trim length?
128 syn keyword rebolStatement alias bind use
131 syn keyword rebolStatement import make make-object rebol info?
134 syn keyword rebolStatement delete echo form format import input load mold prin
135 syn keyword rebolStatement print probe read save secure send write
136 syn keyword rebolOperator size? modified?
139 syn keyword rebolStatement help probe trace
142 syn keyword rebolStatement func function free
145 syn keyword rebolConstant none
148 " Define the default highlighting.
149 " For version 5.7 and earlier: only when not done already
150 " For version 5.8 and later: only when an item doesn't have highlighting yet
151 if version >= 508 || !exists("did_rebol_syntax_inits")
153 let did_rebol_syntax_inits = 1
154 command -nargs=+ HiLink hi link <args>
156 command -nargs=+ HiLink hi def link <args>
159 HiLink rebolTodo Todo
161 HiLink rebolStatement Statement
162 HiLink rebolLabel Label
163 HiLink rebolConditional Conditional
164 HiLink rebolRepeat Repeat
166 HiLink rebolOperator Operator
167 HiLink rebolLogicOperator rebolOperator
168 HiLink rebolLogicFunction rebolLogicOperator
169 HiLink rebolMathOperator rebolOperator
170 HiLink rebolMathFunction rebolMathOperator
171 HiLink rebolBinaryOperator rebolOperator
172 HiLink rebolBinaryFunction rebolBinaryOperator
174 HiLink rebolType Type
175 HiLink rebolTypeFunction rebolOperator
177 HiLink rebolWord Identifier
178 HiLink rebolWordPath rebolWord
179 HiLink rebolFunction Function
181 HiLink rebolCharacter Character
182 HiLink rebolSpecialCharacter SpecialChar
183 HiLink rebolString String
185 HiLink rebolNumber Number
186 HiLink rebolInteger rebolNumber
187 HiLink rebolDecimal rebolNumber
188 HiLink rebolTime rebolNumber
189 HiLink rebolDate rebolNumber
190 HiLink rebolMoney rebolNumber
191 HiLink rebolBinary rebolNumber
192 HiLink rebolEmail rebolString
193 HiLink rebolFile rebolString
194 HiLink rebolURL rebolString
195 HiLink rebolIssue rebolNumber
196 HiLink rebolTuple rebolNumber
197 HiLink rebolFloat Float
198 HiLink rebolBoolean Boolean
200 HiLink rebolConstant Constant
202 HiLink rebolComment Comment
204 HiLink rebolError Error
209 if exists("my_rebol_file")
210 if file_readable(expand(my_rebol_file))
211 execute "source " . my_rebol_file
215 let b:current_syntax = "rebol"