]>
luflow.net public git repositories - flow-web.git/blob - static/highlight/es/languages/ocaml.js
1 /*! `ocaml` grammar compiled for Highlight.js 11.11.1 */
2 var hljsGrammar
= (function () {
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
14 function ocaml(hljs
) {
15 /* missing support for heredoc-like string (OCaml 4.0.2+) */
20 $pattern: '[a-z_]\\w*!?',
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 '
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',
41 begin: '\\[(\\|\\|)?\\]|\\(\\)',
47 { contains: [ 'self' ] }
51 begin: '\'[A-Za-z_](?!\')[\\w\']*'
52 /* the grammar is ambiguous on how 'a'b should be interpreted but not the compiler */
54 { /* polymorphic variant */
56 begin: '`[A-Z][\\w\']*'
58 { /* module or constructor */
60 begin: '\\b[A-Z][\\w\']*',
63 { /* don't color identifiers, but safely catch all identifiers with ' */
64 begin: '[a-z_]\\w*\'[\\w\']*',
67 hljs
.inherit(hljs
.APOS_STRING_MODE
, {
71 hljs
.inherit(hljs
.QUOTE_STRING_MODE
, { illegal: null }),
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_]+)?)?)',
81 { begin: /->/ // relevance booster
91 export default hljsGrammar
;