]> luflow.net public git repositories - flow-web.git/blob - static/highlight/es/languages/ocaml.js
Initial commit.
[flow-web.git] / static / highlight / es / languages / ocaml.js
1 /*! `ocaml` grammar compiled for Highlight.js 11.11.1 */
2 var hljsGrammar = (function () {
3 'use strict';
4
5 /*
6 Language: OCaml
7 Author: Mehdi Dogguy <mehdi@dogguy.org>
8 Contributors: Nicolas Braud-Santoni <nicolas.braud-santoni@ens-cachan.fr>, Mickael Delahaye <mickael.delahaye@gmail.com>
9 Description: OCaml language definition.
10 Website: https://ocaml.org
11 Category: functional
12 */
13
14 function ocaml(hljs) {
15 /* missing support for heredoc-like string (OCaml 4.0.2+) */
16 return {
17 name: 'OCaml',
18 aliases: [ 'ml' ],
19 keywords: {
20 $pattern: '[a-z_]\\w*!?',
21 keyword:
22 'and as assert asr begin class constraint do done downto else end '
23 + 'exception external for fun function functor if in include '
24 + 'inherit! inherit initializer land lazy let lor lsl lsr lxor match method!|10 method '
25 + 'mod module mutable new object of open! open or private rec sig struct '
26 + 'then to try type val! val virtual when while with '
27 /* camlp4 */
28 + 'parser value',
29 built_in:
30 /* built-in types */
31 'array bool bytes char exn|5 float int int32 int64 list lazy_t|5 nativeint|5 string unit '
32 /* (some) types in Pervasives */
33 + 'in_channel out_channel ref',
34 literal:
35 'true false'
36 },
37 illegal: /\/\/|>>/,
38 contains: [
39 {
40 className: 'literal',
41 begin: '\\[(\\|\\|)?\\]|\\(\\)',
42 relevance: 0
43 },
44 hljs.COMMENT(
45 '\\(\\*',
46 '\\*\\)',
47 { contains: [ 'self' ] }
48 ),
49 { /* type variable */
50 className: 'symbol',
51 begin: '\'[A-Za-z_](?!\')[\\w\']*'
52 /* the grammar is ambiguous on how 'a'b should be interpreted but not the compiler */
53 },
54 { /* polymorphic variant */
55 className: 'type',
56 begin: '`[A-Z][\\w\']*'
57 },
58 { /* module or constructor */
59 className: 'type',
60 begin: '\\b[A-Z][\\w\']*',
61 relevance: 0
62 },
63 { /* don't color identifiers, but safely catch all identifiers with ' */
64 begin: '[a-z_]\\w*\'[\\w\']*',
65 relevance: 0
66 },
67 hljs.inherit(hljs.APOS_STRING_MODE, {
68 className: 'string',
69 relevance: 0
70 }),
71 hljs.inherit(hljs.QUOTE_STRING_MODE, { illegal: null }),
72 {
73 className: 'number',
74 begin:
75 '\\b(0[xX][a-fA-F0-9_]+[Lln]?|'
76 + '0[oO][0-7_]+[Lln]?|'
77 + '0[bB][01_]+[Lln]?|'
78 + '[0-9][0-9_]*([Lln]|(\\.[0-9_]*)?([eE][-+]?[0-9_]+)?)?)',
79 relevance: 0
80 },
81 { begin: /->/ // relevance booster
82 }
83 ]
84 };
85 }
86
87 return ocaml;
88
89 })();
90 ;
91 export default hljsGrammar;