1<?xml version="1.0" encoding="UTF-8"?>
2<!-- vim: set sts=2 sw=2: -->
3<!--
4
5 This file is part of GtkSourceView
6
7 Author: Eric Cooper <ecc@cmu.edu>
8 Copyright (C) 2007 Eric Cooper <ecc@cmu.edu>
9 Copyright (C) 2007 Eric Norige <thelema314@gmail.com>
10 Copyright (C) 2009 Alexandr Kuleshov <sterh@live.ru>
11
12 GtkSourceView is free software; you can redistribute it and/or
13 modify it under the terms of the GNU Lesser General Public
14 License as published by the Free Software Foundation; either
15 version 2.1 of the License, or (at your option) any later version.
16
17 GtkSourceView is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20 Lesser General Public License for more details.
21
22 You should have received a copy of the GNU Lesser General Public License
23 along with this library; if not, see <http://www.gnu.org/licenses/>.
24
25-->
26<language id="ocaml" name="OCaml" version="2.0" _section="Source">
27  <metadata>
28    <property name="mimetypes">text/x-ocaml</property>
29    <property name="globs">*.ml;*.mli;*.mll;*.mly</property>
30    <property name="block-comment-start">(*</property>
31    <property name="block-comment-end">*)</property>
32  </metadata>
33
34  <styles>
35    <style id="comment" name="Comment" map-to="def:comment"/>
36    <style id="ocamldoc" name="Ocamldoc Comments" map-to="def:note"/>
37    <style id="base-n-integer" name="Base-N Integer" map-to="def:base-n-integer"/>
38    <style id="floating-point" name="Floating Point number" map-to="def:floating-point"/>
39    <style id="decimal" name="Decimal number" map-to="def:decimal"/>
40    <style id="string" name="String" map-to="def:string"/>
41    <style id="keyword" name="Keyword" map-to="def:keyword"/>
42    <style id="meta-keyword" name="Type, module or object keyword" map-to="def:keyword"/>
43    <style id="fun-keyword" name="Builtin-function keyword" map-to="def:keyword"/>
44    <style id="type" name="Data Type" map-to="def:type"/>
45    <style id="label" name="Labeled argument" map-to="def:type"/>
46    <style id="poly-variant" name="Polymorphic Variant" map-to="def:type"/>
47    <style id="variant" name="Variant Constructor" map-to="def:type"/>
48    <style id="type-var" name="Type Variable" map-to="def:type"/>
49    <style id="module" name="Module Path" map-to="def:type"/>
50    <style id="escape" name="Escaped Character" map-to="def:special-char"/>
51    <style id="boolean" name="Boolean value" map-to="def:boolean"/>
52    <style id="error" name="Error" map-to="def:error"/>
53    <style id="std-modules" name="Standard Modules" map-to="def:type"/>
54  </styles>
55
56  <definitions>
57    <define-regex id="cap-ident">\b[A-Z][A-Za-z0-9_']*</define-regex>
58    <define-regex id="low-ident">\b[a-z][A-Za-z0-9_']*</define-regex>
59    <define-regex id="char-esc">\\((\\|"|'|n|t|b|r)|[0-9]{3}|x[0-9a-fA-F]{2})</define-regex>
60
61    <context id="escape-seq" style-ref="escape">
62      <match>\%{char-esc}</match>
63    </context>
64
65    <!-- here's the main context -->
66    <context id="ocaml" class="no-spell-check">
67      <include>
68	<context id="ocamldoc" style-ref="ocamldoc">
69	  <start>\(\*\*(?!\))</start>
70	  <end>\*\)</end>
71	  <include>
72	    <context id="comment-in-comment" style-ref="comment" class="comment" class-disabled="no-spell-check">
73	      <start>\(\*</start>
74	      <end>\*\)</end>
75	      <include>
76		<context ref="string"/>
77		<context ref="comment-in-comment"/>
78		<context ref="def:in-comment:*"/>
79	      </include>
80	    </context>
81	    <context ref="string"/>
82	    <context ref="def:in-comment:*"/>
83	  </include>
84	</context>
85	<context id="comment" style-ref="comment" class="comment" class-disabled="no-spell-check">
86	  <start>\(\*</start>
87	  <end>\*\)</end>
88	  <include>
89	    <context ref="string"/>
90	    <context ref="comment-in-comment"/>
91	    <context ref="def:in-comment:*"/>
92	  </include>
93	</context>
94	<context id="hex-number" style-ref="base-n-integer">
95	  <match>[-]?0[xX][0-9A-Fa-f][0-9A-Fa-f_]*[lL]?</match>
96	</context>
97	<context id="octal-number" style-ref="base-n-integer">
98	  <match>[-]?0[oO][0-7][0-7_]*[lL]?</match>
99	</context>
100	<context id="binary-number" style-ref="base-n-integer">
101	  <match>[-]?0[bB][01][01_]*[lL]?</match>
102	</context>
103	<context id="decimal" style-ref="decimal">
104	  <match>[-]?[0-9][0-9_]*[lLn]?</match>
105	</context>
106	<context id="floating-point-number" style-ref="floating-point">
107	  <match>[-]?[0-9][0-9_]*(\.[0-9_]*)?([Ee][+-]?[0-9][0-9_]*)?</match>
108	</context>
109	<context id="label" style-ref="label">
110	  <match>[~?]\%{low-ident}</match>
111	</context>
112	<context id="poly-variant" style-ref="poly-variant">
113	  <match>`\%{cap-ident}</match>
114	</context>
115	<context id="modpath" style-ref="module">
116	  <!-- include final '.'?  At the moment, no.  -->
117	  <match>\%{cap-ident}(\.\%{cap-ident})*(?=\.)</match>
118	</context>
119	<context id="variant" style-ref="variant">
120	  <match>\%{cap-ident}</match>
121	</context>
122	<context id="string" style-ref="string">
123	  <start>"</start>
124	  <end>"</end>
125	  <include>
126	    <context ref="escape-seq"/>
127	  </include>
128	</context>
129	<context id="character-constant" style-ref="string">
130	  <match>('\%{char-esc}')|('[^\\']')</match>
131	</context>
132	<context id="type-var" style-ref="type-var">
133	  <match>'\%{low-ident}</match>
134	</context>
135	<context id="arraylit">
136	  <start>\[\|</start>
137	  <end>\|\]</end>
138	  <include>
139	    <context ref="ocaml"/>
140	  </include>
141	</context>
142	<context id="badarray" style-ref="error" extend-parent="false">
143	  <match>\|\]</match>
144	</context>
145	<context id="listlit">
146	  <start>\[</start>
147	  <end>(?&lt;!\|)\]</end>
148	  <include>
149	    <context ref="ocaml"/>
150	  </include>
151	</context>
152	<context id="badlist" style-ref="error" extend-parent="false">
153	  <match>\]</match>
154	</context>
155	<context id="boolean-constant" style-ref="boolean">
156	  <keyword>true</keyword>
157	  <keyword>false</keyword>
158	</context>
159	<!-- Flow control & common keywords -->
160	<context id="keywords" style-ref="keyword">
161	  <keyword>and</keyword>
162	  <keyword>assert</keyword>
163	  <keyword>begin</keyword>
164	  <keyword>do</keyword>
165	  <keyword>done</keyword>
166	  <keyword>downto</keyword>
167	  <keyword>else</keyword>
168	  <keyword>end</keyword>
169	  <keyword>for</keyword>
170	  <keyword>fun</keyword>
171	  <keyword>function</keyword>
172	  <keyword>if</keyword>
173	  <keyword>in</keyword>
174	  <keyword>let</keyword>
175	  <keyword>match</keyword>
176	  <keyword>rec</keyword>
177	  <keyword>then</keyword>
178	  <keyword>to</keyword>
179	  <keyword>try</keyword>
180	  <keyword>val</keyword>
181	  <keyword>when</keyword>
182	  <keyword>while</keyword>
183	  <keyword>with</keyword>
184	</context>
185	<!-- types, objects and modules -->
186	<context id="meta-words" style-ref="meta-keyword">
187	  <keyword>as</keyword>
188	  <keyword>class</keyword>
189	  <keyword>constraint</keyword>
190	  <keyword>exception</keyword>
191	  <keyword>external</keyword>
192	  <keyword>functor</keyword>
193	  <keyword>include</keyword>
194	  <keyword>inherit</keyword>
195	  <keyword>initializer</keyword>
196	  <keyword>method</keyword>
197	  <keyword>module</keyword>
198	  <keyword>mutable</keyword>
199	  <keyword>new</keyword>
200	  <keyword>object</keyword>
201	  <keyword>of</keyword>
202	  <keyword>open</keyword>
203	  <keyword>private</keyword>
204	  <keyword>struct</keyword>
205	  <keyword>sig</keyword>
206	  <keyword>type</keyword>
207	  <keyword>virtual</keyword>
208	</context>
209	<context id="function-keywords" style-ref="fun-keyword">
210	  <!-- function-like keywords -->
211	  <keyword>asr</keyword>
212	  <keyword>land</keyword>
213	  <keyword>lazy</keyword>
214	  <keyword>lor</keyword>
215	  <keyword>lsl</keyword>
216	  <keyword>lsr</keyword>
217	  <keyword>lxor</keyword>
218	  <keyword>mod</keyword>
219	  <keyword>or</keyword>
220	  <!-- from pervasives, but same as others -->
221	  <keyword>lnot</keyword>
222	</context>
223	<context id="types" style-ref="type">
224	  <!-- pervasives types -->
225	  <keyword>option</keyword>
226	  <keyword>ignore</keyword>
227	  <keyword>ref</keyword>
228	  <keyword>array</keyword>
229	  <keyword>bool</keyword>
230	  <keyword>char</keyword>
231	  <keyword>float</keyword>
232	  <keyword>int</keyword>
233	  <keyword>list</keyword>
234	  <keyword>string</keyword>
235	  <keyword>unit</keyword>
236	</context>
237	<context id="standart-modules" style-ref="std-modules">
238	  <!--Standart modules -->
239	  <keyword>Arg</keyword>
240	  <keyword>Arith_status</keyword>
241	  <keyword>Array</keyword>
242	  <keyword>ArrayLabels</keyword>
243	  <keyword>Big_int</keyword>
244	  <keyword>Bigarray</keyword>
245	  <keyword>Buffer</keyword>
246	  <keyword>Callback</keyword>
247	  <keyword>CamlinternalMod</keyword>
248	  <keyword>CamlinternalOO</keyword>
249	  <keyword>Char</keyword>
250	  <keyword>Complex</keyword>
251	  <keyword>Condition</keyword>
252	  <keyword>Dbm</keyword>
253	  <keyword>Digest</keyword>
254	  <keyword>DynLink</keyword>
255	  <keyword>Event</keyword>
256	  <keyword>Filename</keyword>
257	  <keyword>Format</keyword>
258	  <keyword>Gc</keyword>
259	  <keyword>Genlex</keyword>
260	  <keyword>Graphics</keyword>
261	  <keyword>GraphicsX11</keyword>
262	  <keyword>Hashtbl</keyword>
263	  <keyword>Int32</keyword>
264	  <keyword>Int64</keyword>
265	  <keyword>LargeFile</keyword>
266	  <keyword>Lazy</keyword>
267	  <keyword>Lexing</keyword>
268	  <keyword>List</keyword>
269	  <keyword>ListLabels</keyword>
270	  <keyword>Map</keyword>
271	  <keyword>Marshal</keyword>
272	  <keyword>MoreLabels</keyword>
273	  <keyword>Mutex</keyword>
274	  <keyword>Mativeint</keyword>
275	  <keyword>Num</keyword>
276	  <keyword>Oo</keyword>
277	  <keyword>Parsing</keyword>
278	  <keyword>Printexc</keyword>
279	  <keyword>Printf</keyword>
280	  <keyword>Queue</keyword>
281	  <keyword>Random</keyword>
282	  <keyword>Scanf</keyword>
283	  <keyword>Set</keyword>
284	  <keyword>Sort</keyword>
285	  <keyword>Stack</keyword>
286	  <keyword>StdLabels</keyword>
287	  <keyword>Str</keyword>
288	  <keyword>Stream</keyword>
289	  <keyword>StringLabels</keyword>
290	  <keyword>Sys</keyword>
291	  <keyword>Thread</keyword>
292	  <keyword>ThreadUnix</keyword>
293	  <keyword>Unix</keyword>
294	  <keyword>UnixLabels</keyword>
295	  <keyword>Weak</keyword>
296	  <!-- Standart modules -->
297	</context>
298      </include>
299    </context>
300  </definitions>
301</language>
302