-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
109 lines (108 loc) · 2.34 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
module.exports = function (hljs) {
const KEYWORDS = {
className: "keyword",
beginKeywords:
"as assert auto case const delegate derive echo else fn if " +
"implement import let macro opaque panic pub test todo type use",
};
const STRING = {
className: "string",
variants: [{ begin: /"/, end: /"/ }],
contains: [hljs.BACKSLASH_ESCAPE],
relevance: 0,
};
const NAME = {
className: "variable",
begin: "\\b[a-z][a-z0-9_]*\\b",
relevance: 0,
};
const DISCARD_NAME = {
className: "comment",
begin: "\\b_[a-z][a-z0-9_]*\\b",
relevance: 0,
};
const NUMBER = {
className: "number",
variants: [
{
// binary
begin: "\\b0[bB](?:_?[01]+)+",
},
{
// octal
begin: "\\b0[oO](?:_?[0-7]+)+",
},
{
// hex
begin: "\\b0[xX](?:_?[0-9a-fA-F]+)+",
},
{
// dec, float
begin: "\\b\\d(?:_?\\d+)*(?:\\.(?:\\d(?:_?\\d+)*)*)?",
},
],
relevance: 0,
};
return {
name: "Gleam",
aliases: ["gleam"],
contains: [
hljs.C_LINE_COMMENT_MODE,
STRING,
{
// bit array
begin: "<<",
end: ">>",
contains: [
{
className: "keyword",
beginKeywords:
"binary bits bytes int float bit_string bit_array bits utf8 utf16 " +
"utf32 utf8_codepoint utf16_codepoint utf32_codepoint signed " +
"unsigned big little native unit size",
},
KEYWORDS,
STRING,
NAME,
DISCARD_NAME,
NUMBER,
],
relevance: 10,
},
{
className: "function",
beginKeywords: "fn",
end: "\\(",
excludeEnd: true,
contains: [
{
className: "title",
begin: "[a-z][a-z0-9_]*\\w*",
relevance: 0,
},
],
},
{
className: "attribute",
begin: "@",
end: "\\(",
excludeEnd: true,
},
KEYWORDS,
{
// Type names and constructors
className: "title",
begin: "\\b[A-Z][A-Za-z0-9]*\\b",
relevance: 0,
},
{
className: "operator",
begin: "[+\\-*/%!=<>&|.]+",
relevance: 0,
},
NAME,
DISCARD_NAME,
NUMBER,
],
};
};