]> luflow.net public git repositories - flow-web.git/blob - static/highlight/languages/sml.js
Initial commit.
[flow-web.git] / static / highlight / languages / sml.js
1 /*! `sml` grammar compiled for Highlight.js 11.11.1 */
2 (function(){
3 var hljsGrammar = (function () {
4 'use strict';
5
6 /*
7 Language: SML (Standard ML)
8 Author: Edwin Dalorzo <edwin@dalorzo.org>
9 Description: SML language definition.
10 Website: https://www.smlnj.org
11 Origin: ocaml.js
12 Category: functional
13 */
14 function sml(hljs) {
15 return {
16 name: 'SML (Standard ML)',
17 aliases: [ 'ml' ],
18 keywords: {
19 $pattern: '[a-z_]\\w*!?',
20 keyword:
21 /* according to Definition of Standard ML 97 */
22 'abstype and andalso as case datatype do else end eqtype '
23 + 'exception fn fun functor handle if in include infix infixr '
24 + 'let local nonfix of op open orelse raise rec sharing sig '
25 + 'signature struct structure then type val with withtype where while',
26 built_in:
27 /* built-in types according to basis library */
28 'array bool char exn int list option order real ref string substring vector unit word',
29 literal:
30 'true false NONE SOME LESS EQUAL GREATER nil'
31 },
32 illegal: /\/\/|>>/,
33 contains: [
34 {
35 className: 'literal',
36 begin: /\[(\|\|)?\]|\(\)/,
37 relevance: 0
38 },
39 hljs.COMMENT(
40 '\\(\\*',
41 '\\*\\)',
42 { contains: [ 'self' ] }
43 ),
44 { /* type variable */
45 className: 'symbol',
46 begin: '\'[A-Za-z_](?!\')[\\w\']*'
47 /* the grammar is ambiguous on how 'a'b should be interpreted but not the compiler */
48 },
49 { /* polymorphic variant */
50 className: 'type',
51 begin: '`[A-Z][\\w\']*'
52 },
53 { /* module or constructor */
54 className: 'type',
55 begin: '\\b[A-Z][\\w\']*',
56 relevance: 0
57 },
58 { /* don't color identifiers, but safely catch all identifiers with ' */
59 begin: '[a-z_]\\w*\'[\\w\']*' },
60 hljs.inherit(hljs.APOS_STRING_MODE, {
61 className: 'string',
62 relevance: 0
63 }),
64 hljs.inherit(hljs.QUOTE_STRING_MODE, { illegal: null }),
65 {
66 className: 'number',
67 begin:
68 '\\b(0[xX][a-fA-F0-9_]+[Lln]?|'
69 + '0[oO][0-7_]+[Lln]?|'
70 + '0[bB][01_]+[Lln]?|'
71 + '[0-9][0-9_]*([Lln]|(\\.[0-9_]*)?([eE][-+]?[0-9_]+)?)?)',
72 relevance: 0
73 },
74 { begin: /[-=]>/ // relevance booster
75 }
76 ]
77 };
78 }
79
80 return sml;
81
82 })();
83
84 hljs.registerLanguage('sml', hljsGrammar);
85 })();