]> gitweb.factorcode.org Git - factor.git/blob - misc/vim/syntax/factor.vim
Resolved merge.
[factor.git] / misc / vim / syntax / factor.vim
1 " Vim syntax file
2 " Language: factor
3 " Maintainer: Alex Chapman <chapman.alex@gmail.com>
4 " Last Change: 2009 May 19
5 " To run: USE: html.templates.fhtml "resource:misc/factor.vim.fgen" <fhtml> call-template
6
7 " For version 5.x: Clear all syntax items
8 " For version 6.x: Quit when a syntax file was already loaded
9 if version < 600
10     syntax clear
11 elseif exists("b:current_syntax")
12     finish
13 endif
14
15 " factor is case sensitive.
16 syn case match
17
18 " make all of these characters part of a word (useful for skipping over words with w, e, and b)
19 if version >= 600
20     setlocal iskeyword=!,@,33-35,%,$,38-64,A-Z,91-96,a-z,123-126,128-255
21 else
22     set iskeyword=!,@,33-35,%,$,38-64,A-Z,91-96,a-z,123-126,128-255
23 endif
24
25 syn cluster factorCluster contains=factorComment,factorKeyword,factorRepeat,factorConditional,factorBoolean,factorCompileDirective,factorString,factorSbuf,@factorNumber,@factorNumErr,factorDelimiter,factorChar,factorCharErr,factorBackslash,@factorWordOps,factorAlien,factorTuple
26
27 syn match factorTodo /\(TODO\|FIXME\|XXX\):\=/ contained
28 syn match factorComment /\<#! .*/ contains=factorTodo
29 syn match factorComment /\<! .*/ contains=factorTodo
30
31 syn cluster factorDefnContents contains=@factorCluster,factorStackEffect,factorArray0,factorQuotation0
32
33 syn region factorDefn matchgroup=factorDefnDelims start=/\<\(MACRO\|MEMO\|:\)\?:\s\+\S\+\>/ end=/\<;\>/ contains=@factorDefnContents
34 syn region factorMethod matchgroup=factorMethodDelims start=/\<M:\s\+\S\+\s\+\S\+\>/ end=/\<;\>/ contains=@factorDefnContents
35 syn region factorGeneric matchgroup=factorGenericDelims start=/\<GENERIC:\s\+\S\+\>/ end=/$/ contains=factorStackEffect
36 syn region factorGenericN matchgroup=factorGenericNDelims start=/\<GENERIC#\s\+\S\+\s\+\d\+\>/ end=/$/ contains=factorStackEffect
37
38 syn region factorPrivateDefn matchgroup=factorPrivateDefnDelims start=/\<\(MACRO\|MEMO\|:\)\?:\s\+\S\+\>/ end=/\<;\>/ contains=@factorDefnContents contained
39 syn region factorPrivateMethod matchgroup=factorPrivateMethodDelims start=/\<M:\s\+\S\+\s\+\S\+\>/ end=/\<;\>/ contains=@factorDefnContents contained
40 syn region factorPGeneric matchgroup=factorPGenericDelims start=/\<GENERIC:\s\+\S\+\>/ end=/$/ contains=factorStackEffect contained
41 syn region factorPGenericN matchgroup=factorPGenericNDelims start=/\<GENERIC#\s\+\S\+\s\+\d\+\>/ end=/$/ contains=factorStackEffect
42
43 syn region None matchgroup=factorPrivate start=/\<<PRIVATE\>/ end=/\<PRIVATE>\>/ contains=@factorDefnContents,factorPrivateDefn,factorPrivateMethod,factorPGeneric,factorPGenericN
44
45
46 syn keyword factorBoolean boolean f general-t t
47 syn keyword factorCompileDirective inline foldable parsing
48
49 syn keyword factorKeyword or tuck 2bi 2tri while wrapper nip 4dip wrapper? bi* callstack>array both? hashcode die dupd callstack callstack? 3dup tri@ pick curry build ?execute 3bi prepose >boolean ?if clone eq? tri* ? = swapd call-clear 2over 2keep 3keep clear 2dup when not tuple? dup 2bi* 2tri* call tri-curry object bi@ do unless* if* loop bi-curry* drop when* assert= retainstack assert? -rot execute 2bi@ 2tri@ boa with either? 3drop bi curry? datastack until 3dip over 3curry roll tri-curry* swap tri-curry@ 2nip and throw set-retainstack bi-curry (clone) hashcode* compose spin 2dip if 3tri unless compose? tuple keep 2curry equal? set-datastack assert tri 2drop most <wrapper> boolean? identity-tuple? null new set-callstack dip bi-curry@ rot -roll xor identity-tuple boolean
50 syn keyword factorKeyword ?at assoc? assoc-clone-like assoc= delete-at* assoc-partition extract-keys new-assoc value? assoc-size map>assoc push-at assoc-like key? assoc-intersect update assoc-union assoc-combine at* assoc-empty? at+ set-at assoc-all? assoc-subset? assoc-hashcode change-at assoc-each assoc-diff zip values value-at rename-at inc-at enum? at cache assoc>map <enum> assoc assoc-map enum value-at* remove-all assoc-map-as >alist assoc-filter-as substitute-here clear-assoc assoc-stack substitute assoc-filter 2cache delete-at assoc-find keys assoc-any? unzip
51 syn keyword factorKeyword case execute-effect dispatch-case-quot <buckets> no-cond no-case? 3cleave>quot contiguous-range? 2cleave cond>quot wrong-values? no-cond? cleave>quot no-case hash-dispatch-quot case>quot 3cleave wrong-values alist>quot hash-case-table hash-case-quot case-find (distribute-buckets) cond cleave distribute-buckets call-effect 2cleave>quot recursive-hashcode linear-case-quot spread spread>quot
52 syn keyword factorKeyword byte-array>bignum sgn >bignum next-float number= each-integer next-power-of-2 ?1+ fp-special? imaginary-part mod recip float>bits rational >float number? 2^ bignum? integer fixnum? neg fixnum sq bignum fp-snan? fp-infinity? denominator (all-integers?) times find-last-integer (each-integer) bit? * + fp-bitwise= - fp-qnan? / power-of-2? >= bitand find-integer complex <fp-nan> < log2 > integer? real number bits>double double>bits bitor 2/ zero? rem fp-nan-payload all-integers? (find-integer) real-part prev-float align bits>float float? shift float 1+ 1- fp-nan? abs bitxor ratio? even? <= /mod odd? >integer ratio rational? bitnot real? >fixnum complex? /i numerator /f
53 syn keyword factorKeyword append assert-sequence= find-last-from trim-head-slice clone-like 3sequence assert-sequence? map-as filter-here last-index-from prepare-index reversed index-from cut* pad-tail (indices) concat-as remq but-last snip trim-tail nths nth 2pusher sequence slice? <slice> partition remove-nth tail-slice empty? tail* if-empty find-from virtual-sequence? member? set-length delq drop-prefix unclip iota unclip-last-slice bounds-error? sequence-hashcode-step map start midpoint@ rest-slice prepend fourth sift delete sigma new-sequence follow like delete-nth first4 1sequence reverse slice unless-empty padding virtual@ repetition? index 4sequence max-length set-second immutable-sequence first2 first3 replicate-as reduce-index unclip-slice supremum insert-nth trim-tail-slice tail 3append short count suffix concat flip filter sum immutable? 2sequence delete-all start* indices snip-slice check-slice sequence? head map-find reduce append-as reverse-here sequence= halves collapse-slice interleave 2map binary-reduce virtual-seq slice-error? product bounds-check? bounds-check harvest immutable find produce remove pad-head replicate set-fourth peek shorten reversed? map-find-last 3map-as 2unclip-slice shorter? 3map find-last head-slice pop* 2map-as tail-slice* but-last-slice 2map-reduce iota? accumulate each pusher cut-slice new-resizable each-index head-slice* 2reverse-each sequence-hashcode memq? pop set-nth ?nth <flat-slice> second change-each join when-empty accumulator immutable-sequence? <reversed> all? 3append-as virtual-sequence subseq? push-either new-like length last-index push-if 2all? lengthen assert-sequence copy map-reduce move third first 3each tail? set-first prefix bounds-error any? <repetition> trim-slice exchange surround 2reduce cut change-nth min-length set-third produce-as push-all head? delete-slice rest sum-lengths 2each head* infimum glue slice-error subseq replace-slice push repetition map-index trim-head unclip-last mismatch trim
54 syn keyword factorKeyword global +@ change set-namestack change-global init-namespaces on off set-global namespace set with-scope bind with-variable inc dec counter initialize namestack get get-global make-assoc
55 syn keyword factorKeyword <array> 2array 3array pair >array 1array 4array pair? array resize-array array?
56 syn keyword factorKeyword +character+ bad-seek-type? readln stream-seek read print with-output-stream contents write1 stream-write1 stream-copy stream-element-type with-input-stream stream-print stream-read stream-contents bl seek-output bad-seek-type nl stream-nl write flush stream-lines +byte+ stream-flush read1 seek-absolute? stream-read1 lines stream-readln stream-read-until each-line seek-end with-output-stream* seek-absolute with-streams seek-input seek-relative? input-stream stream-write read-partial seek-end? seek-relative error-stream read-until with-input-stream* with-streams* each-block output-stream stream-read-partial
57 syn keyword factorKeyword resize-string >string <string> 1string string string?
58 syn keyword factorKeyword vector? <vector> ?push vector >vector 1vector
59 syn keyword factorKeyword with-return restarts return-continuation with-datastack recover rethrow-restarts <restart> ifcc set-catchstack >continuation< cleanup ignore-errors restart? compute-restarts attempt-all-error error-thread continue <continuation> attempt-all-error? condition? <condition> throw-restarts error catchstack continue-with thread-error-hook continuation rethrow callcc1 error-continuation callcc0 attempt-all condition continuation? restart return
60
61
62 syn cluster factorReal          contains=factorInt,factorFloat,factorRatio,factorBinary,factorHex,factorOctal
63 syn cluster factorNumber        contains=@factorReal,factorComplex
64 syn cluster factorNumErr        contains=factorBinErr,factorHexErr,factorOctErr
65 syn match   factorInt           /\<-\=\d\+\>/
66 syn match   factorFloat         /\<-\=\d*\.\d\+\>/
67 syn match   factorRatio         /\<-\=\d*\.*\d\+\/-\=\d*\.*\d\+\>/
68 syn region  factorComplex       start=/\<C{\>/ end=/\<}\>/ contains=@factorReal
69 syn match   factorBinErr        /\<BIN:\s\+[01]*[^\s01]\S*\>/
70 syn match   factorBinary        /\<BIN:\s\+[01]\+\>/
71 syn match   factorHexErr        /\<HEX:\s\+\x*[^\x\s]\S*\>/
72 syn match   factorHex           /\<HEX:\s\+\x\+\>/
73 syn match   factorOctErr        /\<OCT:\s\+\o*[^\o\s]\S*\>/
74 syn match   factorOctal         /\<OCT:\s\+\o\+\>/
75
76 syn match   factorIn            /\<IN:\s\+\S\+\>/
77 syn match   factorUse           /\<USE:\s\+\S\+\>/
78 syn match   factorUnuse         /\<UNUSE:\s\+\S\+\>/
79
80 syn match   factorCharErr       /\<CHAR:\s\+\S\+/
81 syn match   factorChar          /\<CHAR:\s\+\\\=\S\>/
82
83 syn match   factorBackslash     /\<\\\>\s\+\S\+\>/
84
85 syn region  factorUsing         start=/\<USING:\>/       end=/;/
86 syn region  factorSingletons    start=/\<SINGLETONS:\>/  end=/;/
87 syn match   factorSymbol        /\<SYMBOL:\s\+\S\+\>/
88 syn region  factorSymbols       start=/\<SYMBOLS:\>/     end=/;/
89 syn region  factorConstructor2  start=/\<CONSTRUCTOR:\?/ end=/;/
90 syn region  factorTuple         start=/\<TUPLE:\>/ end=/\<;\>/
91
92 syn match   factorConstant      /\<CONSTANT:\s\+\S\+\>/
93 syn match   factorSingleton     /\<SINGLETON:\s\+\S\+\>/
94 syn match   factorPostpone      /\<POSTPONE:\s\+\S\+\>/
95 syn match   factorDefer         /\<DEFER:\s\+\S\+\>/
96 syn match   factorForget        /\<FORGET:\s\+\S\+\>/
97 syn match   factorMixin         /\<MIXIN:\s\+\S\+\>/
98 syn match   factorInstance      /\<INSTANCE:\s\+\S\+\s\+\S\+\>/
99 syn match   factorHook          /\<HOOK:\s\+\S\+\s\+\S\+\>/
100 syn match   factorMain          /\<MAIN:\s\+\S\+\>/
101 syn match   factorConstructor   /\<C:\s\+\S\+\s\+\S\+\>/
102 syn match   factorAlien         /\<ALIEN:\s\+\d\+\>/
103
104 syn cluster factorWordOps       contains=factorSymbol,factorPostpone,factorDefer,factorForget,factorMixin,factorInstance,factorHook,factorMain,factorConstructor
105
106
107 "TODO:
108 "misc:
109 " HELP:
110 " ARTICLE:
111 "literals:
112 " PRIMITIVE:
113
114 "C interface:
115 " FIELD:
116 " BEGIN-STRUCT:
117 " C-ENUM:
118 " FUNCTION:
119 " END-STRUCT
120 " DLL"
121 " TYPEDEF:
122 " LIBRARY:
123 " C-UNION:
124 "QUALIFIED:
125 "QUALIFIED-WITH:
126 "FROM:
127 "ALIAS:
128 "! POSTPONE: "
129 "#\ "
130
131 syn region factorString start=/"/ skip=/\\"/ end=/"/ oneline
132 syn region factorSbuf start=/SBUF" / skip=/\\"/ end=/"/ oneline
133
134 syn region factorMultiString matchgroup=factorMultiStringDelims start=/\<STRING:\s\+\S\+\>/ end=/^;$/ contains=factorMultiStringContents
135 syn match factorMultiStringContents /.*/ contained
136
137 "syn match factorStackEffectErr /\<)\>/
138 "syn region factorStackEffectErr start=/\<(\>/ end=/\<)\>/
139 syn region factorStackEffect start=/\<(\>/ end=/\<)\>/ contained
140
141 "adapted from lisp.vim
142 if exists("g:factor_norainbow") 
143     syn region factorQuotation matchgroup=factorDelimiter start=/\<\[\>/ matchgroup=factorDelimiter end=/\<\]\>/ contains=ALL
144 else
145     syn region factorQuotation0           matchgroup=hlLevel0 start=/\<\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation1,factorArray1
146     syn region factorQuotation1 contained matchgroup=hlLevel1 start=/\<\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation2,factorArray2
147     syn region factorQuotation2 contained matchgroup=hlLevel2 start=/\<\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation3,factorArray3
148     syn region factorQuotation3 contained matchgroup=hlLevel3 start=/\<\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation4,factorArray4
149     syn region factorQuotation4 contained matchgroup=hlLevel4 start=/\<\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation5,factorArray5
150     syn region factorQuotation5 contained matchgroup=hlLevel5 start=/\<\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation6,factorArray6
151     syn region factorQuotation6 contained matchgroup=hlLevel6 start=/\<\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation7,factorArray7
152     syn region factorQuotation7 contained matchgroup=hlLevel7 start=/\<\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation8,factorArray8
153     syn region factorQuotation8 contained matchgroup=hlLevel8 start=/\<\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation9,factorArray9
154     syn region factorQuotation9 contained matchgroup=hlLevel9 start=/\<\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation0,factorArray0
155 endif
156
157 if exists("g:factor_norainbow") 
158     syn region factorArray    matchgroup=factorDelimiter start=/\<\(V\|H\|T\|W\|F\|B\)\?{\>/  matchgroup=factorDelimiter end=/\<}\>/ contains=ALL
159 else
160     syn region factorArray0           matchgroup=hlLevel0 start=/\<\(V\|H\|T\|W\|F\|B\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray1,factorQuotation1
161     syn region factorArray1 contained matchgroup=hlLevel1 start=/\<\(V\|H\|T\|W\|F\|B\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray2,factorQuotation2
162     syn region factorArray2 contained matchgroup=hlLevel2 start=/\<\(V\|H\|T\|W\|F\|B\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray3,factorQuotation3
163     syn region factorArray3 contained matchgroup=hlLevel3 start=/\<\(V\|H\|T\|W\|F\|B\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray4,factorQuotation4
164     syn region factorArray4 contained matchgroup=hlLevel4 start=/\<\(V\|H\|T\|W\|F\|B\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray5,factorQuotation5
165     syn region factorArray5 contained matchgroup=hlLevel5 start=/\<\(V\|H\|T\|W\|F\|B\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray6,factorQuotation6
166     syn region factorArray6 contained matchgroup=hlLevel6 start=/\<\(V\|H\|T\|W\|F\|B\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray7,factorQuotation7
167     syn region factorArray7 contained matchgroup=hlLevel7 start=/\<\(V\|H\|T\|W\|F\|B\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray8,factorQuotation8
168     syn region factorArray8 contained matchgroup=hlLevel8 start=/\<\(V\|H\|T\|W\|F\|B\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray9,factorQuotation9
169     syn region factorArray9 contained matchgroup=hlLevel9 start=/\<\(V\|H\|T\|W\|F\|B\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray0,factorQuotation0
170 endif
171
172 syn match factorBracketErr /\<\]\>/
173 syn match factorBracketErr /\<}\>/
174
175 syn sync lines=100
176
177 if version >= 508 || !exists("did_factor_syn_inits")
178     if version <= 508
179         let did_factor_syn_inits = 1
180         command -nargs=+ HiLink hi link <args>
181     else
182         command -nargs=+ HiLink hi def link <args>
183     endif
184
185     HiLink factorComment                Comment
186     HiLink factorStackEffect            Typedef
187     HiLink factorTodo                   Todo
188     HiLink factorInclude                Include
189     HiLink factorRepeat                 Repeat
190     HiLink factorConditional            Conditional
191     HiLink factorKeyword                Keyword
192     HiLink factorOperator               Operator
193     HiLink factorBoolean                Boolean
194     HiLink factorDefnDelims             Typedef
195     HiLink factorMethodDelims           Typedef
196     HiLink factorGenericDelims          Typedef
197     HiLink factorGenericNDelims         Typedef
198     HiLink factorConstructor            Typedef
199     HiLink factorConstructor2           Typedef
200     HiLink factorPrivate                Special
201     HiLink factorPrivateDefnDelims      Special
202     HiLink factorPrivateMethodDelims    Special
203     HiLink factorPGenericDelims         Special
204     HiLink factorPGenericNDelims        Special
205     HiLink factorString                 String
206     HiLink factorSbuf                   String
207     HiLink factorMultiStringContents    String
208     HiLink factorMultiStringDelims      Typedef
209     HiLink factorBracketErr             Error
210     HiLink factorComplex                Number
211     HiLink factorRatio                  Number
212     HiLink factorBinary                 Number
213     HiLink factorBinErr                 Error
214     HiLink factorHex                    Number
215     HiLink factorHexErr                 Error
216     HiLink factorOctal                  Number
217     HiLink factorOctErr                 Error
218     HiLink factorFloat                  Float
219     HiLink factorInt                    Number
220     HiLink factorUsing                  Include
221     HiLink factorUse                    Include
222     HiLink factorUnuse                  Include
223     HiLink factorIn                     Define
224     HiLink factorChar                   Character
225     HiLink factorCharErr                Error
226     HiLink factorDelimiter              Delimiter
227     HiLink factorBackslash              Special
228     HiLink factorCompileDirective       Typedef
229     HiLink factorSymbol                 Define
230     HiLink factorConstant               Define
231     HiLink factorSingleton              Define
232     HiLink factorSingletons             Define
233     HiLink factorMixin                  Typedef
234     HiLink factorInstance               Typedef
235     HiLink factorHook                   Typedef
236     HiLink factorMain                   Define
237     HiLink factorPostpone               Define
238     HiLink factorDefer                  Define
239     HiLink factorForget                 Define
240     HiLink factorAlien                  Define
241     HiLink factorTuple                  Typedef
242
243     if &bg == "dark"
244         hi   hlLevel0 ctermfg=red         guifg=red1
245         hi   hlLevel1 ctermfg=yellow      guifg=orange1
246         hi   hlLevel2 ctermfg=green       guifg=yellow1
247         hi   hlLevel3 ctermfg=cyan        guifg=greenyellow
248         hi   hlLevel4 ctermfg=magenta     guifg=green1
249         hi   hlLevel5 ctermfg=red         guifg=springgreen1
250         hi   hlLevel6 ctermfg=yellow      guifg=cyan1
251         hi   hlLevel7 ctermfg=green       guifg=slateblue1
252         hi   hlLevel8 ctermfg=cyan        guifg=magenta1
253         hi   hlLevel9 ctermfg=magenta     guifg=purple1
254     else
255         hi   hlLevel0 ctermfg=red         guifg=red3
256         hi   hlLevel1 ctermfg=darkyellow  guifg=orangered3
257         hi   hlLevel2 ctermfg=darkgreen   guifg=orange2
258         hi   hlLevel3 ctermfg=blue        guifg=yellow3
259         hi   hlLevel4 ctermfg=darkmagenta guifg=olivedrab4
260         hi   hlLevel5 ctermfg=red         guifg=green4
261         hi   hlLevel6 ctermfg=darkyellow  guifg=paleturquoise3
262         hi   hlLevel7 ctermfg=darkgreen   guifg=deepskyblue4
263         hi   hlLevel8 ctermfg=blue        guifg=darkslateblue
264         hi   hlLevel9 ctermfg=darkmagenta guifg=darkviolet
265     endif
266
267     delcommand HiLink
268 endif
269
270 let b:current_syntax = "factor"
271
272 set sw=4
273 set ts=4
274 set expandtab
275 set autoindent " annoying?
276
277 " vim: syntax=vim