CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/assets/rainbow/generic.js
Views: 687
1
/*
2
* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
3
* License: MS-RSL – see LICENSE.md for details
4
*/
5
6
/**
7
* Generic language patterns
8
*
9
* @author Craig Campbell
10
* @version 1.0.9
11
*/
12
Rainbow.extend([
13
{
14
'matches': {
15
1: {
16
'name': 'keyword.operator',
17
'pattern': /\=/g
18
},
19
2: {
20
'name': 'string',
21
'matches': {
22
'name': 'constant.character.escape',
23
'pattern': /\\('|"){1}/g
24
}
25
}
26
},
27
'pattern': /(\(|\s|\[|\=|:)(('|")([^\\\1]|\\.)*?(\3))/gm
28
},
29
{
30
'name': 'comment',
31
'pattern': /\/\*[\s\S]*?\*\/|(\/\/|\#)[\s\S]*?$/gm
32
},
33
{
34
'name': 'constant.numeric',
35
'pattern': /\b(\d+(\.\d+)?(e(\+|\-)?\d+)?(f|d)?|0x[\da-f]+)\b/gi
36
},
37
{
38
'matches': {
39
1: 'keyword'
40
},
41
'pattern': /\b(and|array|as|bool(ean)?|c(atch|har|lass|onst)|d(ef|elete|o(uble)?)|e(cho|lse(if)?|xit|xtends|xcept)|f(inally|loat|or(each)?|unction)|global|if|import|int(eger)?|long|new|object|or|pr(int|ivate|otected)|public|return|self|st(ring|ruct|atic)|switch|th(en|is|row)|try|(un)?signed|var|void|while)(?=\(|\b)/gi
42
},
43
{
44
'name': 'constant.language',
45
'pattern': /true|false|null/g
46
},
47
{
48
'name': 'keyword.operator',
49
'pattern': /\+|\!|\-|&(gt|lt|amp);|\||\*|\=/g
50
},
51
{
52
'matches': {
53
1: 'function.call'
54
},
55
'pattern': /(\w+?)(?=\()/g
56
},
57
{
58
'matches': {
59
1: 'storage.function',
60
2: 'entity.name.function'
61
},
62
'pattern': /(function)\s(.*?)(?=\()/g
63
}
64
]);
65
66