JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
initial import
[vim-syntax.git] / factor.vim
1 " Vim syntax file
2 " Language:     factor
3 " Maintainer:   Alex Chapman <chapman.alex@gmail.com>
4 " Last Change:  2007 Jan 18
5
6 " For version 5.x: Clear all syntax items
7 " For version 6.x: Quit when a syntax file was already loaded
8 if version < 600
9   syntax clear
10 elseif exists("b:current_syntax")
11   finish
12 endif
13
14 " factor is case sensitive.
15 syn case match
16
17 " make all of these characters part of a word (useful for skipping over words with w, e, and b)
18 if version >= 600
19     setlocal iskeyword=!,@,33-35,%,$,38-64,A-Z,91-96,a-z,123-126,128-255
20 else
21     set iskeyword=!,@,33-35,%,$,38-64,A-Z,91-96,a-z,123-126,128-255
22 endif
23
24 syn cluster factorCluster contains=factorComment,factorKeyword,factorRepeat,factorConditional,factorBoolean,factorString,factorSbuf,@factorNumber,@factorNumErr,factorDelimiter,factorChar,factorCharErr,factorBackslash,@factorWordOps,factorAlien,factorTuple
25
26 syn match factorTodo /\(TODO\|FIXME\|XXX\):\=/ contained
27 syn match factorComment /\<#! .*/ contains=factorTodo
28 syn match factorComment /\<! .*/ contains=factorTodo
29
30 syn region None matchgroup=factorDefinition start=/\<\(C\|M\|G\|UNION\|PREDICATE\)\?:\>/ end=/\<;\>/ contains=@factorCluster,factorStackEffect,factorStackEffectErr,factorArray0,factorQuotation0
31
32 syn region None matchgroup=factorGeneric start=/\<GENERIC:\>/ end=/$/ contains=factorStackEffect,factorStackEffectErr
33
34 syn keyword factorBoolean boolean f general-t t
35 syn keyword factorCompileDirective inline foldable parsing
36
37
38
39 " kernel vocab keywords
40 syn keyword factorKeyword continuation-name set-datastack wrapper continuation-catch set-continuation-name slip pick 2slip 2nip tuple set-boot clone with-datastack cpu -roll tuck -rot (continue) set-continuation-retain swapd <continuation> >boolean wrapper? dupd 3dup dup ifcc callstack windows? os-env = over continuation alist>quot ? <wrapper> 2dup cond win64? <quotation> continue 3drop hashcode quotation xor when curry millis set-callstack unless >r die version callcc0 or os callcc1 get-walker-hook depth equal? 3keep no-cond? continue-with if exit tuple? set-retainstack unix? (continue-with) general-t continuation? 3slip <no-cond> macosx? r> rot win32? retainstack 2apply >quotation >continuation< type continuation-call clear call drop continuation-data set-continuation-call 2drop no-cond unit set-continuation-data keep-datastack and when* quotation? ?if literalize datastack swap unless* 2swap set-continuation-catch eq? not roll set-walker-hook continuation-retain with make-dip wrapped keep 2keep <=> if* nip 
41 syn keyword factorKeyword sin integer? log2 cot oct> number>string integer first-bignum sech abs repeat tanh real? vmin norm-sq neg between? asech >rect bignum? atanh -i * + fp-nan? - small / sqrt infimum fix-float cosech even? v*n < bits>double > most-positive-fixnum ^theta numerator digit+ >base (random-int) acosech cosh min pi number vmax zero? sum digit> rem bitor supremum string>integer most-negative-fixnum >polar >fraction ceiling acos acot ^ asin acosh /f ratio e fixnum? /i ^n cis coth 1+ 1- conjugate sinh acosec i number= number? double>bits epsilon float product string>number n/v norm max tan acoth absq float? asinh denominator rational? fixnum rect> >fixnum imaginary recip exp sec bitxor w>h/h >bin align base> times log <= [-] init-random sq odd? (repeat) [v-] ^mag bitnot ratio? random-int >digit (next-power-of-2) v* v+ v- v. v/ >float [-1,1]? arg small? bitand set-axis >oct v/n complex rational shift (^) polar> (gcd) cosec next-power-of-2 >float-rect atan sgn >= float>bits normalize real bin> complex? gcd d>w/w hex> mod string>ratio asec floor n*v >hex truncate bits>float vneg >bignum bignum power-of-2? integer, /mod (string>integer) cos 
42 syn keyword factorKeyword second sort-values all-eq? pop* find slice-error-reason inject-with prune remove (group) split1-slice slice-error (slice*) split* head-slice* find* split, first remove-nth hash-prune push-if ?push reverse subseq split1 diff subset split new padding column? copy-into-check column@ <column> peek last/first add find-last ?nth add* slice-from cache-nth subseq? <reversed> <slice-error> (3append) replace-slice reversed-seq find-last-with empty? ((append)) reversed? reversed@ map-with find-last-with* set-slice-error-reason set-column-col natural-sort (subst) set-slice-seq index* concat push binsearch slice-seq 3append nsort length tail-slice* reversed ?head sequence= ?tail sequence? memq? join split-next, delete set-nth subst monotonic? group map flip unclip set-reversed-seq find-last* start* max-length assoc min-length all-equal? all? pad-left contains? inject slice <slice> first2 first3 first4 exchange bounds-check? column-seq check-slice pad-right each subset-with unpair tail head interleave (delete) copy-into sort sequence reduce set-slice-from set-slice-to 2map (cut) member? cut rassoc (append) last-index* sort-keys change-nth 2each >sequence nth tail* head* third tail-slice set-length collapse-slice column (mismatch) contains-with? push-new pop tail? head? slice? slice@ delete-all binsearch* move find-with* 2reduce slice-to find-with like slice-error? set-column-seq nappend column-col cut* (split) index each-with last-index fourth append accumulate drop-prefix mismatch head-slice all-with? start 
43 syn keyword factorKeyword namespace-error-object inc dec make off bind get-global init-namespaces set-global namespace on ndrop namespace-error? namestack namespace-error +@ # % make-hash global , set-namestack with-scope building <namespace-error> change nest set-namespace-error-object get set counter 
44 syn keyword factorKeyword array <array> pair byte-array pair? 1array 2array resize-array 4array 3array byte-array? <byte-array> array? >array 
45 syn keyword factorKeyword cwd duplex-stream pathname? set-pathname-string with-log-file directory duplex-stream-out format <nested-style-stream> (readln) duplex-stream? read1 with-stream-style c-stream-error? <file-reader> stream-write1 with-stream line-reader? set-duplex-stream-out server? cr> <check-closed> directory? log-message flush format-column stream-readln nested-style-stream? <line-reader> <file-r/w> set-timeout write-pathname file-modified duplex-stream-closed? print set-duplex-stream-closed? pathname line-reader ?resource-path terpri write-object le> string-out stream-terpri log-client do-nested-style path+ <c-stream-error> set-client-stream-host plain-writer? server-stream resource-path >be parent-dir with-stream* <file-writer> server-loop string-in nested-style-stream stream-close stream-copy c-stream-error <client-stream> with-style client-stream-host stat plain-writer file-length contents <string-reader> stream-read stream-format check-closed? set-client-stream-port <duplex-stream> <server> write1 bl write-outliner map-last (with-stream-style) set-line-reader-cr tabular-output (lines) stream-write log-stream server-client (stream-copy) with-nested-stream lines readln cd client-stream nth-byte with-logging stream-read1 nested-style-stream-style accept check-closed client-stream-port do-nested-quot pathname-string set-nested-style-stream-style read home close with-stream-table stdio be> log-error duplex-stream-out+ server stream-flush set-duplex-stream-in line-reader-cr >le with-client <client> <pathname> <string-writer> (directory) set-server-client stream-print with-server exists? <plain-writer> with-nesting string-lines write duplex-stream-in client-stream? duplex-stream-in+ 
46 syn keyword factorKeyword sbuf ch>upper string? LETTER? >sbuf >lower quotable? string>sbuf blank? string sbuf? printable? >string letter? resize-string control? alpha? <string> >upper Letter? ch>lower digit? <sbuf> ch>string 
47 syn keyword factorKeyword <vector> >vector array>vector vector? vector 
48 syn keyword factorKeyword set-restart-continuation cleanup error-hook restart-name restarts. stack-underflow. expired-error. restart restart? word-xt. (:help-none) set-catchstack c-string-error. condition <assert> debug-help :get datastack-overflow. set-condition-restarts condition? error. objc-error. print-error assert :res catchstack rethrow assert= kernel-error restart-obj assert? undefined-symbol-error. retainstack-overflow. restarts error-help divide-by-zero-error. ffi-error. signal-error. (:help-multi) set-restart-obj xt. memory-error. retainstack-underflow. set-condition-continuation datastack-underflow. try assert-depth error-continuation error-stack-trace assert-expect recover :edit kernel-error? error callstack-overflow. stack-overflow. callstack-underflow. set-assert-got set-restart-name restart-continuation condition-restarts heap-scan-error. :help type-check-error. <condition> assert-got throw negative-array-size-error. :c condition-continuation :trace undefined-word-error. io-error. parse-dump <restart> set-assert-expect :r :s compute-restarts catch restart. 
49
50
51 syn cluster factorReal   contains=factorInt,factorFloat,factorRatio,factorBinary,factorHex,factorOctal
52 syn cluster factorNumber contains=@factorReal,factorComplex
53 syn cluster factorNumErr contains=factorBinErr,factorHexErr,factorOctErr
54 syn match   factorInt           /\<-\=\d\+\>/
55 syn match   factorFloat         /\<-\=\d*\.\d\+\>/
56 syn match   factorRatio         /\<-\=\d*\.*\d\+\/-\=\d*\.*\d\+\>/
57 syn region  factorComplex       start=/\<C{\>/ end=/\<}\>/ contains=@factorReal
58 syn match   factorBinErr        /\<BIN:\s\+[01]*[^\s01]\S*\>/
59 syn match   factorBinary        /\<BIN:\s\+[01]\+\>/
60 syn match   factorHexErr        /\<HEX:\s\+\x*[^\x\s]\S*\>/
61 syn match   factorHex           /\<HEX:\s\+\x\+\>/
62 syn match   factorOctErr        /\<OCT:\s\+\o*[^\o\s]\S*\>/
63 syn match   factorOctal         /\<OCT:\s\+\o\+\>/
64
65 syn match factorIn /\<IN:\s\+\S\+\>/
66 syn match factorUse /\<USE:\s\+\S\+\>/
67
68 syn match factorCharErr /\<CHAR:\s\+\S\+/
69 syn match factorChar /\<CHAR:\s\+\\\=\S\>/
70
71 syn match factorBackslash /\<\\\>\s\+\S\+\>/
72
73 syn region factorUsing start=/\<USING:\>/ end=/;/
74 syn region factorRequires start=/\<REQUIRES:\>/ end=/;/
75
76 syn cluster factorWordOps contains=factorSymbol,factorPostpone,factorDefer,factorForget
77 syn match factorSymbol /\<SYMBOL:\s\+\S\+\>/
78 syn match factorPostpone /\<POSTPONE:\s\+\S\+\>/
79 syn match factorDefer /\<DEFER:\s\+\S\+\>/
80 syn match factorForget /\<FORGET:\s\+\S\+\>/
81
82 syn match factorAlien /\<ALIEN:\s\+\d\+\>/
83
84 syn region factorTuple start=/\<TUPLE:\>/ end=/\<;\>/
85
86 "TODO:
87 "misc:
88 " HELP:
89 " ARTICLE:
90 " PROVIDE:
91 " MAIN:
92 "literals:
93 " PRIMITIVE:
94
95 "C interface:
96 " FIELD:
97 " BEGIN-STRUCT:
98 " C-ENUM:
99 " FUNCTION:
100 " END-STRUCT
101 " DLL"
102 " TYPEDEF:
103 " LIBRARY:
104 " C-UNION:
105
106 syn region factorString start=/"/ skip=/\\"/ end=/"/ oneline
107 syn region factorSbuf start=/SBUF" / skip=/\\"/ end=/"/ oneline
108
109 syn match factorStackEffectErr /\<)\>/
110 syn region factorStackEffectErr start=/\<(\>/ end=/\<)\>/
111 syn region factorStackEffect start=/\<(\>/ end=/\<)\>/ contained
112
113 "adapted from lisp.vim
114 if exists("g:factor_norainbow") 
115     syn region factorQuotation matchgroup=factorDelimiter start=/\<\[\>/ matchgroup=factorDelimiter end=/\<\]\>/ contains=ALL
116 else
117     syn region factorQuotation0           matchgroup=hlLevel0 start=/\<\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation1,factorArray1
118     syn region factorQuotation1 contained matchgroup=hlLevel1 start=/\<\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation2,factorArray2
119     syn region factorQuotation2 contained matchgroup=hlLevel2 start=/\<\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation3,factorArray3
120     syn region factorQuotation3 contained matchgroup=hlLevel3 start=/\<\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation4,factorArray4
121     syn region factorQuotation4 contained matchgroup=hlLevel4 start=/\<\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation5,factorArray5
122     syn region factorQuotation5 contained matchgroup=hlLevel5 start=/\<\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation6,factorArray6
123     syn region factorQuotation6 contained matchgroup=hlLevel6 start=/\<\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation7,factorArray7
124     syn region factorQuotation7 contained matchgroup=hlLevel7 start=/\<\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation8,factorArray8
125     syn region factorQuotation8 contained matchgroup=hlLevel8 start=/\<\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation9,factorArray9
126     syn region factorQuotation9 contained matchgroup=hlLevel9 start=/\<\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation0,factorArray0
127 endif
128
129 if exists("g:factor_norainbow") 
130     syn region factorArray    matchgroup=factorDelimiter start=/\<\(V\|H\|T\|W\)\?{\>/  matchgroup=factorDelimiter end=/\<}\>/ contains=ALL
131 else
132     syn region factorArray0           matchgroup=hlLevel0 start=/\<\(V\|H\|T\|W\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray1,factorQuotation1
133     syn region factorArray1 contained matchgroup=hlLevel1 start=/\<\(V\|H\|T\|W\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray2,factorQuotation2
134     syn region factorArray2 contained matchgroup=hlLevel2 start=/\<\(V\|H\|T\|W\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray3,factorQuotation3
135     syn region factorArray3 contained matchgroup=hlLevel3 start=/\<\(V\|H\|T\|W\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray4,factorQuotation4
136     syn region factorArray4 contained matchgroup=hlLevel4 start=/\<\(V\|H\|T\|W\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray5,factorQuotation5
137     syn region factorArray5 contained matchgroup=hlLevel5 start=/\<\(V\|H\|T\|W\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray6,factorQuotation6
138     syn region factorArray6 contained matchgroup=hlLevel6 start=/\<\(V\|H\|T\|W\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray7,factorQuotation7
139     syn region factorArray7 contained matchgroup=hlLevel7 start=/\<\(V\|H\|T\|W\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray8,factorQuotation8
140     syn region factorArray8 contained matchgroup=hlLevel8 start=/\<\(V\|H\|T\|W\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray9,factorQuotation9
141     syn region factorArray9 contained matchgroup=hlLevel9 start=/\<\(V\|H\|T\|W\)\?{\>/ end=/\<}\>/ contains=@factorCluster,factorArray0,factorQuotation0
142 endif
143
144 syn match factorBracketErr /\<\]\>/
145 syn match factorBracketErr /\<}\>/
146
147 syn sync lines=100
148
149 if version >= 508 || !exists("did_factor_syn_inits")
150     if version <= 508
151         let did_factor_syn_inits = 1
152         command -nargs=+ HiLink hi link <args>
153     else
154         command -nargs=+ HiLink hi def link <args>
155     endif
156
157     HiLink factorComment        Comment
158     HiLink factorStackEffect    Typedef
159     HiLink factorTodo           Todo
160     HiLink factorInclude        Include
161     HiLink factorRepeat         Repeat
162     HiLink factorConditional    Conditional
163     HiLink factorKeyword        Keyword
164     HiLink factorOperator       Operator
165     HiLink factorBoolean        Boolean
166     HiLink factorDefinition     Typedef
167     HiLink factorString         String
168     HiLink factorSbuf           String
169     HiLink factorBracketErr     Error
170     HiLink factorStackEffectErr Error
171     HiLink factorComplex        Number
172     HiLink factorRatio          Number
173     HiLink factorBinary         Number
174     HiLink factorBinErr         Error
175     HiLink factorHex            Number
176     HiLink factorHexErr         Error
177     HiLink factorOctal          Number
178     HiLink factorOctErr         Error
179     HiLink factorFloat          Float
180     HiLink factorInt            Number
181     HiLink factorUsing          Include
182     HiLink factorUse            Include
183     HiLink factorRequires       Include
184     HiLink factorIn             Define
185     HiLink factorChar           Character
186     HiLink factorCharErr        Error
187     HiLink factorDelimiter      Delimiter
188     HiLink factorBackslash      Special
189     HiLink factorCompileDirective Keyword
190     HiLink factorSymbol         Define
191     HiLink factorPostpone       Define
192     HiLink factorDefer          Define
193     HiLink factorForget         Define
194     HiLink factorAlien          Define
195     HiLink factorTuple          Typedef
196     HiLink factorGeneric        Define
197
198     if &bg == "dark"
199         hi   hlLevel0 ctermfg=red         guifg=red1
200         hi   hlLevel1 ctermfg=yellow      guifg=orange1
201         hi   hlLevel2 ctermfg=green       guifg=yellow1
202         hi   hlLevel3 ctermfg=cyan        guifg=greenyellow
203         hi   hlLevel4 ctermfg=magenta     guifg=green1
204         hi   hlLevel5 ctermfg=red         guifg=springgreen1
205         hi   hlLevel6 ctermfg=yellow      guifg=cyan1
206         hi   hlLevel7 ctermfg=green       guifg=slateblue1
207         hi   hlLevel8 ctermfg=cyan        guifg=magenta1
208         hi   hlLevel9 ctermfg=magenta     guifg=purple1
209     else
210         hi   hlLevel0 ctermfg=red         guifg=red3
211         hi   hlLevel1 ctermfg=darkyellow  guifg=orangered3
212         hi   hlLevel2 ctermfg=darkgreen   guifg=orange2
213         hi   hlLevel3 ctermfg=blue        guifg=yellow3
214         hi   hlLevel4 ctermfg=darkmagenta guifg=olivedrab4
215         hi   hlLevel5 ctermfg=red         guifg=green4
216         hi   hlLevel6 ctermfg=darkyellow  guifg=paleturquoise3
217         hi   hlLevel7 ctermfg=darkgreen   guifg=deepskyblue4
218         hi   hlLevel8 ctermfg=blue        guifg=darkslateblue
219         hi   hlLevel9 ctermfg=darkmagenta guifg=darkviolet
220     endif
221
222     delcommand HiLink
223 endif
224
225 let b:current_syntax = "factor"
226
227 set sw=4
228 set ts=4
229 set expandtab
230 set autoindent " annoying?
231
232 " vim: syntax=vim