Add /src/vim/release.sh, a script to compile and install vim
[msysgit.git] / share / vim / vim58 / syntax / ocaml.vim
blobf0a62728b6c69ac0f0b807b1f49c76e2a215c996
1 " Vim syntax file
2 " Language:      OCAML
3 " Filenames:     *.ml *.mli *.mll *.mly
4 " Maintainers:   Markus Mottl     <mottl@miss.wu-wien.ac.at>
5 "                Karl-Heinz Sylla <Karl-Heinz.Sylla@gmd.de>
6 " URL:           http://miss.wu-wien.ac.at/~mottl/vim/syntax/ocaml.vim
7 " Last Change:   2001 May 10
8 "                2001 Feb 19 - small fix for functors
9 "                2000 May 05 - small fix for optional arguments
11 " For version 5.x: Clear all syntax items
12 " For version 6.x: Quit when a syntax file was already loaded
13 if version < 600
14   syntax clear
15 elseif exists("b:current_syntax")
16   finish
17 endif
19 " OCAML is case sensitive.
20 syn case match
22 " lowercase identifier - the standard way to match
23 syn match    ocamlLCIdentifier /\<\(\l\|_\)\(\w\|'\)*\>/
25 syn match    ocamlKeyChar    "|"
27 " Errors
28 syn match    ocamlBraceErr   "}"
29 syn match    ocamlBrackErr   "\]"
30 syn match    ocamlParenErr   ")"
31 syn match    ocamlArrErr     "|]"
33 syn match    ocamlCommentErr "\*)"
35 syn match    ocamlCountErr   "\<downto\>"
36 syn match    ocamlCountErr   "\<to\>"
37 syn match    ocamlDoErr      "\<do\>"
38 syn match    ocamlDoneErr    "\<done\>"
39 syn match    ocamlThenErr    "\<then\>"
41 " Error-highlighting of "end" without synchronization:
42 " as keyword or as error (default)
43 if exists("ocaml_noend_error")
44   syn match    ocamlKeyword    "\<end\>"
45 else
46   syn match    ocamlEndErr     "\<end\>"
47 endif
49 " Some convenient clusters
50 syn cluster  ocamlAllErrs contains=ocamlBraceErr,ocamlBrackErr,ocamlParenErr,ocamlCommentErr,ocamlCountErr,ocamlDoErr,ocamlDoneErr,ocamlEndErr,ocamlThenErr
52 syn cluster  ocamlAENoParen contains=ocamlBraceErr,ocamlBrackErr,ocamlCommentErr,ocamlCountErr,ocamlDoErr,ocamlDoneErr,ocamlEndErr,ocamlThenErr
54 syn cluster  ocamlContained contains=ocamlTodo,ocamlPreDef,ocamlModParam,ocamlModParam1,ocamlPreMPRestr,ocamlMPRestr,ocamlMPRestr1,ocamlMPRestr2,ocamlMPRestr3,ocamlModRHS,ocamlFuncWith,ocamlFuncStruct,ocamlModTypeRestr,ocamlModTRWith,ocamlWith,ocamlWithRest,ocamlModType,ocamlFullMod
57 " Enclosing delimiters
58 syn region   ocamlEncl transparent matchgroup=ocamlKeyword start="(" matchgroup=ocamlKeyword end=")" contains=ALLBUT,@ocamlContained,ocamlParenErr
59 syn region   ocamlEncl transparent matchgroup=ocamlKeyword start="{" matchgroup=ocamlKeyword end="}"  contains=ALLBUT,@ocamlContained,ocamlBraceErr
60 syn region   ocamlEncl transparent matchgroup=ocamlKeyword start="\[" matchgroup=ocamlKeyword end="\]" contains=ALLBUT,@ocamlContained,ocamlBrackErr
61 syn region   ocamlEncl transparent matchgroup=ocamlKeyword start="\[|" matchgroup=ocamlKeyword end="|\]" contains=ALLBUT,@ocamlContained,ocamlArrErr
64 " Comments
65 syn region   ocamlComment start="(\*" end="\*)" contains=ocamlComment,ocamlTodo
66 syn keyword  ocamlTodo contained TODO FIXME XXX
69 " Objects
70 syn region   ocamlEnd matchgroup=ocamlKeyword start="\<object\>" matchgroup=ocamlKeyword end="\<end\>" contains=ALLBUT,@ocamlContained,ocamlEndErr
73 " Blocks
74 syn region   ocamlEnd matchgroup=ocamlKeyword start="\<begin\>" matchgroup=ocamlKeyword end="\<end\>" contains=ALLBUT,@ocamlContained,ocamlEndErr
77 " "for"
78 syn region   ocamlNone matchgroup=ocamlKeyword start="\<for\>" matchgroup=ocamlKeyword end="\<\(to\|downto\)\>" contains=ALLBUT,@ocamlContained,ocamlCountErr
81 " "do"
82 syn region   ocamlDo matchgroup=ocamlKeyword start="\<do\>" matchgroup=ocamlKeyword end="\<done\>" contains=ALLBUT,@ocamlContained,ocamlDoneErr
85 " "if"
86 syn region   ocamlNone matchgroup=ocamlKeyword start="\<if\>" matchgroup=ocamlKeyword end="\<then\>" contains=ALLBUT,@ocamlContained,ocamlThenErr
89 "" Modules
91 " "struct"
92 syn region   ocamlStruct matchgroup=ocamlModule start="\<struct\>" matchgroup=ocamlModule end="\<end\>" contains=ALLBUT,@ocamlContained,ocamlEndErr
94 " "sig"
95 syn region   ocamlSig matchgroup=ocamlModule start="\<sig\>" matchgroup=ocamlModule end="\<end\>" contains=ALLBUT,@ocamlContained,ocamlEndErr,ocamlModule
96 syn region   ocamlModSpec matchgroup=ocamlKeyword start="\<module\>" matchgroup=ocamlModule end="\<\u\(\w\|'\)*\>" contained contains=@ocamlAllErrs,ocamlComment skipwhite skipempty nextgroup=ocamlModTRWith,ocamlMPRestr
98 " "open"
99 syn region   ocamlNone matchgroup=ocamlKeyword start="\<open\>" matchgroup=ocamlModule end="\<\u\(\w\|'\)*\(\.\u\(\w\|'\)*\)*\>" contains=@ocamlAllErrs,ocamlComment
101 " "include"
102 syn region   ocamlNone matchgroup=ocamlKeyword start="\<include\>" matchgroup=ocamlModPath end="\<\(\u\(\w\|'\)*\.\)*\w\(\w\|'\)*\>" contains=o@ocamlAllErrs,camlComment
104 " "module" - somewhat complicated stuff ;-)
105 syn region   ocamlModule matchgroup=ocamlKeyword start="\<module\>" matchgroup=ocamlModule end="\<\u\(\w\|'\)*\>" contains=@ocamlAllErrs,ocamlComment skipwhite skipempty nextgroup=ocamlPreDef
106 syn region   ocamlPreDef start="."me=e-1 matchgroup=ocamlKeyword end="\l\|="me=e-1 contained contains=@ocamlAllErrs,ocamlComment,ocamlModParam,ocamlModTypeRestr,ocamlModTRWith nextgroup=ocamlModPreRHS
107 syn region   ocamlModParam start="([^*]" end=")" contained contains=@ocamlAENoParen,ocamlModParam1
108 syn match    ocamlModParam1 "\<\u\(\w\|'\)*\>" contained skipwhite skipempty nextgroup=ocamlPreMPRestr
110 syn region   ocamlPreMPRestr start="."me=e-1 end=")"me=e-1 contained contains=@ocamlAllErrs,ocamlComment,ocamlMPRestr,ocamlModTypeRestr
112 syn region   ocamlMPRestr start=":" end="."me=e-1 contained contains=@ocamlComment skipwhite skipempty nextgroup=ocamlMPRestr1,ocamlMPRestr2,ocamlMPRestr3
113 syn region   ocamlMPRestr1 matchgroup=ocamlModule start="\ssig\s\=" matchgroup=ocamlModule end="\<end\>" contained contains=ALLBUT,@ocamlContained,ocamlEndErr,ocamlModule
114 syn region   ocamlMPRestr2 start="\sfunctor\(\s\|(\)\="me=e-1 matchgroup=ocamlKeyword end="->" contained contains=@ocamlAllErrs,ocamlComment,ocamlModParam skipwhite skipempty nextgroup=ocamlFuncWith,ocamlMPRestr2
115 syn match    ocamlMPRestr3 "\w\(\w\|'\)*\(\.\w\(\w\|'\)*\)*" contained
116 syn match  ocamlModPreRHS "=" contained skipwhite skipempty nextgroup=ocamlModParam,ocamlFullMod
117 syn region  ocamlModRHS start="." end=".\w\|([^*]"me=e-2 contained contains=ocamlComment skipwhite skipempty nextgroup=ocamlModParam,ocamlFullMod
118 syn match   ocamlFullMod "\<\u\(\w\|'\)*\(\.\u\(\w\|'\)*\)*" contained skipwhite skipempty nextgroup=ocamlFuncWith
120 syn region  ocamlFuncWith start="("me=e-1 end=")" contained contains=ocamlComment,ocamlWith,ocamlFuncStruct skipwhite skipempty nextgroup=ocamlFuncWith
121 syn region  ocamlFuncStruct matchgroup=ocamlModule start="[^a-zA-Z]struct\>"hs=s+1 matchgroup=ocamlModule end="\<end\>" contains=ALLBUT,@ocamlContained,ocamlEndErr
123 syn match    ocamlModTypeRestr "\<\w\(\w\|'\)*\(\.\w\(\w\|'\)*\)*\>" contained
124 syn region   ocamlModTRWith start=":\s*("hs=s+1 end=")" contained contains=@ocamlAENoParen,ocamlWith
125 syn match    ocamlWith "\<\(\u\(\w\|'\)*\.\)*\w\(\w\|'\)*\>" contained skipwhite skipempty nextgroup=ocamlWithRest
126 syn region   ocamlWithRest start="[^)]" end=")"me=e-1 contained contains=ALLBUT,@ocamlContained
128 " "module type"
129 syn region   ocamlKeyword start="\<module\s*type\>" matchgroup=ocamlModule end="\<\w\(\w\|'\)*\>" contains=ocamlComment skipwhite skipempty nextgroup=ocamlMTDef
130 syn match    ocamlMTDef "=\s*\w\(\w\|'\)*\>"hs=s+1,me=s
132 syn keyword  ocamlKeyword  and as assert class
133 syn keyword  ocamlKeyword  constraint else
134 syn keyword  ocamlKeyword  exception external fun function
135 syn keyword  ocamlKeyword  in inherit initializer
136 syn keyword  ocamlKeyword  land lazy let match
137 syn keyword  ocamlKeyword  method mutable new of
138 syn keyword  ocamlKeyword  parser private raise rec
139 syn keyword  ocamlKeyword  try type
140 syn keyword  ocamlKeyword  val virtual when while with
142 syn keyword  ocamlType     array bool char exn float format int
143 syn keyword  ocamlType     list option string unit
145 syn keyword  ocamlOperator asr lor lsl lsr lxor mod not or
147 syn keyword  ocamlBoolean      true false
148 syn match    ocamlConstructor  "(\s*)"
149 syn match    ocamlConstructor  "\[\s*\]"
150 syn match    ocamlConstructor  "\[|\s*>|]"
151 syn match    ocamlConstructor  "\[<\s*>\]"
152 syn match    ocamlConstructor  "\u\(\w\|'\)*\>"
154 " Polymorphic variants
155 syn match    ocamlConstructor  "`\w\(\w\|'\)*\>"
157 " Module prefix
158 syn match    ocamlModPath      "\u\(\w\|'\)*\."he=e-1
160 syn match    ocamlCharacter    "'.'\|'\\\d\d\d'\|'\\[\'ntbr]'"
161 syn match    ocamlCharErr      "'\\\d\d'\|'\\\d'"
162 syn match    ocamlCharErr      "'\\[^\'ntbr]'"
163 syn region   ocamlString       start=+"+ skip=+\\\\\|\\"+ end=+"+
165 syn match    ocamlFunDef       "->"
166 syn match    ocamlRefAssign    ":="
167 syn match    ocamlTopStop      ";;"
168 syn match    ocamlOperator     "\^"
169 syn match    ocamlOperator     "::"
170 syn match    ocamlOperator     "<-"
171 syn match    ocamlAnyVar       "\<_\>"
172 syn match    ocamlKeyChar      "!"
173 syn match    ocamlKeyChar      "|[^\]]"me=e-1
174 syn match    ocamlKeyChar      ";"
175 syn match    ocamlKeyChar      "\~"
176 syn match    ocamlKeyChar      "?"
177 syn match    ocamlKeyChar      "\*"
178 syn match    ocamlKeyChar      "="
180 syn match    ocamlNumber        "\<-\=\d\+\>"
181 syn match    ocamlNumber        "\<-\=0[x|X]\x\+\>"
182 syn match    ocamlNumber        "\<-\=0[o|O]\o\+\>"
183 syn match    ocamlNumber        "\<-\=0[b|B][01]\+\>"
184 syn match    ocamlFloat         "\<-\=\d\+\.\d*\([eE][-+]\=\d\+\)\=[fl]\=\>"
186 " Labels
187 syn match    ocamlLabel        "\~\(\l\|_\)\(\w\|'\)*"lc=1
188 syn match    ocamlLabel        "?\(\l\|_\)\(\w\|'\)*"lc=1
189 syn region   ocamlLabel transparent matchgroup=ocamlLabel start="?(\(\l\|_\)\(\w\|'\)*"lc=2 end=")"me=e-1 contains=ALLBUT,@ocamlContained,ocamlParenErr
192 " Synchronization
193 syn sync minlines=50
194 syn sync maxlines=500
196 syn sync match ocamlDoSync      grouphere  ocamlDo      "\<do\>"
197 syn sync match ocamlDoSync      groupthere ocamlDo      "\<done\>"
198 syn sync match ocamlEndSync     grouphere  ocamlEnd     "\<\(begin\|object\)\>"
199 syn sync match ocamlEndSync     groupthere ocamlEnd     "\<end\>"
200 syn sync match ocamlStructSync  grouphere  ocamlStruct  "\<struct\>"
201 syn sync match ocamlStructSync  groupthere ocamlStruct  "\<end\>"
202 syn sync match ocamlSigSync     grouphere  ocamlSig     "\<sig\>"
203 syn sync match ocamlSigSync     groupthere ocamlSig     "\<end\>"
205 " Define the default highlighting.
206 " For version 5.7 and earlier: only when not done already
207 " For version 5.8 and later: only when an item doesn't have highlighting yet
208 if version >= 508 || !exists("did_ocaml_syntax_inits")
209   if version < 508
210     let did_ocaml_syntax_inits = 1
211     command -nargs=+ HiLink hi link <args>
212   else
213     command -nargs=+ HiLink hi def link <args>
214   endif
216   HiLink ocamlBraceErr     Error
217   HiLink ocamlBrackErr     Error
218   HiLink ocamlParenErr     Error
219   HiLink ocamlArrErr       Error
221   HiLink ocamlCommentErr   Error
223   HiLink ocamlCountErr     Error
224   HiLink ocamlDoErr        Error
225   HiLink ocamlDoneErr      Error
226   HiLink ocamlEndErr       Error
227   HiLink ocamlThenErr      Error
229   HiLink ocamlCharErr      Error
231   HiLink ocamlComment      Comment
233   HiLink ocamlModPath      Include
234   HiLink ocamlModule       Include
235   HiLink ocamlModParam1    Include
236   HiLink ocamlModType      Include
237   HiLink ocamlMPRestr3     Include
238   HiLink ocamlFullMod      Include
239   HiLink ocamlModTypeRestr Include
240   HiLink ocamlWith         Include
241   HiLink ocamlMTDef        Include
243   HiLink ocamlConstructor  Constant
245   HiLink ocamlModPreRHS    Keyword
246   HiLink ocamlMPRestr2     Keyword
247   HiLink ocamlKeyword      Keyword
248   HiLink ocamlFunDef       Keyword
249   HiLink ocamlRefAssign    Keyword
250   HiLink ocamlKeyChar      Keyword
251   HiLink ocamlAnyVar       Keyword
252   HiLink ocamlTopStop      Keyword
253   HiLink ocamlOperator     Keyword
255   HiLink ocamlBoolean      Boolean
256   HiLink ocamlCharacter    Character
257   HiLink ocamlNumber       Number
258   HiLink ocamlFloat        Float
259   HiLink ocamlString       String
261   HiLink ocamlLabel        Identifier
263   HiLink ocamlType         Type
265   HiLink ocamlTodo         Todo
267   HiLink ocamlEncl         Keyword
269   delcommand HiLink
270 endif
272 let b:current_syntax = "ocaml"
274 " vim: ts=28