motoko 2.0.6 → 2.0.7
Sign up to get free protection for your applications and to get access to all the features.
- package/contrib/monaco.js +65 -52
- package/package.json +1 -1
package/contrib/monaco.js
CHANGED
@@ -1,44 +1,44 @@
|
|
1
|
-
'use strict'
|
1
|
+
'use strict';
|
2
2
|
|
3
3
|
/// Monaco editor configuration
|
4
4
|
exports.configure = (monaco) => {
|
5
|
-
monaco.languages.register({ id:
|
6
|
-
monaco.languages.setLanguageConfiguration(
|
5
|
+
monaco.languages.register({ id: 'motoko' });
|
6
|
+
monaco.languages.setLanguageConfiguration('motoko', {
|
7
7
|
comments: {
|
8
|
-
lineComment:
|
9
|
-
blockComment: [
|
8
|
+
lineComment: '//',
|
9
|
+
blockComment: ['/*', '*/'],
|
10
10
|
},
|
11
11
|
brackets: [
|
12
|
-
[
|
13
|
-
[
|
14
|
-
[
|
12
|
+
['{', '}'],
|
13
|
+
['[', ']'],
|
14
|
+
['(', ')'],
|
15
15
|
],
|
16
16
|
autoClosingPairs: [
|
17
|
-
{ open:
|
18
|
-
{ open:
|
19
|
-
{ open:
|
17
|
+
{ open: '{', close: '}' },
|
18
|
+
{ open: '[', close: ']' },
|
19
|
+
{ open: '(', close: ')' },
|
20
20
|
{ open: '"', close: '"' },
|
21
|
-
{ open:
|
21
|
+
{ open: '<', close: '>' },
|
22
22
|
],
|
23
23
|
});
|
24
|
-
monaco.languages.setMonarchTokensProvider(
|
25
|
-
defaultToken:
|
26
|
-
tokenPostfix:
|
24
|
+
monaco.languages.setMonarchTokensProvider('motoko', {
|
25
|
+
defaultToken: '',
|
26
|
+
tokenPostfix: '.mo',
|
27
27
|
// prettier-ignore
|
28
28
|
keywords: [
|
29
29
|
'actor', 'and', 'async', 'assert', 'await', 'break', 'case', 'catch', 'class',
|
30
|
-
'continue', 'debug', 'debug_show', 'do', 'else', 'false', 'for', 'from_candid', 'func', 'if', 'ignore', 'in',
|
31
|
-
'label', 'let', 'loop', 'module', 'not', 'null', 'object', 'or', 'return',
|
32
|
-
'switch', 'throw', 'to_candid', 'true', 'try', 'type', 'var', 'while', 'with',
|
30
|
+
'continue', 'debug', 'debug_show', 'do', 'else', 'false', 'flexible', 'for', 'from_candid', 'func', 'if', 'ignore', 'in',
|
31
|
+
'import', 'label', 'let', 'loop', 'module', 'not', 'null', 'object', 'or', 'private', 'public', 'query', 'return', 'shared',
|
32
|
+
'stable', 'switch', 'system', 'throw', 'to_candid', 'true', 'try', 'type', 'var', 'while', 'with',
|
33
33
|
],
|
34
34
|
accessmodifiers: [
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
35
|
+
'public',
|
36
|
+
'private',
|
37
|
+
'flexible',
|
38
|
+
'query',
|
39
|
+
'shared',
|
40
|
+
'stable',
|
41
|
+
'system',
|
42
42
|
],
|
43
43
|
// prettier-ignore
|
44
44
|
typeKeywords: [
|
@@ -62,55 +62,68 @@ exports.configure = (monaco) => {
|
|
62
62
|
/[a-zA-Z_$][\w$]*/,
|
63
63
|
{
|
64
64
|
cases: {
|
65
|
-
|
66
|
-
|
67
|
-
|
65
|
+
'@typeKeywords': 'keyword.type',
|
66
|
+
'@keywords': 'keyword',
|
67
|
+
'@default': 'identifier',
|
68
68
|
},
|
69
69
|
},
|
70
70
|
],
|
71
71
|
// whitespace
|
72
|
-
{ include:
|
72
|
+
{ include: '@whitespace' },
|
73
73
|
|
74
74
|
// delimiters and operators
|
75
|
-
[/[{}()[\]]/,
|
76
|
-
[/[<>](?!@symbols)/,
|
77
|
-
[
|
75
|
+
[/[{}()[\]]/, '@brackets'],
|
76
|
+
[/[<>](?!@symbols)/, '@brackets'],
|
77
|
+
[
|
78
|
+
/@symbols/,
|
79
|
+
{ cases: { '@operators': 'operator', '@default': '' } },
|
80
|
+
],
|
78
81
|
// numbers
|
79
|
-
[/\d*\.\d+([eE][-+]?\d+)?/,
|
80
|
-
[/0[xX][0-9a-fA-F_]+/,
|
81
|
-
[/[0-9_]+/,
|
82
|
+
[/\d*\.\d+([eE][-+]?\d+)?/, 'number.float'],
|
83
|
+
[/0[xX][0-9a-fA-F_]+/, 'number.hex'],
|
84
|
+
[/[0-9_]+/, 'number'],
|
82
85
|
|
83
86
|
// delimiter: after number because of .\d floats
|
84
|
-
[/[;,.]/,
|
87
|
+
[/[;,.]/, 'delimiter'],
|
85
88
|
|
86
89
|
// strings
|
87
|
-
[/"([^"\\]|\\.)*$/,
|
88
|
-
[
|
90
|
+
[/"([^"\\]|\\.)*$/, 'string.invalid'], // non-teminated string
|
91
|
+
[
|
92
|
+
/"/,
|
93
|
+
{
|
94
|
+
token: 'string.quote',
|
95
|
+
bracket: '@open',
|
96
|
+
next: '@string',
|
97
|
+
},
|
98
|
+
],
|
89
99
|
|
90
100
|
// characters
|
91
|
-
[/'[^\\']'/,
|
92
|
-
[/(')(@escapes)(')/, [
|
93
|
-
[/'/,
|
101
|
+
[/'[^\\']'/, 'string'],
|
102
|
+
[/(')(@escapes)(')/, ['string', 'string.escape', 'string']],
|
103
|
+
[/'/, 'string.invalid'],
|
94
104
|
],
|
95
105
|
|
96
106
|
comment: [
|
97
|
-
[/[^/*]+/,
|
98
|
-
[/\/\*/,
|
99
|
-
[
|
100
|
-
[/[/*]/,
|
107
|
+
[/[^/*]+/, 'comment'],
|
108
|
+
[/\/\*/, 'comment', '@push'], // nested comment
|
109
|
+
['\\*/', 'comment', '@pop'],
|
110
|
+
[/[/*]/, 'comment'],
|
101
111
|
],
|
102
112
|
|
103
113
|
string: [
|
104
|
-
[/[^\\"]+/,
|
105
|
-
[/@escapes/,
|
106
|
-
[/\\./,
|
107
|
-
[
|
114
|
+
[/[^\\"]+/, 'string'],
|
115
|
+
[/@escapes/, 'string.escape'],
|
116
|
+
[/\\./, 'string.escape.invalid'],
|
117
|
+
[
|
118
|
+
/"/,
|
119
|
+
{ token: 'string.quote', bracket: '@close', next: '@pop' },
|
120
|
+
],
|
108
121
|
],
|
109
122
|
|
110
123
|
whitespace: [
|
111
|
-
[/[ \t\r\n]+/,
|
112
|
-
[/\/\*/,
|
113
|
-
[/\/\/.*$/,
|
124
|
+
[/[ \t\r\n]+/, 'white'],
|
125
|
+
[/\/\*/, 'comment', '@comment'],
|
126
|
+
[/\/\/.*$/, 'comment'],
|
114
127
|
],
|
115
128
|
},
|
116
129
|
});
|