]> luflow.net public git repositories - flow-web.git/blob - static/highlight/languages/reasonml.js
Initial commit.
[flow-web.git] / static / highlight / languages / reasonml.js
1 /*! `reasonml` grammar compiled for Highlight.js 11.11.1 */
2 (function(){
3 var hljsGrammar = (function () {
4 'use strict';
5
6 /*
7 Language: ReasonML
8 Description: Reason lets you write simple, fast and quality type safe code while leveraging both the JavaScript & OCaml ecosystems.
9 Website: https://reasonml.github.io
10 Author: Gidi Meir Morris <oss@gidi.io>
11 Category: functional
12 */
13 function reasonml(hljs) {
14 const BUILT_IN_TYPES = [
15 "array",
16 "bool",
17 "bytes",
18 "char",
19 "exn|5",
20 "float",
21 "int",
22 "int32",
23 "int64",
24 "list",
25 "lazy_t|5",
26 "nativeint|5",
27 "ref",
28 "string",
29 "unit",
30 ];
31 return {
32 name: 'ReasonML',
33 aliases: [ 're' ],
34 keywords: {
35 $pattern: /[a-z_]\w*!?/,
36 keyword: [
37 "and",
38 "as",
39 "asr",
40 "assert",
41 "begin",
42 "class",
43 "constraint",
44 "do",
45 "done",
46 "downto",
47 "else",
48 "end",
49 "esfun",
50 "exception",
51 "external",
52 "for",
53 "fun",
54 "function",
55 "functor",
56 "if",
57 "in",
58 "include",
59 "inherit",
60 "initializer",
61 "land",
62 "lazy",
63 "let",
64 "lor",
65 "lsl",
66 "lsr",
67 "lxor",
68 "mod",
69 "module",
70 "mutable",
71 "new",
72 "nonrec",
73 "object",
74 "of",
75 "open",
76 "or",
77 "pri",
78 "pub",
79 "rec",
80 "sig",
81 "struct",
82 "switch",
83 "then",
84 "to",
85 "try",
86 "type",
87 "val",
88 "virtual",
89 "when",
90 "while",
91 "with",
92 ],
93 built_in: BUILT_IN_TYPES,
94 literal: ["true", "false"],
95 },
96 illegal: /(:-|:=|\$\{|\+=)/,
97 contains: [
98 {
99 scope: 'literal',
100 match: /\[(\|\|)?\]|\(\)/,
101 relevance: 0
102 },
103 hljs.C_LINE_COMMENT_MODE,
104 hljs.COMMENT(/\/\*/, /\*\//, { illegal: /^(#,\/\/)/ }),
105 { /* type variable */
106 scope: 'symbol',
107 match: /\'[A-Za-z_](?!\')[\w\']*/
108 /* the grammar is ambiguous on how 'a'b should be interpreted but not the compiler */
109 },
110 { /* polymorphic variant */
111 scope: 'type',
112 match: /`[A-Z][\w\']*/
113 },
114 { /* module or constructor */
115 scope: 'type',
116 match: /\b[A-Z][\w\']*/,
117 relevance: 0
118 },
119 { /* don't color identifiers, but safely catch all identifiers with ' */
120 match: /[a-z_]\w*\'[\w\']*/,
121 relevance: 0
122 },
123 {
124 scope: 'operator',
125 match: /\s+(\|\||\+[\+\.]?|\*[\*\/\.]?|\/[\.]?|\.\.\.|\|>|&&|===?)\s+/,
126 relevance: 0
127 },
128 hljs.inherit(hljs.APOS_STRING_MODE, {
129 scope: 'string',
130 relevance: 0
131 }),
132 hljs.inherit(hljs.QUOTE_STRING_MODE, { illegal: null }),
133 {
134 scope: 'number',
135 variants: [
136 { match: /\b0[xX][a-fA-F0-9_]+[Lln]?/ },
137 { match: /\b0[oO][0-7_]+[Lln]?/ },
138 { match: /\b0[bB][01_]+[Lln]?/ },
139 { match: /\b[0-9][0-9_]*([Lln]|(\.[0-9_]*)?([eE][-+]?[0-9_]+)?)/ },
140 ],
141 relevance: 0
142 },
143 ]
144 };
145 }
146
147 return reasonml;
148
149 })();
150
151 hljs.registerLanguage('reasonml', hljsGrammar);
152 })();