-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgleam.js
54 lines (43 loc) · 1.13 KB
/
gleam.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
// Up to date as of Gleam v1.6.3
Prism.languages.gleam = {
comment: {
pattern: /\/\/\/?.*/,
greedy: true,
},
tag: /@(deprecated|external|internal)/,
target: {
pattern: /\b(erlang|javascript)\b/,
alias: "symbol",
},
function: /\b(?<!@)([a-z_][a-z0-9_]+)(?=\()/,
// Keyword list taken from https://github.com/gleam-lang/gleam/blob/v1.6.3/compiler-core/src/parse/lexer.rs#L23
keyword:
/\b(as|assert|auto|case|const|delegate|derive|echo|else|fn|if|implement|import|let|macro|opaque|panic|pub|test|todo|type|use)\b/,
number:
/\b(?:\d[\d_]*(\\.[\d_]*(e-?[\d_]+)?)?|0[bB][01_]+|0[oO][0-7_]+|0[xX][\da-fA-F_]+)\b/,
type: {
pattern: /(?:[A-Z][A-Za-z0-9_]+)/,
greedy: true,
alias: "symbol",
},
namespace: {
pattern: /(?:[a-z][a-z0-9_]*)\.(?!{)/,
inside: {
punctuation: /\./,
},
},
punctuation: /[:!,{}()\[\]]/,
operator: {
pattern:
/(<<|>>|<-|->|\|>|<>|\.\.|<=\.?|>=\.?|==\.?|!=\.?|<\.?|>\.?|&&|\|\||\+\.?|-\.?|\/\.?|\*\.?|%|=|\|)/,
greedy: true,
},
boolean: /\b(?:True|False|Ok|Error|Nil)\b/,
string: {
pattern: /"[\s\S]*?(?<!\\)"/,
inside: {
punctuation: /\\./,
},
greedy: true,
},
};