]>
luflow.net public git repositories - flow-web.git/blob - static/highlight/languages/ocaml.js
1 /*! `ocaml` grammar compiled for Highlight.js 11.11.1 */
3 var hljsGrammar
= (function () {
8 Author: Mehdi Dogguy <mehdi@dogguy.org>
9 Contributors: Nicolas Braud-Santoni <nicolas.braud-santoni@ens-cachan.fr>, Mickael Delahaye <mickael.delahaye@gmail.com>
10 Description: OCaml language definition.
11 Website: https://ocaml.org
15 function ocaml(hljs
) {
16 /* missing support for heredoc-like string (OCaml 4.0.2+) */
21 $pattern: '[a-z_]\\w*!?',
23 'and as assert asr begin class constraint do done downto else end '
24 + 'exception external for fun function functor if in include '
25 + 'inherit! inherit initializer land lazy let lor lsl lsr lxor match method!|10 method '
26 + 'mod module mutable new object of open! open or private rec sig struct '
27 + 'then to try type val! val virtual when while with '
32 'array bool bytes char exn|5 float int int32 int64 list lazy_t|5 nativeint|5 string unit '
33 /* (some) types in Pervasives */
34 + 'in_channel out_channel ref',
42 begin: '\\[(\\|\\|)?\\]|\\(\\)',
48 { contains: [ 'self' ] }
52 begin: '\'[A-Za-z_](?!\')[\\w\']*'
53 /* the grammar is ambiguous on how 'a'b should be interpreted but not the compiler */
55 { /* polymorphic variant */
57 begin: '`[A-Z][\\w\']*'
59 { /* module or constructor */
61 begin: '\\b[A-Z][\\w\']*',
64 { /* don't color identifiers, but safely catch all identifiers with ' */
65 begin: '[a-z_]\\w*\'[\\w\']*',
68 hljs
.inherit(hljs
.APOS_STRING_MODE
, {
72 hljs
.inherit(hljs
.QUOTE_STRING_MODE
, { illegal: null }),
76 '\\b(0[xX][a-fA-F0-9_]+[Lln]?|'
77 + '0[oO][0-7_]+[Lln]?|'
78 + '0[bB][01_]+[Lln]?|'
79 + '[0-9][0-9_]*([Lln]|(\\.[0-9_]*)?([eE][-+]?[0-9_]+)?)?)',
82 { begin: /->/ // relevance booster
92 hljs
.registerLanguage('ocaml', hljsGrammar
);