1 |
|
2 |
|
3 | (function (Prism) {
|
4 |
|
5 | var keywords = /\b(?:abstype|and|andalso|as|case|datatype|do|else|end|eqtype|exception|fn|fun|functor|handle|if|in|include|infix|infixr|let|local|nonfix|of|op|open|orelse|raise|rec|sharing|sig|signature|struct|structure|then|type|val|where|while|with|withtype)\b/i;
|
6 |
|
7 | Prism.languages.sml = {
|
8 |
|
9 | 'comment': /\(\*(?:[^*(]|\*(?!\))|\((?!\*)|\(\*(?:[^*(]|\*(?!\))|\((?!\*))*\*\))*\*\)/,
|
10 | 'string': {
|
11 | pattern: /#?"(?:[^"\\]|\\.)*"/,
|
12 | greedy: true
|
13 | },
|
14 |
|
15 | 'class-name': [
|
16 | {
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 | pattern: RegExp(
|
24 | /((?:^|[^:]):\s*)<TERMINAL>(?:\s*(?:(?:\*|->)\s*<TERMINAL>|,\s*<TERMINAL>(?:(?=<NOT-LAST>)|(?!<NOT-LAST>)\s+<LONG-ID>)))*/.source
|
25 | .replace(/<NOT-LAST>/g, function () { return /\s*(?:[*,]|->)/.source; })
|
26 | .replace(/<TERMINAL>/g, function () {
|
27 | return /(?:'[\w']*|<LONG-ID>|\((?:[^()]|\([^()]*\))*\)|\{(?:[^{}]|\{[^{}]*\})*\})(?:\s+<LONG-ID>)*/.source;
|
28 | })
|
29 | .replace(/<LONG-ID>/g, function () { return /(?!<KEYWORD>)[a-z\d_][\w'.]*/.source; })
|
30 | .replace(/<KEYWORD>/g, function () { return keywords.source; }),
|
31 | 'i'
|
32 | ),
|
33 | lookbehind: true,
|
34 | greedy: true,
|
35 | inside: null // see below
|
36 | },
|
37 | {
|
38 | pattern: /((?:^|[^\w'])(?:datatype|exception|functor|signature|structure|type)\s+)[a-z_][\w'.]*/i,
|
39 | lookbehind: true
|
40 | }
|
41 | ],
|
42 | 'function': {
|
43 | pattern: /((?:^|[^\w'])fun\s+)[a-z_][\w'.]*/i,
|
44 | lookbehind: true
|
45 | },
|
46 |
|
47 | 'keyword': keywords,
|
48 | 'variable': {
|
49 | pattern: /(^|[^\w'])'[\w']*/,
|
50 | lookbehind: true,
|
51 | },
|
52 |
|
53 | 'number': /~?\b(?:\d+(?:\.\d+)?(?:e~?\d+)?|0x[\da-f]+)\b/i,
|
54 | 'word': {
|
55 | pattern: /\b0w(?:\d+|x[\da-f]+)\b/i,
|
56 | alias: 'constant'
|
57 | },
|
58 |
|
59 | 'boolean': /\b(?:false|true)\b/i,
|
60 | 'operator': /\.\.\.|:[>=:]|=>?|->|[<>]=?|[!+\-*/^#|@~]/,
|
61 | 'punctuation': /[(){}\[\].:,;]/
|
62 | };
|
63 |
|
64 | Prism.languages.sml['class-name'][0].inside = Prism.languages.sml;
|
65 |
|
66 | Prism.languages.smlnj = Prism.languages.sml;
|
67 |
|
68 | }(Prism));
|