-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Expand file tree
/
Copy pathgleam.js
More file actions
36 lines (26 loc) · 942 Bytes
/
gleam.js
File metadata and controls
36 lines (26 loc) · 942 Bytes
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
Prism.languages.gleam = {
// doc comments first so /// isn't matched as //
'comment': [
/\/\/{3,4}.*/,
/\/\/.*/
],
'string': {
pattern: /"(?:\\.|[^"\\])*"/,
greedy: true
},
'attribute': {
pattern: /@\w+/,
alias: 'annotation'
},
'keyword': /\b(?:as|assert|case|const|echo|else|fn|if|import|let|opaque|panic|pub|todo|type|use)\b/,
'boolean': /\b(?:True|False)\b/,
// keep before class-name so builtins are highlighted correctly
'builtin': /\b(?:Int|Float|String|Bool|List|Result|Option|Nil)\b/,
// heuristic: matches types and constructors (no AST available)
'class-name': /\b[A-Z]\w*\b/,
'number': /\b(?:0b[01][01_]*|0o[0-7][0-7_]*|0x[\da-fA-F][\da-fA-F_]*|\d[\d_]*(?:\.[\d_]+)?(?:[eE][+-]?\d[\d_]*)?)\b/,
// best-effort: identifier followed by (
'function': /\b[a-z_]\w*(?=\s*\()/,
'operator': /\|>|<>|->|<-|\.\.|\+\.|-\.|\*\.|\/\.|==|!=|<=|>=|&&|\|\||[+\-*\/%<>=!]/,
'punctuation': /[{}[\](),.:;#]/
};