1" Vim syntax file
2" Language:	Rebol
3" Maintainer:	Mike Williams <mrw@eandem.co.uk>
4" Filenames:	*.r
5" Last Change:	27th June 2002
6" URL:		http://www.eandem.co.uk/mrw/vim
7"
8
9" For version 5.x: Clear all syntax items
10" For version 6.x: Quit when a syntax file was already loaded
11if version < 600
12  syntax clear
13elseif exists("b:current_syntax")
14  finish
15endif
16
17" Rebol is case insensitive
18syn case ignore
19
20" As per current users documentation
21if version < 600
22  set isk=@,48-57,?,!,.,',+,-,*,&,\|,=,_,~
23else
24  setlocal isk=@,48-57,?,!,.,',+,-,*,&,\|,=,_,~
25endif
26
27" Yer TODO highlighter
28syn keyword	rebolTodo	contained TODO
29
30" Comments
31syn match       rebolComment    ";.*$" contains=rebolTodo
32
33" Words
34syn match       rebolWord       "\a\k*"
35syn match       rebolWordPath   "[^[:space:]]/[^[:space]]"ms=s+1,me=e-1
36
37" Booleans
38syn keyword     rebolBoolean    true false on off yes no
39
40" Values
41" Integers
42syn match       rebolInteger    "\<[+-]\=\d\+\('\d*\)*\>"
43" Decimals
44syn match       rebolDecimal    "[+-]\=\(\d\+\('\d*\)*\)\=[,.]\d*\(e[+-]\=\d\+\)\="
45syn match       rebolDecimal    "[+-]\=\d\+\('\d*\)*\(e[+-]\=\d\+\)\="
46" Time
47syn match       rebolTime       "[+-]\=\(\d\+\('\d*\)*\:\)\{1,2}\d\+\('\d*\)*\([.,]\d\+\)\=\([AP]M\)\=\>"
48syn match       rebolTime       "[+-]\=:\d\+\([.,]\d*\)\=\([AP]M\)\=\>"
49" Dates
50" DD-MMM-YY & YYYY format
51syn match       rebolDate       "\d\{1,2}\([/-]\)\(Jan\|Feb\|Mar\|Apr\|May\|Jun\|Jul\|Aug\|Sep\|Oct\|Nov\|Dec\)\1\(\d\{2}\)\{1,2}\>"
52" DD-month-YY & YYYY format
53syn match       rebolDate       "\d\{1,2}\([/-]\)\(January\|February\|March\|April\|May\|June\|July\|August\|September\|October\|November\|December\)\1\(\d\{2}\)\{1,2}\>"
54" DD-MM-YY & YY format
55syn match       rebolDate       "\d\{1,2}\([/-]\)\d\{1,2}\1\(\d\{2}\)\{1,2}\>"
56" YYYY-MM-YY format
57syn match       rebolDate       "\d\{4}-\d\{1,2}-\d\{1,2}\>"
58" DD.MM.YYYY format
59syn match       rebolDate       "\d\{1,2}\.\d\{1,2}\.\d\{4}\>"
60" Money
61syn match       rebolMoney      "\a*\$\d\+\('\d*\)*\([,.]\d\+\)\="
62" Strings
63syn region      rebolString     oneline start=+"+ skip=+^"+ end=+"+ contains=rebolSpecialCharacter
64syn region      rebolString     start=+[^#]{+ end=+}+ skip=+{[^}]*}+ contains=rebolSpecialCharacter
65" Binary
66syn region      rebolBinary     start=+\d*#{+ end=+}+ contains=rebolComment
67" Email
68syn match       rebolEmail      "\<\k\+@\(\k\+\.\)*\k\+\>"
69" File
70syn match       rebolFile       "%\(\k\+/\)*\k\+[/]\=" contains=rebolSpecialCharacter
71syn region      rebolFile       oneline start=+%"+ end=+"+ contains=rebolSpecialCharacter
72" URLs
73syn match	rebolURL	"http://\k\+\(\.\k\+\)*\(:\d\+\)\=\(/\(\k\+/\)*\(\k\+\)\=\)*"
74syn match	rebolURL	"file://\k\+\(\.\k\+\)*/\(\k\+/\)*\k\+"
75syn match	rebolURL	"ftp://\(\k\+:\k\+@\)\=\k\+\(\.\k\+\)*\(:\d\+\)\=/\(\k\+/\)*\k\+"
76syn match	rebolURL	"mailto:\k\+\(\.\k\+\)*@\k\+\(\.\k\+\)*"
77" Issues
78syn match	rebolIssue	"#\(\d\+-\)*\d\+"
79" Tuples
80syn match	rebolTuple	"\(\d\+\.\)\{2,}"
81
82" Characters
83syn match       rebolSpecialCharacter contained "\^[^[:space:][]"
84syn match       rebolSpecialCharacter contained "%\d\+"
85
86
87" Operators
88" Math operators
89syn match       rebolMathOperator  "\(\*\{1,2}\|+\|-\|/\{1,2}\)"
90syn keyword     rebolMathFunction  abs absolute add arccosine arcsine arctangent cosine
91syn keyword     rebolMathFunction  divide exp log-10 log-2 log-e max maximum min
92syn keyword     rebolMathFunction  minimum multiply negate power random remainder sine
93syn keyword     rebolMathFunction  square-root subtract tangent
94" Binary operators
95syn keyword     rebolBinaryOperator complement and or xor ~
96" Logic operators
97syn match       rebolLogicOperator "[<>=]=\="
98syn match       rebolLogicOperator "<>"
99syn keyword     rebolLogicOperator not
100syn keyword     rebolLogicFunction all any
101syn keyword     rebolLogicFunction head? tail?
102syn keyword     rebolLogicFunction negative? positive? zero? even? odd?
103syn keyword     rebolLogicFunction binary? block? char? date? decimal? email? empty?
104syn keyword     rebolLogicFunction file? found? function? integer? issue? logic? money?
105syn keyword     rebolLogicFunction native? none? object? paren? path? port? series?
106syn keyword     rebolLogicFunction string? time? tuple? url? word?
107syn keyword     rebolLogicFunction exists? input? same? value?
108
109" Datatypes
110syn keyword     rebolType       binary! block! char! date! decimal! email! file!
111syn keyword     rebolType       function! integer! issue! logic! money! native!
112syn keyword     rebolType       none! object! paren! path! port! string! time!
113syn keyword     rebolType       tuple! url! word!
114syn keyword     rebolTypeFunction type?
115
116" Control statements
117syn keyword     rebolStatement  break catch exit halt reduce return shield
118syn keyword     rebolConditional if else
119syn keyword     rebolRepeat     for forall foreach forskip loop repeat while until do
120
121" Series statements
122syn keyword     rebolStatement  change clear copy fifth find first format fourth free
123syn keyword     rebolStatement  func function head insert last match next parse past
124syn keyword     rebolStatement  pick remove second select skip sort tail third trim length?
125
126" Context
127syn keyword     rebolStatement  alias bind use
128
129" Object
130syn keyword     rebolStatement  import make make-object rebol info?
131
132" I/O statements
133syn keyword     rebolStatement  delete echo form format import input load mold prin
134syn keyword     rebolStatement  print probe read save secure send write
135syn keyword     rebolOperator   size? modified?
136
137" Debug statement
138syn keyword     rebolStatement  help probe trace
139
140" Misc statements
141syn keyword     rebolStatement  func function free
142
143" Constants
144syn keyword     rebolConstant   none
145
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_rebol_syntax_inits")
151  if version < 508
152    let did_rebol_syntax_inits = 1
153    command -nargs=+ HiLink hi link <args>
154  else
155    command -nargs=+ HiLink hi def link <args>
156  endif
157
158  HiLink rebolTodo     Todo
159
160  HiLink rebolStatement Statement
161  HiLink rebolLabel	Label
162  HiLink rebolConditional Conditional
163  HiLink rebolRepeat	Repeat
164
165  HiLink rebolOperator	Operator
166  HiLink rebolLogicOperator rebolOperator
167  HiLink rebolLogicFunction rebolLogicOperator
168  HiLink rebolMathOperator rebolOperator
169  HiLink rebolMathFunction rebolMathOperator
170  HiLink rebolBinaryOperator rebolOperator
171  HiLink rebolBinaryFunction rebolBinaryOperator
172
173  HiLink rebolType     Type
174  HiLink rebolTypeFunction rebolOperator
175
176  HiLink rebolWord     Identifier
177  HiLink rebolWordPath rebolWord
178  HiLink rebolFunction	Function
179
180  HiLink rebolCharacter Character
181  HiLink rebolSpecialCharacter SpecialChar
182  HiLink rebolString	String
183
184  HiLink rebolNumber   Number
185  HiLink rebolInteger  rebolNumber
186  HiLink rebolDecimal  rebolNumber
187  HiLink rebolTime     rebolNumber
188  HiLink rebolDate     rebolNumber
189  HiLink rebolMoney    rebolNumber
190  HiLink rebolBinary   rebolNumber
191  HiLink rebolEmail    rebolString
192  HiLink rebolFile     rebolString
193  HiLink rebolURL      rebolString
194  HiLink rebolIssue    rebolNumber
195  HiLink rebolTuple    rebolNumber
196  HiLink rebolFloat    Float
197  HiLink rebolBoolean  Boolean
198
199  HiLink rebolConstant Constant
200
201  HiLink rebolComment	Comment
202
203  HiLink rebolError	Error
204
205  delcommand HiLink
206endif
207
208if exists("my_rebol_file")
209  if file_readable(expand(my_rebol_file))
210    execute "source " . my_rebol_file
211  endif
212endif
213
214let b:current_syntax = "rebol"
215
216" vim: ts=8
217