3 " Maintainer: Alex Chapman <chapman.alex@gmail.com>
4 " Last Change: 2008 Apr 28
6 " For version 5.x: Clear all syntax items
7 " For version 6.x: Quit when a syntax file was already loaded
10 elseif exists("b:current_syntax")
14 " factor is case sensitive.
17 " make all of these characters part of a word (useful for skipping over words with w, e, and b)
19 setlocal iskeyword=!,@,33-35,%,$,38-64,A-Z,91-96,a-z,123-126,128-255
21 set iskeyword=!,@,33-35,%,$,38-64,A-Z,91-96,a-z,123-126,128-255
24 syn cluster factorCluster contains=factorComment,factorKeyword,factorRepeat,factorConditional,factorBoolean,factorCompileDirective,factorString,factorSbuf,@factorNumber,@factorNumErr,factorDelimiter,factorChar,factorCharErr,factorBackslash,@factorWordOps,factorAlien,factorTuple
26 syn match factorTodo /\(TODO\|FIXME\|XXX\):\=/ contained
27 syn match factorComment /\<#! .*/ contains=factorTodo
28 syn match factorComment /\<! .*/ contains=factorTodo
30 syn cluster factorDefnContents contains=@factorCluster,factorStackEffect,factorArray0,factorQuotation0
32 syn region factorDefn matchgroup=factorDefnDelims start=/\<\(MACRO\|MEMO\|:\)\?:\s\+\S\+\>/ end=/\<;\>/ contains=@factorDefnContents
33 syn region factorMethod matchgroup=factorMethodDelims start=/\<M:\s\+\S\+\s\+\S\+\>/ end=/\<;\>/ contains=@factorDefnContents
34 syn region factorGeneric matchgroup=factorGenericDelims start=/\<GENERIC:\s\+\S\+\>/ end=/$/ contains=factorStackEffect
35 syn region factorGenericN matchgroup=factorGenericNDelims start=/\<GENERIC#\s\+\S\+\s\+\d\+\>/ end=/$/ contains=factorStackEffect
37 syn region factorPrivateDefn matchgroup=factorPrivateDefnDelims start=/\<\(MACRO\|MEMO\|:\)\?:\s\+\S\+\>/ end=/\<;\>/ contains=@factorDefnContents contained
38 syn region factorPrivateMethod matchgroup=factorPrivateMethodDelims start=/\<M:\s\+\S\+\s\+\S\+\>/ end=/\<;\>/ contains=@factorDefnContents contained
39 syn region factorPGeneric matchgroup=factorPGenericDelims start=/\<GENERIC:\s\+\S\+\>/ end=/$/ contains=factorStackEffect contained
40 syn region factorPGenericN matchgroup=factorPGenericNDelims start=/\<GENERIC#\s\+\S\+\s\+\d\+\>/ end=/$/ contains=factorStackEffect
42 syn region None matchgroup=factorPrivate start=/\<<PRIVATE\>/ end=/\<PRIVATE>\>/ contains=@factorDefnContents,factorPrivateDefn,factorPrivateMethod,factorPGeneric,factorPGenericN
45 syn keyword factorBoolean boolean f general-t t
46 syn keyword factorCompileDirective inline foldable parsing
50 " kernel vocab keywords
51 syn keyword factorKeyword or construct-delegate set-slots tuck 2bi 2tri while wrapper nip bi* wrapper? hashcode callstack>array both? die set-delegate dupd callstack callstack? 3dup tri@ pick curry build prepose 3bi >boolean ?if clone eq? tri* ? = swapd call-clear 2over 2keep 3keep construct clear 2dup when not tuple? 3compose dup 2bi* call object bi@ wrapped unless* if* >r curry-quot drop when* retainstack -rot 2bi@ delegate boa with 3slip slip compose-first compose-second 3drop either? bi curry? datastack curry-obj over 3curry roll throw swap and 2nip set-retainstack (clone) hashcode* get-slots compose spin if 3tri unless compose? tuple keep 2curry equal? set-datastack 2slip tri 2drop most <wrapper> identity-tuple? null r> new set-callstack dip xor rot -roll identity-tuple
52 syn keyword factorKeyword assoc? assoc-clone-like delete-any assoc= delete-at* new-assoc subassoc? assoc-size map>assoc search-alist assoc-like key? assoc-intersect update assoc-union at* assoc-empty? at+ set-enum-seq set-at assoc-all? assoc-hashcode change-at assoc-each assoc-diff zip values value-at rename-at (assoc-stack) enum? at cache assoc>map assoc-any? <enum> assoc assoc-map assoc-pusher (assoc>map) enum assoc-push-if remove-all >alist (substitute) substitute-here clear-assoc assoc-stack substitute assoc-filter delete-at assoc-find enum-seq keys
53 syn keyword factorKeyword case dispatch-case-quot with-datastack <buckets> no-cond no-case? 3cleave>quot (distribute-buckets) contiguous-range? 2cleave cond>quot no-cond? cleave>quot no-case recursive-hashcode case>quot 3cleave alist>quot dispatch-case hash-case-table hash-case-quot case-find cond cleave distribute-buckets 2cleave>quot linear-case-quot spread spread>quot hash-dispatch-quot
54 syn keyword factorKeyword byte-array>bignum sgn >bignum number= each-integer next-power-of-2 ?1+ imaginary-part mod recip float>bits rational >float number? 2^ bignum? integer fixnum? neg fixnum sq bignum (all-integers?) times denominator find-last-integer (each-integer) bit? * + power-of-2? - / >= bitand find-integer complex < real > log2 integer? number bits>double double>bits bitor 2/ zero? rem all-integers? (find-integer) real-part align bits>float float? shift float 1+ 1- fp-nan? ratio? bitxor even? ratio <= /mod >integer odd? rational? bitnot real? >fixnum complex? (next-power-of-2) /i numerator /f
55 syn keyword factorKeyword slice-to append left-trim find-last-from clone-like 3sequence map-as last-index-from reversed index-from pad-left cut* nth sequence slice? <slice> tail-slice empty? tail* find-from member? virtual-sequence? unclip set-length drop-prefix bounds-error? set-slice-seq map start open-slice midpoint@ set-immutable-seq move-forward rest-slice prepend fourth delete set-slice-to new-sequence follow all-eq? monotonic? set-reversed-seq like delete-nth first4 repetition-len (open-slice) reverse slice padding virtual@ repetition? index 4sequence max-length set-second first2 first3 (3append) supremum unclip-slice move-backward tail 3append sequence-hashcode-step right-trim reversed-seq pad-right suffix concat set-slice-from flip filter sum immutable? 2sequence delete-all start* immutable-sequence? (append) check-slice sequence? head set-slice-error-reason reduce set-bounds-error-index reverse-here sequence= halves collapse-slice interleave 2map binary-reduce virtual-seq slice-error? product bounds-check? bounds-check immutable find remove ((append)) set-fourth peek any? reversed? shorter? push-new find-last head-slice pop* immutable-seq tail-slice* accumulate each pusher all-equal? new-resizable cut-slice head-slice* 2reverse-each pop memq? set-nth ?nth <flat-slice> second change-each join set-repetition-len <reversed> all? virtual-sequence set-repetition-elt subseq? immutable-sequence slice-error-reason new-like length last-index push-if 2all? lengthen joined-length copy set-bounds-error-seq cache-nth move third first slice-from repetition-elt tail? set-first prefix bounds-error bounds-error-seq bounds-error-index <repetition> unfold exchange slice-seq cut 2reduce change-nth min-length set-third (delete) push-all head? delete-slice rest sum-lengths 2each head* infimum sequence-hashcode slice-error subseq replace-slice repetition push trim mismatch
56 syn keyword factorKeyword global +@ set-namestack with-variable on set bind dec namestack get get-global change init-namespaces with-scope off set-global namespace % make , inc counter building make-assoc
57 syn keyword factorKeyword <array> 3array >array 4array pair? array pair 2array 1array resize-array array?
58 syn keyword factorKeyword readln stream-read-until stream-read-partial stderr with-stream read with-stream* print contents make-span-stream write1 stream-write1 stream-format make-block-stream stream-copy with-cell stream-write format with-row stream-print stream-read with-nesting (stream-copy) bl write-object nl stream-nl write stdio flush read-until tabular-output make-cell-stream write-cell stream-flush read1 lines stream-read1 stream-write-table with-style stream-readln
59 syn keyword factorKeyword resize-string >string <string> 1string string string?
60 syn keyword factorKeyword vector? <vector> ?push vector >vector 1vector
61 syn keyword factorKeyword rethrow-restarts restarts recover set-restart-name set-continuation-name condition-continuation <restart> ifcc continuation-name condition-error set-restart-continuation ignore-errors continuation-retain continue <continuation> restart-continuation with-disposal set-continuation-catch set-condition-error restart-obj error thread-error-hook set-continuation-retain continuation rethrow callcc1 callcc0 condition continuation? continuation-call continuation-data set-condition-restarts set-catchstack >continuation< error-continuation cleanup restart? compute-restarts condition? error-thread set-continuation-call set-condition-continuation <condition> set-restart-obj dispose set-continuation-data throw-restarts catchstack continue-with attempt-all restart restart-name continuation-catch condition-restarts
64 syn cluster factorReal contains=factorInt,factorFloat,factorRatio,factorBinary,factorHex,factorOctal
65 syn cluster factorNumber contains=@factorReal,factorComplex
66 syn cluster factorNumErr contains=factorBinErr,factorHexErr,factorOctErr
67 syn match factorInt /\<-\=\d\+\>/
68 syn match factorFloat /\<-\=\d*\.\d\+\>/
69 syn match factorRatio /\<-\=\d*\.*\d\+\/-\=\d*\.*\d\+\>/
70 syn region factorComplex start=/\<C{\>/ end=/\<}\>/ contains=@factorReal
71 syn match factorBinErr /\<BIN:\s\+[01]*[^\s01]\S*\>/
72 syn match factorBinary /\<BIN:\s\+[01]\+\>/
73 syn match factorHexErr /\<HEX:\s\+\x*[^\x\s]\S*\>/
74 syn match factorHex /\<HEX:\s\+\x\+\>/
75 syn match factorOctErr /\<OCT:\s\+\o*[^\o\s]\S*\>/
76 syn match factorOctal /\<OCT:\s\+\o\+\>/
78 syn match factorIn /\<IN:\s\+\S\+\>/
79 syn match factorUse /\<USE:\s\+\S\+\>/
81 syn match factorCharErr /\<CHAR:\s\+\S\+/
82 syn match factorChar /\<CHAR:\s\+\\\=\S\>/
84 syn match factorBackslash /\<\\\>\s\+\S\+\>/
86 syn region factorUsing start=/\<USING:\>/ end=/;/
87 syn region factorRequires start=/\<REQUIRES:\>/ end=/;/
89 syn cluster factorWordOps contains=factorSymbol,factorPostpone,factorDefer,factorForget,factorMixin,factorInstance,factorHook,factorMain,factorConstructor
90 syn match factorSymbol /\<SYMBOL:\s\+\S\+\>/
91 syn match factorPostpone /\<POSTPONE:\s\+\S\+\>/
92 syn match factorDefer /\<DEFER:\s\+\S\+\>/
93 syn match factorForget /\<FORGET:\s\+\S\+\>/
94 syn match factorMixin /\<MIXIN:\s\+\S\+\>/
95 syn match factorInstance /\<INSTANCE:\s\+\S\+\s\+\S\+\>/
96 syn match factorHook /\<HOOK:\s\+\S\+\s\+\S\+\>/
97 syn match factorMain /\<MAIN:\s\+\S\+\>/
98 syn match factorConstructor /\<C:\s\+\S\+\s\+\S\+\>/
100 syn match factorAlien /\<ALIEN:\s\+\d\+\>/
102 syn region factorTuple start=/\<TUPLE:\>/ end=/\<;\>/
122 syn region factorString start=/"/ skip=/\\"/ end=/"/ oneline
123 syn region factorSbuf start=/SBUF" / skip=/\\"/ end=/"/ oneline
125 syn region factorMultiString matchgroup=factorMultiStringDelims start=/\<STRING:\s\+\S\+\>/ end=/^;$/ contains=factorMultiStringContents
126 syn match factorMultiStringContents /.*/ contained
128 "syn match factorStackEffectErr /\<)\>/
129 "syn region factorStackEffectErr start=/\<(\>/ end=/\<)\>/
130 syn region factorStackEffect start=/\<(\>/ end=/\<)\>/ contained
132 "adapted from lisp.vim
133 if exists("g:factor_norainbow")
134 syn region factorQuotation0 matchgroup=factorDelimiter start=/\<\'\?\[\>/ matchgroup=factorDelimiter end=/\<\]\>/ contains=ALL
136 syn region factorQuotation0 matchgroup=hlLevel0 start=/\<\'\?\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation1,factorArray1
137 syn region factorQuotation1 contained matchgroup=hlLevel1 start=/\<\'\?\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation2,factorArray2
138 syn region factorQuotation2 contained matchgroup=hlLevel2 start=/\<\'\?\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation3,factorArray3
139 syn region factorQuotation3 contained matchgroup=hlLevel3 start=/\<\'\?\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation4,factorArray4
140 syn region factorQuotation4 contained matchgroup=hlLevel4 start=/\<\'\?\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation5,factorArray5
141 syn region factorQuotation5 contained matchgroup=hlLevel5 start=/\<\'\?\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation6,factorArray6
142 syn region factorQuotation6 contained matchgroup=hlLevel6 start=/\<\'\?\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation7,factorArray7
143 syn region factorQuotation7 contained matchgroup=hlLevel7 start=/\<\'\?\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation8,factorArray8
144 syn region factorQuotation8 contained matchgroup=hlLevel8 start=/\<\'\?\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation9,factorArray9
145 syn region factorQuotation9 contained matchgroup=hlLevel9 start=/\<\'\?\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation0,factorArray0
148 if exists("g:factor_norainbow")
149 syn region factorArray matchgroup=factorDelimiter start=/\<\(V\|H\|T\|W\|F\|B\)\?{\>/ matchgroup=factorDelimiter end=/\<}\>/ contains=ALL
151 syn region factorArray0 matchgroup=hlLevel0 start=/\<\(V\|H\|T\|W\|F\|B\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray1,factorQuotation1
152 syn region factorArray1 contained matchgroup=hlLevel1 start=/\<\(V\|H\|T\|W\|F\|B\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray2,factorQuotation2
153 syn region factorArray2 contained matchgroup=hlLevel2 start=/\<\(V\|H\|T\|W\|F\|B\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray3,factorQuotation3
154 syn region factorArray3 contained matchgroup=hlLevel3 start=/\<\(V\|H\|T\|W\|F\|B\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray4,factorQuotation4
155 syn region factorArray4 contained matchgroup=hlLevel4 start=/\<\(V\|H\|T\|W\|F\|B\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray5,factorQuotation5
156 syn region factorArray5 contained matchgroup=hlLevel5 start=/\<\(V\|H\|T\|W\|F\|B\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray6,factorQuotation6
157 syn region factorArray6 contained matchgroup=hlLevel6 start=/\<\(V\|H\|T\|W\|F\|B\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray7,factorQuotation7
158 syn region factorArray7 contained matchgroup=hlLevel7 start=/\<\(V\|H\|T\|W\|F\|B\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray8,factorQuotation8
159 syn region factorArray8 contained matchgroup=hlLevel8 start=/\<\(V\|H\|T\|W\|F\|B\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray9,factorQuotation9
160 syn region factorArray9 contained matchgroup=hlLevel9 start=/\<\(V\|H\|T\|W\|F\|B\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray0,factorQuotation0
163 syn match factorBracketErr /\<\]\>/
164 syn match factorBracketErr /\<}\>/
168 if version >= 508 || !exists("did_factor_syn_inits")
170 let did_factor_syn_inits = 1
171 command -nargs=+ HiLink hi link <args>
173 command -nargs=+ HiLink hi def link <args>
176 HiLink factorComment Comment
177 HiLink factorStackEffect Typedef
178 HiLink factorTodo Todo
179 HiLink factorInclude Include
180 HiLink factorRepeat Repeat
181 HiLink factorConditional Conditional
182 HiLink factorKeyword Keyword
183 HiLink factorOperator Operator
184 HiLink factorBoolean Boolean
185 HiLink factorDefnDelims Typedef
186 HiLink factorMethodDelims Typedef
187 HiLink factorGenericDelims Typedef
188 HiLink factorGenericNDelims Typedef
189 HiLink factorConstructor Typedef
190 HiLink factorPrivate Special
191 HiLink factorPrivateDefnDelims Special
192 HiLink factorPrivateMethodDelims Special
193 HiLink factorPGenericDelims Special
194 HiLink factorPGenericNDelims Special
195 HiLink factorString String
196 HiLink factorSbuf String
197 HiLink factorMultiStringContents String
198 HiLink factorMultiStringDelims Typedef
199 HiLink factorBracketErr Error
200 HiLink factorComplex Number
201 HiLink factorRatio Number
202 HiLink factorBinary Number
203 HiLink factorBinErr Error
204 HiLink factorHex Number
205 HiLink factorHexErr Error
206 HiLink factorOctal Number
207 HiLink factorOctErr Error
208 HiLink factorFloat Float
209 HiLink factorInt Number
210 HiLink factorUsing Include
211 HiLink factorUse Include
212 HiLink factorRequires Include
213 HiLink factorIn Define
214 HiLink factorChar Character
215 HiLink factorCharErr Error
216 HiLink factorDelimiter Delimiter
217 HiLink factorBackslash Special
218 HiLink factorCompileDirective Typedef
219 HiLink factorSymbol Define
220 HiLink factorMixin Typedef
221 HiLink factorInstance Typedef
222 HiLink factorHook Typedef
223 HiLink factorMain Define
224 HiLink factorPostpone Define
225 HiLink factorDefer Define
226 HiLink factorForget Define
227 HiLink factorAlien Define
228 HiLink factorTuple Typedef
231 hi hlLevel0 ctermfg=red guifg=red1
232 hi hlLevel1 ctermfg=yellow guifg=orange1
233 hi hlLevel2 ctermfg=green guifg=yellow1
234 hi hlLevel3 ctermfg=cyan guifg=greenyellow
235 hi hlLevel4 ctermfg=magenta guifg=green1
236 hi hlLevel5 ctermfg=red guifg=springgreen1
237 hi hlLevel6 ctermfg=yellow guifg=cyan1
238 hi hlLevel7 ctermfg=green guifg=slateblue1
239 hi hlLevel8 ctermfg=cyan guifg=magenta1
240 hi hlLevel9 ctermfg=magenta guifg=purple1
242 hi hlLevel0 ctermfg=red guifg=red3
243 hi hlLevel1 ctermfg=darkyellow guifg=orangered3
244 hi hlLevel2 ctermfg=darkgreen guifg=orange2
245 hi hlLevel3 ctermfg=blue guifg=yellow3
246 hi hlLevel4 ctermfg=darkmagenta guifg=olivedrab4
247 hi hlLevel5 ctermfg=red guifg=green4
248 hi hlLevel6 ctermfg=darkyellow guifg=paleturquoise3
249 hi hlLevel7 ctermfg=darkgreen guifg=deepskyblue4
250 hi hlLevel8 ctermfg=blue guifg=darkslateblue
251 hi hlLevel9 ctermfg=darkmagenta guifg=darkviolet
257 let b:current_syntax = "factor"
262 set autoindent " annoying?